source: quickinst/quickinst @ 394

Revision 394, 5.1 KB checked in by henning, 3 months ago (diff)

quickinst cosmetics: comments for package profiles

  • Property svn:executable set to *
Line 
1#!/bin/bash
2#
3# Arch Linux bootstrap script. Released under the terms of the GPL.
4# henning mueller <henning@orgizm.net>
5#
6# TODO
7#  * fstab generation gave "ome" instead of "/home" as a mountpoint
8#  * on_arch mode (without chroot) deleted due to errors on 2009.06 cd
9#    reintegrate?
10#
11
12usage() {
13cat >&2 <<EOF
14usage: $(basename $0) [options] <ftp|cd> <target> [source]
15
16This script is for installing Arch Linux after manual partitioning and
17network configuration.
18
19For the FTP installation, the original throttled Arch mirror is selected by
20default, so run with another mirror as [source], please. The full URL is
21expected in this case. Example:
22ftp://mirrors.kernel.org/archlinux/core/os/i686
23
24If you want to bootstrap another architecture than the script is currently
25running on, you have to specify a custom source.
26
27Options:
28    -i <file>  Include packages from <file> in the installation. <file> should
29               contain one package name per line.
30    -x         Xen mode. Activate serial console and deactivate virtual
31               terminals.
32
33EOF
34exit 1
35}
36
37wget="wget -q -t0"
38arch=$(uname -m)
39
40while [ $# -gt 1 ]; do
41        case $1 in
42                -i)
43                        [ -f /usr/share/quickinst/$2 ] &&
44                                path=/usr/share/quickinst/$2 ||
45                                path=$2
46
47                        [ ! -f $path ] &&
48                                echo "Package file '$path' does not exist." &&
49                                exit 1
50
51                        addpkgs=$(cat $path | egrep -v ^# | tr "\n" " ")
52                        shift; shift
53                        ;;
54                -v) wget="wget -t0"; shift;;
55                -x) xen=true; shift;;
56                -h) usage;;
57                *) break
58        esac
59done
60
61mode=$1
62target=$2
63source=$3
64
65[ "$mode" == "" ] || [ "$target" == "" ] && usage
66[ "$mode" == "ftp" ] || [ "$mode" == "cd" ] || usage
67
68[ "$UID" != "0" ] &&
69        echo "run as root, please." >&2 &&
70        exit 1
71
72[ $(echo $target | egrep ^/) ] ||
73        target=$(pwd)/$target
74
75[ -d "$target" ] ||
76        mkdir -p $target
77
78[ "$source" == "" ] &&
79        source=ftp://mirrors.kernel.org/archlinux/core/os/$arch ||
80        arch=$(basename $source)
81
82cache=$target/var/cache/pacman/pkg
83mkdir -p $cache
84
85[ "$mode" == "ftp" ] && {
86        install() {
87                cd $cache
88                echo "  · $1"
89
90                package=$(ls $1*.pkg.tar.*z 2>/dev/null | tail -1)
91
92                [ ! -f "$package" ] &&
93                        $wget $source/$1*.pkg.tar.*z
94
95                [ $? -gt 0 ] &&
96                        echo "wget returned error $?." >&2 &&
97                        exit 1
98
99                package=$(ls $1*.pkg.tar.*z | tail -1)
100                tar xf $package -C $target ||
101                        exit 1
102        }
103}
104[ "$mode" == "cd" ] && {
105        install() {
106                exit 1
107        }
108}
109
110echo · downloading and installing bash.
111        for package in glibc ncurses readline bash; do
112                install $package
113        done
114
115echo · downloading and installing pacman.
116        for package in libfetch libarchive acl attr zlib bzip2 expat; do
117                install $package
118        done
119        for package in openssl xz-utils pacman-?. pacman-mirrorlist; do
120                install $package
121        done
122
123echo · installing base.
124        cd $target
125        cp /etc/resolv.conf etc/resolv.conf
126
127        mkdir sys proc dev tmp 2> /dev/null
128
129        cp etc/pacman.d/mirrorlist etc/pacman.d/mirrorlist.original
130        tmp=$(echo $source | sed -e "s:core:\$repo:")
131        echo "Server = $tmp" > etc/pacman.d/mirrorlist
132
133        mount -o bind /dev dev
134        mount -t proc proc proc
135        mount -t sysfs sys sys
136
137        chroot $target /bin/bash <<EOF
138                pacman --noconfirm $config \
139                        -Sfy base $addpkgs || exit 1
140EOF
141
142[ $xen ] && {
143        echo · preparing for use in xen.
144
145                vc=xvc0
146
147                [ -f /etc/debian_version ] && vc=hvc0
148
149                cat <<EOF > etc/inittab
150rc::sysinit:/etc/rc.sysinit
151rs:S1:wait:/etc/rc.single
152rm:2345:wait:/etc/rc.multi
153rh:06:wait:/etc/rc.shutdown
154su:S:wait:/sbin/sulogin -p
155c:2345:respawn:/sbin/agetty -8 38400 $vc linux
156EOF
157
158                echo $vc > etc/securetty
159}
160
161grep $target /proc/mounts | while read line; do
162        device=$(echo $line | cut -d ' ' -f 1)
163        uuid=$(/lib/udev/vol_id --uuid $device)
164
165        [ "$(echo $line | sed -e "s:$target::" | cut -d ' ' -f 2)" == "" ] &&
166                repl='/' || repl=''
167
168        [ "$uuid" != "" ] &&
169                echo $line | sed -e "s:$target:$repl:" -e "s:$device:UUID=$uuid:" \
170                        >> etc/fstab
171done
172
173echo · cleaning up.
174        umount sys proc dev
175        mv etc/resolv.conf.pacorig etc/resolv.conf
176        rm -f etc/*.pac* .FILELIST .INSTALL .PKGINFO
177        cp usr/lib/grub/* boot/grub
178
179echo -e "\nPackage installation complete.\n"
180
181[ ! $xen ] && cat <<EOF
182Probably you have to install a boot loader.
183Therefor chroot into your system (you have to be root):
184# mount -o bind /dev $target/dev
185# mount -t proc none $target/proc
186# mount -t sysfs none $target/sys
187# chroot $target /bin/bash
188
189# grub
190grub> root (hd0,0)
191grub> setup (hd0)
192
193A default initramfs setup was created during the package installation process.
194If you have special demands, generate a new one after editing
195/etc/mkinitcpio.conf and /etc/mkinitcpio.d/kernel26-fallback.conf:
196mkinitcpio -p kernel26 -k <kernel-version> (example: 2.6.33-ARCH)
197
198Don't forget to set a root password.
199
200For completing the installation, edit /etc/rc.conf and check /etc/fstab before
201unmounting the devices and rebooting.
202
203EOF
204
205[ $xen ] && cat <<EOF
206Don't forget to set a root password:
207# chroot $target /bin/bash
208# passwd
209
210For completing the installation, edit /etc/rc.conf and /etc/fstab before
211creating the xen guest.
212
213Your xen config could look like this:
214kernel = '/boot/vmlinuz26-xen'
215memory = 256
216name = 'guest'
217disk = [ 'phy:/dev/mapper/lvm-guest,sda1,w' ]
218vif = [ 'bridge=br0' ]
219ramdisk = '/boot/kernel26-xen.img'
220root = '/dev/sda1 ro'
221vcpus = 1
222extra = '3 console=xvc0'
223restart = 'onreboot'
224
225EOF
Note: See TracBrowser for help on using the repository browser.