pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/mk/flavor/pkg When creating the binary package, first ...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/0ea7837ca3bf
branches:  trunk
changeset: 537117:0ea7837ca3bf
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Thu Jan 03 23:21:48 2008 +0000

description:
When creating the binary package, first create a temporary file, and if
everything went well, rename it to the real name. That way, it is less
likely that broken binary packages are created. It is a common
assumption that binary package files, if they exist, are usable.

An example for a broken binary package is security/sudo-1.6.9p10, in
which sbin/visudo wasn't readable when creating the package as an
unprivileged user.

diffstat:

 mk/flavor/pkg/package.mk |  10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diffs (24 lines):

diff -r 10e249b2a010 -r 0ea7837ca3bf mk/flavor/pkg/package.mk
--- a/mk/flavor/pkg/package.mk  Thu Jan 03 23:18:07 2008 +0000
+++ b/mk/flavor/pkg/package.mk  Thu Jan 03 23:21:48 2008 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: package.mk,v 1.12 2007/11/07 17:30:01 rillig Exp $
+# $NetBSD: package.mk,v 1.13 2008/01/03 23:21:48 rillig Exp $
 
 PKG_SUFX?=             .tgz
 PKGFILE?=              ${PKGREPOSITORY}/${PKGNAME}${PKG_SUFX}
@@ -40,7 +40,13 @@
 
 ${PKGFILE}: ${_CONTENTS_TARGETS}
        ${RUN} ${MKDIR} ${.TARGET:H}
-       ${RUN} ${PKG_CREATE} ${_PKG_ARGS_PACKAGE} ${.TARGET}
+       ${RUN} if ${PKG_CREATE} ${_PKG_ARGS_PACKAGE} ${.TARGET}.tmp; then \
+               ${MV} -f ${.TARGET}.tmp ${.TARGET};                     \
+       else                                                            \
+               exitcode=$$?;                                           \
+               ${RM} -f ${.TARGET}.tmp;                                \
+               exit $$exitcode;                                        \
+       fi
 
 ######################################################################
 ### package-remove (PRIVATE)



Home | Main Index | Thread Index | Old Index