Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 21 Sep 2012 15:51:29 +0900
From:      poyopoyo@puripuri.plala.or.jp
To:        Beat Gaetzi <beat@FreeBSD.org>
Cc:        svn-ports-head@freebsd.org, svn-ports-all@freebsd.org, ports-committers@freebsd.org
Subject:   Re: svn commit: r304594 - head/Mk
Message-ID:  <868vc3rhqm.wl%poyopoyo@puripuri.plala.or.jp>
In-Reply-To: <201209201951.q8KJpUNr085151@svn.freebsd.org>
References:  <201209201951.q8KJpUNr085151@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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.

-- 
kuro



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?868vc3rhqm.wl%poyopoyo>