Add in filesystem package explicitly.
[bootcd.git] / prep.sh
1 #!/bin/bash
2 #
3 # Builds the BootCD reference image, the first of two
4 # initramfs cpio archives that are concatenated together by
5 # isolinux/syslinux to form a custom BootCD.
6 #
7 # Aaron Klingaman <alk@absarokasoft.com>
8 # Mark Huang <mlhuang@cs.princeton.edu>
9 # Copyright (C) 2004-2006 The Trustees of Princeton University
10 #
11 # $Id: prep.sh,v 1.13.6.1 2007/08/30 16:38:59 mef Exp $
12 #
13
14 PATH=/sbin:/bin:/usr/sbin:/usr/bin
15
16 # In both a normal CVS environment and a PlanetLab RPM
17 # build environment, all of our dependencies are checked out into
18 # directories at the same level as us.
19 if [ -d ../build ] ; then
20     PATH=$PATH:../build
21     srcdir=..
22 else
23     echo "Error: Could not find sources in either . or .."
24     exit 1
25 fi
26
27 export PATH
28
29 . build.common
30
31 # Packages to install
32 packagelist=(
33 udev
34 dhclient
35 bash
36 coreutils
37 iputils
38 kernel
39 bzip2
40 diffutils
41 logrotate
42 passwd
43 rsh
44 rsync
45 sudo
46 tcpdump
47 telnet
48 traceroute
49 time
50 wget
51 yum
52 curl
53 gzip
54 python
55 tar
56 pciutils
57 kbd
58 authconfig
59 hdparm
60 lvm
61 lvm2
62 kexec-tools
63 gnupg
64 nano
65 parted
66 pyparted
67 openssh-server
68 openssh-clients
69 ncftp
70 dosfstools
71 dos2unix
72 bind-utils
73 sharutils
74 vconfig
75 filesystem
76 )
77
78 # Unnecessary junk
79 junk=(
80 lib/obsolete
81 lib/tls
82 usr/share/cracklib
83 usr/share/emacs
84 usr/share/gnupg
85 usr/share/i18n
86 usr/share/locale
87 usr/share/terminfo
88 usr/share/zoneinfo
89 usr/sbin/build-locale-archive
90 usr/sbin/dbconverter-2
91 usr/sbin/sasl*
92 usr/sbin/tcpslice
93 usr/lib/perl*
94 usr/lib/locale
95 usr/lib/sasl*
96 usr/lib/gconv
97 usr/lib/tls
98 )
99
100 precious=(
101 usr/share/i18n/locales/en_US
102 usr/share/i18n/charmaps/UTF-8.gz
103 usr/share/locale/en
104 usr/share/terminfo/l/linux
105 usr/share/terminfo/v/vt100
106 usr/share/terminfo/x/xterm
107 usr/share/zoneinfo/UTC
108 usr/lib/locale/en_US.utf8
109 )
110
111 # Do not tolerate errors
112 set -e
113
114 # Root of the initramfs reference image
115 bootcd=$PWD/build/bootcd
116 install -d -m 755 $bootcd
117
118 # Write version number
119 rpmquery --specfile bootcd.spec --queryformat '%{VERSION}\n' | head -1 >build/version.txt
120
121 # Install base system
122 for package in "${packagelist[@]}" ; do
123     packages="$packages -p $package"
124 done
125
126 pl_setup_chroot $bootcd $packages
127
128 pushd $bootcd
129
130 echo "* Removing unnecessary junk"
131
132 # Save precious files
133 tar --ignore-failed-read -cpf precious.tar ${precious[*]}
134
135 # Remove unnecessary junk
136 rm -rf ${junk[*]}
137
138 # Restore precious files
139 tar -xpf precious.tar
140 rm -f precious.tar
141
142 popd
143
144 # Install ipnmac (for SuperMicro machines with IPMI)
145 echo "* Installing IPMI utilities"
146 install -D -m 755 ipnmac/ipnmac.x86 $bootcd/usr/sbin/ipnmac
147
148 # Install configuration files
149 echo "* Installing configuration files"
150 for file in fstab mtab modprobe.conf inittab hosts sysctl.conf ; do
151     install -D -m 644 conf_files/$file $bootcd/etc/$file
152 done
153
154 # Install initscripts
155 echo "* Installing initscripts"
156 for file in pl_sysinit pl_hwinit pl_netinit pl_validateconf pl_boot ; do
157     install -D -m 755 conf_files/$file $bootcd/etc/init.d/$file
158 done
159
160 # Install fallback node configuration file
161 echo "* Installing fallback node configuration file"
162 install -D -m 644 conf_files/default-net.cnf $bootcd/usr/boot/default-net.cnf
163
164 # Build pcitable for hardware detection
165 echo "* Building pcitable for hardware detection"
166 pci_map_file=$(find $bootcd/lib/modules/ -name modules.pcimap | head -1)
167 module_dep_file=$(find $bootcd/lib/modules/ -name modules.dep | head -1)
168 pci_table=$bootcd/usr/share/hwdata/pcitable
169 $srcdir/BootManager/source/merge_hw_tables.py \
170     $module_dep_file $pci_map_file $pci_table $bootcd/etc/pl_pcitable
171
172 # Copy /etc/passwd out
173 install -D -m 644 $bootcd/etc/passwd build/passwd
174
175 # Root of the isofs
176 isofs=$PWD/build/isofs
177 install -d -m 755 $isofs
178
179 # Copy the kernel out
180 for kernel in $bootcd/boot/vmlinuz-* ; do
181     if [ -f $kernel ] ; then
182         install -D -m 644 $kernel $isofs/kernel
183     fi
184 done
185
186 # Don't need /boot anymore
187 rm -rf $bootcd/boot
188
189 # initramfs requires that /init be present
190 ln -sf /sbin/init $bootcd/init
191
192 # Pack the rest into a compressed archive
193 echo "* Compressing reference image"
194 (cd $bootcd && find . | cpio --quiet -c -o) | gzip -9 >$isofs/bootcd.img
195
196 # Build syslinux
197 echo "* Building syslinux"
198 CFLAGS="-Werror -Wno-unused -finline-limit=2000" make -C syslinux
199
200 # Install isolinux
201 echo "* Installing isolinux"
202 install -D -m 644 syslinux/isolinux.bin $isofs/isolinux.bin
203
204 exit 0