When running mirrorselect and redirecting stdout, mirrorselect will truncate the file that it's directed to. The error is in using /dev/std* for io redirection, as the symlinks to /proc/self/fd/* symlink directly to the file that i/o hasbeen redirected to, and mirrorselect will echo with a >, which will always clobber the file. When used as per the install instructions, mirrorselect will destroy /etc/make.conf! A patch for this (untested) is located here: http://frap.net/stuff/mirrorselect.patch A log detailing the problem in action follows: scale root # echo what >test scale root # cat test what scale root # mirrorselect -a -s1 -o >> test Downloading a list of mirrors... Removing IPV6 Only Servers... Running netselect to determine mirrors, this might take a moment... netselect: unknown host mirror.iawnet.sandia.gov netselect: unknown host mirrors.sec.informatik.tu-darmstadt.de scale root # cat test GENTOO_MIRRORS="ftp://gentoo.ccccom.com" scale root # echo what >test scale root # cat test what scale root # ./mirrorselect.fixed -a -s1 -o >> test Downloading a list of mirrors... Removing IPV6 Only Servers... Running netselect to determine mirrors, this might take a moment... netselect: unknown host mirror.iawnet.sandia.gov scale root # cat test what GENTOO_MIRRORS="http://mirrors.tds.net/gentoo" scale root # diff `which mirrorselect` mirrorselect.fixed 296c296 < echo "${PATTERN}=\"${MIRRORS}\"" > /dev/stdout --- > echo "${PATTERN}=\"${MIRRORS}\"" # > /dev/stdout /dev/std* must not be used in this manner!
I have not modified mirrorselect for this test but... # echo what > test # mirrorselect -a -s15 -o >> test Downloading a list of mirrors... Removing IPV6 Only Servers... Running netselect to determine mirrors, this might take a moment... VHOST entries have been removed. This list might be shorter than expected root@johnm johnm # cat test what GENTOO_MIRRORS="http://www.mirror.ac.uk/sites/www.ibiblio.org/gentoo/ ftp://ftp.easynet.nl/mirror/gentoo/" Do you results differ from this then?
Yes, my results differ, and I've tested this on several machines. Are you using version 0.82?
yes i am. # mirrorselect -v Mirrorselect version: 0.82 Could you please remove the file from distfiles and try again.
I removed /usr/sbin/mirrorselect, /var/tmp/portage/mirrorselect-0.82/ and /usr/portage/distfiles/mirrorselect-0.82.tbz2, and then emerged it again. I'm still having the same problem. 48e84253f50bdf970e889a0c7f398f32 /usr/sbin/mirrorselect It's evident what the bug is. It can be re-created with this simple shell script: #!/bin/bash ls -l /proc/self/fd/1 >&2 echo truncate > /dev/stdout Ran like so: scale root # echo data>test; ./iobug.sh >>test; cat test lrwx------ 1 root root 64 Sep 29 11:57 /proc/self/fd/1 -> /dev/pts/7 truncated Any usage of /dev/std* symlinks will create this behavior.
mirrorselect-0.82-r1 was just commited, with the new tarball propogating shortly. I have ammended it to redirect the same way you did in your patch, and i have tested here. The results i got with both versions are identical, however hopefully you now should get the same results as myself. Please test and report back, and then i shall close this bug.
Works as expected now, thanks!
fixed