From owner-svn-ports-head@FreeBSD.ORG Fri Sep 21 19:52:21 2012 Return-Path: Delivered-To: svn-ports-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 652471065674 for ; Fri, 21 Sep 2012 19:52:21 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 44A888FC15 for ; Fri, 21 Sep 2012 19:52:21 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q8LJqKQ0065230 for ; Fri, 21 Sep 2012 19:52:20 GMT (envelope-from bdrewery@freefall.freebsd.org) Received: (from bdrewery@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q8LJqKPP065225 for svn-ports-head@FreeBSD.org; Fri, 21 Sep 2012 19:52:20 GMT (envelope-from bdrewery) Received: (qmail 42359 invoked from network); 21 Sep 2012 14:52:17 -0500 Received: from unknown (HELO ?10.10.0.115?) (freebsd@shatow.net@10.10.0.115) by sweb.xzibition.com with ESMTPA; 21 Sep 2012 14:52:17 -0500 Message-ID: <505CC56F.3090306@FreeBSD.org> Date: Fri, 21 Sep 2012 14:52:15 -0500 From: Bryan Drewery Organization: FreeBSD User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20120907 Thunderbird/15.0.1 MIME-Version: 1.0 To: poyopoyo@puripuri.plala.or.jp References: <201209201951.q8KJpUNr085151@svn.freebsd.org> <868vc3rhqm.wl%poyopoyo@puripuri.plala.or.jp> <505C646A.6030009@FreeBSD.org> <867grnqs7s.wl%poyopoyo@puripuri.plala.or.jp> In-Reply-To: <867grnqs7s.wl%poyopoyo@puripuri.plala.or.jp> X-Enigmail-Version: 1.4.4 OpenPGP: id=3C9B0CF9; url=http://www.shatow.net/bryan/bryan.asc Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: svn-ports-head@FreeBSD.org, svn-ports-all@FreeBSD.org, Beat Gaetzi , ports-committers@FreeBSD.org Subject: Re: svn commit: r304594 - head/Mk X-BeenThere: svn-ports-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the ports tree for head List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Sep 2012 19:52:21 -0000 On 9/21/2012 11:02 AM, poyopoyo@puripuri.plala.or.jp wrote: > Hi Bryan, > > At Fri, 21 Sep 2012 07:58:18 -0500, > Bryan Drewery wrote: >> >> On 9/21/2012 1:51 AM, poyopoyo@puripuri.plala.or.jp wrote: >>> At Thu, 20 Sep 2012 19:51:30 +0000 (UTC), >>> Beat Gaetzi wrote: >>>> - Make 'do-package' atomic while creating the pkg file [4] >>> >>>> Modified: head/Mk/bsd.port.mk >>>> ============================================================================== >>>> @@ -3911,11 +3905,15 @@ do-package: ${TMPPLIST} >>>> fi; \ >>>> fi; \ >>>> fi >>>> - @if ${PKG_CMD} -b ${PKGNAME} ${PKGFILE}; then \ >>>> + @TMPPKGFILE=$$(mktemp -t pkg); \ >>>> + trap "${RM} -f $${TMPPKGFILE} $${TMPPKGFILE}${PKG_SUFX}; exit 1" 1 2 3 5 10 13 15; \ >>>> + if ${PKG_CMD} -b ${PKGNAME} $${TMPPKGFILE}; then \ >>>> + ${MV} -f $${TMPPKGFILE}${PKG_SUFX} ${PKGFILE}; \ >>>> if [ -d ${PACKAGES} ]; then \ >>>> cd ${.CURDIR} && eval ${MAKE} package-links; \ >>>> fi; \ >>>> else \ >>>> + ${RM} -f $${TMPPKGFILE}; \ >>>> cd ${.CURDIR} && eval ${MAKE} delete-package; \ >>>> exit 1; \ >>>> fi >>> >>> This does not seem to atomic at all. Well being visible when PKG_SUFX is set. >> >> How is a single mv(1) on a tempfile not atomic? The purpose here is to >> avoid the very long pkg_create(1) call and avoid leaving an invalid >> package behind on ctrl+c or other interruptions. > > Because temporary file which mktemp creates is not referenced by anyone. > >>>> + @TMPPKGFILE=$$(mktemp -t pkg); \ > > TMPPKGFILE=pkg.XXXXXXXX (here, for example) > >>>> + if ${PKG_CMD} -b ${PKGNAME} $${TMPPKGFILE}; then \ >>>> + ${MV} -f $${TMPPKGFILE}${PKG_SUFX} ${PKGFILE}; \ > > pkg_create creates pkg.XXXXXXXX.tbz and mv it to ${PKGFILE}. > ${TMPPKGFILE} left untouched. mv is atomic, but pkg_create does not. > (While mktemp succeed to create pkg.XXXXXXXX, pkg.XXXXXXXX.tbz could be > a symlink, a directory or something fancy) > > At Fri, 21 Sep 2012 08:22:37 -0500, > Bryan Drewery wrote: >> I will also try creating the tempfile in the PKGREPOSITORY, to keep it >> on the same filesystem :) > > It's nice. I think an easiest way for me to fix this is mktemp -d to > create own temporary directory and pkg_crate ${PKGNAME} under it, then > mv it to ${PKGFILE}. Just a thought, BTW. > I was thinking the same. Mind testing this patch out? http://people.freebsd.org/~bdrewery/patch-bsd.port.mk-do-package.txt It will keep the same behavior of unrecognized PKG_SUFX for pkg_create, not leave any temp files, keeps the tempdir on the save device, and allows overriding PACKAGES/PKGREPOSITORY/PKGFILE all properly. -- Regards, Bryan Drewery bdrewery@freenode/EFNet