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 2117 by niro, Thu May 12 20:43:28 2011 UTC revision 2616 by niro, Wed Jul 6 22:02:19 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    
34  read_value()  read_value()
35  {  {
36   local file=$1   local file=$1
# Line 14  read_value() Line 44  read_value()
44   return 0   return 0
45  }  }
46    
47  MAGERC="/etc/mage.rc"  updateconfig()
48  MAGEPROFILE="alx-060"  {
49  NEW_MAGE_DISTRIBUTION="unstable"   local variables="$@"
50  NEW_RSYNC="rsync://magellan-linux.de/mage-alx-0.6.0"   local value
51  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  
52    
53  # 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}) ]]  
54   then   then
55   echo "fixing $i -> ${value}"   echo "You must define \$CONFIG varibale first!"
56   sed -i "s|^\(${i}=\).*|\1\"${value}\"|" ${MAGERC}   return 1
  else  
  echo "adding $i=${value}"  
  echo "${i}=\"${value}\"" >> ${MAGERC}  
57   fi   fi
58  done  
59     for i in ${variables}
60     do
61     value="$(eval echo \${NEW_${i}})"
62     if [[ ! -z $(grep "^${i}=" ${CONFIG}) ]]
63     then
64     echo "fixing ${i} -> ${value}"
65     sed -i "s|^\(${i}=\).*|\1\"${value}\"|" ${CONFIG}
66     else
67     echo "adding ${i}=${value}"
68     echo "${i}=\"${value}\"" >> ${CONFIG}
69     fi
70     done
71    }
72    
73    # fix mage.rc
74    CONFIG="${MAGERC}"
75    updateconfig RSYNC MIRRORS MAGE_DISTRIBUTION PACKAGES_SERVER_PATH MAGE_UNINSTALL_TIMEOUT
76    
77    # fix config.rc
78    CONFIG="${CONFIGRC}"
79    updateconfig ALX_NETWORKING ALX_DHCP_PROG ALX_DHCP_START ALX_DHCP_STOP MIN_DISK_SPACE
80    
81  # fix profile  # fix profile
82  if [[ $(readlink /etc/mage-profile) != */${MAGEPROFILE} ]]  if [[ $(readlink /etc/mage-profile) != */${MAGEPROFILE} ]]
# Line 71  then Line 113  then
113   touch /.dist-upgrade   touch /.dist-upgrade
114  fi  fi
115    
116    # only run this if X11R6 is a directory and not a symlink
117    if [[ -d /usr/X11R6 ]] && [[ ! -L /usr/X11R6 ]]
118    then
119     # check for -f option
120     if [[ -n $(magequery -h | grep -- -f) ]]
121     then
122     # uninstall all /usr/X11R6 packages first
123     for i in $(magequery -f /usr/X11R6 | sed 's:.*/\(.*\)-.*-r.*:\1:')
124     do
125     mage uninstall ${i}
126     done
127     fi
128    
129     # if there are any files after uninstall, simply delete them
130     [ -d /usr/X11R6 ] && rm -rf /usr/X11R6
131    fi
132    
133  # install new toolchain if not exist  # install new toolchain if not exist
134  TOOLCHAIN="$(< /etc/mage-profile/toolchain.defaults)"  TOOLCHAIN="$(< /etc/mage-profile/toolchain.defaults)"
135  if [[ -z $(magequery -n ${TOOLCHAIN}) ]]  if [[ -z $(magequery -n ${TOOLCHAIN}) ]]
# Line 125  for i in $(magequery -i | grep -- -alx | Line 184  for i in $(magequery -i | grep -- -alx |
184  do  do
185   # excludes   # excludes
186   case ${i} in   case ${i} in
187     alxconfig-ng) continue ;;
188     alxinstall-ng) continue ;;
189   kernel-alx) continue ;;   kernel-alx) continue ;;
190   kernel26-alx) continue ;;   kernel26-alx) continue ;;
191   kernel-sources-alx) continue ;;   kernel-sources-alx) continue ;;
# Line 180  then Line 241  then
241   rm -f /.orphaned   rm -f /.orphaned
242  fi  fi
243    
244  if [[ -f /.dist-upgrade ]]  #if [[ -f /.dist-upgrade ]]
245  then  #then
246   rm -f /.dist-upgrade  # rm -f /.dist-upgrade
247   # force a reboot at this point here  # # force a reboot at this point here
248   reboot -f  # ( reboot -f & ); exit 0
249  fi  #fi

Legend:
Removed from v.2117  
changed lines
  Added in v.2616