Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 2 Feb 2007 00:39:10 +0300
From:      Stanislav Sedov <stas@FreeBSD.org>
To:        Luigi Rizzo <rizzo@icir.org>
Cc:        ports@freebsd.org
Subject:   Re: proper way to do a recursive install ?
Message-ID:  <20070202003910.f8a4495a.stas@FreeBSD.org>
In-Reply-To: <20070201110345.A83474@xorpc.icir.org>
References:  <20070201110345.A83474@xorpc.icir.org>

next in thread | previous in thread | raw e-mail | index | archive | help
--Signature=_Fri__2_Feb_2007_00_39_10_+0300_fDfC8TQaT82ctJH=
Content-Type: text/plain; charset=US-ASCII
Content-Disposition: inline
Content-Transfer-Encoding: 7bit

On Thu, 1 Feb 2007 11:03:45 -0800
Luigi Rizzo <rizzo@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

--Signature=_Fri__2_Feb_2007_00_39_10_+0300_fDfC8TQaT82ctJH=
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (FreeBSD)

iD8DBQFFwl4DK/VZk+smlYERAj1uAJ99SBfFE8i18SzPboz/1PhwWePgpwCgg9aI
gx3IqtSZ5pPxkO1jlBlisPI=
=nUZb
-----END PGP SIGNATURE-----

--Signature=_Fri__2_Feb_2007_00_39_10_+0300_fDfC8TQaT82ctJH=--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070202003910.f8a4495a.stas>