pkgsrc-Users archive

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

Re: [patch] package.mk: use cp without -p if it fails



On 5 Aug 2021, at 15:47, Sijmen J. Mulder wrote:

After setting up pkgsrc on a new FreeBSD 13 installation on ZFS, I
encoutnered an error when building any package: cp would report a
chattr failure copying the package file from the work directory to the
packages directory.

This was because my work directory is hosted on the ZFS root
filesystem, which sets 'uarch' flags, and the packages directory is on
an NFS-mounted volume which doesn't support that flag (or any?).

The attached patch uses regular 'cp' if 'cp -p' doesn't work.

I'd like to get review on my (similar but different) patch, below. It's served me well for quite some time.

-----

I export pkgsrc over NFS from a macOS host to a variety of VMs, each of
which sets ${PACKAGES} to a subdir of ${PKGSRCDIR}/packages (on the same
NFS mount) so that the generated packages all land in one place.

From my Debian, Devuan, Ubuntu, and CentOS 8 (but not 7) VMs,
copying ${STAGE_PKGFILE} to ${PKGFILE} fails to preserve permissions,
which fails the copy and the "package" target with it. The error
looks like so:

===> Building binary package for foo-4.2
=> Creating binary package /home/schmonz/trees/pkgsrc-cvs/packages/Debian/All/foo-4.2.tgz /bin/cp: preserving permissions for ‘/home/schmonz/trees/pkgsrc-cvs/packages/Debian/All/foo-4.2.tgz’: Operation not permitted

Assuming permissions on built packages are merely a nice-to-have, avoid
failing if we couldn't preserve them, while making sure to still fail if
package _contents_ weren't copied byte-for-byte.

Index: mk/pkgformat/pkg/package.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/pkgformat/pkg/package.mk,v
retrieving revision 1.16
diff -u -r1.16 package.mk
--- mk/pkgformat/pkg/package.mk	19 Aug 2017 00:30:19 -0000	1.16
+++ mk/pkgformat/pkg/package.mk	27 Nov 2021 21:35:40 -0000
@@ -66,7 +66,8 @@
 	@${STEP_MSG} "Creating binary package ${.TARGET}"
 	${RUN} ${MKDIR} ${.TARGET:H};					\
 	${LN} -f ${STAGE_PKGFILE} ${PKGFILE} 2>/dev/null ||		\
-		${CP} -pf ${STAGE_PKGFILE} ${PKGFILE}
+		${CP} -pf ${STAGE_PKGFILE} ${PKGFILE} 2>/dev/null ||	\
+		${CMP} ${STAGE_PKGFILE} ${PKGFILE}
 .endif

 ######################################################################


Home | Main Index | Thread Index | Old Index