Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 21 Sep 2012 08:22:37 -0500
From:      Bryan Drewery <bdrewery@freebsd.org>
To:        Beat Gaetzi <beat@freebsd.org>, ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org, poyopoyo@puripuri.plala.or.jp, Baptiste Daroussin <bapt@freebsd.org>
Subject:   Re: svn commit: r304594 - head/Mk
Message-ID:  <505C6A1D.4070206@FreeBSD.org>
In-Reply-To: <868vc3rhqm.wl%poyopoyo@puripuri.plala.or.jp>
References:  <201209201951.q8KJpUNr085151@svn.freebsd.org> <868vc3rhqm.wl%poyopoyo@puripuri.plala.or.jp>

next in thread | previous in thread | raw e-mail | index | archive | help
In my testing it was all working. I must have messed it up!

I am going to back out for now and rewrite it.

I will also try creating the tempfile in the PKGREPOSITORY, to keep it
on the same filesystem :)

Thank you for reporting this.

Bryan

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.
> 
> ==
> # make package -C /usr/ports/ports-mgmt/portlint PKG_SUFX=.tgz
> ...
> | ===>   Registering installation for portlint-2.13.12
> | ===>  Building package for portlint-2.13.12
> | mv: rename /home/tmp/pkg.ENocPBwh.tgz to /home/packages/10/All/portlint-2.13.12.tgz: No such file or directory
> | *** [do-package] Error code 1
> | 
> | Stop in /usr/ports/ports-mgmt/portlint.
> 
> # ls -l /home/tmp/pkg.ENocPBwh*
> -rw-------  1 root  wheel      0 Sep 21 14:36 /home/tmp/pkg.ENocPBwh
> -rw-r--r--  1 root  wheel  32270 Sep 21 14:36 /home/tmp/pkg.ENocPBwh.tbz
> ==
> 
> (1) pkg_create creates package with default suffix *added* to
>     given pkg-filename if pkg-filename does not have one of known suffixes
>     which are now .tgz, .tbz and .txz.
> (2) TMPPKGFILE does not give PKG_SUFX to mktemp. This makes pkg_create
>     *adding* known default suffix to given TMPPKGFILE, this time
>     "pkg.ENocPBwh.tbz".
> (3-a) when PKG_SUFX is set and it was other than default suffix pkg_create
>     knows, make package fails.
> (3-b) when PKG_SUFX is not set, it looks like make package successfully
>     completes, but its operation is not atomic at all, because intended
>     TMPPKGFILE did not used at all (see empty file above, "pkg.ENocPBwh".)
> (4) TMPPKGFILE is left on TMPDIR and not removed.
> 
> An hour of effort make me giving up fixing this correctly -- are someone
> able to tell mktemp to use pkg.XXXXXXXX.tgz as template? I could not. :-)
> 
> Anyway, this chunk of patch does not work as intended currently and
> breaks PKG_SUFX support badly. It would be nice to be backed out until
> someone makes this really work, PKG_SUFX compliant and being atomic.
> 


-- 
Regards,
Bryan Drewery
bdrewery@freenode/EFNet



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?505C6A1D.4070206>