(*) groups distro-dependent files in build/config.<distro>
[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$
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, junk and precious : see build/<pldistro>/bootcd.pkgs
36
37 # Do not tolerate errors
38 set -e
39
40 # Root of the initramfs reference image
41 bootcd=$PWD/build/bootcd
42 install -d -m 755 $bootcd
43
44 # Write version number
45 rpmquery --specfile bootcd.spec --queryformat '%{VERSION}\n' | head -1 >build/version.txt
46
47 # Install base system
48 pkgsfile=$(pl_locateDistroFile ../build/ $pldistro bootcd.pkgs) 
49 pl_setup_chroot $bootcd -k -f $pkgsfile 
50
51 # Install ipnmac (for SuperMicro machines with IPMI)
52 echo "* Installing IPMI utilities"
53 install -D -m 755 ipnmac/ipnmac.x86 $bootcd/usr/sbin/ipnmac
54
55 # Install configuration files
56 echo "* Installing configuration files"
57 for file in fstab mtab modprobe.conf inittab hosts sysctl.conf ; do
58     install -D -m 644 conf_files/$file $bootcd/etc/$file
59 done
60
61 # Install initscripts
62 echo "* Installing initscripts"
63 for file in pl_sysinit pl_hwinit pl_netinit pl_validateconf pl_boot ; do
64     install -D -m 755 conf_files/$file $bootcd/etc/init.d/$file
65 done
66
67 # Install fallback node configuration file
68 echo "* Installing fallback node configuration file"
69 install -D -m 644 conf_files/default-net.cnf $bootcd/usr/boot/default-net.cnf
70
71 # Copy /etc/passwd out
72 install -D -m 644 $bootcd/etc/passwd build/passwd
73
74 # Root of the isofs
75 isofs=$PWD/build/isofs
76 install -d -m 755 $isofs
77
78 # Copy the kernel out
79 for kernel in $bootcd/boot/vmlinuz-* ; do
80     if [ -f $kernel ] ; then
81         install -D -m 644 $kernel $isofs/kernel
82     fi
83 done
84
85 # Don't need /boot anymore
86 rm -rf $bootcd/boot
87
88 # initramfs requires that /init be present
89 ln -sf /sbin/init $bootcd/init
90
91 # Pack the rest into a compressed archive
92 echo "* Compressing reference image"
93 (cd $bootcd && find . | cpio --quiet -c -o) | gzip -9 >$isofs/bootcd.img
94
95 # Build syslinux
96 # echo "* Building syslinux"
97 # CFLAGS="-Werror -Wno-unused -finline-limit=2000" make -C syslinux
98
99 # Install isolinux
100 #echo "* Installing isolinux"
101 #install -D -m 644 syslinux/isolinux.bin $isofs/isolinux.bin
102
103 exit 0