Brian Harring wrote:
Looks good; game to do the same for emerge-webrsync, and add in
support for tarsync if it's available?
Done. Please look at the patches, I hope this is what you had in mind.
I basically copied it from emerge-delta-webrsync.
Users will feed you cookies for the faster emerge-webrsync ;)
Hmmm... I like cookies ;-)
Offhand... one option, minimal diff (although untested, so might have
args wrong)-
if [[ -n $PORTAGE_NICENESS ]] && ! [[ -z $WE_ARE_NICED ]]; then
export WE_ARE_NICED=1
exec nice -n "$PORTAGE_NICENESS" "$0" "$@"
fi
Ok, put it in emerge-delta-webrsync and emerge-webrsync. I had to change
if [[ -n $PORTAGE_NICENESS ]] && ! [[ -z $WE_ARE_NICED ]]; then
to
if [[ -n $PORTAGE_NICENESS ]] && [[ -z $WE_ARE_NICED ]]; then
(otherwise it would have read AND NOT $WE_ARE_NICED is NOT set...)
Icky re-execing, but is the usual trick...
Seems to work for me.
If these patches should get accepted and I should get credited, please
say "Johannes Fahrenkrug (jfahrenkrug_gmail_com)".
Thank you and I'm looking forward to hearing what you think.
- Johannes.
--- /usr/bin/emerge-delta-webrsync 2006-01-04 09:26:07.0 +0100
+++ emerge-delta-webrsync 2006-01-11 10:04:14.551773368 +0100
@@ -7,8 +7,18 @@
#---
#initialization
#--
+PORTAGE_NICENESS=$(portageq envvar PORTAGE_NICENESS)
-f=$(python -c'import portage; print "|".join([portage.settings[x] for x in ("GENTOO_MIRRORS", "PORTDIR", "FETCHCOMMAND", "USERLAND", "DISTDIR", "PORTAGE_TMPDIR")])')
+if [[ -n $PORTAGE_NICENESS ]] && [[ -z $WE_ARE_NICED ]]; then
+ export WE_ARE_NICED=1
+ exec nice -n "$PORTAGE_NICENESS" "$0" "$@"
+fi
+
+if [ -z "$PORTAGE_NICENESS" ] ; then
+PORTAGE_NICENESS=0
+fi
+
+f=$(nice -n $PORTAGE_NICENESS python -c'import portage; print "|".join([portage.settings[x] for x in ("GENTOO_MIRRORS", "PORTDIR", "FETCHCOMMAND", "USERLAND", "DISTDIR", "PORTAGE_TMPDIR")])')
IFS='|'
GENTOO_MIRRORS="${f%%|*}" ; f="${f#*|}"
@@ -183,7 +193,7 @@
echo Syncing local tree...
if type -p tarsync &> /dev/null; then
echo "apparently you have tarsync installed. using it."
- if ! tarsync "${FILE}" "${PORTDIR}" -v -s 1 -o portage -g portage -e /distfiles -e /packages -e /local; then
+ if ! nice -n $PORTAGE_NICENESS tarsync "${FILE}" "${PORTDIR}" -v -s 1 -o portage -g portage -e /distfiles -e /packages -e /local; then
echo "ok, tarsync failed. that's teh suck :/"
exit 6
fi
@@ -201,7 +211,7 @@
# Make sure user and group file ownership is root
chown -R 0:0 portage
cd portage
- rsync -av --progress --stats --delete --delete-after \
+ nice -n $PORTAGE_NICENESS rsync -av --progress --stats --delete --delete-after \
--exclude='/distfiles' --exclude='/packages' \
--exclude='/local' . ${PORTDIR%%/}
cd ..
--- /usr/sbin/emerge-webrsync 2005-12-28 11:49:18.0 +0100
+++ emerge-webrsync 2006-01-11 09:28:54.378088760 +0100
@@ -18,9 +18,25 @@
cd "$DISTDIR"
found=0
+rsyncops="-av --progress"
+
+PORTAGE_NICENESS=$(portageq envvar PORTAGE_NICENESS)
+
+if [[ -n $PORTAGE_NICENESS ]] && [[ -z $WE_ARE_NICED ]]; then
+ export WE_ARE_NICED=1
+ exec nice -n "$PORTAGE_NICENESS" "$0" "$@"
+fi
+
+if [ -z "$PORTAGE_NICENESS" ] ; then
+PORTAGE_NICENESS=0
+fi
+
if [ "$1" == "-v" ] ; then
wgetops=
else
+if [ "$1" == "-q" ] ; then
+ rsyncops="-aq"
+fi
#this sucks. probably better to do 1> /dev/null
#that said, waiting on the refactoring.
if [ "${FETCHCOMMAND/wget}" != "${FETCHCOMMAND}" ]; then
@@ -42,23 +58,31 @@
sync_local() {
echo Syncing local tree...
- if ! tar jxf $FILE; then
- echo "Tar failed to extract the image. Please review the output."
- echo "Executed command: tar jxf $FILE"
- exit 1
- fi
+ if type -p tarsync &> /dev/null; then
+ echo "apparently you have tarsync installed. using it."
+if ! nice -n $PORTAGE_NICENESS tarsync "${FILE}" "${PORTDIR}" -v -s 1 -o portage -g portage -e /distfiles -e /packages -e /local; then
+ echo "ok, tarsync failed. that's teh suck :/"
+ exit 6
+fi
+else
+ if ! nice -n $PORTAGE_NICENESS tar jxf $FILE; then
+ echo "Tar failed to extract the image. Please review the output."
+ echo "Executed command: tar jxf $FILE"
+ exit 1
+ fi
+ fi
rm -f $FILE
# Make sure user and group file ownership is root
chown -R 0:0 portage
cd portage
- rsync -av --progress --stats --delete --delete-after \
+ nice -n $PORTAGE_NICENESS rsync ${rsyncops} --stats --delete --delete-after \
--exclude='/distfiles' --exclude='/packages' \
--exclude='/local' . ${PORTDIR%%/}
cd ..
echo "cleaning up"
rm -rf portage
echo "transferring metadata/cache"
- emerge metadata
+ nice -n $PORTAGE_NICENESS emerge metadata
}
echo "Fetching most recent snapshot"