From owner-freebsd-ports@FreeBSD.ORG Thu Feb 1 21:39:32 2007 Return-Path: X-Original-To: ports@freebsd.org Delivered-To: freebsd-ports@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4FF2316A400 for ; Thu, 1 Feb 2007 21:39:32 +0000 (UTC) (envelope-from stas@FreeBSD.org) Received: from com1.ht-systems.ru (com1.ht-systems.ru [83.97.104.204]) by mx1.freebsd.org (Postfix) with ESMTP id CFAB413C467 for ; Thu, 1 Feb 2007 21:39:29 +0000 (UTC) (envelope-from stas@FreeBSD.org) Received: from [213.87.72.70] (helo=phonon.SpringDaemons.com) by com1.ht-systems.ru with esmtpa (Exim 4.62) (envelope-from ) id 1HCjVw-0001J0-8i; Fri, 02 Feb 2007 00:30:43 +0300 Received: from localhost (localhost [IPv6:::1]) by phonon.SpringDaemons.com (Postfix) with SMTP id 0366611473; Fri, 2 Feb 2007 00:39:16 +0300 (MSK) Date: Fri, 2 Feb 2007 00:39:10 +0300 From: Stanislav Sedov To: Luigi Rizzo Message-Id: <20070202003910.f8a4495a.stas@FreeBSD.org> In-Reply-To: <20070201110345.A83474@xorpc.icir.org> References: <20070201110345.A83474@xorpc.icir.org> Organization: The FreeBSD Project X-Mailer: carrier-pigeon X-Voice: +7 916 849 20 23 X-XMPP: ssedov@jabber.ru X-ICQ: 208105021 X-Yahoo: stanislav_sedov X-PGP-Fingerprint: F21E D6CC 5626 9609 6CE2 A385 2BF5 5993 EB26 9581 X-University: MEPhI Mime-Version: 1.0 Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg="PGP-SHA1"; boundary="Signature=_Fri__2_Feb_2007_00_39_10_+0300_fDfC8TQaT82ctJH=" X-Spam-Flag: SKIP X-Spam-Yversion: Spamooborona 1.6.0 X-Mailman-Approved-At: Fri, 02 Feb 2007 03:28:54 +0000 Cc: ports@freebsd.org Subject: Re: proper way to do a recursive install ? X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Feb 2007 21:39:32 -0000 --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 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 > 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 > > #--- 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=--