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 2081 by niro, Wed May 11 22:17:14 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"  MAGERC="/etc/mage.rc"
20  MAGEPROFILE="alx-060"  MAGEPROFILE="alx-060"
21  NEW_MAGE_DISTRIBUTION="unstable"  NEW_MAGE_DISTRIBUTION="unstable"
# Line 9  NEW_MIRRORS="http://magellan-linux.de/ma Line 24  NEW_MIRRORS="http://magellan-linux.de/ma
24  NEW_PACKAGES_SERVER_PATH='packages/${ARCH}'  NEW_PACKAGES_SERVER_PATH='packages/${ARCH}'
25  NEW_MAGE_UNINSTALL_TIMEOUT=0  NEW_MAGE_UNINSTALL_TIMEOUT=0
26    
27  # fix mage.rc  CONFIGRC="/etc/alxconfig-ng/config.rc"
28  for i in RSYNC MIRRORS MAGE_DISTRIBUTION PACKAGES_SERVER_PATH MAGE_UNINSTALL_TIMEOUT  NEW_ALX_NETWORKING="dhcp"
29  do  NEW_ALX_DHCP_PROG="/sbin/udhcpc"
30   value="$(eval echo \${NEW_${i}})"  NEW_ALX_DHCP_START="-T 10 -t 5 -n -i"
31   if [[ ! -z $(grep "^${i}=" ${MAGERC}) ]]  NEW_ALX_DHCP_STOP=""
32    NEW_MIN_DISK_SPACE="85000"
33    NEW_ALX_PLUGINS="/etc/alxconfig-ng/plugins"
34    
35    read_value()
36    {
37     local file=$1
38     local var=$2
39     local value
40    
41     [[ ! -e ${file} ]] && return 1
42    
43     value=$(source ${file}; echo $(eval echo \${${var}}))
44     echo "${value}"
45     return 0
46    }
47    
48    updateconfig()
49    {
50     local variables="$@"
51     local value
52     local i
53    
54     if [[ -z ${CONFIG} ]]
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
  else  
  echo "adding $i=${value}"  
  echo "${i}=\"${value}\"" >> ${MAGERC}  
58   fi   fi
59  done  
60     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
81    
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 53  then Line 134  then
134    
135   # enable run of orphaned files check   # enable run of orphaned files check
136   touch /.orphaned   touch /.orphaned
137    
138     # tell that we're running an dist-upgrade
139     touch /.dist-upgrade
140    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  fi
158    
159  # install new toolchain if not exist  # install new toolchain if not exist
# Line 66  then Line 167  then
167    
168   # enable run of orphaned files check   # enable run of orphaned files check
169   touch /.orphaned   touch /.orphaned
170    
171     # tell that we're running an dist-upgrade
172     touch /.dist-upgrade
173  fi  fi
174    
175  # install new basesystem  # install new basesystem
# Line 79  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    
192     # tell that we're running an dist-upgrade
193     touch /.dist-upgrade
194  fi  fi
195    
196  # install remserial, if the plugin was enabled  # install remserial, if the plugin was enabled
# Line 92  then Line 202  then
202   touch /.orphaned   touch /.orphaned
203  fi  fi
204    
205    # etc-update
206    #etc-update
207    
208  # clean mage cache  # clean mage cache
209  mage clean  mage clean
210    
 # # uninstall all other deprecated -alx packages  
 # DEPRECATED="bzip2  
 # gzip  
 # perl  
 # glib1  
 # openssl  
 # popt  
 # libungif  
 # samba  
 # dhcpcd  
 # openssh  
 # wget  
 # cups  
 # ddcxinfo-knoppix  
 # debianutils  
 # grep  
 # inetutils  
 # kbd  
 # less  
 # net-tools  
 # pciutils  
 # procps  
 # psmisc  
 # sed  
 # shadow  
 # sysvinit  
 # tar  
 # which  
 # gtk1+  
 # ttmkfdir  
 # xdialog"  
 #  
 # echo "Searching for deprecated packages ..."  
 # for i in ${DEPRECATED}  
 # do  
 # if [[ ! -z $(magequery -n ${i}-alx) ]]  
 # then  
 # echo "Removing deprecated mage-target '${i}-alx'"  
 # mage uninstall ${i}-alx  
 # fi  
 # done  
   
211  echo "Searching for deprecated packages ..."  echo "Searching for deprecated packages ..."
212  for i in $(magequery -i | grep -- -alx | sed 's:.*/\(.*\)-.*-.*:\1:')  for i in $(magequery -i | grep -- -alx | sed 's:.*/\(.*\)-.*-.*:\1:')
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 152  do Line 225  do
225   mage uninstall ${i}   mage uninstall ${i}
226  done  done
227    
228    if [[ -f /.dist-upgrade ]]
229    then
230     # array of wireless opts
231     WIRELESS_OPTS=( WIRELESS_BITRATE WIRELESS_CHANNEL WIRELESS_ESSID WIRELESS_FREQUENCY WIRELESS_MODE WIRELESS_NICK WIRELESS_AUTH_MODE WIRELESS_KEY_LENGTH WIRELESS_KEY WIRELESS_KEY_ASCII WIRELESS_WPA_DRIVER )
232    
233     # fixing current dhcp network settings
234     #for i in $(grep -irl NETWORKING=.*dhcp.* /etc/conf.d/net.*)
235     for i in $(grep -irl DHCP_PROG=.*dhcpcd.* /etc/conf.d/net.*)
236     do
237     case ${i} in
238     */net.sample) continue ;;
239     */net.routes) continue ;;
240     esac
241    
242     echo "fixing current dhcp network settings in '${i}'"
243     mv ${i}{,.orig}
244     onboot="$(read_value ${i}.orig ONBOOT)"
245     echo "ONBOOT=\"${onboot}\"" > ${i}
246     echo 'NETWORKING="dhcp"' >> ${i}
247     # check wireless extensions
248     for opt in ${WIRELESS_OPTS[*]}
249     do
250     value="$(read_value ${i}.orig ${opt})"
251     if [[ ! -z ${value} ]]
252     then
253     echo "${opt}=\"${value}\"" >> ${i}
254     fi
255     done
256     rm -f ${i}.orig
257     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
282    
283  if [[ -f /.orphaned ]]  if [[ -f /.orphaned ]]
284  then  then
285   echo "Searching for orphaned files and directories ..."   echo "Searching for orphaned files and directories ..."
# Line 159  then Line 287  then
287   rm -f /.orphaned   rm -f /.orphaned
288  fi  fi
289    
290  # force a reboot at this point here  #if [[ -f /.dist-upgrade ]]
291  reboot -f  #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.2081  
changed lines
  Added in v.2716