1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
|
#!/bin/sh
getsource() {
S_SRC=0
if [ "$MODE" = "cd" ]; then
DIALOG --menu "You can either install packages from an Arch Linux CD, or you can switch to another VC and manually mount the source media under /src. If you manually mount to /src, make sure the packages are available under /src/core-$(uname -m)/pkg.\n\n" \
15 55 2 \
"CD" "Mount the CD-ROM and install from there" \
"SRC" "I have manually mounted the source media" 2>$ANSWER || return 1
case $(cat $ANSWER) in
"CD")
select_cdrom
;;
"SRC")
;;
esac
if [ ! -d /src/core-$(uname -m)/pkg ]; then
DIALOG --msgbox "Package directory /src/core-$(uname -m)/pkg is missing!" 0 0
return 1
fi
fi
if [ "$MODE" = "ftp" ]; then
select_mirror
fi
S_SRC=1
}
# select_mirror()
# Prompt user for preferred mirror and set $SYNC_URL
#
# args: none
# returns: nothing
select_mirror() {
DIALOG --msgbox "Keep in mind ftp.archlinux.org is throttled.\nPlease select another mirror to get full download speed." 18 70
# FIXME: this regex doesn't honor commenting
MIRRORS=$(egrep -o '((ftp)|(http))://[^/]*' "${MIRRORLIST}" | sed 's|$| _|g')
DIALOG --menu "Select an FTP/HTTP mirror" 14 55 7 \
$MIRRORS \
"Custom" "_" 2>$ANSWER || return 1
local _server=$(cat $ANSWER)
if [ "${_server}" = "Custom" ]; then
DIALOG --inputbox "Enter the full URL to core repo." 8 65 \
"ftp://ftp.archlinux.org/core/os/i686" 2>$ANSWER || return 1
SYNC_URL=$(cat $ANSWER)
else
SYNC_URL=$(egrep -o "${_server}.*" "${MIRRORLIST}" | sed 's/\$repo/core/g')
fi
}
prepare_pacman() {
cd /tmp
if [ "$MODE" = "cd" ]; then
local serverurl="${FILE_URL}"
elif [ "$MODE" = "ftp" ]; then
local serverurl="${SYNC_URL}"
fi
# Setup a pacman.conf in /tmp
cat << EOF > /tmp/pacman.conf
[options]
CacheDir = ${DESTDIR}/var/cache/pacman/pkg
CacheDir = /src/core-$(uname -m)/pkg
[core]
Server = ${serverurl}
EOF
# Set up the necessary directories for pacman use
[ ! -d "${DESTDIR}/var/cache/pacman/pkg" ] && mkdir -m 755 -p "${DESTDIR}/var/cache/pacman/pkg"
[ ! -d "${DESTDIR}/var/lib/pacman" ] && mkdir -m 755 -p "${DESTDIR}/var/lib/pacman"
DIALOG --infobox "Refreshing package database..." 6 45
# FIXME: if sync fails. this function needs to fail.
$PACMAN -Sy >$LOG 2>&1
}
selectpkg() {
if ! [ "$S_SRC" = "1" ]; then
DIALOG --msgbox "Error:\nYou must select Source first." 0 0
return 1
fi
# Archboot setup CD Mode uses packages.txt!
if [ "$MODE" = "cd" ]; then
DIALOG --msgbox "Package selection is split into two stages. First you will select package categories that contain packages you may be interested in. Then you will be presented with a full list of packages in your selected categories, allowing you to fine-tune your selection.\n\nNOTE: It is recommended that you install the BASE category from this setup, SUPPORT contains additional useful packages for networking and filesystems, DEVEL contains software building tools." 18 70
# set up our install location if necessary and sync up
# so we can get package lists
prepare_pacman
PKGS="/src/core-$(uname -m)/pkg/packages.txt"
if ! [ -f /tmp/.pkgcategory ]; then
CHKLIST="base ^ ON"
for category in $(cat $PKGS | sed 's|/.*$||g' | uniq | grep -v base | grep -v kernels); do
CHKLIST="$CHKLIST $category - OFF"
done
else
CHKLIST=
for i in $(cat /tmp/.pkgcategory | sed 's|\"||g'); do
CHKLIST="$CHKLIST $i ^ ON"
done
for category in $(cat $PKGS | sed 's|/.*$||g' | uniq | grep -v kernels); do
grep $category /tmp/.pkgcategory > /dev/null 2>&1 || CHKLIST="$CHKLIST $category - OFF"
done
fi
DIALOG --checklist "Select Package Categories" 19 55 12 $CHKLIST 2>/tmp/.pkgcategory || return 1
SELECTALL="no"
DIALOG --yesno "Select all packages by default?" 0 0 && SELECTALL="yes"
CHKLIST=
for category in $(cat /tmp/.pkgcategory | sed 's|"||g'); do
if [ "$category" = "x11-drivers" ]; then
DIALOG --msgbox "NOTE:\n-------\nxf86-video-via and xf86-video-unichrome are disabled by default, please select the correct package you need and don't choose both! Else installation will fail!" 0 0
fi
tag="OFF"
if [ "$SELECTALL" = "yes" ]; then
tag="ON"
fi
list=$(cat $PKGS | grep "$category/" | grep -v 'xf86-video-unichrome' | grep -v 'xf86-video-via' | sed 's|^[a-z0-9-]*/||g' | sed "s|.pkg.tar.gz$| ($category) $tag|g" | sort)
CHKLIST="$CHKLIST $list"
tag="OFF"
list=$(cat $PKGS | grep "$category/" | grep 'xf86-video-unichrome' | sed 's|^[a-z0-9-]*/||g' | sed "s|.pkg.tar.gz$| ($category) $tag|g" | sort)
CHKLIST="$CHKLIST $list"
list=$(cat $PKGS | grep "$category/" | grep 'xf86-video-via' | sed 's|^[a-z0-9-]*/||g' | sed "s|.pkg.tar.gz$| ($category) $tag|g" | sort)
CHKLIST="$CHKLIST $list"
done
DIALOG --checklist "Select Packages to install. Use SPACE to select." 19 60 12 $CHKLIST 2>/tmp/.pkglist || return 1
fi
# Use default ftp install routine from arch livecd
if [ "$MODE" = "ftp" ]; then
DIALOG --msgbox "Package selection is split into two stages. First you will select package categories that contain packages you may be interested in. Then you will be presented with a full list of packages with your categories already selected, allowing you to fine-tune.\n\nNOTE: The BASE category is always installed, and its packages will not appear in this menu." 18 70
# set up our install location if necessary and sync up
# so we can get package lists
prepare_pacman
# category selection hasn't been done before
if ! [ -f /tmp/.pkgcategory ]; then
CATLIST=""
for i in $($PACMAN -Sg | sed "s/^base$/ /g"); do
CATLIST="${CATLIST} ${i} - OFF"
done
else
# category selection was already run at least once
CATLIST=""
for i in $(cat /tmp/.pkgcategory | sed 's|\"||g'); do
CATLIST="$CATLIST $i ^ ON"
done
for i in $($PACMAN -Sg | sed "s/^base$/ /g"); do
grep $i /tmp/.pkgcategory > /dev/null 2>&1 || CATLIST="$CATLIST $i - OFF"
done
fi
DIALOG --checklist "Select Package Categories" 19 55 12 $CATLIST 2>/tmp/.pkgcategory || return 1
# mash up the package lists
COREPKGS=$($PACMAN -Sl core | cut -d' ' -f2)
# remove base packages from the selectable list
for i in $($PACMAN -Sg base | tail +2); do
COREPKGS=$(echo ${COREPKGS} | sed "s/\(^${i} \| ${i} \| ${i}$\)/ /g")
done
# assemble a list of pre-selected packages
for i in $(cat /tmp/.pkgcategory | sed 's|"||g'); do
CATPKGS="$CATPKGS $($PACMAN -Sg ${i} | tail +2)"
done
# put together the menu list
PKGLIST=""
for i in ${COREPKGS}; do
# if the package was preselected, check it
if [ -n "$(echo $CATPKGS | grep "\(^${i} \| ${i} \| ${i}$\)")" ]; then
PKGLIST="$PKGLIST ${i} ^ ON"
else
PKGLIST="$PKGLIST ${i} - OFF"
fi
done
DIALOG --checklist "Select Packages To Install." 19 60 12 $PKGLIST 2>/tmp/.pkglist || return 1
fi
S_SELECT=1
}
doinstall()
{
# begin install
rm -f /tmp/pacman.log
# all pacman output goes to /tmp/pacman.log, which we tail into a dialog
( \
echo "Installing Packages..." >/tmp/pacman.log ; echo >>/tmp/pacman.log ; \
touch /tmp/setup-pacman-running ; \
$PACMAN -S $(echo $* | sed 's|"||g') >>/tmp/pacman.log 2>&1 ; \
echo $? >/tmp/.pacman.retcode; \
echo >>/tmp/pacman.log; \
if [ "$(cat /tmp/.pacman.retcode)" -gt 0 ]; then
echo "Package Installation FAILED." >>/tmp/pacman.log
else
echo "Package Installation Complete." >>/tmp/pacman.log
fi
rm /tmp/setup-pacman-running
) &
sleep 2
dialog --backtitle "$TITLE" --title " Installing... Please Wait " \
--no-kill --tailboxbg "/tmp/pacman.log" 18 70 2>/tmp/.pid
while [ -f /tmp/setup-pacman-running ]; do
sleep 1
done
kill $(cat /tmp/.pid)
if [ "$(cat /tmp/.pacman.retcode)" -gt 0 ]; then
result="Installation Failed (see errors below)"
retcode=1
else
result="Installation Complete"
retcode=0
fi
# disabled for now
#dialog --backtitle "$TITLE" --title " $result " \
# --exit-label "Continue" --textbox "/tmp/pacman.log" 18 70
# fix the stair-stepping that --tailboxbg leaves us with
stty onlcr
rm -f /tmp/.pacman.retcode
return $retcode
}
installpkg() {
if ! [ "$S_SRC" = "1" ]; then
DIALOG --msgbox "Error:\nYou must select Source first." 0 0
return 1
fi
if [ "$MODE" = "cd" ]; then
if [ ! -f /tmp/.pkglist -o "$S_SELECT" != "1" ]; then
DIALOG --msgbox "You must select packages first." 0 0
return 1
fi
fi
if [ "$S_MKFS" != "1" -a "$S_MKFSAUTO" != "1" ]; then
getdest
fi
DIALOG --msgbox "Package installation will begin now. You can watch the output in the progress window. Please be patient." 0 0
if [ "$MODE" = "cd" ]; then
LIST=
# fix pacman list!
sed -i -e 's/-i686//g' -e 's/-x86_64//g' /tmp/.pkglist
for pkg in $(cat /tmp/.pkglist); do
pkgname=${pkg%-*-*}
LIST="$LIST $pkgname"
done
fi
if [ "$MODE" = "ftp" ]; then
LIST="base" # always install base
for pkg in $(cat /tmp/.pkglist); do
LIST="$LIST $pkg"
done
fi
# for a CD install, we don't need to download packages first
if [ "$MODE" = "ftp" ]; then
DIALOG --infobox "Downloading packages. See $LOG for output." 6 55
$PACMAN -Sw $(echo $LIST | sed 's|"||g') >$LOG 2>&1
if [ $? -gt 0 ]; then
DIALOG --msgbox "One or more packages failed to download. You can try again by re-selecting Install Packages from the main menu." 12 65
return 1
fi
fi
# mount proc/sysfs first, so initcpio can use auto-detection if it wants
! [ -d $DESTDIR/proc ] && mkdir $DESTDIR/proc
! [ -d $DESTDIR/sys ] && mkdir $DESTDIR/sys
! [ -d $DESTDIR/dev ] && mkdir $DESTDIR/dev
mount -t proc none $DESTDIR/proc
mount -t sysfs none $DESTDIR/sys
mount -o bind /dev $DESTDIR/dev
doinstall $LIST
if [ $? -gt 0 ]; then
DIALOG --msgbox "One or more packages failed to install. You can try again by re-selecting Install Packages from the main menu." 12 65
return 1
fi
dialog --backtitle "$TITLE" --title " $result " \
--exit-label "Continue" --textbox "/tmp/pacman.log" 18 70
if [ $? -gt 0 ]; then
return 1
fi
S_INSTALL=1
# add archboot addons if activated
if [ -d /tmp/packages ]; then
DO_ADDON=""
DIALOG --yesno "Would you like to install your addons packages to installed system?" 0 0 && DO_ADDON="yes"
if [ "$DO_ADDON" = "yes" ] ; then
DIALOG --infobox "Installing the addons packages..." 0 0
$PACMAN -U /tmp/packages/*
fi
fi
umount $DESTDIR/proc $DESTDIR/sys $DESTDIR/dev
sync
# Modify fstab
if [ "$S_MKFS" = "1" -o "$S_MKFSAUTO" = "1" ]; then
if [ -f /tmp/.fstab ]; then
# clean fstab first from /dev entries
sed -i -e '/^\/dev/d' $DESTDIR/etc/fstab
# clean /media from old floppy,cd,dvd entries
rm -r $DESTDIR/media/cd*
rm -r $DESTDIR/media/dvd*
rm -r $DESTDIR/media/fl*
# add floppy,cd and dvd entries first
for i in $(ls -d /dev/cdro* | grep -v "0"); do
k=$(echo $i | sed -e 's|/dev/||g')
echo "$i /media/$k auto ro,user,noauto,unhide 0 0" >>$DESTDIR/etc/fstab
# create dirs in /media
mkdir -p $DESTDIR/media/$k
done
for i in $(ls -d /dev/dvd* | grep -v "0"); do
k=$(echo $i | sed -e 's|/dev/||g')
echo "$i /media/$k auto ro,user,noauto,unhide 0 0" >>$DESTDIR/etc/fstab
# create dirs in /media
mkdir -p $DESTDIR/media/$k
done
for i in $(ls -d /dev/fd[0-9] | grep -v "[0-9][0-9][0-9]"); do
k=$(echo $i | sed -e 's|/dev/||g')
echo "$i /media/$k auto user,noauto 0 0" >>$DESTDIR/etc/fstab
# create dirs in /media
mkdir -p $DESTDIR/media/$k
done
sort /tmp/.fstab >>$DESTDIR/etc/fstab
fi
fi
}
select_source()
{
if ! [ $(which $DLPROG) ]; then
DIALOG --menu "Please select an installation source" 10 35 3 \
"1" "CD-ROM or OTHER SOURCE" 2>$ANSWER || return 1
else
DIALOG --menu "Please select an installation source" 10 35 3 \
"1" "CD-ROM or OTHER SOURCE" \
"2" "FTP/HTTP" 2>$ANSWER || return 1
fi
case $(cat $ANSWER) in
"1")
MODE="cd"
;;
"2")
MODE="ftp"
;;
esac
if [ "$MODE" = "cd" ]; then
TITLE="Arch Linux CDROM or OTHER SOURCE Installation"
getsource
else
TITLE="Arch Linux FTP/HTTP Installation"
DIALOG --msgbox "If you wish to load your ethernet modules manually, please do so now (consoles 1 thru 6 are active)." 12 65
while $(/bin/true); do
DIALOG --menu "FTP Installation" 10 35 3 \
"0" "Setup Network" \
"1" "Choose Mirror" \
"2" "Return to Main Menu" 2>$ANSWER
case "$(cat $ANSWER)" in
"0")
donetwork ;;
"1")
getsource ;;
*)
break ;;
esac
done
fi
}
|