I have a server, where a partition is mounted under /usr/portage/distfiles_$(hostname), e.g.: root@caiman:/root(9)# mount | grep distfiles /dev/sda6 on /usr/portage_caiman/distfiles_caiman type ext4 (rw,noatime,user_xattr,commit=0) At caiman /usr/portage/distfiles is a link to /usr/portage_caiman/distfiles_caiman. At the other gentoo systems of my local network /usr/portage/distfiles is a link to /net/caiman/usr/portage/distfiles_caiman/, e.g. root@impala:/root(51)# ll /usr/portage/distfiles lrwxrwxrwx 1 root root 40 Sep 22 14:13 /usr/portage/distfiles -> /net/caiman/usr/portage/distfiles_caiman/ In this way I hoped to reduce the network traffic, but there is a problem. If I do a 'emerge -v --sync' at caiman, all files in /usr/portage/distfiles_caiman are erased: root@caiman:/root(8)# ls -ld /usr/portage/distfiles ; ls /usr/portage/distfiles/ | wc -w ; emerge -v --sync | grep "Number of files"; ls /usr/portage/distfiles/ | wc -w lrwxrwxrwx 1 root root 16 Jun 6 23:58 /usr/portage/distfiles -> distfiles_caiman 9 Number of files: 1 Number of files transferred: 1 rsync: delete_file: rmdir(distfiles_caiman) failed: Device or resource busy (16) Number of files: 159077 Number of files transferred: 17 0 It seems that 'emerge -v --sync' erases all files in /usr/portage/distfiles_$(hostname). I see this also at my laptop (lynx), where I want to use /usr/portage/distfiles_lynx/ as backup distfile directory. root@lynx:/root(37)# ls /usr/portage/distfiles_lynx | wc -w ; echo "--- 1 ---"; emerge -v --sync | grep "Number of files"; echo "--- 2 ---"; ls /usr/portage/distfiles_lynx | wc -w 3 --- 1 --- Number of files: 1 Number of files transferred: 1 rsync: delete_file: rmdir(distfiles_lynx) failed: Device or resource busy (16) Number of files: 159078 Number of files transferred: 18 q: Updating ebuild cache ... q: Finished 32133 entries in 0.139856 seconds --- 2 --- 0 Is this a bug or a feature?
I also tried to rename /usr/portage/distfiles_$(hostfile) to /usr/portage/distfiles__$(hostfile). Now 'emerge -v --sync' deletes the files under /usr/portage/distfiles__$(hostfile): root@caiman:/root(22)# ls -ld /usr/portage/distfiles* ; ls /usr/portage/distfiles__caiman | wc -w ; emerge -v --sync | grep "Number of files"; ls /usr/portage/distfiles__caiman | wc -w drwxrwsr-x 2 root portage 688128 Oct 23 15:26 /usr/portage/distfiles__caiman 5 Number of files: 1 Number of files transferred: 1 rsync: delete_file: rmdir(distfiles__caiman) failed: Device or resource busy (16) Number of files: 159078 Number of files transferred: 31 0 Tries 'emerge -v --sync' do delete all files under /usr/portage/distfiles_*?
man emerge: WARNING: The emerge --sync action will modify and/or delete files located inside the directory that the PORTDIR variable refers to (default location is /usr/portage). For more information, see the PORTDIR documentation in the make.conf(5) man page. man 5 make.conf: ***Warning*** Data stored inside PORTDIR is in peril of being overwritten or deleted by the emerge --sync command. The default value of PORTAGE_RSYNC_OPTS will protect the default locations of DISTDIR and PKGDIR, but users are warned that any other locations inside PORTDIR are not necessarily safe for data storage. You should not put other data (such as overlays) in your PORTDIR. Portage will walk directory structures and may arbitrarily add invalid categories as packages. So you should modify PORTAGE_RSYNC_OPTS or move your files outside PORTDIR.
Thanks Piotr, I moved /usr/portage/distfiles_$(hostfile) to /usr/local/portage/distfiles_$(hostfile) . It seems now to work.