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

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