Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
safesync1.0b avoids uneeded/unwanted upgrades.
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Unsupported Software
View previous topic :: View next topic  
Author Message
dagurasu
n00b
n00b


Joined: 29 Apr 2005
Posts: 74

PostPosted: Sun Jan 21, 2007 4:27 pm    Post subject: safesync1.0b avoids uneeded/unwanted upgrades. Reply with quote

Last edited Feb 5, 2007

I have moved this here from it's original location because this seems like the appropriate forum. Also after about six weeks the original author, barefootcoder, has been silent. If he comes back sorry if I stepped on his toes. There is still alot of his original script in here. See the comments for details about that and everything else. I am testing this on my system now and have been testing a nearly final version for a few weeks. It seems to be working but it's certainly still beta. Even if you do everything right I won't gaurantee that this code won't destroy your whole computer, put a curse on your family and shave your dog, but that's not the plan. Use at your own risk, and I would reccomend actually reading the script first to see if it's right for you. READ THE INSTRUCTIONS IN THE COMMENTS OR YOU COULD END UP UNHAPPY WITH THE RESULTS (you could anyway). Don't expect daily maintenance on this, but maybe I'll be able to work on it a little from time to time.

Here it is:
(removed some incorrect comments at 10:15 CST on 1/21/07)
Code:

#! /bin/bash
# vi: set ai ts=4 sw=4 :
#(Buddy doesn't like to update much as proven by the vi comment above... so he made this script :) )
# Safesync v 1.1b, Feb. 2007
#Version author: Dagurasu
#Modified from the original version written by Buddy Burden in 2005.
#
#In the present version this script backs up installed ebuilds and related files using hard links and thus no disk space.  If
#the original is removed the hard-link still exists.  If the orignal is not removed, the hard-link gets removed.  It saves alot
#of disk space of simple copy ideas.  It also handles fixes digests and Manifest but only as needed, saving time.  It can
#even restore ebuilds from packages  that have

#already left portage, although with minimal functionality


##########################################################################
 # Original copyright 2005 Buddy Burden <buddy@barefoot.net>
 #
 #       This program is free software; you can redistribute it and/or modify
 #       it under the terms of the GNU General Public License version 2, as
 #       published by the Free Software Foundation.
 #
 #       Required packages:
 #               sys-apps/coreutils
 #               sys-apps/findutils
 #               sys-apps/portage
 #
 #       10/8/5
 #       Initial version
 #
 #       1/13/6
 #       Added code to rebuild manifests for saved ebuilds
 #       Also now properly deals with PORTAGE_DIR being set in make.conf
 ###############################################################################

#History:
#There was once a similar script here:
#http://forums.gentoo.org/viewtopic-t-360366-highlight-.html
#
#There was more discussion here:
#http://forums.gentoo.org/viewtopic-t-372840-highlight-sane.html
#where Dagurasu proposed and tested the use of hard-links for copying the overlay files in order to save LOTS of space
#
#Then the ORIGINAL version of this script appeared here:
#http://forums.gentoo.org/viewtopic-t-422428-highlight-.html
#by barefootcoder who actually did something with dagurasu's idea.
#
#In version 1.0b dagurasu has added alot of features and streamlined some things.
#Changes from the original are mostly commented.

#******************************************************************************
#Motivation: (Dagurasu Jan 2007)
#
#Portage has many nice features, but easily maintaining stable production machines is hardly one of
#them, and develepors (rightfully) do not seem focussed on that as a primary mission. The biggest
#problem is that the rather basic feature of being able to upgrade most things, while keeping specific
#applications unchanged (to the extent possible) is certainly NOT supported.  The package.mask file will
#prevent updates of certain packages, but when your version no longer exists in the portage tree,
#portage will not recognize that it satisifies dependancies of other packages or of a top-level world
#file entry.  Commands like emerge -u world will then complain and refuse to do anything and you will be
#forced to upgrade or manually copy your program to an overlay, if you even know or care what an overlay
#is, and assuming you still have the source code, which, by the time portage complains, YOU
#DON'T!(unless you were thinking ahead)... so basically you are just forced to upgrade(actually if you
#don't ever want to recompile your old version, you can get a backup copy of the ebuild alone from the
#system and use that in the overlay to prevent a forced upgrade, that's how dagurasu's first script
#worked).  Ok, so maybe there's only a few programs like that and you don't mind learning what an
#overlay is and copying your programs there (before you get the error messages)... keep reading.
#
#As the experts know, Portage has a world file that keeps in it things you want to have running on your
#computer. Portage then keeps track of things you NEED to have running.  If you want to update "world"
#(or something big like kde) it's often because you want the latest top level user features, not because
#you care that there is a new compiler which happens to support hidden visibility which MIGHT end up
#making kde start 1.5 seconds faster if you recompiled your whole system (say ooooh), which is exactly
#why the emerge -u world command exists and only updates the top level programs and other programs that
#are REQUIRED to be updated to make these work.... right? WRONG!!!!!! in principle this is true, but in
#fact it is not true.  Portage only keeps about 3 to 10 versions of any one package, typcially no more
#than a few months old.  Once the dependancies you have installed are not in Portage, they will be
#updated whether they need to be or not.  That means extra downloading and compiling that you didn't
#think you asked for.  So in fact ALL dependancies WILL be updated whether they need to be or not, just
#not quite as often.  Now it's undoubtly true that not every combination of new software has been tested
#with every old software and unknown bugs could arise if you have lots of software interacting that's
#too many generations apart, but keeping everything on the bleeding edge of development and changing
#things that were once working can also cause bugs.
#
#The main issue really, in the belief of the present maintainer, is that you should get what you ask for
#and in the spirit of Gentoo, you should have choices.
#*******************************************************************************************
#Changes:
#version 1.1b, Feb 5, 2007
#fixed typo that caused script to copy files that were already copied previously.  This caused no errors, only minor extra work.
#
#version 1.0b Jan 2007
#
#Tracks changes to do much less digest(usually none) and Manifest building, more file cleaning, options
# for handling ebuilds that are already missing, default behaviours if config file doesn't exist... activates
# overlay automatically if needed, gets/checks process locks, does cleanup if stale lock exists.
#
#Todo:
#Maybe check that emerge is not running.  But is there a way to keep emerge from starting?
#The catch 22 is we ned to run emerge --sync, but don't want any other emerges interfering.
#Portage doesn't have this kind of feature either, but that doesn't mean it shouldn't.

#Fine print. The authors take no resposibility for and provide NO warranty for any use of this software. 
#It is open software and you can read it for yourself.  If you are not cabable of understanding it and
#accepting for yourself what it does, then you instead can accept for yourself the risk of using
#un-warrantied software that you do not understand, or you can chose to not use it at all.  In any case,
#any consequences, direct or indirect, of such use are not the responsibility of the authors.  Your use of this
#software indicates that you understand and agree with these conditions.

#All that said, hope you find it useful.

#************************************************************************************************
#Instructions:
#YOU MUST MODIFY ANY AUTOMATED portage syncs to use this script.  If any portage sync is
#done without this script it will interfere with and defeat the purpose of this script.  For standard
#configurations the automatic sync command is found in /etc/crond.weekly/sync.  After you ahve tested
#this script enough to decide to try it, edit the command in this file to point to this script, or
#disable automatic syncing entirely. (maybe possible through some other config file).
#
#That, said, you can just run the script as is.  For some advanced features you will need to make a
#configuration file named /etc/portage/safesync.conf
#
#The following variables can be defined there (or actually you can as well just uncomment them right here
# but then ignoring the warnings about using default settings)

#Set the overaly directory, default is: If you use hardlinks (required presently) then this directory
#should be on the same filesystem as portage but preferably not in a portage subdirectory.  You can
#place it in a portage subdirectory if you set the RSYNC_EXCLUDEFROM to include that directory in your
#make.conf.  You should certainly NOT set it to a directory which alrady contains something else. The
#contents of this directory may be deleted. (Don't set it to "/" for instance, that would not be smart)
#SAFESYNC_DIR=/usr/local/portage/safesync

#Set the overlay copy method, default (and only supported method) is:
#SAFESYNC_FEATURES=hardlinks

#Take missing ebuilds from the package database, this does not recover source code but will cause
#dependancies to be satisfied so long as you don't try to recompile.  This won't ever be an issue if you
#only use safesync for your syncing, at least not after you deal with the packages you've already lost. 
#If you do keep missing ebuilds and the related pakcage files are not recovered succesfully (with
#DIGEST_MISSING=yes) and you try to recompile these packages with forced versioning (like using
#package.mask) you will get errors.  You will likely need to emerge an update in this case.  The first
#dagurasu script used this technique alone and had useful benefits.
#KEEP_MISSING_EBUILDS=yes # default is "no".

#Remove ebuild from the overlay for packages which are no longer installed on your computer If you
#un-install something temporarily, safesync could remove it(or at least that version) permanently but it
#will save space.  If this is set to no, there is no limit to the size the overlay may eventually reach.
#Probably using this option ocassionally is the best aproach... maybe should be command-line option.
#REMOVE_UNINSTALLED=no # default is "no", but "yes" can be good too, inspite of the risks.

#Attempt to recover the digest (and all related package files along with it) for ebuilds that were not
#in portage and were recovered from the systems package database.  This is slow and in many cases won't
#even be successful, not recommended.
#DIGEST_MISSING=no  # default is "no", "yes" is not recommended.
#*************************************************************************************************
# The script:

cleanup (){
echo ">>> Doing cleanup phase..."
echo
#This is the stuff to do after a sync command to clean uneeded stuff out of the overlay and to update
# digests and manifests
#
#
# now get rid of any ebuilds that actually are still in the main portage dir
         installedlist=$(ls /var/db/pkg/*/*/*.ebuild)
#         echo installed $installedlist
echo ">>> Cleaning overlay of ebuilds still in portage tree"
if [[ "$REMOVE_UNINSTALLED" == "yes" ]]
then
  echo "    Overlay ebuilds for un-installed packages will also be removed"
fi
echo

# see if we can use every possible method to list and parse file names :P

for file in `find $SAFESYNC_DIR -name "*.ebuild"`
do
         ebuild=${file##*/}
         dir=${file%%/$ebuild}

         orig=${file/#$SAFESYNC_DIR/$PORTAGE_DIR}
         if [[ -e $orig ]]
         then
# double check what we're rm'ing
#still doesn't help if the user sets  crazy safesync directory like /, but at least
# checks for completing broken filename parsing above.
             if [[ `echo $file |grep -c $SAFESYNC_DIR` == "1" ]]
              then
#              echo removing $file
                 /bin/rm  -f $file
# It should be impossible for the the untouched file to still be here because if this ebuild is still in portage
# it would not have been in the overlay when we started (because it would have been cleaned out last time) so it
# was just copied there by this script, and thus the untouched file was already removed when that happened.
# Just to avoid non-local assumptions....
                 rm ${dir}/untouched 2> /dev/null
             else
              echo safesync:  Error, this should never happen >&2
             fi
         fi

# Dagurasu adds an optional check to clean stuff that's no longer installed be careful with this option.  If you
# un-install something #off the portage tree for just a little while and your cron job safesync runs while this
# option is set, the ebuild will be deleted.  You get what you ask for.(unless there's bugs ;))
         if [[ "$installedlist" !=  *"$ebuild"* ]]
         then
           echo " $ebuild is still in overlay but is not installed"
           if [[ "$REMOVE_UNINSTALLED" == "yes" ]]
           then
# double check what we're rm'ing...
             if [[ `echo $file |grep -c $SAFESYNC_DIR` == 1 ]]
             then
#               echo removing $file
               /bin/rm -f $file
# This time we definitely need to touch the directory
               rm ${dir}/untouched 2> /dev/null
             fi
           else
           echo "To clean from overlay automatically add REMOVE_UNINSTALLED=yes to $conffile"
           echo "If you unistalled something mistakenly and do this, you can't re-install it"
           echo "if it's no longer in portage."
           fi
         fi
 done
 
 # now find any directories that have no ebuilds in them and ditch those too
 echo ">>> Removing overlay directories containing no ebuilds"
 echo
 for dir in $SAFESYNC_DIR/*/*
 do
         if [[ -z $(ls $dir/*.ebuild 2>/dev/null) ]]
         then
# double check what we're rm'ing
             if [[ `echo $file |grep -c $SAFESYNC_DIR` == 1 ]]
             then
#                 echo removing $dir
                 /bin/rm -rf $dir            # the -r is necessary because it may contain other "files/"
            fi
         fi
 done
 
# just to be extremely tidy, try to remove all the dirs directly under $SAFESYNC_DIR
# if the rmdir doesn't work, it means it's not empty, so no biggie
# and if it does work, then it was empty and now it's gone, which is what we want

 for dir in $SAFESYNC_DIR/*
 do
         rmdir $dir 2>/dev/null   # do this quitely
 done
 
# last thing we have to do is to rebuild any manifests for new ebuilds that we copied over
# the easiest thing to do is just rebuild them all, so that's what we do here
# if anyone can think of a way to rebuild only the necessary ones, please feel free to contribute an idea

# Dagurasu completely overhauls the digest building.  First of all, we don't need to build package digests at all,
# except for a new #exception that I've introduced.  We just need Manifests for the package directory.  The
# individual digest files will (normaly) be #copied over from the portage tree.  This alone saves ALOT of time.

# With this in we'll loop over all the overlay ebuilds and first check if this is a "missing" ebuild, one that
#didn't exist in portage #before the sync was performed.  This can happen if it's the first time to use the script
#or if emerge --sync gets called directly #without this script. (like in you weekly cron jobs... this shouldn't
#happen).  Otherwise this should never happen.  #If #DIGEST_MISSING=yes (in config file) try to rebuild digests
#for these missing ebuilds.  At the moment it is only done for #directories changed in present run of this script. 
#By removing the touched conditional, you could go back and add digests to all #missing ebuilds, there's ups and
#downs to both ways. In the case of ebuilds that have been out of portage for awhile, the digest build will
#attempt to fetch the needed files(which you #are almost certainly missing) to accompany the ebuild.  This can be
#good becasue it might get lucky and find them, but it will #probably take a long time and probably won't find
#them.  You are warned. Otherwise, this step will do nothing.

#Next we check that there is a manifest file.  If not, it certainly needs to be rebuilt and will.  This could
#happen because of a missing ebuild with DIGEST_MISSING not equal to "yes". Or for any other random reason you
#may have deleted your Manifest #file.  Just because #the Manifest file is there though, doesn't mean it doesn't
#need updating either. Next check if the directory has #been "touched"(changed) by the script.  If so, the update
#the Manifest file. That's it.  If no missing ebuilds and no missing Manifest, and no changes to the directory,
#then nothing happens.

#Now one could also add a double-check here to make sure that the digest
#file itself exist even for non-missing ebuilds, but if it #does, it's
#becuase it was already missing in your portage tree and it's not this
#scripts fault anyway.

echo ">>> Rebuilding broken Manifest and digest files ..."

for file in `find $SAFESYNC_DIR -name "*.ebuild"`
do
         ebuild=${file##*/}
         dir=${file%%/$ebuild}
         if [[ ( "$DIGEST_MISSING" == "yes" ) && ( ! -e "${dir}/untouched" ) &&  ( -e "${file}.missing" )  ]]
         then
             ebuild $file digest  #digest automatically does Manifest too.
             touch ${dir}/untouched
         fi
         if [[ ( ! -e "${dir}/Manifest" ) || ( ! -e "${dir}/untouched" ) ]]
         then
             ebuild $file manifest
#We don't need to make the Manifest twice for the same directory, so we can mark it as ok now.
             touch ${dir}/untouched 
         fi
done
# end of cleanup function
}

 get_filesys ()
 {
         cd "$1"
         df . | tail -n1 | cut -d' ' -f1
         cd -
 }

function cleanexit {
# call this to exit from a place that will leave the overlay in a consistent state
 rm -f $lockfile
 exit $1
}



#************************************************************************
#************************Start of main script*****************************
#************************************************************************
# If safesync didn't finish we need to mkae sure to rebuild manifests for all the packages changed
# before marking everything as untouched.  Also it's best to do all the cleanup.  We need to get and
# and check locks.  If the lock wasn't removed and the process doesn't exist, then we can start with cleanup.

lockfile="/etc/portage/safesync.lock"
docleanup="n"


# get a lock
if ! ( set -o noclobber; echo "$$" > "$lockfile") 2> /dev/null;
then
#if lock fails, see if the old process is still running
  procnum=`cat $lockfile`
  proc_running=`ls -1 --color=none /proc |grep -c -x $procnum`
  if [[ $proc_running != 0  ]]
  then
    echo "It looks like safesync is already running with PID $procnum"
    echo "If this is not true, please remove $lockfile and try again."
    echo "Exiting"
    exit 1
  else
# We need a cleanup at the end of every script.  If a directory was changed, it needs it's Manifests
# updated. It may not be changed next time so may not get updated next time, so if the cleanup wasn't
# done, we need to do it.
     echo "It looks like safesync exited unexpectedly last time"
     echo "Cleanup will run before syncing"
# Now remove the old lock...
     rm -f $lockfile
# And claim a new one for ourselves.
     if ! ( set -o noclobber; echo "$$" > "$lockfile") 2> /dev/null;
     then
       echo "safesync: Failed to get process lock. Check for other running safesync processes"
       echo "    and check that $lockfile is in a writeable directory"
     fi
     docleanup="y"
  fi
fi


 readonly me=${0##*/}
 source /etc/make.conf
 if [[ -z $PORTAGE_DIR ]]
 then
         readonly PORTAGE_DIR=/usr/portage
 fi
 
 # check for --help in args
 if [[ " $* " == *" --help "* ]]
 then
         echo "Usage:"
         echo "   $me [ options ]"
         echo "   $me --help"
         echo "options are passed through to emerge sync"
         cleanexit 
 fi
 
# make sure our config file exists and then suck it in
# Dagarasu changes this from $me.conf to safesync.conf
# This text is passed on message boards and the program may not always be run with the same name.
# This way the config file will be the same and the instructions simpler.
 conffile=/etc/portage/safesync.conf
 if [[ ! -e $conffile ]]
 then
         echo "$me: cannot find config file $conffile" >&2
#Dagurasu adds default behaviors
         echo "  Using default settings" >&2
 else
  source $conffile
 fi

# figure out what our overlay directory is and make sure it's okay
 if [[ -z $SAFESYNC_DIR ]]
 then
         echo "$me: SAFESYNC_DIR is not set in config file" >&2
         echo "Using default directory /usr/local/portage/safesync" >&2
         SAFESYNC_DIR=/usr/local/portage/safesync
 fi
 if [[ ! -d $SAFESYNC_DIR ]]
 then
         echo "$me: overlay directory $SAFESYNC_DIR does not exist"

#Dagurasu adds his automatic overlay directory creation

         echo "Creating portage overlay in ${SAFESYNC_DIR}"
         mkdir -p $SAFESYNC_DIR
         if [[ ! -d $SAFESYNC_DIR ]]
         then
           echo "$me: error making portage overlay directory" >&2
           cleanexit 1
         fi
 fi
 if [[ " $PORTDIR_OVERLAY " != *" $SAFESYNC_DIR "* ]]
 then
         echo "$me: overlay directory $SAFESYNC_DIR is not listed in PORTDIR_OVERLAY in /etc/make.conf"
#Dagurasu adds automatic overlay activation.
         echo "Enabling  overlay directory ${overlay} in /etc/make.conf ." 
         echo "PORTDIR_OVERLAY=\"\${PORTDIR_OVERLAY} ${SAFESYNC_DIR}\""    >> /etc/make.conf
 fi


 if [[ $SAFESYNC_DIR == $PORTAGE_DIR/* && " $RSYNC_EXCLUDEFROM " != *" $SAFESYNC_DIR "* ]]
 then
         echo "$me: if you want to put overlay dir under $PORTAGE_DIR, you have to list it in RSYNC_EXCLUDEFROM" >&2
         cleanexit 1
 fi
 
# check for hard links in features
# If hard links are used extra space required is limited to the ebuild files for programs installed in your system
# and not in portage.  If hard links are not used, extra space needed will temporarily be twice the portage directories
#corresponding to all packages installed on the system, easily hundreds of megabytes.
#
# Now default to using hard-links
 if [[ " $SAFESYNC_FEATURES " == *" hardlinks "* || "$SAFESYNC_FEATURES " == " " ]]
 then
         # they want to use hard links, so make sure our overlay dir is on the same filesys as $PORTAGE_DIR
         if [[ $(get_filesys $SAFESYNC_DIR) != $(get_filesys $PORTAGE_DIR) ]]
         then
                 echo "$me: in order to use hard links, overlay dir $SAFESYNC_DIR must be on the same file system as $PORTAGE_DIR" >&2
                 cleanexit 1
         fi
         copy_cmd="ln -f"
 else
         echo "$me: sorry; copies to overlay is not implemented at this time" >&2
         echo "     (please turn on hardlinks in SAFESYNC_FEATURES)" >&2
         cleanexit 3
         # could it be as simple as this?
         #Answer: Of course, but what sane person would not want to use hard links?
        copy_cmd="cp -pf"
 fi

if [[ $docleanup == "y" ]]
then
  cleanup
fi

portage_installed=` ls -1 --color=none /var/db/pkg/*/*/*.ebuild `

#First mark directories as untouched so that clean directories
# don't need digest rebuilding
for file in `find $SAFESYNC_DIR -name "*.ebuild"`
do
         ebuild=${file##*/}
         dir=${file%%/$ebuild}
         touch $dir/untouched
done


 # now go through the installed packages one at a time

for installed_pkg in $(ls /var/db/pkg/*/*/*.ebuild)
do
        ebuild=${installed_pkg##*/}
        dir=${installed_pkg%-[0-9]*/$ebuild}
        dir=${dir#/var/db/pkg/}
        found_in_overlay=0
#        echo $ebuild
#        echo $dir
         # if the dir isn't there at all, the package is from an overlay
         # we don't care about those, since emerge sync won't delete them
         if [[ ! -d $PORTAGE_DIR/$dir ]]
         then
                 found_in_overlay=1
         else
                 # of course, even if the dir exists, it could _still_
                 # be from an overlay, so better check for that
                 for odir in $PORTDIR_OVERLAY
                 do
                         if [[ -e $odir/$dir/$ebuild ]]
                         then
                                 found_in_overlay=1
                         fi
                 done
         fi
 
         if [[ $found_in_overlay == 0 ]]
         then
                 if [[ ! -d $SAFESYNC_DIR/$dir ]]
                 then
                         mkdir -p $SAFESYNC_DIR/$dir/files 2>/dev/null
                 fi
# Dagurasu changes to no "copy"(no link really) if it's already in the overlay.
# this way we can try to leave the directory untouched and won't need to
# rebuild the manifest later
# just to be safe we'll say if ANYTHING in this $dir is touched we should rebuild all the
# the manifest... this is what will happen.
                 if [[ -e $PORTAGE_DIR/$dir/$ebuild && ! -e $SAFESYNC_DIR/$dir/$ebuild ]]
                 then
                         /bin/rm -f $SAFESYNC_DIR/$dir/$ebuild
                         /bin/rm -f $SAFESYNC_DIR/$dir/untouched 2>/dev/null
                         $copy_cmd $PORTAGE_DIR/$dir/$ebuild $SAFESYNC_DIR/$dir
 
                         for file in $(find $PORTAGE_DIR/$dir/files/*)
                         do
                                 if [[ -d $file ]]
                                 then
                                         file=${file/#$PORTAGE_DIR/$SAFESYNC_DIR}
                                         mkdir $file 2>/dev/null
                                 else
                                         $copy_cmd $file $SAFESYNC_DIR/$dir/files
                                 fi
                         done
                 else
                         echo "$me: ebuild $ebuild is already gone!" >&2
                         got_missing=1
                         if [[ "$KEEP_MISSING_EBUILDS" == "yes" ]]
# Dagurasu's option to salvage installed ebuilds that are not in the overlay and have already gone from portage.
                         then
                            echo "Copying ebuild from package database"
                            echo "Package files will not be copied and this ebuild cannot be re-compiled"   
                            cp $installed_pkg $SAFESYNC_DIR/$dir
                            if [ ! -f $SAFESYNC_DIR/$dir/$ebuild ]; then
                              echo "error copying ${buildfile} to overlay"
                              exit 1
                             fi
# mark this ebuild as one that doesn't have all it's files.
                             touch $SAFESYNC_DIR/$dir/$ebuild.missing
                         fi
                 fi
         fi
 done

chgrp -R portage $SAFESYNC_DIR
 
#if [[ $got_missing ]]
#then
#  Dagurasu believes that this script should replace the normal cron job or else it is useless
# (if emerge sync is run directly even once, this script is defeated)
# for this reason the script should NOT be interactive. This prompt was broken anyway,
# probably for this very reason so it is now commented out entirely in this version.
# Anyway there is now a configuration choice about what to do with missing ebuilds.
#         echo "Do you want to continue? [y/N] "
#fi
 
# added "--" for current syntax
echo ">>> Doing  emerge --sync"
echo
emerge --sync "$@"
#now cleanup.
cleanup
#release the lock
rm -f $lockfile


Last edited by dagurasu on Mon Feb 05, 2007 11:53 pm; edited 6 times in total
Back to top
View user's profile Send private message
Belliash
Advocate
Advocate


Joined: 24 Nov 2004
Posts: 2503
Location: Wroclaw, Poland

PostPosted: Sun Jan 21, 2007 4:41 pm    Post subject: Reply with quote

for short: what does it do and how does it work?
does not everyone knows scripting...
_________________
Asio Software Technologies
Belliash IT Weblog
Back to top
View user's profile Send private message
dagurasu
n00b
n00b


Joined: 29 Apr 2005
Posts: 74

PostPosted: Sun Jan 21, 2007 4:47 pm    Post subject: Reply with quote

Gotta leave for church, but it hard-links the portage directories for all installed ebuilds to an overlay (a place where they are safe). It then does emerge sync. If any of your installed ebuilds are no longer in portage you'll still have a copy and won't be forced to upgrade. Becasue it hard links it can copy everything, even though it doesn't yet know which ones will be needed, and yet only ends up using disk space for the ones that get removed from the main portage tree. Basically, it makes package.unmask work forever as many newbies expect it to. Actually package.unmask only wors until the package is gone from portage at which point your sad.

Anyway, please read the motivation section in the comments. I can explain more later. Also please check out the links in the comments.
as well as this https://forums.gentoo.org/viewtopic-p-3857352.html#3857352
Back to top
View user's profile Send private message
Belliash
Advocate
Advocate


Joined: 24 Nov 2004
Posts: 2503
Location: Wroclaw, Poland

PostPosted: Sun Jan 21, 2007 4:53 pm    Post subject: Reply with quote

Could you tell me how long does it take?
_________________
Asio Software Technologies
Belliash IT Weblog
Back to top
View user's profile Send private message
dagurasu
n00b
n00b


Joined: 29 Apr 2005
Posts: 74

PostPosted: Sun Jan 21, 2007 7:51 pm    Post subject: Reply with quote

I haven't timed it. It's not like blink and it's done; it's some seconds, but it's not minutes generally, unless you use some of the more extreme options to recover old ebuild files that you've already lost. Maybe if you've waited a long time between syncs it will need to build more Manifest files, but even this shouldn't take all that long. Of course the emerge --sync that is called in the middle of it could take a very long time on a slow connection, but that's not this script's fault. This is meant as a wrapper for emerge --sync. If you want to use it, you should use it to replace ALL of your direct usage of emerge --sync, including in any scheduled crond jobs.
Back to top
View user's profile Send private message
dagurasu
n00b
n00b


Joined: 29 Apr 2005
Posts: 74

PostPosted: Sun Jan 21, 2007 8:13 pm    Post subject: Reply with quote

already found an error, it come from cutting and pasting somehow I think.

this:
#KEEP_MISSING_EBUILDS=yes # default is "no".

was uncommented, and probably caused the default or at least initial setting to in fact be "yes". It's fixed now and the default is now "no" as claimed.
Back to top
View user's profile Send private message
dagurasu
n00b
n00b


Joined: 29 Apr 2005
Posts: 74

PostPosted: Tue Jan 23, 2007 6:17 pm    Post subject: Reply with quote

I linked this thread in to bug #126059. There is as of the day before I started this thread, another script there to do similar things. It requires a portage patch or something too. I haven't looked at it enough yet, but I suspect there are good things to take from both of these scripts. Glad to see this issue getting some attention.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Unsupported Software All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum