Magellan Linux

Diff of /mage/branches/alx-0_6_0/profiles/alx-060/forced-uninstall

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2112 by niro, Thu May 12 18:51:46 2011 UTC revision 2716 by niro, Mon Aug 8 08:23:09 2011 UTC
# Line 1  Line 1 
1  #!/bin/bash  #!/bin/bash
2  # $Id$  # $Id$
3    
4    # setup exit trap for reboot
5    trap_exit()
6    {
7     if [[ -f /.dist-upgrade ]]
8     then
9     rm -f /.dist-upgrade
10     # force a reboot at this point here
11     ( sleep 3 && reboot -f & ); exit 0
12     fi
13    }
14    trap "trap_exit" EXIT
15    
16    # get a suitable environment
17    source /etc/profile
18    
19    MAGERC="/etc/mage.rc"
20    MAGEPROFILE="alx-060"
21    NEW_MAGE_DISTRIBUTION="unstable"
22    NEW_RSYNC="rsync://magellan-linux.de/mage-alx-0.6.0"
23    NEW_MIRRORS="http://magellan-linux.de/magellan/alx-0.6.0/${NEW_MAGE_DISTRIBUTION}"
24    NEW_PACKAGES_SERVER_PATH='packages/${ARCH}'
25    NEW_MAGE_UNINSTALL_TIMEOUT=0
26    
27    CONFIGRC="/etc/alxconfig-ng/config.rc"
28    NEW_ALX_NETWORKING="dhcp"
29    NEW_ALX_DHCP_PROG="/sbin/udhcpc"
30    NEW_ALX_DHCP_START="-T 10 -t 5 -n -i"
31    NEW_ALX_DHCP_STOP=""
32    NEW_MIN_DISK_SPACE="85000"
33    NEW_ALX_PLUGINS="/etc/alxconfig-ng/plugins"
34    
35  read_value()  read_value()
36  {  {
37   local file=$1   local file=$1
# Line 14  read_value() Line 45  read_value()
45   return 0   return 0
46  }  }
47    
48  MAGERC="/etc/mage.rc"  updateconfig()
49  MAGEPROFILE="alx-060"  {
50  NEW_MAGE_DISTRIBUTION="unstable"   local variables="$@"
51  NEW_RSYNC="rsync://magellan-linux.de/mage-alx-0.6.0"   local value
52  NEW_MIRRORS="http://magellan-linux.de/magellan/alx-0.6.0/${NEW_MAGE_DISTRIBUTION}"   local i
 NEW_PACKAGES_SERVER_PATH='packages/${ARCH}'  
 NEW_MAGE_UNINSTALL_TIMEOUT=0  
53    
54  # fix mage.rc   if [[ -z ${CONFIG} ]]
 for i in RSYNC MIRRORS MAGE_DISTRIBUTION PACKAGES_SERVER_PATH MAGE_UNINSTALL_TIMEOUT  
 do  
  value="$(eval echo \${NEW_${i}})"  
  if [[ ! -z $(grep "^${i}=" ${MAGERC}) ]]  
55   then   then
56   echo "fixing $i -> ${value}"   echo "You must define \$CONFIG varibale first!"
57   sed -i "s|^\(${i}=\).*|\1\"${value}\"|" ${MAGERC}   return 1
58   else   fi
59   echo "adding $i=${value}"  
60   echo "${i}=\"${value}\"" >> ${MAGERC}   for i in ${variables}
61     do
62     value="$(eval echo \${NEW_${i}})"
63     if [[ ! -z $(grep "^${i}=" ${CONFIG}) ]]
64     then
65     echo "fixing ${i} -> ${value}"
66     sed -i "s|^\(${i}=\).*|\1\"${value}\"|" ${CONFIG}
67     else
68     echo "adding ${i}=${value}"
69     echo "${i}=\"${value}\"" >> ${CONFIG}
70     fi
71     done
72    }
73    
74    updategrub2()
75    {
76     # create a device.map
77     if [[ ! -f /boot/grub/device.map ]]
78     then
79     grub-mkdevicemap
80   fi   fi
81  done  
82     # needed by grub-mkconfig on the first run
83     if [[ ! -f /boot/grub/video.lst ]]
84     then
85     install -m0644 /lib/grub/*/video.lst /boot/grub/video.lst
86     fi
87    
88     # update grub.cfg
89     grub-mkconfig -o /boot/grub/grub.cfg
90    
91     # install bootloader to disk
92     local bootdisk
93     bootdisk="$(grub-probe --target=drive /boot | sed 's:(\(.*\),.*):(\1):')"
94    
95     # Generate core.img, but don't let it be installed in boot sector
96     grub-install --no-floppy "${bootdisk}"
97    }
98    
99    # fix mage.rc
100    CONFIG="${MAGERC}"
101    updateconfig RSYNC MIRRORS MAGE_DISTRIBUTION PACKAGES_SERVER_PATH MAGE_UNINSTALL_TIMEOUT
102    
103    # fix config.rc
104    CONFIG="${CONFIGRC}"
105    updateconfig ALX_NETWORKING ALX_DHCP_PROG ALX_DHCP_START ALX_DHCP_STOP MIN_DISK_SPACE ALX_PLUGINS
106    
107  # fix profile  # fix profile
108  if [[ $(readlink /etc/mage-profile) != */${MAGEPROFILE} ]]  if [[ $(readlink /etc/mage-profile) != */${MAGEPROFILE} ]]
# Line 71  then Line 139  then
139   touch /.dist-upgrade   touch /.dist-upgrade
140  fi  fi
141    
142    # only run this if X11R6 is a directory and not a symlink
143    if [[ -d /usr/X11R6 ]] && [[ ! -L /usr/X11R6 ]]
144    then
145     # check for -f option
146     if [[ -n $(magequery -h | grep -- -f) ]]
147     then
148     # uninstall all /usr/X11R6 packages first
149     for i in $(magequery -f /usr/X11R6 | sed 's:.*/\(.*\)-.*-r.*:\1:')
150     do
151     mage uninstall ${i}
152     done
153     fi
154    
155     # if there are any files after uninstall, simply delete them
156     [ -d /usr/X11R6 ] && rm -rf /usr/X11R6
157    fi
158    
159  # install new toolchain if not exist  # install new toolchain if not exist
160  TOOLCHAIN="$(< /etc/mage-profile/toolchain.defaults)"  TOOLCHAIN="$(< /etc/mage-profile/toolchain.defaults)"
161  if [[ -z $(magequery -n ${TOOLCHAIN}) ]]  if [[ -z $(magequery -n ${TOOLCHAIN}) ]]
# Line 98  then Line 183  then
183   mage install ${BASESYSTEM}   mage install ${BASESYSTEM}
184   unset MAGE_BOOTSTRAP   unset MAGE_BOOTSTRAP
185    
186     # fix locale
187     echo "LANG=\"de_DE\"" > /etc/conf.d/locale
188    
189   # enable run of orphaned files check   # enable run of orphaned files check
190   touch /.orphaned   touch /.orphaned
191    
# Line 125  for i in $(magequery -i | grep -- -alx | Line 213  for i in $(magequery -i | grep -- -alx |
213  do  do
214   # excludes   # excludes
215   case ${i} in   case ${i} in
216     alxconfig-ng) continue ;;
217     alxinstall-ng) continue ;;
218   kernel-alx) continue ;;   kernel-alx) continue ;;
219   kernel26-alx) continue ;;   kernel26-alx) continue ;;
220   kernel-sources-alx) continue ;;   kernel-sources-alx) continue ;;
# Line 135  do Line 225  do
225   mage uninstall ${i}   mage uninstall ${i}
226  done  done
227    
 if [[ -f /.orphaned ]]  
 then  
  echo "Searching for orphaned files and directories ..."  
  bash /etc/mage-profile/prune-orphaned-files  
  rm -f /.orphaned  
 fi  
   
228  if [[ -f /.dist-upgrade ]]  if [[ -f /.dist-upgrade ]]
229  then  then
230   # array of wireless opts   # array of wireless opts
# Line 172  then Line 255  then
255   done   done
256   rm -f ${i}.orig   rm -f ${i}.orig
257   done   done
258     # search modules files
259     for i in $(find /etc/modules.d -name net.\*)
260     do
261     install -d /etc/modprobe.d
262     mv ${i} /etc/modprobe.d/${i%.conf}.conf
263     done
264    
265     mount /boot &> /dev/null
266     # install an appropriate uvesafb.conf
267     install -d /etc/modprobe.d || die
268     echo "options uvesafb mode_option=1024x768-32@60 scroll=ywrap" > /etc/modprobe.d/uvesafb.conf || die
269     # create an updated initrd
270     local DISKMODS="sd_mod"
271     local OLDPATAMODS="amd74xx piix sis5513 via82cxxx"
272     local PATAMODS="ata_piix pata_amd pata_mpiix pata_oldpiix pata_sis pata_via"
273     local SATAMODS="sata_via sata_sis sata_nv"
274     local DRMMODS="i915 mga nouveau r128 radeon savage sis tdfx ttm via"
275     local FBMODS="uvesafb"
276     echo "MODULES=\"${FORMAT_FILESYSTEM} ${DISKMODS} ${OLDATAMODS} ${PATAMODS} ${SATAMODS} ${DRMMODS} ${FBMODS}\"" > /etc/conf.d/mkinitrd
277     local kernelver=$(readlink /boot/vmlinuz | sed 's:kernel-::')
278     mkinitrd -f /boot/initrd-${kernelver}.img ${kernelver}
279     # update grub bootloader
280     updategrub2
281  fi  fi
282    
283  if [[ -f /.dist-upgrade ]]  if [[ -f /.orphaned ]]
284  then  then
285   rm -f /.dist-upgrade   echo "Searching for orphaned files and directories ..."
286   # force a reboot at this point here   bash /etc/mage-profile/prune-orphaned-files
287   reboot -f   rm -f /.orphaned
288  fi  fi
289    
290    #if [[ -f /.dist-upgrade ]]
291    #then
292    # rm -f /.dist-upgrade
293    # # force a reboot at this point here
294    # ( reboot -f & ); exit 0
295    #fi

Legend:
Removed from v.2112  
changed lines
  Added in v.2716