--- mage/branches/alx-0_6_0/profiles/alx-060/forced-uninstall 2011/05/12 20:43:28 2117 +++ mage/branches/alx-0_6_0/profiles/alx-060/forced-uninstall 2011/07/06 22:02:19 2616 @@ -1,6 +1,36 @@ #!/bin/bash # $Id$ +# setup exit trap for reboot +trap_exit() +{ + if [[ -f /.dist-upgrade ]] + then + rm -f /.dist-upgrade + # force a reboot at this point here + ( sleep 3 && reboot -f & ); exit 0 + fi +} +trap "trap_exit" EXIT + +# get a suitable environment +source /etc/profile + +MAGERC="/etc/mage.rc" +MAGEPROFILE="alx-060" +NEW_MAGE_DISTRIBUTION="unstable" +NEW_RSYNC="rsync://magellan-linux.de/mage-alx-0.6.0" +NEW_MIRRORS="http://magellan-linux.de/magellan/alx-0.6.0/${NEW_MAGE_DISTRIBUTION}" +NEW_PACKAGES_SERVER_PATH='packages/${ARCH}' +NEW_MAGE_UNINSTALL_TIMEOUT=0 + +CONFIGRC="/etc/alxconfig-ng/config.rc" +NEW_ALX_NETWORKING="dhcp" +NEW_ALX_DHCP_PROG="/sbin/udhcpc" +NEW_ALX_DHCP_START="-T 10 -t 5 -n -i" +NEW_ALX_DHCP_STOP="" +NEW_MIN_DISK_SPACE="85000" + read_value() { local file=$1 @@ -14,27 +44,39 @@ return 0 } -MAGERC="/etc/mage.rc" -MAGEPROFILE="alx-060" -NEW_MAGE_DISTRIBUTION="unstable" -NEW_RSYNC="rsync://magellan-linux.de/mage-alx-0.6.0" -NEW_MIRRORS="http://magellan-linux.de/magellan/alx-0.6.0/${NEW_MAGE_DISTRIBUTION}" -NEW_PACKAGES_SERVER_PATH='packages/${ARCH}' -NEW_MAGE_UNINSTALL_TIMEOUT=0 +updateconfig() +{ + local variables="$@" + local value + local i -# fix mage.rc -for i in RSYNC MIRRORS MAGE_DISTRIBUTION PACKAGES_SERVER_PATH MAGE_UNINSTALL_TIMEOUT -do - value="$(eval echo \${NEW_${i}})" - if [[ ! -z $(grep "^${i}=" ${MAGERC}) ]] + if [[ -z ${CONFIG} ]] then - echo "fixing $i -> ${value}" - sed -i "s|^\(${i}=\).*|\1\"${value}\"|" ${MAGERC} - else - echo "adding $i=${value}" - echo "${i}=\"${value}\"" >> ${MAGERC} + echo "You must define \$CONFIG varibale first!" + return 1 fi -done + + for i in ${variables} + do + value="$(eval echo \${NEW_${i}})" + if [[ ! -z $(grep "^${i}=" ${CONFIG}) ]] + then + echo "fixing ${i} -> ${value}" + sed -i "s|^\(${i}=\).*|\1\"${value}\"|" ${CONFIG} + else + echo "adding ${i}=${value}" + echo "${i}=\"${value}\"" >> ${CONFIG} + fi + done +} + +# fix mage.rc +CONFIG="${MAGERC}" +updateconfig RSYNC MIRRORS MAGE_DISTRIBUTION PACKAGES_SERVER_PATH MAGE_UNINSTALL_TIMEOUT + +# fix config.rc +CONFIG="${CONFIGRC}" +updateconfig ALX_NETWORKING ALX_DHCP_PROG ALX_DHCP_START ALX_DHCP_STOP MIN_DISK_SPACE # fix profile if [[ $(readlink /etc/mage-profile) != */${MAGEPROFILE} ]] @@ -71,6 +113,23 @@ touch /.dist-upgrade fi +# only run this if X11R6 is a directory and not a symlink +if [[ -d /usr/X11R6 ]] && [[ ! -L /usr/X11R6 ]] +then + # check for -f option + if [[ -n $(magequery -h | grep -- -f) ]] + then + # uninstall all /usr/X11R6 packages first + for i in $(magequery -f /usr/X11R6 | sed 's:.*/\(.*\)-.*-r.*:\1:') + do + mage uninstall ${i} + done + fi + + # if there are any files after uninstall, simply delete them + [ -d /usr/X11R6 ] && rm -rf /usr/X11R6 +fi + # install new toolchain if not exist TOOLCHAIN="$(< /etc/mage-profile/toolchain.defaults)" if [[ -z $(magequery -n ${TOOLCHAIN}) ]] @@ -125,6 +184,8 @@ do # excludes case ${i} in + alxconfig-ng) continue ;; + alxinstall-ng) continue ;; kernel-alx) continue ;; kernel26-alx) continue ;; kernel-sources-alx) continue ;; @@ -180,9 +241,9 @@ rm -f /.orphaned fi -if [[ -f /.dist-upgrade ]] -then - rm -f /.dist-upgrade - # force a reboot at this point here - reboot -f -fi +#if [[ -f /.dist-upgrade ]] +#then +# rm -f /.dist-upgrade +# # force a reboot at this point here +# ( reboot -f & ); exit 0 +#fi