How to install all when NO_WRKSUBDIR=yes?

I want to install a zip file that does not extract to a subdirectory. According to the docs I have to use NO_WRKSUBDIR= yes in such a case. Since it's an web application, I want to copy all files from ${WRKSRC} to ${STAGEDIR}${WWWDIR}; however this is is a mess because ${WRKSRC} contains ${STAGEDIR}.

So how do I solve this? Solutions that came to my mind:

- Extract the zip somewhere else. I haven't found anything that would allow me to do this.
- Move the files after extracting them. Not so great.
- Exclude ${STAGEDIR} when copying. Even worse.

So is there any better method?


Find my Makefile below, but be aware that it may mess up your file system. This is my first port, any feedback is greatly appreciated! ;)

Code:
# $FreeBSD$

PORTNAME=	ghost
PORTVERSION=	0.3.3
CATEGORIES=	www
MASTER_SITES=	http://ghost.org/archives/

MAINTAINER=	jakob@gillich.me
COMMENT=	Simple blogging platform

LICENSE=	MIT

RUN_DEPENDS=	node:${PORTSDIR}/www/node
BUILD_DEPENDS=	${RUN_DEPENDS} \
		npm:${PORTSDIR}/www/npm

USE_ZIP=	yes
NO_WRKSUBDIR=	yes
NO_BUILD=	yes

OPTIONS_MULTI=	DB
OPTIONS_MULTI_DB=	MYSQL PGSQL SQLITE
OPTIONS_DEFAULT=	SQLITE
MYSQL_USE=	MYSQL=client
PGSQL_USE=	PGSQL=yes
SQLITE_USE=	SQLITE=yes

do-install:
	${MKDIR} -m 0755 ${STAGEDIR}${WWWDIR}
	cd ${WRKSRC} && npm install --sqlite=${PREFIX}
	cd ${WRKSRC} && ${COPYTREE_SHARE} . ${STAGEDIR}${WWWDIR}

.include <bsd.port.mk>

Oh, and is ${PREFIX} also the path where dependencies are installed? I have to pass it to npm install due to an issue with node-sqlite.
 
I can not comment on the other stuff but PREFIX is the final destination path of your installed port, usually /usr/local. If your port depends on some other installed ports they are searched from LOCALBASE that also defaults to /usr/local.
 
About your other questions, I would look at some ports that use a special do-extract target to create the work directory and extract the distfiles. With a quick search I found sysutils/ddrescue that does this:

Code:
do-extract:
        @${MKDIR} ${WRKDIR}
        @${LOCALBASE}/bin/lzip -dc ${DISTDIR}/${DISTFILES} | \
        ${TAR} -x -f - -C ${WRKDIR} --no-same-owner --no-same-permissions

It's not quite what you need in your own port but should give you ideas what could be done in your own do-extract target.


Edit: I can now finally see what the problem really is, ports that have distfiles that extract directly to WRKDIR without creating a subdirectory under it could conflict with staging if they happen to have a stage subdirectory as well. A custom do-extract target is probably needed for those ports.
 
Thank you, that (kind of) solved my problem! But I can't get the permissions right. Currently files have 111, I want them to have something like 755. I tried umask and chmod without proper results. Then I saw a port that used @mode xxx in the plist, but that doesn't work for me either.

I've put everything on Github to make it easier to retrieve: https://github.com/jgillich/Ghost-FreeBSD
 
Back
Top