site  contact  subhomenews

coreutils 'cp' output change

April 30, 2013 — BarryK
Recently we ran into a problem with the 'ln' utility in coreutils. One of the eudev developers used the '-r' option, but my 'ln' in Precise Puppy does not have that option.
It turned out that the 'ln' in coreutils version 8.20 (as used in Ubuntu Raring Ringtail) does have the '-r' option, but earlier versions don't -- well, I don't know exactly what version it was introduced, but it was recent, within the last year.

Now, I have discovered another change in coreutils, this time in the 'cp' utility. I was using Woof in Raring Puppy, and noticed an error message from '3builddistro'.

The problem is that 'cp' outputs an error message with a different format to earlier versions. I fixed it in 3builddistro:
 #cp -a --remove-destination packages-${DISTRO_FILE_PREFIX}/${ONEPKG}/* sandbox3/rootfs-complete/ 2> /dev/null

#w003 problem. pet pkg seamonkey_addon_adblock has files in /usr/lib/seamonkey but in rootfs-complete
#usr/lib/seamonkey is a symlink to seamonkey-1.1.14 and copy fails. this will follow path with a
#symlink (hopefully doesn't break something else)...
#looks okay. the --remove-destination ensures that if target file already exists as a symlink
#it will be deleted first and won't be followed. shit no, it changed /usr/lib/seamonkey into a dir...
#cp -r --preserve=mode,ownership,timestamps,links --dereference --remove-destination packages-${DISTRO_FILE_PREFIX}/${ONEPKG}/* sandbox3/rootfs-complete/ 2> /dev/null
#/usr/sbin/petget solves this a different way, let's try that...

#130430 new problem with coreutils 8.20... ex building raring pup...
#ex: cp -a --remove-destination packages-raring/synclient/* sandbox3/rootfs-complete/
#coreutils 5.2.1 stderr: cannot overwrite non-directory `sandbox3/rootfs-complete/usr/X11' with directory `packages-raring/synclient/usr/X11'
#coreutils 8.20 (in Raring) stderr: cp: cannot overwrite non-directory ‘sandbox3/rootfs-complete/usr/X11’ with directory ‘packages-raring/synclient/usr/X11’
#...!!!! ok, attempt to fix...

cp -a --remove-destination packages-${DISTRO_FILE_PREFIX}/${ONEPKG}/* sandbox3/rootfs-complete/ 2> /tmp/3builddistro-cp-errlog
sync #110727 running drake pup 0.3 with k2.6.39-3 new laptop, mysterious loss of dirs/files. try sync.
if [ -s /tmp/3builddistro-cp-errlog ];then #130430 next line fixes those quote chars...
cat /tmp/3builddistro-cp-errlog | grep 'cannot overwrite non-directory' | tr '[`‘’]' "'" | cut -f 2 -d "'" |
while read ONEDIRSYMLINK
do
xONEDIRSYMLINK="`echo -n "$ONEDIRSYMLINK" | sed -e 's%sandbox3/rootfs-complete%%'`"
#adding that extra trailing / does the trick...
cp -a --remove-destination packages-${DISTRO_FILE_PREFIX}/${ONEPKG}${xONEDIRSYMLINK}/* sandbox3/rootfs-complete${xONEDIRSYMLINK}/
done
fi
#...now seems ok. note, there are two places in woof v003 where this problem occurs: /usr/lib/seamonkey
# and /usr/share/cups/model.


...see the "130430" date where I changed the code.

Woof commit:
http://bkhome.org/fossil/woof2.cgi/info/bf15545a21

Comments

ln --relative
Username: BarryK
I have just been informed by Alexey D. That 'ln' gained the '-r' option in coreutils version 8.16: http://savannah.gnu.org/forum/forum.php?forum_id=7170 ...a useful option!


Tags: woof