--- mage/branches/alx-0_6_0/profiles/alx-060/forced-uninstall 2011/07/04 21:21:17 2572 +++ mage/branches/alx-0_6_0/profiles/alx-060/forced-uninstall 2011/08/31 09:14:41 2816 @@ -1,26 +1,16 @@ #!/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_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_RSYNC="rsync://128.20.41.110/mage-alx-060" +NEW_MIRRORS="http://128.20.41.110/magellan/alx-060" NEW_PACKAGES_SERVER_PATH='packages/${ARCH}' NEW_MAGE_UNINSTALL_TIMEOUT=0 @@ -30,6 +20,14 @@ NEW_ALX_DHCP_START="-T 10 -t 5 -n -i" NEW_ALX_DHCP_STOP="" NEW_MIN_DISK_SPACE="85000" +NEW_ALX_PLUGINS="/usr/lib/alxconfig-ng/plugins" +NEW_ALX_FUNCTIONS="/usr/lib/alxconfig-ng/functions" + +# fake mage upgrade to prevent annoying error messages +if [[ ! -x /usr/sbin/mageupgrade ]] +then + mageupgrade() { true; }; export -f mageupgrade +fi read_value() { @@ -70,13 +68,38 @@ done } +updategrub2() +{ + # create a device.map + if [[ ! -f /boot/grub/device.map ]] + then + grub-mkdevicemap + fi + + # needed by grub-mkconfig on the first run + if [[ ! -f /boot/grub/video.lst ]] + then + install -m0644 /lib/grub/*/video.lst /boot/grub/video.lst + fi + + # update grub.cfg + grub-mkconfig -o /boot/grub/grub.cfg + + # install bootloader to disk + local bootdisk + bootdisk="$(grub-probe --target=drive /boot | sed 's:(\(.*\),.*):(\1):')" + + # Generate core.img, but don't let it be installed in boot sector + grub-install --no-floppy "${bootdisk}" +} + # 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 +updateconfig ALX_NETWORKING ALX_DHCP_PROG ALX_DHCP_START ALX_DHCP_STOP MIN_DISK_SPACE ALX_PLUGINS ALX_FUNCTIONS # fix profile if [[ $(readlink /etc/mage-profile) != */${MAGEPROFILE} ]] @@ -85,6 +108,14 @@ ln -snf /usr/mage/profiles/${MAGEPROFILE} /etc/mage-profile fi +# fix missing /dev/root device +if [[ ! -e /dev/root ]] +then + echo "fixing missing /dev/root symlink ..." + rootdev=$(basename $(mount | grep ' / ' | cut -d' ' -f1)) + [[ -e /dev/${rootdev} ]] && ln -snf ${rootdev} /dev/root +fi + # update mage3 -> mage4 if [[ -z $(magequery -n mage) ]] then @@ -113,17 +144,22 @@ touch /.dist-upgrade fi -# check for -f option -if [[ -n $(magequery -h | grep -- -f) ]] +# only run this if X11R6 is a directory and not a symlink +if [[ -d /usr/X11R6 ]] && [[ ! -L /usr/X11R6 ]] then - # uninstall all /usr/X11R6 packages first - for i in $(magequery -f /usr/X11R6 | sed 's:.*/\(.*\)-.*-r.*:\1:') - do - mage uninstall ${i} - done + # 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 -# if /usr/X11R6 is a directoy, simply delete it with the content -[ -d /usr/X11R6 ] && rm -rf /usr/X11R6 # install new toolchain if not exist TOOLCHAIN="$(< /etc/mage-profile/toolchain.defaults)" @@ -146,12 +182,15 @@ if [[ -z $(magequery -n ${BASESYSTEM}) ]] then # first keep some important files - + # export bootstrap to not start any services export MAGE_BOOTSTRAP=true mage install ${BASESYSTEM} unset MAGE_BOOTSTRAP +# # fix locale +# echo "LANG=\"de_DE\"" > /etc/conf.d/locale + # enable run of orphaned files check touch /.orphaned @@ -168,9 +207,6 @@ touch /.orphaned fi -# etc-update -#etc-update - # clean mage cache mage clean @@ -191,6 +227,13 @@ mage uninstall ${i} done +if [[ -f /.orphaned ]] +then + echo "Searching for orphaned files and directories ..." + bash /etc/mage-profile/prune-orphaned-files + rm -f /.orphaned +fi + if [[ -f /.dist-upgrade ]] then # array of wireless opts @@ -227,18 +270,50 @@ install -d /etc/modprobe.d mv ${i} /etc/modprobe.d/${i%.conf}.conf done + + mount /boot &> /dev/null + # install an appropriate uvesafb.conf + install -d /etc/modprobe.d || die + echo "options uvesafb mode_option=1024x768-32@60 scroll=ywrap" > /etc/modprobe.d/uvesafb.conf || die + # create an updated initrd + DISKMODS="sd_mod" + OLDPATAMODS="amd74xx piix sis5513 via82cxxx" + PATAMODS="ata_piix pata_amd pata_mpiix pata_oldpiix pata_sis pata_via" + SATAMODS="sata_via sata_sis sata_nv" + DRMMODS="i915 mga nouveau r128 radeon savage sis tdfx ttm via" + FBMODS="uvesafb" + echo "MODULES=\"${FORMAT_FILESYSTEM} ${DISKMODS} ${OLDATAMODS} ${PATAMODS} ${SATAMODS} ${DRMMODS} ${FBMODS}\"" > /etc/conf.d/mkinitrd + kernelver=$(readlink /boot/vmlinuz | sed 's:kernel-::') + # run depmod before + depmod -aF /boot/System.map-${kernelver} + mkinitrd -f /boot/initrd-${kernelver}.img ${kernelver} + # update grub bootloader + updategrub2 fi -if [[ -f /.orphaned ]] +if [[ -f /.dist-upgrade ]] then - echo "Searching for orphaned files and directories ..." - bash /etc/mage-profile/prune-orphaned-files - rm -f /.orphaned + echo "preparing a reboot in 60 seconds ..." + # reboot via cronjob + [[ ! -d /var/spool/cron/crontabs ]] && install -d /var/spool/cron/crontabs + # setup a proper cronjob + tmp=$(mktemp) + :> ${tmp} + # fake mageupgrade to fix annoying error messages + if [[ ! -x /sbin/mageupgrade ]] + then + echo '!/bin/sh' > /sbin/mageupgrade + echo 'exit 0' >> /sbin/mageupgrade + chmod +x /sbin/mageupgrade + echo "* * * * * rm /sbin/mageupgrade" >> ${tmp} + fi + echo "* * * * * crontab -r && reboot -f" >> ${tmp} + crontab ${tmp} + [[ -f ${tmp} ]] && rm -f ${tmp} + # start cron daemon in background + crond -b -S + + rm -f /.dist-upgrade fi -#if [[ -f /.dist-upgrade ]] -#then -# rm -f /.dist-upgrade -# # force a reboot at this point here -# ( reboot -f & ); exit 0 -#fi +exit 0