proper way to do a recursive install ?

Luigi Rizzo rizzo at
Thu Feb 1 19:28:47 UTC 2007

I have a port that just need to install the content of a tarball
(a set of headers and C sources) into

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 <>
    MY_DST=      ${DESTDIR}${PREFIX}/share/linux-bsd-kmod/linux_compat

    do-build: # nothing to build here

	${MKDIR} -p ${MY_DST}
        cp -Rp ${WRKSRC} ${MY_DST}
        find  ${MY_DST} -type f -exec chmod ${SHAREMODE} \{\} \;
        chown -R ${SHAREOWN}:${SHAREGRP} ${MY_DST}

    .include <>

    #--- 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.


More information about the freebsd-ports mailing list