vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Greetings. I have a script that runs once a week to update my Gentoo stable 2006.1. This script is added to my /etc/cron.weekly directory. I am posting it here in the hopes that it will be useful to someone. I also appreciate any critical feedback that you may have. Thanks, Randall -- #!/bin/bash # # Weekly portage update... UNAME=`uname -n` DATE=`date +%Y.%b.%d` LOG_FILE="/var/log/update/${UNAME}.${DATE}" TMP_FILE=`mktemp /tmp/update.XXXXXX` PREFIX="... Error: the " POSTFIX=" package conflicts with another package;" # Update all packages to the best available version. Consider the # entire dependency tree, and not just the immediate dependencies. # Catch all new USE flags. function update { echo "/usr/bin/emerge --update --deep --newuse world" 2>&1 \ | tee -a ${LOG_FILE} /usr/bin/emerge --update --deep --newuse world 2>&1 \ | tee -a ${LOG_FILE} | tee ${TMP_FILE} } # Check for underlying packages that are blocking the update. function remove_blocker { RV=0 CONFLICT_LINE=`grep "${PREFIX}" ${TMP_FILE}` GREP_CODE=$? if [ ${GREP_CODE} -eq 0 ] then echo "${CONFLICT_LINE}" 2>&1 | tee -a ${LOG_FILE} PKG=`echo ${CONFLICT_LINE} | sed -e "s/${PREFIX}//" \ | sed -e "s/${POSTFIX}//"` echo "Fixing..." 2>&1 | tee -a ${LOG_FILE} echo "/usr/bin/emerge --unmerge ${PKG}" 2>&1 \ | tee -a ${LOG_FILE} /usr/bin/emerge --unmerge ${PKG} 2>&1 | tee -a ${LOG_FILE} \ | tee -a ${LOG_FILE} echo "Retrying..." 2>&1 | tee -a ${LOG_FILE} update RV=1 else echo "No package conflicts, continuing..." 2>&1 \ | tee -a ${LOG_FILE} fi return ${RV} } # start main # 2>&1 redirects error to where output is going echo "${UNAME} update ${DATE}" 2>&1 | tee ${LOG_FILE} date 2>&1 | tee -a ${LOG_FILE} # Synchronize with the latest information echo "/usr/bin/emerge --sync" 2>&1 | tee -a ${LOG_FILE} /usr/bin/emerge --sync 2>&1 | tee -a ${LOG_FILE} # Fix all packages that are impacted by Gentoo Linux security # advisories. echo "/usr/bin/glsa-check --fix all" 2>&1 | tee -a ${LOG_FILE} /usr/bin/glsa-check --fix all 2>&1 | tee -a ${LOG_FILE} # Do the initial update. update # Remove any packages that are blocking the update and re-emerge. remove_blocker CHECK=$? # echo "CHECK = ${CHECK}" while [ ${CHECK} -eq 1 ] do echo "." remove_blocker CHECK=$? # echo "CHECK = ${CHECK}" done rm ${TMP_FILE} # Remove unnecessary and unused packages. echo "/usr/bin/emerge --depclean" 2>&1 | tee -a ${LOG_FILE} /usr/bin/emerge --depclean 2>&1 | tee -a ${LOG_FILE} # Fix any shared libraries that were accidentally removed, or broken # by upgrades. echo "/usr/bin/revdep-rebuild" 2>&1 | tee -a ${LOG_FILE} /usr/bin/revdep-rebuild 2>&1 | tee -a ${LOG_FILE} # Sanely update configuration files. For command line only: # /usr/sbin/dispatch-conf # Show the differences for the day. Be certain your svn is setup # securely if you have your /etc directory checked into revision # control! Omitting shadow, and ssh keys, and other very private # files is also a good idea. # # echo "/usr/bin/svn stat /etc" 2>&1 | tee -a ${LOG_FILE} # /usr/bin/svn stat /etc 2>&1 | tee -a ${LOG_FILE} # End date 2>&1 | tee -a ${LOG_FILE} echo "Complete" 2>&1 | tee -a ${LOG_FILE} |
| ||||
| rwfields@yahoo.com wrote: > Greetings. I have a script that runs once a week to update my Gentoo > stable 2006.1. This script is added to my /etc/cron.weekly directory. > I am posting it here in the hopes that it will be useful to someone. > I also appreciate any critical feedback that you may have. I think trying to automate this is a bad idea, for several reasons: 1: You can't merge ._cfg0001_foo with foo, and some packages are automatically restarted after emerge, meaning the new version will run (or fail to run) with the old config file, which may not be appropriate. 2: Some packages overwrite the config files without even using configprotect. 3: Every now and then, the latest package breaks your system, or will only work with a certain kernel version. 4: There's no rebuild of the toolchain when gcc or libc is updated 5: Certain packages must be re-emerged after certain other packages. (Example: madwifi drivers must be re-emerged after wpa_supplicant) I also fail to see why you run "glsa-check --fix all". For one thing, what's covered there will also be covered by an emerge update, and even if it wasn't there yet, "glsa-check --fix affected" is probably the one you want. Regards, -- *Art |
| Thread Tools | |
| Display Modes | |
|
|