proper way to do a recursive install ?

Luigi Rizzo rizzo at icir.org
Thu Feb 1 21:25:08 UTC 2007


On Thu, Feb 01, 2007 at 11:03:45AM -0800, Luigi Rizzo wrote:
> 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}
> 
>     .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.

And for the benefit of the archives, these are numbers that show
that it _is_ a common problem. Grepping INSTALL in the ports'
Makefiles give these counts (sorted, largest first):

        ./graphics/libx3dtk/Makefile :      464         YUCK!!!
        ./irc/psybnc/Makefile :      252
        ./editors/setedit/Makefile :       79
        ./www/ssserver/Makefile :       59
        ./games/macopix/Makefile :       43
        ./x11-toolkits/open-motif/Makefile :       34
        ./www/awstats/Makefile :       29
        ./www/validator/Makefile :       28
        ./mail/mailscanner/Makefile :       28
        ./ftp/bsdftpd-ssl/Makefile :       28
        ...

There are 262 entries with 10 or more 'INSTALL' in them;
several use tricks like this

    .for f in dot.mosaic-hotlist-default
        @${INSTALL_DATA} ${FILESDIR}/${f} ${SAMPLEDIR}
    .endfor

so, it seems a feature that is largely useful

	cheers
	luigi


More information about the freebsd-ports mailing list