proper way to do a recursive install ?

Matthew Seaman m.seaman at infracaninophile.co.uk
Thu Feb 1 22:14:52 UTC 2007


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

>     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}

cpio is a common choice for this.  For instance this example from
the java/diablo-jre15 port:

do-install:
        ${MKDIR} "${INSTALL_DIR}"
        cd "${WRKSRC}" && ${FIND} . \
          | ${CPIO} -pdmu -R ${LIBOWN}:${LIBGRP} "${INSTALL_DIR}"

cpio is handy because it can set the ownership on the installed files
in the same pass as they are installed.  It relies on the correct
permissions being set in the source directory, which it will apply to
the copied files and directories (although use of 'find -depth' does
give best results for directory permissions).  There are plenty of
other choices around the ports tree though.

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

If your build process generates a constant set of files, then
why wouldn't you just generate a pkg-plist exactly as would be done
for any other port?  It might be a bit long, but so what?  We have
computers that can wrangle all that stuff for us.

http://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/plist-autoplist.html

You can even generate a PLIST on the fly as an afterthought to the
build process, although nowadays the preference is to have a static
pkg-plist or else use the PLIST_DIRS and PLIST_FILES make variables
unless there are good reasons not to do so. 

See, for instance the code that implements the PORTDOCS functionality
in bsd.port.mk.  Or this example from the phpmyadmin port I maintain:

post-patch:
        ${CP} ${FILESDIR}/${CFGFILE}.sample ${WRKSRC}/${CFGFILE}.sample
        cd ${WRKSRC} ; \
        ${FIND} . ! -type d ! -name ${CFGFILE}.sample | ${SORT} | \
            ${SED} -e "s,^\.,%%MYADMDIR%%,"           >${PLIST} ; \
        ${CAT} ${PKGDIR}/pkg-plist-chunk             >>${PLIST} ; \
        ${FIND} . -type d | ${SORT} -r | ${SED} \
             -e "s,^\.$$, at dirrmtry %%MYADMDIR%%," \
             -e "s,^\., at dirrm %%MYADMDIR%%,"         >>${PLIST}

	Cheers,

	Matthew

-- 
Dr Matthew J Seaman MA, D.Phil.                       7 Priory Courtyard
                                                      Flat 3
PGP: http://www.infracaninophile.co.uk/pgpkey         Ramsgate
                                                      Kent, CT11 9PW

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 250 bytes
Desc: OpenPGP digital signature
Url : http://lists.freebsd.org/pipermail/freebsd-ports/attachments/20070201/022e9231/signature-0001.pgp


More information about the freebsd-ports mailing list