Commit f9d8281bff133b7259d2f886d3cff111879aa522

Authored by Silvan Calarco
1 parent 0bac1eb055
Exists in master and in 1 other branch milestone2

installer.sh: fix label in grub menu entries for other OSes

Showing 2 changed files with 4 additions and 4 deletions Inline Diff

1 VERSION=2.5.0 1 VERSION=2.5.1
2 2
3 3
4 4
installer/installer.sh
1 # openmamba installation script 1 # openmamba installation script
2 # Copyright (c) 2007-2011 by Silvan Calarco <silvan.calarco@mambasoft.it> 2 # Copyright (c) 2007-2011 by Silvan Calarco <silvan.calarco@mambasoft.it>
3 # 3 #
4 # For the devfs2gdev() function: 4 # For the devfs2gdev() function:
5 # Copyright (c) 2006 by Davide Madrisan <davide.madrisan@gmail.com> 5 # Copyright (c) 2006 by Davide Madrisan <davide.madrisan@gmail.com>
6 # 6 #
7 # Released under the terms of the GNU GPLv3 License 7 # Released under the terms of the GNU GPLv3 License
8 8
9 VERSION=1.1 9 VERSION=1.1
10 TEXTDOMAIN=installer 10 TEXTDOMAIN=installer
11 TEXTDOMAINDIR=/opt/kde3/share/locale/ 11 TEXTDOMAINDIR=/opt/kde3/share/locale/
12 INSTALL_DATE=`date +%Y%m%d-%H%M` 12 INSTALL_DATE=`date +%Y%m%d-%H%M`
13 INPUT_FILE=~/.installer.conf 13 INPUT_FILE=~/.installer.conf
14 MAMBAWELCOME_SCRIPT=/usr/share/openmamba/mambawelcome/mambawelcome.sh 14 MAMBAWELCOME_SCRIPT=/usr/share/openmamba/mambawelcome/mambawelcome.sh
15 LOG_FILE=/var/log/install-$INSTALL_DATE.log 15 LOG_FILE=/var/log/install-$INSTALL_DATE.log
16 MOUNTPOINT=/mnt/install 16 MOUNTPOINT=/mnt/install
17 KERNEL_RELEASE=`uname -r` 17 KERNEL_RELEASE=`uname -r`
18 18
19 function abort() { 19 function abort() {
20 [ "$DCOPID" ] && { 20 [ "$DCOPID" ] && {
21 dcop $DCOPID KommanderIf setText progressText $"Installation aborted; press Next to see the error log." 21 dcop $DCOPID KommanderIf setText progressText $"Installation aborted; press Next to see the error log."
22 dcop $DCOPID KommanderIf setText finallabel $"Installation aborted :-(" 22 dcop $DCOPID KommanderIf setText finallabel $"Installation aborted :-("
23 dcop $DCOPID KommanderIf setEnabled next true 23 dcop $DCOPID KommanderIf setEnabled next true
24 } 24 }
25 exit 1 25 exit 1
26 } 26 }
27 27
28 function finished() { 28 function finished() {
29 [ "$DCOPID" ] && { 29 [ "$DCOPID" ] && {
30 dcop $DCOPID KommanderIf setText progressText $"Installation completed; press Next to continue." 30 dcop $DCOPID KommanderIf setText progressText $"Installation completed; press Next to continue."
31 dcop $DCOPID KommanderIf setText progressBar 100 31 dcop $DCOPID KommanderIf setText progressBar 100
32 dcop $DCOPID KommanderIf setText installTopLabel $"Installation completed." 32 dcop $DCOPID KommanderIf setText installTopLabel $"Installation completed."
33 dcop $DCOPID KommanderIf setText installInfoLabel "" 33 dcop $DCOPID KommanderIf setText installInfoLabel ""
34 dcop $DCOPID KommanderIf setEnabled next true 34 dcop $DCOPID KommanderIf setEnabled next true
35 dcop $DCOPID KommanderIf setEnabled ProgressGroupBox true 35 dcop $DCOPID KommanderIf setEnabled ProgressGroupBox true
36 } 36 }
37 exit 1 37 exit 1
38 } 38 }
39 39
40 function dcop_write() { 40 function dcop_write() {
41 [ "$DCOPID" ] && { 41 [ "$DCOPID" ] && {
42 dcop $DCOPID KommanderIf setText progressText "$1" 42 dcop $DCOPID KommanderIf setText progressText "$1"
43 dcop $DCOPID KommanderIf setText progressBar $2 43 dcop $DCOPID KommanderIf setText progressBar $2
44 } 44 }
45 } 45 }
46 46
47 function dcop_write_details() { 47 function dcop_write_details() {
48 [ "$DCOPID" ] && { 48 [ "$DCOPID" ] && {
49 dcop $DCOPID KommanderIf setText progressText2 "$1" 49 dcop $DCOPID KommanderIf setText progressText2 "$1"
50 } 50 }
51 } 51 }
52 52
53 function apt_parser() { 53 function apt_parser() {
54 while read line; do 54 while read line; do
55 [ "$DCOPID" ] && { 55 [ "$DCOPID" ] && {
56 echo $line 56 echo $line
57 dcop $DCOPID KommanderIf setText progressText2 "$line" 57 dcop $DCOPID KommanderIf setText progressText2 "$line"
58 } 58 }
59 done 59 done
60 } 60 }
61 61
62 cp_parser_count=0 62 cp_parser_count=0
63 date_start=`date +%s` 63 date_start=`date +%s`
64 64
65 function cp_parser() { 65 function cp_parser() {
66 while read line; do 66 while read line; do
67 let cp_parser_count+=1 67 let cp_parser_count+=1
68 if [ $cp_parser_count -ge 100 ]; then 68 if [ $cp_parser_count -ge 100 ]; then
69 CP_LINE=`echo ${line/*$MOUNTPOINT/}` 69 CP_LINE=`echo ${line/*$MOUNTPOINT/}`
70 MOUNT_SPACE=`df -m $MOUNTPOINT | tail -1 | awk '{ print $3; }'` 70 MOUNT_SPACE=`df -m $MOUNTPOINT | tail -1 | awk '{ print $3; }'`
71 PERCENT=`expr $MOUNT_SPACE \* 100 / $TOTAL_SPACE` 71 PERCENT=`expr $MOUNT_SPACE \* 100 / $TOTAL_SPACE`
72 let TIME_ELAPSED=\(`date +%s`-$date_start\)/60 72 let TIME_ELAPSED=\(`date +%s`-$date_start\)/60
73 if [ "$DCOPID" ]; then 73 if [ "$DCOPID" ]; then
74 dcop_write $"Copying files (/$d)..." `expr $PERCENT / 2 + $prog` 74 dcop_write $"Copying files (/$d)..." `expr $PERCENT / 2 + $prog`
75 dcop_write_details $"\ 75 dcop_write_details $"\
76 Copying: '$CP_LINE 76 Copying: '$CP_LINE
77 ${MOUNT_SPACE} Mbytes copied 77 ${MOUNT_SPACE} Mbytes copied
78 Installation time: $TIME_ELAPSED minutes" 78 Installation time: $TIME_ELAPSED minutes"
79 else 79 else
80 echo -e -n "\rCopying files (${MOUNT_SPACE}M ${TIME_ELAPSED}m ${PERCENT}%) " 80 echo -e -n "\rCopying files (${MOUNT_SPACE}M ${TIME_ELAPSED}m ${PERCENT}%) "
81 echo -e -n "\rCopying files (${MOUNT_SPACE}M ${TIME_ELAPSED}m ${PERCENT}%) ${CP_LINE:0:40}..." 81 echo -e -n "\rCopying files (${MOUNT_SPACE}M ${TIME_ELAPSED}m ${PERCENT}%) ${CP_LINE:0:40}..."
82 fi 82 fi
83 cp_parser_count=0 83 cp_parser_count=0
84 fi 84 fi
85 done 85 done
86 } 86 }
87 87
88 function get_udisks_key() { 88 function get_udisks_key() {
89 LANG=C udisks --show-info $1 | grep " $2:" | head -n1 | sed "s|[[:space:]]*$2:[[:space:]]*\(.*\)|\1|" 89 LANG=C udisks --show-info $1 | grep " $2:" | head -n1 | sed "s|[[:space:]]*$2:[[:space:]]*\(.*\)|\1|"
90 } 90 }
91 91
92 [ "$1" = "-y" ] || { 92 [ "$1" = "-y" ] || {
93 echo $"Warning: this script will perform an automatic installation erasing all the" 93 echo $"Warning: this script will perform an automatic installation erasing all the"
94 echo $" contents of device $INSTALL_DEVICE; use $0 -y to actually start the" 94 echo $" contents of device $INSTALL_DEVICE; use $0 -y to actually start the"
95 echo $" operation." 95 echo $" operation."
96 exit 0 96 exit 0
97 } 97 }
98 98
99 DCOPID=$2 99 DCOPID=$2
100 100
101 echo $"\ 101 echo $"\
102 openmamba installation script - version $VERSION 102 openmamba installation script - version $VERSION
103 Copyright (c) 2007-2011 by Silvan Calarco <silvan.calarco@mambasoft.it> 103 Copyright (c) 2007-2011 by Silvan Calarco <silvan.calarco@mambasoft.it>
104 " 104 "
105 105
106 dcop_write $"Starting installation..." 5 106 dcop_write $"Starting installation..." 5
107 107
108 [ -r $INPUT_FILE ] || { 108 [ -r $INPUT_FILE ] || {
109 echo $"Error: cannot read input file $INPUT_FILE; aborting." >&2 109 echo $"Error: cannot read input file $INPUT_FILE; aborting." >&2
110 abort 110 abort
111 } 111 }
112 112
113 . $INPUT_FILE 113 . $INPUT_FILE
114 114
115 FORMAT_APPEND= 115 FORMAT_APPEND=
116 [ "$INSTALL_HOSTNAME" ] || INSTALL_HOSTNAME="openmamba" 116 [ "$INSTALL_HOSTNAME" ] || INSTALL_HOSTNAME="openmamba"
117 117
118 case "$INSTALL_FSTYPE" in 118 case "$INSTALL_FSTYPE" in
119 ext2|ext3|ext4) FORMAT_CMD="/sbin/mkfs.$INSTALL_FSTYPE" 119 ext2|ext3|ext4) FORMAT_CMD="/sbin/mkfs.$INSTALL_FSTYPE"
120 [ "$INSTALL_HOSTNAME" ] && \ 120 [ "$INSTALL_HOSTNAME" ] && \
121 FORMAT_APPEND="$FORMAT_APPEND -L $INSTALL_HOSTNAME" 121 FORMAT_APPEND="$FORMAT_APPEND -L $INSTALL_HOSTNAME"
122 ;; 122 ;;
123 reiserfs|reiser4) FORMAT_CMD="/sbin/mkfs.$INSTALL_FSTYPE" 123 reiserfs|reiser4) FORMAT_CMD="/sbin/mkfs.$INSTALL_FSTYPE"
124 FORMAT_APPEND="$FORMAT_APPEND -ff" 124 FORMAT_APPEND="$FORMAT_APPEND -ff"
125 [ "$INSTALL_HOSTNAME" ] && \ 125 [ "$INSTALL_HOSTNAME" ] && \
126 FORMAT_APPEND="$FORMAT_APPEND -l $INSTALL_HOSTNAME" 126 FORMAT_APPEND="$FORMAT_APPEND -l $INSTALL_HOSTNAME"
127 ;; 127 ;;
128 *) FORMAT_CMD="/sbin/mkfs.$INSTALL_FSTYPE" 128 *) FORMAT_CMD="/sbin/mkfs.$INSTALL_FSTYPE"
129 [ -e "$FORMAT_CMD" ] || { 129 [ -e "$FORMAT_CMD" ] || {
130 echo $"Error: $INSTALL_FSTYPE is not a supported filesystem type; aborting." >&2 130 echo $"Error: $INSTALL_FSTYPE is not a supported filesystem type; aborting." >&2
131 abort 131 abort
132 } 132 }
133 ;; 133 ;;
134 "") echo $"Error: filesystem type non specified; aborting." >&2 134 "") echo $"Error: filesystem type non specified; aborting." >&2
135 abort 135 abort
136 ;; 136 ;;
137 esac 137 esac
138 138
139 if [ "$INSTALL_HOME_DEVICE" ]; then 139 if [ "$INSTALL_HOME_DEVICE" ]; then
140 case "$INSTALL_HOME_FSTYPE" in 140 case "$INSTALL_HOME_FSTYPE" in
141 ext2|ext3|ext4) FORMAT_HOME_CMD="/sbin/mkfs.$INSTALL_HOME_FSTYPE" 141 ext2|ext3|ext4) FORMAT_HOME_CMD="/sbin/mkfs.$INSTALL_HOME_FSTYPE"
142 FORMAT_HOME_APPEND="$FORMAT_APPEND -L home" 142 FORMAT_HOME_APPEND="$FORMAT_APPEND -L home"
143 ;; 143 ;;
144 reiserfs|reiser4) FORMAT_HOME_CMD="/sbin/mkfs.$INSTALL_HOME_FSTYPE" 144 reiserfs|reiser4) FORMAT_HOME_CMD="/sbin/mkfs.$INSTALL_HOME_FSTYPE"
145 FORMAT_HOME_APPEND="$FORMAT_APPEND -ff -l home" 145 FORMAT_HOME_APPEND="$FORMAT_APPEND -ff -l home"
146 ;; 146 ;;
147 *) FORMAT_HOME_CMD="/sbin/mkfs.$INSTALL_HOME_FSTYPE" 147 *) FORMAT_HOME_CMD="/sbin/mkfs.$INSTALL_HOME_FSTYPE"
148 [ -e "$FORMAT_HOME_CMD" ] || { 148 [ -e "$FORMAT_HOME_CMD" ] || {
149 echo $"Error: $INSTALL_HOME_FSTYPE is not a supported filesystem type; aborting." >&2 149 echo $"Error: $INSTALL_HOME_FSTYPE is not a supported filesystem type; aborting." >&2
150 abort 150 abort
151 } 151 }
152 ;; 152 ;;
153 "") echo $"Error: filesystem type non specified; aborting." >&2 153 "") echo $"Error: filesystem type non specified; aborting." >&2
154 abort 154 abort
155 ;; 155 ;;
156 esac 156 esac
157 fi 157 fi
158 158
159 [ $INSTALL_DEVICE ] || { 159 [ $INSTALL_DEVICE ] || {
160 echo $"Error: installation device is not defined in $INPUT_FILE; aborting." >&2 160 echo $"Error: installation device is not defined in $INPUT_FILE; aborting." >&2
161 abort 161 abort
162 } 162 }
163 163
164 #INSTALL_DISK_DEVICE=${INSTALL_DEVICE:0:8} 164 #INSTALL_DISK_DEVICE=${INSTALL_DEVICE:0:8}
165 165
166 [ -e $INSTALL_DEVICE ] || { 166 [ -e $INSTALL_DEVICE ] || {
167 echo $"Error: missing install device $INSTALL_DEVICE; aborting." >&2 167 echo $"Error: missing install device $INSTALL_DEVICE; aborting." >&2
168 abort 168 abort
169 } 169 }
170 170
171 echo $"openmamba installation started" 171 echo $"openmamba installation started"
172 172
173 tempfile=`tempfile 2>/dev/null` 173 tempfile=`tempfile 2>/dev/null`
174 mapfile=`tempfile 2>/dev/null` 174 mapfile=`tempfile 2>/dev/null`
175 175
176 # generate current volumes sorted list with driver information 176 # generate current volumes sorted list with driver information
177 devices=`udisks --enumerate-device-files | grep -v /dev/disk` 177 devices=`udisks --enumerate-device-files | grep -v /dev/disk`
178 for s in $storages; do 178 for s in $storages; do
179 native_path=`get_udisks_key $device native-path` 179 native_path=`get_udisks_key $device native-path`
180 [ -e $native_path/partition ] && continue 180 [ -e $native_path/partition ] && continue
181 is_system_internal=`get_udisks_key $device "system internal"` 181 is_system_internal=`get_udisks_key $device "system internal"`
182 #linux_driver=`find_driver_for_udi $s` 182 #linux_driver=`find_driver_for_udi $s`
183 [ "${device:5:2}" = "sd" -o "${device:5:2}" = "hd" ] && \ 183 [ "${device:5:2}" = "sd" -o "${device:5:2}" = "hd" ] && \
184 echo "${device:0:8}" >> $tempfile 184 echo "${device:0:8}" >> $tempfile
185 if [ "$INSTALL_BOOTLOADER_DEVICE" = "$device" ]; then 185 if [ "$INSTALL_BOOTLOADER_DEVICE" = "$device" ]; then
186 INSTALL_BOOTLOADER_DEVICE_INTERNAL=$is_system_internal 186 INSTALL_BOOTLOADER_DEVICE_INTERNAL=$is_system_internal
187 fi 187 fi
188 done 188 done
189 # sort 189 # sort
190 cat $tempfile|sort > $mapfile 190 cat $tempfile|sort > $mapfile
191 rm -f $tempfile 191 rm -f $tempfile
192 192
193 echo $"Available disks information" 193 echo $"Available disks information"
194 echo "===========================" 194 echo "==========================="
195 cat $mapfile 195 cat $mapfile
196 echo 196 echo
197 197
198 LETTERS=(a b c d e f g h i j k l m n o p q r s t u v w x y z) 198 LETTERS=(a b c d e f g h i j k l m n o p q r s t u v w x y z)
199 199
200 GRUB_DRIVE_NUMBER=0 200 GRUB_DRIVE_NUMBER=0
201 while read line; do 201 while read line; do
202 set -- $line 202 set -- $line
203 [ "$1" = "${INSTALL_DEVICE:0:8}" ] && REMAPPED_INSTALL_DEVICE="${INSTALL_DEVICE:0:7}${LETTERS[CURR_DRIVE_LETTER]}${INSTALL_DEVICE:8:2}" 203 [ "$1" = "${INSTALL_DEVICE:0:8}" ] && REMAPPED_INSTALL_DEVICE="${INSTALL_DEVICE:0:7}${LETTERS[CURR_DRIVE_LETTER]}${INSTALL_DEVICE:8:2}"
204 [ "$1" = "${INSTALL_HOME_DEVICE:0:8}" ] && REMAPPED_INSTALL_HOME_DEVICE="${INSTALL_HOME_DEVICE:0:7}${LETTERS[CURR_DRIVE_LETTER]}${INSTALL_HOME_DEVICE:8:2}" 204 [ "$1" = "${INSTALL_HOME_DEVICE:0:8}" ] && REMAPPED_INSTALL_HOME_DEVICE="${INSTALL_HOME_DEVICE:0:7}${LETTERS[CURR_DRIVE_LETTER]}${INSTALL_HOME_DEVICE:8:2}"
205 [ "$2" = "$INSTALL_DRIVER" ] && { 205 [ "$2" = "$INSTALL_DRIVER" ] && {
206 DEV_NAME_ORIG=(${DEV_NAME_ORIG[*]} $1) 206 DEV_NAME_ORIG=(${DEV_NAME_ORIG[*]} $1)
207 DEV_NAME_DEST=(${DEV_NAME_DEST[*]} ${1:0:7}${LETTERS[CURR_DRIVE_LETTER]}) 207 DEV_NAME_DEST=(${DEV_NAME_DEST[*]} ${1:0:7}${LETTERS[CURR_DRIVE_LETTER]})
208 GRUB_NAME_DEST=(${GRUB_NAME_DEST[*]} hd${GRUB_DRIVE_NUMBER}) 208 GRUB_NAME_DEST=(${GRUB_NAME_DEST[*]} hd${GRUB_DRIVE_NUMBER})
209 let CURR_DRIVE_LETTER+=1 209 let CURR_DRIVE_LETTER+=1
210 let GRUB_DRIVE_NUMBER+=1 210 let GRUB_DRIVE_NUMBER+=1
211 PREV_DEV_NAME=$1 211 PREV_DEV_NAME=$1
212 } 212 }
213 done < $mapfile 213 done < $mapfile
214 [ "$REMAPPED_INSTALL_DEVICE" ] || REMAPPED_INSTALL_DEVICE=$INSTALL_DEVICE 214 [ "$REMAPPED_INSTALL_DEVICE" ] || REMAPPED_INSTALL_DEVICE=$INSTALL_DEVICE
215 [ "$REMAPPED_INSTALL_HOME_DEVICE" ] || REMAPPED_INSTALL_HOME_DEVICE=$INSTALL_HOME_DEVICE 215 [ "$REMAPPED_INSTALL_HOME_DEVICE" ] || REMAPPED_INSTALL_HOME_DEVICE=$INSTALL_HOME_DEVICE
216 echo $"Install device $INSTALL_DEVICE will be known as $REMAPPED_INSTALL_DEVICE in the installed system" 216 echo $"Install device $INSTALL_DEVICE will be known as $REMAPPED_INSTALL_DEVICE in the installed system"
217 217
218 # other drivers follow the root disk device driver 218 # other drivers follow the root disk device driver
219 while read line; do 219 while read line; do
220 set -- $line 220 set -- $line
221 # differentiate letter count for e.g. hd* and sd* disks 221 # differentiate letter count for e.g. hd* and sd* disks
222 [ "${1:5:2}" != "${PREV_DEV_NAME:5:2}" ] && CURR_DRIVE_LETTER=0 222 [ "${1:5:2}" != "${PREV_DEV_NAME:5:2}" ] && CURR_DRIVE_LETTER=0
223 PREV_DEV_NAME=$1 223 PREV_DEV_NAME=$1
224 [ "$2" = "$INSTALL_DRIVER" ] && continue 224 [ "$2" = "$INSTALL_DRIVER" ] && continue
225 DEV_NAME_ORIG=(${DEV_NAME_ORIG[*]} $1) 225 DEV_NAME_ORIG=(${DEV_NAME_ORIG[*]} $1)
226 DEV_NAME_DEST=(${DEV_NAME_DEST[*]} ${1:0:7}${LETTERS[CURR_DRIVE_LETTER]}) 226 DEV_NAME_DEST=(${DEV_NAME_DEST[*]} ${1:0:7}${LETTERS[CURR_DRIVE_LETTER]})
227 GRUB_NAME_DEST=(${GRUB_NAME_DEST[*]} hd${GRUB_DRIVE_NUMBER}) 227 GRUB_NAME_DEST=(${GRUB_NAME_DEST[*]} hd${GRUB_DRIVE_NUMBER})
228 let CURR_DRIVE_LETTER+=1 228 let CURR_DRIVE_LETTER+=1
229 let GRUB_DRIVE_NUMBER+=1 229 let GRUB_DRIVE_NUMBER+=1
230 done < $mapfile 230 done < $mapfile
231 231
232 echo $"The following live versus installed system mappings have been calculated:" 232 echo $"The following live versus installed system mappings have been calculated:"
233 for i in `seq 1 ${#DEV_NAME_ORIG[*]}`; do 233 for i in `seq 1 ${#DEV_NAME_ORIG[*]}`; do
234 echo "${DEV_NAME_ORIG[i-1]} -> ${DEV_NAME_DEST[i-1]} (${GRUB_NAME_DEST[i-1]})" 234 echo "${DEV_NAME_ORIG[i-1]} -> ${DEV_NAME_DEST[i-1]} (${GRUB_NAME_DEST[i-1]})"
235 done 235 done
236 echo 236 echo
237 237
238 if [ "$INSTALL_HOME_DEVICE" ]; then 238 if [ "$INSTALL_HOME_DEVICE" ]; then
239 mount | grep "$INSTALL_HOME_DEVICE " && { 239 mount | grep "$INSTALL_HOME_DEVICE " && {
240 echo $"Info: device $INSTALL_HOME_DEVICE already mounted; unmounting." 240 echo $"Info: device $INSTALL_HOME_DEVICE already mounted; unmounting."
241 umount $INSTALL_HOME_DEVICE || { 241 umount $INSTALL_HOME_DEVICE || {
242 echo $"Error: could not unmount $INSTALL_HOME_DEVICE; aborting." >&2 242 echo $"Error: could not unmount $INSTALL_HOME_DEVICE; aborting." >&2
243 abort 243 abort
244 } 244 }
245 } 245 }
246 fi 246 fi
247 247
248 mount | grep "$INSTALL_DEVICE " && { 248 mount | grep "$INSTALL_DEVICE " && {
249 echo $"Info: device $INSTALL_DEVICE already mounted; unmounting." 249 echo $"Info: device $INSTALL_DEVICE already mounted; unmounting."
250 [ -e $MOUNTPOINT/dev ] && umount $MOUNTPOINT/dev 250 [ -e $MOUNTPOINT/dev ] && umount $MOUNTPOINT/dev
251 [ -e $MOUNTPOINT/proc ] && umount $MOUNTPOINT/proc 251 [ -e $MOUNTPOINT/proc ] && umount $MOUNTPOINT/proc
252 mount | grep " $MOUNTPOINT/home " && umount $MOUNTPOINT/home 252 mount | grep " $MOUNTPOINT/home " && umount $MOUNTPOINT/home
253 umount $INSTALL_DEVICE || { 253 umount $INSTALL_DEVICE || {
254 echo $"Error: could not unmount $INSTALL_DEVICE; aborting." >&2 254 echo $"Error: could not unmount $INSTALL_DEVICE; aborting." >&2
255 abort 255 abort
256 } 256 }
257 } 257 }
258 258
259 mount | grep "on $MOUNTPOINT/dev" && { 259 mount | grep "on $MOUNTPOINT/dev" && {
260 echo $"Info: device already mounted on $MOUNTPOINT/dev; unmounting." >&2 260 echo $"Info: device already mounted on $MOUNTPOINT/dev; unmounting." >&2
261 umount $MOUNTPOINT/dev || { 261 umount $MOUNTPOINT/dev || {
262 echo $"Error: could not unmount $MOUNTPOINT/dev; aborting." >&2 262 echo $"Error: could not unmount $MOUNTPOINT/dev; aborting." >&2
263 abort 263 abort
264 } 264 }
265 } 265 }
266 266
267 mount | grep "on $MOUNTPOINT" && { 267 mount | grep "on $MOUNTPOINT" && {
268 echo $"Info: device already mounted on $MOUNTPOINT; unmounting." >&2 268 echo $"Info: device already mounted on $MOUNTPOINT; unmounting." >&2
269 umount $MOUNTPOINT || { 269 umount $MOUNTPOINT || {
270 echo $"Error: could not unmount $MOUNTPOINT; aborting." >&2 270 echo $"Error: could not unmount $MOUNTPOINT; aborting." >&2
271 abort 271 abort
272 } 272 }
273 } || { 273 } || {
274 mkdir -p $MOUNTPOINT || { 274 mkdir -p $MOUNTPOINT || {
275 echo $"Error: could not create mount point $MOUNTPOINT; aborting." >&2 275 echo $"Error: could not create mount point $MOUNTPOINT; aborting." >&2
276 abort 276 abort
277 } 277 }
278 } 278 }
279 279
280 [ -x $FORMAT_CMD ] || { 280 [ -x $FORMAT_CMD ] || {
281 echo $"Error: missing initialization tool $FORMAT_CMD; aborting." >&2 281 echo $"Error: missing initialization tool $FORMAT_CMD; aborting." >&2
282 abort 282 abort
283 } 283 }
284 284
285 dcop_write $"Formatting device $INSTALL_DEVICE..." 10 285 dcop_write $"Formatting device $INSTALL_DEVICE..." 10
286 echo $"Formatting device $INSTALL_DEVICE" 286 echo $"Formatting device $INSTALL_DEVICE"
287 287
288 $FORMAT_CMD $INSTALL_DEVICE $FORMAT_APPEND 288 $FORMAT_CMD $INSTALL_DEVICE $FORMAT_APPEND
289 289
290 [ $? -ne 0 ] && { 290 [ $? -ne 0 ] && {
291 echo $"Error: could not format device $INSTALL_DEVICE; aborting." >&2 291 echo $"Error: could not format device $INSTALL_DEVICE; aborting." >&2
292 abort 292 abort
293 } 293 }
294 294
295 dcop_write $"Mounting $INSTALL_FSTYPE filesystem..." 10 295 dcop_write $"Mounting $INSTALL_FSTYPE filesystem..." 10
296 echo $"Mounting $INSTALL_FSTYPE filesystem" 296 echo $"Mounting $INSTALL_FSTYPE filesystem"
297 mount $INSTALL_DEVICE $MOUNTPOINT || { 297 mount $INSTALL_DEVICE $MOUNTPOINT || {
298 echo $"Error: could not mount filesystem; aborting." >&2 298 echo $"Error: could not mount filesystem; aborting." >&2
299 abort 299 abort
300 } 300 }
301 301
302 if [ "$INSTALL_HOME_DEVICE" ]; then 302 if [ "$INSTALL_HOME_DEVICE" ]; then
303 if [ "$INSTALL_HOME_FORMAT" == "1" ]; then 303 if [ "$INSTALL_HOME_FORMAT" == "1" ]; then
304 dcop_write $"Formatting device $INSTALL_HOME_DEVICE..." 10 304 dcop_write $"Formatting device $INSTALL_HOME_DEVICE..." 10
305 echo $"Formatting device $INSTALL_HOME_DEVICE" 305 echo $"Formatting device $INSTALL_HOME_DEVICE"
306 $FORMAT_HOME_CMD $INSTALL_HOME_DEVICE $FORMAT_HOME_APPEND 306 $FORMAT_HOME_CMD $INSTALL_HOME_DEVICE $FORMAT_HOME_APPEND
307 [ $? -ne 0 ] && { 307 [ $? -ne 0 ] && {
308 echo $"Error: could not format device $INSTALL_DEVICE; aborting." >&2 308 echo $"Error: could not format device $INSTALL_DEVICE; aborting." >&2
309 abort 309 abort
310 } 310 }
311 fi 311 fi
312 312
313 dcop_write $"Mounting home filesystem..." 10 313 dcop_write $"Mounting home filesystem..." 10
314 echo $"Mounting home filesystem" 314 echo $"Mounting home filesystem"
315 mkdir -p $MOUNTPOINT/home 315 mkdir -p $MOUNTPOINT/home
316 mount $INSTALL_HOME_DEVICE $MOUNTPOINT/home || { 316 mount $INSTALL_HOME_DEVICE $MOUNTPOINT/home || {
317 echo $"Error: could not mount home filesystem; aborting." >&2 317 echo $"Error: could not mount home filesystem; aborting." >&2
318 abort 318 abort
319 } 319 }
320 fi 320 fi
321 321
322 echo -n $"Copying files..." 322 echo -n $"Copying files..."
323 dcop_write $"Copying files..." 15 323 dcop_write $"Copying files..." 15
324 prog=15 324 prog=15
325 325
326 for d in etc bin boot lib opt sbin srv usr var root; do 326 for d in etc bin boot lib opt sbin srv usr var root; do
327 [ ! "$INSTALL_CLONE_MODE" == "1" -a -e /squashfs/$d ] && canonical_dir=/squashfs/$d || canonical_dir=`readlink -f /$d` 327 [ ! "$INSTALL_CLONE_MODE" == "1" -a -e /squashfs/$d ] && canonical_dir=/squashfs/$d || canonical_dir=`readlink -f /$d`
328 DIR_SPACE=`du -sxm $canonical_dir | awk '{ print $1; }'` 328 DIR_SPACE=`du -sxm $canonical_dir | awk '{ print $1; }'`
329 TOTAL_SPACE=`expr $TOTAL_SPACE + $DIR_SPACE` 329 TOTAL_SPACE=`expr $TOTAL_SPACE + $DIR_SPACE`
330 done 330 done
331 331
332 for d in etc bin boot lib opt sbin srv usr var root; do 332 for d in etc bin boot lib opt sbin srv usr var root; do
333 [ ! "$INSTALL_CLONE_MODE" == "1" -a -e /squashfs/$d ] && canonical_dir=/squashfs/$d || canonical_dir=`readlink -f /$d` 333 [ ! "$INSTALL_CLONE_MODE" == "1" -a -e /squashfs/$d ] && canonical_dir=/squashfs/$d || canonical_dir=`readlink -f /$d`
334 cp -av $canonical_dir $MOUNTPOINT/ | cp_parser || { 334 cp -av $canonical_dir $MOUNTPOINT/ | cp_parser || {
335 echo $"Error: cannot copy $canonical_dir to $MOUNTPOINT; aborting." >&2 335 echo $"Error: cannot copy $canonical_dir to $MOUNTPOINT; aborting." >&2
336 abort 336 abort
337 } 337 }
338 done 338 done
339 339
340 MOUNT_SPACE=`df -m $MOUNTPOINT | tail -1 | awk '{ print $3; }'` 340 MOUNT_SPACE=`df -m $MOUNTPOINT | tail -1 | awk '{ print $3; }'`
341 let TIME_ELAPSED=\(`date +%s`-$date_start\)/60 341 let TIME_ELAPSED=\(`date +%s`-$date_start\)/60
342 dcop_write_details $"\ 342 dcop_write_details $"\
343 343
344 ${MOUNT_SPACE} Mbytes copied 344 ${MOUNT_SPACE} Mbytes copied
345 Installation time: $TIME_ELAPSED minutes" 345 Installation time: $TIME_ELAPSED minutes"
346 346
347 CONFIGURED_FILES="/etc/sysconfig/keyboard /etc/sysconfig/i18n /etc/vconsole.conf /etc/locale.conf \ 347 CONFIGURED_FILES="/etc/sysconfig/keyboard /etc/sysconfig/i18n /etc/vconsole.conf /etc/locale.conf \
348 /etc/X11/xorg.conf /etc/X11/xorg.conf.d/10-keyboard.conf /etc/X11/xorg.conf.d/20-touchpad.conf" 348 /etc/X11/xorg.conf /etc/X11/xorg.conf.d/10-keyboard.conf /etc/X11/xorg.conf.d/20-touchpad.conf"
349 for f in $CONFIGURED_FILES; do 349 for f in $CONFIGURED_FILES; do
350 cp $f ${MOUNTPOINT}/${f} 350 cp $f ${MOUNTPOINT}/${f}
351 done 351 done
352 echo 352 echo
353 353
354 mkdir -p $MOUNTPOINT/{dev,home,initrd,media,mnt,proc,run,sys,tmp} 354 mkdir -p $MOUNTPOINT/{dev,home,initrd,media,mnt,proc,run,sys,tmp}
355 chmod 1777 $MOUNTPOINT/tmp 355 chmod 1777 $MOUNTPOINT/tmp
356 chmod 0750 $MOUNTPOINT/root 356 chmod 0750 $MOUNTPOINT/root
357 357
358 # create base devices 358 # create base devices
359 [ -x /lib/udev/devices/MAKEDEV ] || { 359 [ -x /lib/udev/devices/MAKEDEV ] || {
360 echo $"Error: cannot run MAKEDEV; aborting." >&2 360 echo $"Error: cannot run MAKEDEV; aborting." >&2
361 abort 361 abort
362 } 362 }
363 363
364 UDEV_ROOT=$MOUNTPOINT/dev /lib/udev/devices/MAKEDEV 364 UDEV_ROOT=$MOUNTPOINT/dev /lib/udev/devices/MAKEDEV
365 365
366 dcop_write $"Binding system dirs to new mountpoint..." 73 366 dcop_write $"Binding system dirs to new mountpoint..." 73
367 echo $"Binding /dev to new mountpoint" 367 echo $"Binding /dev to new mountpoint"
368 mount -o bind /dev $MOUNTPOINT/dev || { 368 mount -o bind /dev $MOUNTPOINT/dev || {
369 echo $"Error: could not bind /dev to new mountpoint; aborting." >&2 369 echo $"Error: could not bind /dev to new mountpoint; aborting." >&2
370 abort 370 abort
371 } 371 }
372 mount -o bind /proc $MOUNTPOINT/proc || { 372 mount -o bind /proc $MOUNTPOINT/proc || {
373 echo $"Error: could not bind /proc to new mountpoint; aborting." >&2 373 echo $"Error: could not bind /proc to new mountpoint; aborting." >&2
374 abort 374 abort
375 } 375 }
376 376
377 # set root partition in fstab 377 # set root partition in fstab
378 # must be done before mkinitrd 378 # must be done before mkinitrd
379 #currroot=`readlink /dev/root` 379 #currroot=`readlink /dev/root`
380 eval `blkid $INSTALL_DEVICE -o udev` 380 eval `blkid $INSTALL_DEVICE -o udev`
381 [ "$ID_FS_UUID" ] && INSTALL_DEVICE_UUID=$ID_FS_UUID || unset INSTALL_DEVICE_UUID 381 [ "$ID_FS_UUID" ] && INSTALL_DEVICE_UUID=$ID_FS_UUID || unset INSTALL_DEVICE_UUID
382 grep -v ^/dev $MOUNTPOINT/etc/fstab | grep -v ^UUID= > $MOUNTPOINT/etc/fstab.new 382 grep -v ^/dev $MOUNTPOINT/etc/fstab | grep -v ^UUID= > $MOUNTPOINT/etc/fstab.new
383 if [ "$INSTALL_DEVICE_UUID" ]; then 383 if [ "$INSTALL_DEVICE_UUID" ]; then
384 echo "UUID=$INSTALL_DEVICE_UUID / $INSTALL_FSTYPE defaults 1 1" >> $MOUNTPOINT/etc/fstab.new 384 echo "UUID=$INSTALL_DEVICE_UUID / $INSTALL_FSTYPE defaults 1 1" >> $MOUNTPOINT/etc/fstab.new
385 else 385 else
386 echo "$REMAPPED_INSTALL_DEVICE / $INSTALL_FSTYPE defaults 1 1" >> $MOUNTPOINT/etc/fstab.new 386 echo "$REMAPPED_INSTALL_DEVICE / $INSTALL_FSTYPE defaults 1 1" >> $MOUNTPOINT/etc/fstab.new
387 fi 387 fi
388 388
389 if [ "$INSTALL_HOME_DEVICE" ]; then 389 if [ "$INSTALL_HOME_DEVICE" ]; then
390 eval `blkid $INSTALL_HOME_DEVICE -o udev` 390 eval `blkid $INSTALL_HOME_DEVICE -o udev`
391 [ "$ID_FS_UUID" ] && INSTALL_HOME_DEVICE_UUID=$ID_FS_UUID || unset INSTALL_HOME_DEVICE_UUID 391 [ "$ID_FS_UUID" ] && INSTALL_HOME_DEVICE_UUID=$ID_FS_UUID || unset INSTALL_HOME_DEVICE_UUID
392 [ "$INSTALL_HOME_FORMAT" == "1" ] || INSTALL_HOME_FSTYPE="auto" 392 [ "$INSTALL_HOME_FORMAT" == "1" ] || INSTALL_HOME_FSTYPE="auto"
393 if [ "$INSTALL_HOME_DEVICE_UUID" ]; then 393 if [ "$INSTALL_HOME_DEVICE_UUID" ]; then
394 echo "UUID=$INSTALL_HOME_DEVICE_UUID /home $INSTALL_HOME_FSTYPE defaults 2 2" >> $MOUNTPOINT/etc/fstab.new 394 echo "UUID=$INSTALL_HOME_DEVICE_UUID /home $INSTALL_HOME_FSTYPE defaults 2 2" >> $MOUNTPOINT/etc/fstab.new
395 else 395 else
396 echo "$REMAPPED_INSTALL_HOME_DEVICE /home $INSTALL_HOME_FSTYPE defaults 2 2" >> $MOUNTPOINT/etc/fstab.new 396 echo "$REMAPPED_INSTALL_HOME_DEVICE /home $INSTALL_HOME_FSTYPE defaults 2 2" >> $MOUNTPOINT/etc/fstab.new
397 fi 397 fi
398 fi 398 fi
399 mv $MOUNTPOINT/etc/fstab.new $MOUNTPOINT/etc/fstab 399 mv $MOUNTPOINT/etc/fstab.new $MOUNTPOINT/etc/fstab
400 400
401 if [ "$INSTALL_DRIVER" ]; then 401 if [ "$INSTALL_DRIVER" ]; then
402 /sbin/lsmod | grep "^$INSTALL_DRIVER " && { 402 /sbin/lsmod | grep "^$INSTALL_DRIVER " && {
403 echo "alias scsi_hostadapter $INSTALL_DRIVER" >> $MOUNTPOINT/etc/modprobe.d/initramfs.conf 403 echo "alias scsi_hostadapter $INSTALL_DRIVER" >> $MOUNTPOINT/etc/modprobe.d/initramfs.conf
404 MKINITRAMFS_ADD="--with=$INSTALL_DRIVER" 404 MKINITRAMFS_ADD="--with=$INSTALL_DRIVER"
405 } || MKINITRAMFS_ADD="" 405 } || MKINITRAMFS_ADD=""
406 fi 406 fi
407 407
408 # remove not-running installed kernel 408 # remove not-running installed kernel
409 RUNNING_KERNEL=`uname -r | sed "s|[0-9.]*||"` 409 RUNNING_KERNEL=`uname -r | sed "s|[0-9.]*||"`
410 for i in `ls $MOUNTPOINT/boot/vmlinuz-*`; do 410 for i in `ls $MOUNTPOINT/boot/vmlinuz-*`; do
411 INSTALLED_KERNEL=`echo ${i} | sed "s|.*/vmlinuz-[0-9.]*||"` 411 INSTALLED_KERNEL=`echo ${i} | sed "s|.*/vmlinuz-[0-9.]*||"`
412 [ "$INSTALLED_KERNEL" = "$RUNNING_KERNEL" ] && continue 412 [ "$INSTALLED_KERNEL" = "$RUNNING_KERNEL" ] && continue
413 dcop_write $"Removing ""$INSTALLED_KERNEL kernel..." 74 413 dcop_write $"Removing ""$INSTALLED_KERNEL kernel..." 74
414 echo $"Removing ""$INSTALLED_KERNEL kernel..." 414 echo $"Removing ""$INSTALLED_KERNEL kernel..."
415 chroot $MOUNTPOINT smart remove -y kernel-$INSTALLED_KERNEL 415 chroot $MOUNTPOINT smart remove -y kernel-$INSTALLED_KERNEL
416 done 416 done
417 417
418 dcop_write $"Creating initramfs..." 75 418 dcop_write $"Creating initramfs..." 75
419 echo $"Creating initramfs" 419 echo $"Creating initramfs"
420 chroot $MOUNTPOINT \ 420 chroot $MOUNTPOINT \
421 mkinitrd /boot/initramfs-$KERNEL_RELEASE.img \ 421 mkinitrd /boot/initramfs-$KERNEL_RELEASE.img \
422 $KERNEL_RELEASE -f $MKINITRAMFS_ADD || \ 422 $KERNEL_RELEASE -f $MKINITRAMFS_ADD || \
423 { 423 {
424 echo $"Error: initramfs creation failed; aborting." >&2 424 echo $"Error: initramfs creation failed; aborting." >&2
425 abort 425 abort
426 } 426 }
427 # --fstab=/etc/fstab || 427 # --fstab=/etc/fstab ||
428 428
429 if [ "$INSTALL_BOOTLOADER_DEVICE" ]; then 429 if [ "$INSTALL_BOOTLOADER_DEVICE" ]; then
430 dcop_write $"Installing bootloader on $INSTALL_BOOTLOADER_DEVICE..." 85 430 dcop_write $"Installing bootloader on $INSTALL_BOOTLOADER_DEVICE..." 85
431 INSTALL_BOOTLOADER_DEVICE_BYID=$INSTALL_BOOTLOADER_DEVICE 431 INSTALL_BOOTLOADER_DEVICE_BYID=$INSTALL_BOOTLOADER_DEVICE
432 for f in `ls /dev/disk/by-id/*`; do 432 for f in `ls /dev/disk/by-id/*`; do
433 if [ "$INSTALL_BOOTLOADER_DEVICE" = "`readlink -f $f`" ]; then 433 if [ "$INSTALL_BOOTLOADER_DEVICE" = "`readlink -f $f`" ]; then
434 INSTALL_BOOTLOADER_DEVICE_BYID=$f 434 INSTALL_BOOTLOADER_DEVICE_BYID=$f
435 break 435 break
436 fi 436 fi
437 done 437 done
438 echo "GRUB_INSTALL_DEVICE=$INSTALL_BOOTLOADER_DEVICE_BYID" >> $MOUNTPOINT/etc/sysconfig/grub 438 echo "GRUB_INSTALL_DEVICE=$INSTALL_BOOTLOADER_DEVICE_BYID" >> $MOUNTPOINT/etc/sysconfig/grub
439 if [ "$INSTALL_BOOTLOADER_DEVICE_INTERNAL" != "1" ]; then 439 if [ "$INSTALL_BOOTLOADER_DEVICE_INTERNAL" != "1" ]; then
440 echo $"Installing grub bootloader on removable device $INSTALL_BOOTLOADER_DEVICE" 440 echo $"Installing grub bootloader on removable device $INSTALL_BOOTLOADER_DEVICE"
441 echo "(hd0) $INSTALL_BOOTLOADER_DEVICE" > $MOUNTPOINT/boot/grub/device.map 441 echo "(hd0) $INSTALL_BOOTLOADER_DEVICE" > $MOUNTPOINT/boot/grub/device.map
442 grub-install $INSTALL_BOOTLOADER_DEVICE --root-directory=$MOUNTPOINT --no-floppy --force 442 grub-install $INSTALL_BOOTLOADER_DEVICE --root-directory=$MOUNTPOINT --no-floppy --force
443 else 443 else
444 echo $"Installing grub bootloader on $INSTALL_BOOTLOADER_DEVICE" 444 echo $"Installing grub bootloader on $INSTALL_BOOTLOADER_DEVICE"
445 > $MOUNTPOINT/boot/grub/device.map 445 > $MOUNTPOINT/boot/grub/device.map
446 for i in `seq 1 ${#DEV_NAME_ORIG[*]}`; do 446 for i in `seq 1 ${#DEV_NAME_ORIG[*]}`; do
447 echo "(${GRUB_NAME_DEST[i-1]}) ${DEV_NAME_ORIG[i-1]}" >> $MOUNTPOINT/boot/grub/device.map 447 echo "(${GRUB_NAME_DEST[i-1]}) ${DEV_NAME_ORIG[i-1]}" >> $MOUNTPOINT/boot/grub/device.map
448 done 448 done
449 grub-install $INSTALL_BOOTLOADER_DEVICE --root-directory=$MOUNTPOINT --no-floppy --force 449 grub-install $INSTALL_BOOTLOADER_DEVICE --root-directory=$MOUNTPOINT --no-floppy --force
450 fi 450 fi
451 451
452 # DEV_NAME_ORIG=(${DEV_NAME_ORIG[*]} $GRUB_DEV) 452 # DEV_NAME_ORIG=(${DEV_NAME_ORIG[*]} $GRUB_DEV)
453 # DEV_NAME_DEST=(${DEV_NAME_DEST[*]} $NEW_GRUB_DEV) 453 # DEV_NAME_DEST=(${DEV_NAME_DEST[*]} $NEW_GRUB_DEV)
454 454
455 # # create a couple of conversion vectors to convert/dev/sd* devices names 455 # # create a couple of conversion vectors to convert/dev/sd* devices names
456 # # into how they will appear on the installed system 456 # # into how they will appear on the installed system
457 # unset CURR_DRIVER LOAD_DRIVER_LIST 457 # unset CURR_DRIVER LOAD_DRIVER_LIST
458 # CURR_SD_LETTER=0 458 # CURR_SD_LETTER=0
459 # while read line; do 459 # while read line; do
460 # GRUB_DEV=`echo ${line/*[[:space:]]/}` 460 # GRUB_DEV=`echo ${line/*[[:space:]]/}`
461 # if [ "${GRUB_DEV:0:7}" = "/dev/sd" ]; then 461 # if [ "${GRUB_DEV:0:7}" = "/dev/sd" ]; then
462 # NEW_GRUB_DEV=/dev/sd${LETTERS[CURR_SD_LETTER]} 462 # NEW_GRUB_DEV=/dev/sd${LETTERS[CURR_SD_LETTER]}
463 # let CURR_SD_LETTER+=1 463 # let CURR_SD_LETTER+=1
464 # else 464 # else
465 # NEW_GRUB_DEV=$GRUB_DEV 465 # NEW_GRUB_DEV=$GRUB_DEV
466 # fi 466 # fi
467 # DEV_NAME_ORIG=(${DEV_NAME_ORIG[*]} $GRUB_DEV) 467 # DEV_NAME_ORIG=(${DEV_NAME_ORIG[*]} $GRUB_DEV)
468 # DEV_NAME_DEST=(${DEV_NAME_DEST[*]} $NEW_GRUB_DEV) 468 # DEV_NAME_DEST=(${DEV_NAME_DEST[*]} $NEW_GRUB_DEV)
469 # done < /boot/grub/device.map 469 # done < /boot/grub/device.map
470 470
471 if [ "${INSTALL_BOOTLOADER_DEVICE:8:2}" = "" ]; then 471 if [ "${INSTALL_BOOTLOADER_DEVICE:8:2}" = "" ]; then
472 # MBR install: set /boot partition as bootable as required by grub2 472 # MBR install: set /boot partition as bootable as required by grub2
473 # CHECK: this does not work when install device is an extended partition, but in this case 473 # CHECK: this does not work when install device is an extended partition, but in this case
474 # a 1-4 boot partition is already set by another system 474 # a 1-4 boot partition is already set by another system
475 if [ ${INSTALL_DEVICE:8:2} -le 4 ]; then 475 if [ ${INSTALL_DEVICE:8:2} -le 4 ]; then
476 parted ${INSTALL_DEVICE:0:8} \ 476 parted ${INSTALL_DEVICE:0:8} \
477 set ${INSTALL_DEVICE:8:2} boot on || \ 477 set ${INSTALL_DEVICE:8:2} boot on || \
478 echo $"Warning: there was an error setting /boot partition as bootable." >&2 478 echo $"Warning: there was an error setting /boot partition as bootable." >&2
479 fi 479 fi
480 elif [ "$INSTALL_BOOTLOADER_DEVICE_SETBOOTABLE" = "1" ]; then 480 elif [ "$INSTALL_BOOTLOADER_DEVICE_SETBOOTABLE" = "1" ]; then
481 parted ${INSTALL_BOOTLOADER_DEVICE:0:8} \ 481 parted ${INSTALL_BOOTLOADER_DEVICE:0:8} \
482 set ${INSTALL_BOOTLOADER_DEVICE:8:2} boot on || \ 482 set ${INSTALL_BOOTLOADER_DEVICE:8:2} boot on || \
483 echo $"Warning: there was an error setting bootloader partition as bootable." >&2 483 echo $"Warning: there was an error setting bootloader partition as bootable." >&2
484 fi 484 fi
485 485
486 [ "$INSTALL_BOOTLOADER_CHAINLOAD" ] && { 486 [ "$INSTALL_BOOTLOADER_CHAINLOAD" ] && {
487 # configure boot chainloader for e.g. windows 487 # configure boot chainloader for e.g. windows
488 GRUB_OTHER_TITLES=() 488 GRUB_OTHER_TITLES=()
489 GRUB_OTHER_DEVICES=() 489 GRUB_OTHER_DEVICES=()
490 for i in ${INSTALL_BOOTLOADER_CHAINLOAD[*]}; do 490 for i in ${INSTALL_BOOTLOADER_CHAINLOAD[*]}; do
491 # FIXME: missing conversion from device to grub (hdx,y) form 491 # FIXME: missing conversion from device to grub (hdx,y) form
492 unset ID_FS_UUID 492 unset ID_FS_UUID ID_FS_TYPE ID_FS_LABEL
493 eval `blkid $i -o udev` 493 eval `blkid $i -o udev`
494 if [ "$ID_FS_UUID" ]; then 494 if [ "$ID_FS_UUID" ]; then
495 if [ "$ID_FS_TYPE" = "ntfs" ]; then 495 if [ "$ID_FS_TYPE" = "ntfs" ]; then
496 [ "$ID_FS_LABEL" ] && 496 [ "$ID_FS_LABEL" ] &&
497 ID_FS_LABEL="Windows ($ID_FS_LABEL)" || ID_FS_LABEL="Windows" 497 ID_FS_LABEL="Windows ($ID_FS_LABEL)" || ID_FS_LABEL="Windows"
498 elif [ "${ID_FS_TYPE:0:3}" = "fat" ]; then 498 elif [ "${ID_FS_TYPE:0:3}" = "fat" ]; then
499 [ "$ID_FS_LABEL" ] && 499 [ "$ID_FS_LABEL" ] &&
500 ID_FS_LABEL="Win/DOS ($ID_FS_LABEL)" || ID_FS_LABEL="Windows/DOS" 500 ID_FS_LABEL="Win/DOS ($ID_FS_LABEL)" || ID_FS_LABEL="Windows/DOS"
501 else 501 else
502 [ "$ID_FS_LABEL" ] && 502 [ "$ID_FS_LABEL" ] &&
503 ID_FS_LABEL="Other OS ($ID_FS_LABEL)" || ID_FS_LABEL="Other OS" 503 ID_FS_LABEL="Other OS ($ID_FS_LABEL)" || ID_FS_LABEL="Other OS"
504 fi 504 fi
505 [ "$ID_FS_LABEL" ] || ID_FS_LABEL="W" 505 [ "$ID_FS_LABEL" ] || ID_FS_LABEL="Unknown"
506 GRUB_OTHER_DEVICES=(${GRUB_OTHER_DEVICES[*]} /dev/disk/by-uuid/$ID_FS_UUID) 506 GRUB_OTHER_DEVICES=(${GRUB_OTHER_DEVICES[*]} /dev/disk/by-uuid/$ID_FS_UUID)
507 GRUB_OTHER_TITLES=(${GRUB_OTHER_TITLES[*]} "\"$ID_FS_LABEL\"") 507 GRUB_OTHER_TITLES=(${GRUB_OTHER_TITLES[*]} "\"$ID_FS_LABEL\"")
508 else 508 else
509 GRUB_OTHER_DEV=$i 509 GRUB_OTHER_DEV=$i
510 for o in `seq 1 ${#DEV_NAME_ORIG[*]}`; do 510 for o in `seq 1 ${#DEV_NAME_ORIG[*]}`; do
511 [ "${DEV_NAME_ORIG[o-1]}" = "${i:5:3}" ] && { 511 [ "${DEV_NAME_ORIG[o-1]}" = "${i:5:3}" ] && {
512 GRUB_OTHER_DEV=${DEV_NAME_DEST[o-1]}${i:8:2} 512 GRUB_OTHER_DEV=${DEV_NAME_DEST[o-1]}${i:8:2}
513 break 513 break
514 } 514 }
515 done 515 done
516 # echo $"Renaming device "${DEV_NAME_ORIG[o-1]}$" to "${DEV_NAME_DEST[o-1]} 516 # echo $"Renaming device "${DEV_NAME_ORIG[o-1]}$" to "${DEV_NAME_DEST[o-1]}
517 # sed -i "s|/dev/${DEV_NAME_ORIG[o-1]:5:3}|/dev/${DEV_NAME_DEST[o-1]:5:3}|" \ 517 # sed -i "s|/dev/${DEV_NAME_ORIG[o-1]:5:3}|/dev/${DEV_NAME_DEST[o-1]:5:3}|" \
518 # $MOUNTPOINT/boot/grub/devices.map \ 518 # $MOUNTPOINT/boot/grub/devices.map \
519 # $MOUNTPOINT/etc/sysconfig/grub 519 # $MOUNTPOINT/etc/sysconfig/grub
520 # CURR_ROOT_LETTER=0 520 # CURR_ROOT_LETTER=0
521 # sed -i "s|root=/dev/${INSTALL_DEVICE:5:5}|root=/dev/${DEV_NAME_DEST[o-1]:5:3}|" \ 521 # sed -i "s|root=/dev/${INSTALL_DEVICE:5:5}|root=/dev/${DEV_NAME_DEST[o-1]:5:3}|" \
522 # $MOUNTPOINT/boot/grub/grub.cfg 522 # $MOUNTPOINT/boot/grub/grub.cfg
523 # done 523 # done
524 GRUB_OTHER_DEVICES=(${GRUB_OTHER_DEVICES[*]} $GRUB_OTHER_DEV) 524 GRUB_OTHER_DEVICES=(${GRUB_OTHER_DEVICES[*]} $GRUB_OTHER_DEV)
525 GRUB_OTHER_TITLES=(${GRUB_OTHER_TITLES[*]} "\"Windows on $GRUB_OTHER_DEV\"") 525 GRUB_OTHER_TITLES=(${GRUB_OTHER_TITLES[*]} "\"Windows on $GRUB_OTHER_DEV\"")
526 fi 526 fi
527 done 527 done
528 cat >> $MOUNTPOINT/etc/sysconfig/grub << _EOF 528 cat >> $MOUNTPOINT/etc/sysconfig/grub << _EOF
529 GRUB_OTHER_DEVICES=(${GRUB_OTHER_DEVICES[*]}) 529 GRUB_OTHER_DEVICES=(${GRUB_OTHER_DEVICES[*]})
530 GRUB_OTHER_TITLES=(${GRUB_OTHER_TITLES[*]}) 530 GRUB_OTHER_TITLES=(${GRUB_OTHER_TITLES[*]})
531 _EOF 531 _EOF
532 } 532 }
533 533
534 # mount all disks and dbus for Grub other linuxes detection to work (30_other_linux) 534 # mount all disks and dbus for Grub other linuxes detection to work (30_other_linux)
535 mount -o bind /mnt $MOUNTPOINT/mnt 535 mount -o bind /mnt $MOUNTPOINT/mnt
536 mount -o bind /var/run/dbus $MOUNTPOINT/var/run/dbus 536 mount -o bind /var/run/dbus $MOUNTPOINT/var/run/dbus
537 for d in /mnt/*; do 537 for d in /mnt/*; do
538 [ -d $d ] && mount -o bind,ro $d ${MOUNTPOINT}${d} 538 [ -d $d ] && mount -o bind,ro $d ${MOUNTPOINT}${d}
539 done 539 done
540 chroot $MOUNTPOINT grub-mkconfig -o /boot/grub/grub.cfg 540 chroot $MOUNTPOINT grub-mkconfig -o /boot/grub/grub.cfg
541 for d in /mnt/*; do 541 for d in /mnt/*; do
542 [ -d $d ] && umount ${MOUNTPOINT}${d} 542 [ -d $d ] && umount ${MOUNTPOINT}${d}
543 done 543 done
544 umount $MOUNTPOINT/var/run/dbus 544 umount $MOUNTPOINT/var/run/dbus
545 umount $MOUNTPOINT/mnt 545 umount $MOUNTPOINT/mnt
546 546
547 # for o in `seq 1 ${#DEV_NAME_ORIG[*]}`; do 547 # for o in `seq 1 ${#DEV_NAME_ORIG[*]}`; do
548 # [ ${DEV_NAME_ORIG[o-1]} != ${DEV_NAME_DEST[o-1]} ] & continue 548 # [ ${DEV_NAME_ORIG[o-1]} != ${DEV_NAME_DEST[o-1]} ] & continue
549 # echo $"Renaming device "${DEV_NAME_ORIG[o-1]}$" to "${DEV_NAME_DEST[o-1]} 549 # echo $"Renaming device "${DEV_NAME_ORIG[o-1]}$" to "${DEV_NAME_DEST[o-1]}
550 # sed -i "s|/dev/${DEV_NAME_ORIG[o-1]:5:3}|/dev/${DEV_NAME_DEST[o-1]:5:3}|" \ 550 # sed -i "s|/dev/${DEV_NAME_ORIG[o-1]:5:3}|/dev/${DEV_NAME_DEST[o-1]:5:3}|" \
551 # $MOUNTPOINT/boot/grub/devices.map \ 551 # $MOUNTPOINT/boot/grub/devices.map \
552 # $MOUNTPOINT/etc/sysconfig/grub 552 # $MOUNTPOINT/etc/sysconfig/grub
553 # CURR_ROOT_LETTER=0 553 # CURR_ROOT_LETTER=0
554 # sed -i "s|root=/dev/${INSTALL_DEVICE:5:5}|root=/dev/${DEV_NAME_DEST[o-1]:5:3}|" \ 554 # sed -i "s|root=/dev/${INSTALL_DEVICE:5:5}|root=/dev/${DEV_NAME_DEST[o-1]:5:3}|" \
555 # $MOUNTPOINT/boot/grub/grub.cfg 555 # $MOUNTPOINT/boot/grub/grub.cfg
556 # done 556 # done
557 557
558 [ "${INSTALL_DEVICE}" != "${REMAPPED_INSTALL_DEVICE}" ] && \ 558 [ "${INSTALL_DEVICE}" != "${REMAPPED_INSTALL_DEVICE}" ] && \
559 sed -i "s|root=/dev/${INSTALL_DEVICE:5:5}|root=/dev/${REMAPPED_INSTALL_DEVICE:5:5}|" \ 559 sed -i "s|root=/dev/${INSTALL_DEVICE:5:5}|root=/dev/${REMAPPED_INSTALL_DEVICE:5:5}|" \
560 $MOUNTPOINT/boot/grub/grub.cfg 560 $MOUNTPOINT/boot/grub/grub.cfg
561 else 561 else
562 echo $"Info: skipping bootloader installation" 562 echo $"Info: skipping bootloader installation"
563 fi 563 fi
564 564
565 ## MBR backup 565 ## MBR backup
566 #echo "Installing MBR record on $INSTALL_BOOTLOADER_DEVICE" 566 #echo "Installing MBR record on $INSTALL_BOOTLOADER_DEVICE"
567 #dd if=$INSTALL_BOOTLOADER_DEVICE of=$MOUNTPOINT/boot/mbr-backup bs=1 count=512 567 #dd if=$INSTALL_BOOTLOADER_DEVICE of=$MOUNTPOINT/boot/mbr-backup bs=1 count=512
568 #install-mbr $INSTALL_BOOTLOADER_DEVICE 568 #install-mbr $INSTALL_BOOTLOADER_DEVICE
569 569
570 dcop_write $"Configuring system startup files..." 85 570 dcop_write $"Configuring system startup files..." 85
571 echo $"Configuring system startup files" 571 echo $"Configuring system startup files"
572 572
573 # configure inittab 573 # configure inittab
574 sed -i "s,^1:.*,1:234:respawn:/sbin/agetty tty1 9600," \ 574 sed -i "s,^1:.*,1:234:respawn:/sbin/agetty tty1 9600," \
575 $MOUNTPOINT/etc/inittab 575 $MOUNTPOINT/etc/inittab
576 sed -i "s,^\([2-3]\):.*,\1:2345:respawn:/sbin/agetty tty\1 9600," \ 576 sed -i "s,^\([2-3]\):.*,\1:2345:respawn:/sbin/agetty tty\1 9600," \
577 $MOUNTPOINT/etc/inittab 577 $MOUNTPOINT/etc/inittab
578 578
579 # enable multithreaded init 579 # enable multithreaded init
580 sed -i "s|multithread=.*|multithread=1|" $MOUNTPOINT/etc/sysconfig/rc 580 sed -i "s|multithread=.*|multithread=1|" $MOUNTPOINT/etc/sysconfig/rc
581 chroot $MOUNTPOINT depinit 581 chroot $MOUNTPOINT depinit
582 582
583 if [ -d /cdrom/openmamba/base ]; then 583 if [ -d /cdrom/openmamba/base ]; then
584 584
585 # openmamba install_packages script section 585 # openmamba install_packages script section
586 dcop_write $"Installing packages..." 90 586 dcop_write $"Installing packages..." 90
587 echo $"Installing packages" 587 echo $"Installing packages"
588 588
589 PKGGROUPS_DB=$MOUNTPOINT/usr/share/openmamba/pkggroups.db 589 PKGGROUPS_DB=$MOUNTPOINT/usr/share/openmamba/pkggroups.db
590 . $PKGGROUPS_DB 590 . $PKGGROUPS_DB
591 591
592 # trap "umount $MOUNTPOINT/var/lib/apt/cdrom 2>/dev/null" 0 1 2 5 15 592 # trap "umount $MOUNTPOINT/var/lib/apt/cdrom 2>/dev/null" 0 1 2 5 15
593 593
594 mount -o bind /cdrom $MOUNTPOINT/var/lib/apt/cdrom 594 mount -o bind /cdrom $MOUNTPOINT/var/lib/apt/cdrom
595 chroot $MOUNTPOINT apt-cdrom add -m -d /var/lib/apt/cdrom 595 chroot $MOUNTPOINT apt-cdrom add -m -d /var/lib/apt/cdrom
596 596
597 # disable the service command 597 # disable the service command
598 mv $MOUNTPOINT/sbin/service $MOUNTPOINT/sbin/service.preinst 598 mv $MOUNTPOINT/sbin/service $MOUNTPOINT/sbin/service.preinst
599 ln -sf /bin/true $MOUNTPOINT/sbin/service 599 ln -sf /bin/true $MOUNTPOINT/sbin/service
600 600
601 echo $"Launching chrooted apt-get..." 601 echo $"Launching chrooted apt-get..."
602 chroot $MOUNTPOINT apt-get -y install $ALL_PKGS \ 602 chroot $MOUNTPOINT apt-get -y install $ALL_PKGS \
603 -o Acquire::CDROM::mount=/var/lib/apt/cdrom \ 603 -o Acquire::CDROM::mount=/var/lib/apt/cdrom \
604 -o Acquire::CDROM::Copy=false \ 604 -o Acquire::CDROM::Copy=false \
605 -o Acquire::CDROM::Copy-All=false | apt_parser 605 -o Acquire::CDROM::Copy-All=false | apt_parser
606 606
607 # re-enable the service command 607 # re-enable the service command
608 rm -f $MOUNTPOINT/sbin/service 608 rm -f $MOUNTPOINT/sbin/service
609 mv $MOUNTPOINT/sbin/service.preinst $MOUNTPOINT/sbin/service 609 mv $MOUNTPOINT/sbin/service.preinst $MOUNTPOINT/sbin/service
610 610
611 umount $MOUNTPOINT/var/lib/apt/cdrom 2>/dev/null 611 umount $MOUNTPOINT/var/lib/apt/cdrom 2>/dev/null
612 612
613 # installation completed, remove cdrom volume from apt sources list 613 # installation completed, remove cdrom volume from apt sources list
614 sed -i "s|^\(rpm cdrom:.*\)|#\1|" $MOUNTPOINT/etc/apt/sources.list 614 sed -i "s|^\(rpm cdrom:.*\)|#\1|" $MOUNTPOINT/etc/apt/sources.list
615 fi 615 fi
616 616
617 dcop_write $"Removing/cleaning unnecessary files and packages..." 95 617 dcop_write $"Removing/cleaning unnecessary files and packages..." 95
618 echo $"Removing/cleaning unnecessary files and packages" 618 echo $"Removing/cleaning unnecessary files and packages"
619 # remove unnecessary files and packages for fixed disk install 619 # remove unnecessary files and packages for fixed disk install
620 rpm -r $MOUNTPOINT -e livecd-tools 620 rpm -r $MOUNTPOINT -e livecd-tools
621 [ "$INSTALL_STABLE_UPDATES" = "1" ] && rpm -r $MOUNTPOINT -e openmamba-devel 2>/dev/null 621 [ "$INSTALL_STABLE_UPDATES" = "1" ] && rpm -r $MOUNTPOINT -e openmamba-devel 2>/dev/null
622 622
623 # remove ssh live medium keys 623 # remove ssh live medium keys
624 rm -f $MOUNTPOINT/etc/ssh_host_*.key $MOUNTPOINT/etc/ssh_host_*.key.pub 624 rm -f $MOUNTPOINT/etc/ssh_host_*.key $MOUNTPOINT/etc/ssh_host_*.key.pub
625 625
626 sed -i /eject_cd.sh/d $MOUNTPOINT/etc/rc0.d/K99halt 626 sed -i /eject_cd.sh/d $MOUNTPOINT/etc/rc0.d/K99halt
627 sed -i /eject_cd.sh/d $MOUNTPOINT/etc/rc6.d/K99reboot 627 sed -i /eject_cd.sh/d $MOUNTPOINT/etc/rc6.d/K99reboot
628 628
629 # fix paths in root home directory and perform some cleanup 629 # fix paths in root home directory and perform some cleanup
630 for d in $MOUNTPOINT/root/.kde $MOUNTPOINT/root/.kde4 $MOUNTPOINT/root/.qt; do 630 for d in $MOUNTPOINT/root/.kde $MOUNTPOINT/root/.kde4 $MOUNTPOINT/root/.qt; do
631 [ -e $d ] && find $d -type f -exec sed -i "s|/squashfs||" {} \; 631 [ -e $d ] && find $d -type f -exec sed -i "s|/squashfs||" {} \;
632 done 632 done
633 rm -f $MOUNTPOINT/root/.DCOPserver* $MOUNTPOINT/root/.ICEauthority 633 rm -f $MOUNTPOINT/root/.DCOPserver* $MOUNTPOINT/root/.ICEauthority
634 634
635 [ "$INSTALL_USER" -a -e $MOUNTPOINT/$MAMBAWELCOME_SCRIPT ] && { 635 [ "$INSTALL_USER" -a -e $MOUNTPOINT/$MAMBAWELCOME_SCRIPT ] && {
636 dcop_write $"Configuring users and host..." 87 636 dcop_write $"Configuring users and host..." 87
637 echo $"Configuring users and host" 637 echo $"Configuring users and host"
638 chroot $MOUNTPOINT sh $MAMBAWELCOME_SCRIPT -y 638 chroot $MOUNTPOINT sh $MAMBAWELCOME_SCRIPT -y
639 } 639 }
640 640
641 # FIXME: test gconftool-2 --shutdown 641 # FIXME: test gconftool-2 --shutdown
642 [ "`pidof gconfd-2`" ] && killall -9 gconfd-2 642 [ "`pidof gconfd-2`" ] && killall -9 gconfd-2
643 643
644 umount $MOUNTPOINT/dev 644 umount $MOUNTPOINT/dev
645 umount $MOUNTPOINT/proc 645 umount $MOUNTPOINT/proc
646 [ "$INSTALL_HOME_DEVICE" ] && umount $MOUNTPOINT/home 646 [ "$INSTALL_HOME_DEVICE" ] && umount $MOUNTPOINT/home
647 647
648 # NOTE: move INPUT_FILE instead of copying to prevent mambawelcome from starting from 648 # NOTE: move INPUT_FILE instead of copying to prevent mambawelcome from starting from
649 # bootusb after an installation 649 # bootusb after an installation
650 cp $INPUT_FILE $MOUNTPOINT/root/ 650 cp $INPUT_FILE $MOUNTPOINT/root/
651 mv $INPUT_FILE ~/.installer.conf.$INSTALL_DATE 651 mv $INPUT_FILE ~/.installer.conf.$INSTALL_DATE
652 652
653 REDIRECTED_FILE=`readlink /proc/$$/fd/1` 653 REDIRECTED_FILE=`readlink /proc/$$/fd/1`
654 [ -f $REDIRECTED_FILE ] && { 654 [ -f $REDIRECTED_FILE ] && {
655 cp -a $REDIRECTED_FILE ${MOUNTPOINT}${LOG_FILE} 655 cp -a $REDIRECTED_FILE ${MOUNTPOINT}${LOG_FILE}
656 [ -f ${MOUNTPOINT}${REDIRECTED_FILE} ] && rm -f ${MOUNTPOINT}${REDIRECTED_FILE} 656 [ -f ${MOUNTPOINT}${REDIRECTED_FILE} ] && rm -f ${MOUNTPOINT}${REDIRECTED_FILE}
657 } 657 }
658 658
659 ## now remove sensible information from input file 659 ## now remove sensible information from input file
660 #sed -i "/^INSTALL_ROOT_PASSWORD=.*/d" $INPUT_FILE 660 #sed -i "/^INSTALL_ROOT_PASSWORD=.*/d" $INPUT_FILE
661 #sed -i "/^INSTALL_USER_PASSWORD=.*/d" $INPUT_FILE 661 #sed -i "/^INSTALL_USER_PASSWORD=.*/d" $INPUT_FILE
662 662
663 umount $MOUNTPOINT 663 umount $MOUNTPOINT
664 finished 664 finished
665 665
666 echo $"Installation done. You can now reboot to start the freshly installed system." 666 echo $"Installation done. You can now reboot to start the freshly installed system."
667 667
668 exit 0 668 exit 0
669 669