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