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 2780 by niro, Fri Aug 26 11:54:23 2011 UTC
# Line 1  Line 1 
1  #!/bin/bash  #!/bin/bash
2  # $Id$  # $Id$
3    
4    # get a suitable environment
5    source /etc/profile
6    
7  MAGERC="/etc/mage.rc"  MAGERC="/etc/mage.rc"
8  MAGEPROFILE="alx-060"  MAGEPROFILE="alx-060"
9  NEW_MAGE_DISTRIBUTION="unstable"  NEW_MAGE_DISTRIBUTION="unstable"
# Line 9  NEW_MIRRORS="http://magellan-linux.de/ma Line 12  NEW_MIRRORS="http://magellan-linux.de/ma
12  NEW_PACKAGES_SERVER_PATH='packages/${ARCH}'  NEW_PACKAGES_SERVER_PATH='packages/${ARCH}'
13  NEW_MAGE_UNINSTALL_TIMEOUT=0  NEW_MAGE_UNINSTALL_TIMEOUT=0
14    
15  # fix mage.rc  CONFIGRC="/etc/alxconfig-ng/config.rc"
16  for i in RSYNC MIRRORS MAGE_DISTRIBUTION PACKAGES_SERVER_PATH MAGE_UNINSTALL_TIMEOUT  NEW_ALX_NETWORKING="dhcp"
17  do  NEW_ALX_DHCP_PROG="/sbin/udhcpc"
18   value="$(eval echo \${NEW_${i}})"  NEW_ALX_DHCP_START="-T 10 -t 5 -n -i"
19   if [[ ! -z $(grep "^${i}=" ${MAGERC}) ]]  NEW_ALX_DHCP_STOP=""
20    NEW_MIN_DISK_SPACE="85000"
21    NEW_ALX_PLUGINS="/usr/lib/alxconfig-ng/plugins"
22    NEW_ALX_FUNCTIONS="/usr/lib/alxconfig-ng/functions"
23    
24    # fake mage upgrade to prevent annoying error messages
25    if [[ ! -x /usr/sbin/mageupgrade ]]
26    then
27     mageupgrade() { true; }; export -f mageupgrade
28    fi
29    
30    read_value()
31    {
32     local file=$1
33     local var=$2
34     local value
35    
36     [[ ! -e ${file} ]] && return 1
37    
38     value=$(source ${file}; echo $(eval echo \${${var}}))
39     echo "${value}"
40     return 0
41    }
42    
43    updateconfig()
44    {
45     local variables="$@"
46     local value
47     local i
48    
49     if [[ -z ${CONFIG} ]]
50   then   then
51   echo "fixing $i -> ${value}"   echo "You must define \$CONFIG varibale first!"
52   sed -i "s|^\(${i}=\).*|\1\"${value}\"|" ${MAGERC}   return 1
  else  
  echo "adding $i=${value}"  
  echo "${i}=\"${value}\"" >> ${MAGERC}  
53   fi   fi
54  done  
55     for i in ${variables}
56     do
57     value="$(eval echo \${NEW_${i}})"
58     if [[ ! -z $(grep "^${i}=" ${CONFIG}) ]]
59     then
60     echo "fixing ${i} -> ${value}"
61     sed -i "s|^\(${i}=\).*|\1\"${value}\"|" ${CONFIG}
62     else
63     echo "adding ${i}=${value}"
64     echo "${i}=\"${value}\"" >> ${CONFIG}
65     fi
66     done
67    }
68    
69    updategrub2()
70    {
71     # create a device.map
72     if [[ ! -f /boot/grub/device.map ]]
73     then
74     grub-mkdevicemap
75     fi
76    
77     # needed by grub-mkconfig on the first run
78     if [[ ! -f /boot/grub/video.lst ]]
79     then
80     install -m0644 /lib/grub/*/video.lst /boot/grub/video.lst
81     fi
82    
83     # update grub.cfg
84     grub-mkconfig -o /boot/grub/grub.cfg
85    
86     # install bootloader to disk
87     local bootdisk
88     bootdisk="$(grub-probe --target=drive /boot | sed 's:(\(.*\),.*):(\1):')"
89    
90     # Generate core.img, but don't let it be installed in boot sector
91     grub-install --no-floppy "${bootdisk}"
92    }
93    
94    # fix mage.rc
95    CONFIG="${MAGERC}"
96    updateconfig RSYNC MIRRORS MAGE_DISTRIBUTION PACKAGES_SERVER_PATH MAGE_UNINSTALL_TIMEOUT
97    
98    # fix config.rc
99    CONFIG="${CONFIGRC}"
100    updateconfig ALX_NETWORKING ALX_DHCP_PROG ALX_DHCP_START ALX_DHCP_STOP MIN_DISK_SPACE ALX_PLUGINS ALX_FUNCTIONS
101    
102  # fix profile  # fix profile
103  if [[ $(readlink /etc/mage-profile) != */${MAGEPROFILE} ]]  if [[ $(readlink /etc/mage-profile) != */${MAGEPROFILE} ]]
# Line 30  then Line 106  then
106   ln -snf /usr/mage/profiles/${MAGEPROFILE} /etc/mage-profile   ln -snf /usr/mage/profiles/${MAGEPROFILE} /etc/mage-profile
107  fi  fi
108    
109    # fix missing /dev/root device
110    if [[ ! -e /dev/root ]]
111    then
112     echo "fixing missing /dev/root symlink ..."
113     rootdev=$(basename $(mount | grep ' / ' | cut -d' ' -f1))
114     [[ -e /dev/${rootdev} ]] && ln -snf ${rootdev} /dev/root
115    fi
116    
117  # update mage3 -> mage4  # update mage3 -> mage4
118  if [[ -z $(magequery -n mage) ]]  if [[ -z $(magequery -n mage) ]]
119  then  then
# Line 53  then Line 137  then
137    
138   # enable run of orphaned files check   # enable run of orphaned files check
139   touch /.orphaned   touch /.orphaned
140    
141     # tell that we're running an dist-upgrade
142     touch /.dist-upgrade
143    fi
144    
145    # only run this if X11R6 is a directory and not a symlink
146    if [[ -d /usr/X11R6 ]] && [[ ! -L /usr/X11R6 ]]
147    then
148     # check for -f option
149     if [[ -n $(magequery -h | grep -- -f) ]]
150     then
151     # uninstall all /usr/X11R6 packages first
152     for i in $(magequery -f /usr/X11R6 | sed 's:.*/\(.*\)-.*-r.*:\1:')
153     do
154     mage uninstall ${i}
155     done
156     fi
157    
158     # if there are any files after uninstall, simply delete them
159     [ -d /usr/X11R6 ] && rm -rf /usr/X11R6
160  fi  fi
161    
162  # install new toolchain if not exist  # install new toolchain if not exist
# Line 66  then Line 170  then
170    
171   # enable run of orphaned files check   # enable run of orphaned files check
172   touch /.orphaned   touch /.orphaned
173    
174     # tell that we're running an dist-upgrade
175     touch /.dist-upgrade
176  fi  fi
177    
178  # install new basesystem  # install new basesystem
# Line 73  BASESYSTEM="$(< /etc/mage-profile/basesy Line 180  BASESYSTEM="$(< /etc/mage-profile/basesy
180  if [[ -z $(magequery -n ${BASESYSTEM}) ]]  if [[ -z $(magequery -n ${BASESYSTEM}) ]]
181  then  then
182   # first keep some important files   # first keep some important files
183    
184   # export bootstrap to not start any services   # export bootstrap to not start any services
185   export MAGE_BOOTSTRAP=true   export MAGE_BOOTSTRAP=true
186   mage install ${BASESYSTEM}   mage install ${BASESYSTEM}
187   unset MAGE_BOOTSTRAP   unset MAGE_BOOTSTRAP
188    
189    # # fix locale
190    # echo "LANG=\"de_DE\"" > /etc/conf.d/locale
191    
192   # enable run of orphaned files check   # enable run of orphaned files check
193   touch /.orphaned   touch /.orphaned
194    
195     # tell that we're running an dist-upgrade
196     touch /.dist-upgrade
197  fi  fi
198    
199  # install remserial, if the plugin was enabled  # install remserial, if the plugin was enabled
# Line 95  fi Line 208  fi
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 159  then Line 232  then
232   rm -f /.orphaned   rm -f /.orphaned
233  fi  fi
234    
235  # force a reboot at this point here  if [[ -f /.dist-upgrade ]]
236  reboot -f  then
237     # array of wireless opts
238     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 )
239    
240     # fixing current dhcp network settings
241     #for i in $(grep -irl NETWORKING=.*dhcp.* /etc/conf.d/net.*)
242     for i in $(grep -irl DHCP_PROG=.*dhcpcd.* /etc/conf.d/net.*)
243     do
244     case ${i} in
245     */net.sample) continue ;;
246     */net.routes) continue ;;
247     esac
248    
249     echo "fixing current dhcp network settings in '${i}'"
250     mv ${i}{,.orig}
251     onboot="$(read_value ${i}.orig ONBOOT)"
252     echo "ONBOOT=\"${onboot}\"" > ${i}
253     echo 'NETWORKING="dhcp"' >> ${i}
254     # check wireless extensions
255     for opt in ${WIRELESS_OPTS[*]}
256     do
257     value="$(read_value ${i}.orig ${opt})"
258     if [[ ! -z ${value} ]]
259     then
260     echo "${opt}=\"${value}\"" >> ${i}
261     fi
262     done
263     rm -f ${i}.orig
264     done
265     # search modules files
266     for i in $(find /etc/modules.d -name net.\*)
267     do
268     install -d /etc/modprobe.d
269     mv ${i} /etc/modprobe.d/${i%.conf}.conf
270     done
271    
272     mount /boot &> /dev/null
273     # install an appropriate uvesafb.conf
274     install -d /etc/modprobe.d || die
275     echo "options uvesafb mode_option=1024x768-32@60 scroll=ywrap" > /etc/modprobe.d/uvesafb.conf || die
276     # create an updated initrd
277     DISKMODS="sd_mod"
278     OLDPATAMODS="amd74xx piix sis5513 via82cxxx"
279     PATAMODS="ata_piix pata_amd pata_mpiix pata_oldpiix pata_sis pata_via"
280     SATAMODS="sata_via sata_sis sata_nv"
281     DRMMODS="i915 mga nouveau r128 radeon savage sis tdfx ttm via"
282     FBMODS="uvesafb"
283     echo "MODULES=\"${FORMAT_FILESYSTEM} ${DISKMODS} ${OLDATAMODS} ${PATAMODS} ${SATAMODS} ${DRMMODS} ${FBMODS}\"" > /etc/conf.d/mkinitrd
284     kernelver=$(readlink /boot/vmlinuz | sed 's:kernel-::')
285     mkinitrd -f /boot/initrd-${kernelver}.img ${kernelver}
286     # update grub bootloader
287     updategrub2
288    fi
289    
290    if [[ -f /.dist-upgrade ]]
291    then
292     echo "preparing a reboot in 60 seconds ..."
293     # reboot via cronjob
294     [[ ! -d /var/spool/cron/crontabs ]] && install -d /var/spool/cron/crontabs
295     # setup a proper cronjob
296     tmp=$(mktemp)
297     echo "* * * * * crontab -r && reboot -f" > ${tmp}
298     crontab ${tmp}
299     [[ -f ${tmp} ]] && rm -f ${tmp}
300     # start cron daemon in background
301     crond -b -S
302    
303     rm -f /.dist-upgrade
304    fi
305    
306    exit 0

Legend:
Removed from v.2081  
changed lines
  Added in v.2780