proper way to do a recursive install ?
Stanislav Sedov
stas at FreeBSD.org
Thu Feb 1 21:39:32 UTC 2007
On Thu, 1 Feb 2007 11:03:45 -0800
Luigi Rizzo <rizzo at icir.org> mentioned:
> I have a port that just need to install the content of a tarball
> (a set of headers and C sources) into
> /usr/local/share/linux-bsd-kmod/linux_compat,
>
> and was wondering what is the proper way to handle this (both in
> the port's Makefile and in the pkg_plist file).
>
> Given that INSTALL doesn't have a 'recursive' flag, and a combination
> of 'find' and INSTALL is quite clumsy (short of calling INSTALL on
> each file) to preserve the full pathnames, I have come up with
> something like the combination of find/cp/chown below (to set up
> permissions and ownership correctly).
>
> #--- this is in the Makefile ---
>
> ....
> .include <bsd.port.pre.mk>
> MY_DST= ${DESTDIR}${PREFIX}/share/linux-bsd-kmod/linux_compat
>
> do-build: # nothing to build here
>
> do-install:
> ${MKDIR} -p ${MY_DST}
> cp -Rp ${WRKSRC} ${MY_DST}
> find ${MY_DST} -type f -exec chmod ${SHAREMODE} \{\} \;
> chown -R ${SHAREOWN}:${SHAREGRP} ${MY_DST}
>
You should set permissions on directories as well.
> .include <bsd.port.post.mk>
>
> #--- this is pkg-plist 000
> @exec mkdir -p %D/share/linux-bsd-kmod
> @exec echo "installing into %D/share/linux-bsd-kmod"
> @unexec echo "uninstalling into %D/share/linux-bsd-kmod"
> @unexec rm -rf %D/share/linux-bsd-kmod
>
> Given that it seems a relatively common problem, and that is is
> easy to make mistakes in the above commands re. pathnames and
> permissions, i wonder if it wouldn't be the case to put together a
> 'recursive install' function that can be called from the port's top
> level makefile.
>
> In my opinion naming individual files would be a mainteinance nightmare.
> In a case like this, the destination directory is private for the
> port and there is not any reason to be shared.
>
I've found a slighter better way to deal with this problem some time
ago. E.g. you can add the following macros to your makefile:
COPYTREE_SHARE= ${SH} -c '(${FIND} -d $$0 $$2 | ${CPIO} -dumpl $$1 >/dev/null \ 2>&1) && \
${CHOWN} -R ${SHAREOWN}:${SHAREGRP} $$1 && \
${FIND} $$1/ -type d -exec ${CHMOD} 755 {} \; && \
${FIND} $$1/ -type f -exec ${CHMOD} ${SHAREMODE} {} \;' --
And then use something like (@(cd ${WRKSRC}/sample/ && ${COPYTREE_SHARE} \* ${EXAMPLESDIR}/) to install recursively.
You can look through the port collection for additional examples.
See http://www.freebsd.org/cgi/query-pr.cgi?pr=100996 for additional info.
--
Stanislav Sedov
ST4096-RIPE
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-ports/attachments/20070201/d64491d1/attachment.pgp
More information about the freebsd-ports
mailing list