figures where modprobe.conf.dist gets installed
[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 # pldistro expected as $1 - defaults to planetlab
32 pldistro=planetlab
33 [ -n "$@" ] && pldistro=$1
34
35 # Packages to install : see <pldistro>-<fcdistro>-bootcd.lst
36
37 # Unnecessary junk
38 junk=(
39 lib/obsolete
40 lib/tls
41 usr/share/cracklib
42 usr/share/emacs
43 usr/share/gnupg
44 usr/share/i18n
45 usr/share/locale
46 usr/share/terminfo
47 usr/share/zoneinfo
48 usr/sbin/build-locale-archive
49 usr/sbin/dbconverter-2
50 usr/sbin/sasl*
51 usr/sbin/tcpslice
52 usr/lib/perl*
53 usr/lib/locale
54 usr/lib/sasl*
55 usr/lib/gconv
56 usr/lib/tls
57 )
58
59 precious=(
60 usr/share/i18n/locales/en_US
61 usr/share/i18n/charmaps/UTF-8.gz
62 usr/share/locale/en
63 usr/share/terminfo/l/linux
64 usr/share/terminfo/v/vt100
65 usr/share/terminfo/x/xterm
66 usr/share/zoneinfo/UTC
67 usr/lib/locale/en_US.utf8
68 )
69
70 # Do not tolerate errors
71 set -e
72
73 # Root of the initramfs reference image
74 bootcd=$PWD/build/bootcd
75 install -d -m 755 $bootcd
76
77 # Write version number
78 rpmquery --specfile bootcd.spec --queryformat '%{VERSION}\n' | head -1 >build/version.txt
79
80 # Install base system
81 lst=${pldistro}-${pl_DISTRO_NAME}-bootcd.lst
82 options=$(pl_getPackagesOptions $lst)
83
84 pl_setup_chroot $bootcd $options -k
85
86 pushd $bootcd
87
88 echo "* Removing unnecessary junk"
89
90 # Save precious files
91 tar --ignore-failed-read -cpf precious.tar ${precious[*]}
92
93 # Remove unnecessary junk
94 rm -rf ${junk[*]}
95
96 # Restore precious files
97 tar -xpf precious.tar
98 rm -f precious.tar
99
100 popd
101
102 # Install ipnmac (for SuperMicro machines with IPMI)
103 echo "* Installing IPMI utilities"
104 install -D -m 755 ipnmac/ipnmac.x86 $bootcd/usr/sbin/ipnmac
105
106 # the place where modprobe.conf gets installed has changed
107 modprobedist=$(rpm -ql module-init-tools | grep modprobe.conf.dist)
108 sed -i -e "s,@MODPROBECONFDIST@,$modprobedist,g" conf_files/modprobe.conf
109
110 # Install configuration files
111 echo "* Installing configuration files"
112 for file in fstab mtab modprobe.conf inittab hosts sysctl.conf ; do
113     install -D -m 644 conf_files/$file $bootcd/etc/$file
114 done
115
116 # Install initscripts
117 echo "* Installing initscripts"
118 for file in pl_sysinit pl_hwinit pl_netinit pl_validateconf pl_boot ; do
119     install -D -m 755 conf_files/$file $bootcd/etc/init.d/$file
120 done
121
122 # Install fallback node configuration file
123 echo "* Installing fallback node configuration file"
124 install -D -m 644 conf_files/default-net.cnf $bootcd/usr/boot/default-net.cnf
125
126 # Build pcitable for hardware detection
127 echo "* Building pcitable for hardware detection"
128 pci_map_file=$(find $bootcd/lib/modules/ -name modules.pcimap | head -1)
129 module_dep_file=$(find $bootcd/lib/modules/ -name modules.dep | head -1)
130 pci_table=$bootcd/usr/share/hwdata/pcitable
131 $srcdir/BootManager/source/merge_hw_tables.py \
132     $module_dep_file $pci_map_file $pci_table $bootcd/etc/pl_pcitable
133
134 # Copy /etc/passwd out
135 install -D -m 644 $bootcd/etc/passwd build/passwd
136
137 # Root of the isofs
138 isofs=$PWD/build/isofs
139 install -d -m 755 $isofs
140
141 # Copy the kernel out
142 for kernel in $bootcd/boot/vmlinuz-* ; do
143     if [ -f $kernel ] ; then
144         install -D -m 644 $kernel $isofs/kernel
145     fi
146 done
147
148 # Don't need /boot anymore
149 rm -rf $bootcd/boot
150
151 # initramfs requires that /init be present
152 ln -sf /sbin/init $bootcd/init
153
154 # Pack the rest into a compressed archive
155 echo "* Compressing reference image"
156 (cd $bootcd && find . | cpio --quiet -c -o) | gzip -9 >$isofs/bootcd.img
157
158 # Build syslinux
159 echo "* Building syslinux"
160 CFLAGS="-Werror -Wno-unused -finline-limit=2000" make -C syslinux
161
162 # Install isolinux
163 echo "* Installing isolinux"
164 install -D -m 644 syslinux/isolinux.bin $isofs/isolinux.bin
165
166 exit 0