`cp -Rp symlink-with-nohistory' fails...

YONETANI Tomokazu qhwt+dfly at les.ath.cx
Wed Sep 3 08:08:18 PDT 2008


Hello.

How it fails:
$ mkdir test test2
$ chflags nohistory test
$ chflags history test2		# to make sure test2 doesn't have nohistory
$ ln -s foo test/bar		# this creates a symlink with nohistory set
$ cp -Rp test/bar test2
cp: chflags: test2/bar: Function not implemented

Why does that matter:
installation of postfix fails (I know makedefs barfs first, but that's
another story, and perhaps someone else's working on it).  I have my
${WRKDIR} on a HAMMER PFS with nohistory flag set.  On the other hand
${PREFIX} (=/usr/pkg) has no nohistory set on it.  And ${WRKDIR} and
${PREFIX} are on different partitions.  I don't think this is very odd
configuration, as you want your ${WRKDIR} on a big partition but don't
want to retain the history, while you want to keep your ${PREFIX} on
a UFS filesystem to be very conservative, or at least retain history.

There's the following code in postfix-install script, which is responsible
for the installation:

compare_or_symlink() {
		:

	ln -s $link $tempdir/junk || exit 1
	mv -f $tempdir/junk $2 || {

$tempdir points to somewhere under ${WRKDIR}, so it has nohistory flag set,
so symlinks get created with nohistory flag set, then mv'ed to
${PREFIX}/*bin.  Since ${WRKDIR} and ${PREFIX}/*bin are in different
partitions, mv internally invokes `cp -PRp' to perform the copy
across partitions, then fails.
Currently there are three workarounds for this problem(known to me):
A) run `bmake install' twice, B) set nohistory flag on ${PREFIX}/*, or
C) patch cp to special case the history flags rather than let it
   unconditionally refuse to chflags() on a symlink.

But: why does cp refuse to set file flags on a symlink in the first place?





More information about the Bugs mailing list