1 %define name vserver-reference
3 %define release 1.planetlab%{?date:.%{date}}
6 Packager: PlanetLab Central <support@planet-lab.org>
7 Distribution: PlanetLab 3.0
8 URL: http://www.planet-lab.org
10 Summary: VServer reference image
14 Source0: %{name}-%{version}.tar.bz2
16 Group: Applications/System
17 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
18 BuildArchitectures: noarch
19 Requires: util-vserver
21 BuildRequires: e2fsprogs, yum
24 This package creates the virtual server (VServer) reference image used
25 as the installation base for new PlanetLab slivers.
27 %define vrootdir /vservers
28 %define vrefdir %{vrootdir}/%{name}
29 %define installroot $RPM_BUILD_ROOT%{vrefdir}
34 # chattr, mknod, mount, yum all require root privileges. Yech.
35 if [ $UID -ne 0 ] ; then
36 echo You must be root to build the %{name} package.
44 if grep -q %{installroot}/proc /proc/mounts ; then
45 umount %{installroot}/proc
47 if grep -q %{installroot}/dev/pts /proc/mounts ; then
48 umount %{installroot}/dev/pts
50 chattr -R -i $RPM_BUILD_ROOT
51 rm -rf $RPM_BUILD_ROOT
54 mkdir -p $RPM_BUILD_ROOT%{vrootdir}
55 chmod 000 $RPM_BUILD_ROOT%{vrootdir}
56 chattr +t $RPM_BUILD_ROOT%{vrootdir}
58 # Make /vservers/vserver-reference
59 mkdir -p %{installroot}
60 chattr -t %{installroot}
61 chmod 755 %{installroot}
65 if grep -q %{installroot}/dev/pts /proc/mounts ; then
66 umount %{installroot}/dev/pts
68 rm -rf %{installroot}/dev
69 mkdir -p %{installroot}/dev
70 mknod -m 666 %{installroot}/dev/null c 1 3
71 mknod -m 666 %{installroot}/dev/zero c 1 5
72 mknod -m 666 %{installroot}/dev/full c 1 7
73 mknod -m 644 %{installroot}/dev/random c 1 8
74 mknod -m 644 %{installroot}/dev/urandom c 1 9
75 mknod -m 666 %{installroot}/dev/tty c 5 0
76 mknod -m 666 %{installroot}/dev/ptmx c 5 2
77 touch %{installroot}/dev/hdv1
80 # Initialize /dev in reference image
83 # Mount /dev/pts in reference image
84 mkdir -p %{installroot}/dev/pts
85 mount -t devpts none %{installroot}/dev/pts
87 # Mount /proc in reference image
88 mkdir -p %{installroot}/proc
89 mount -t proc none %{installroot}/proc
91 # Create a dummy /etc/fstab in reference image
92 mkdir -p %{installroot}/etc
93 cat > %{installroot}/etc/fstab <<EOF
94 # This fake fstab exists only to please df and linuxconf.
95 /dev/hdv1 / ext2 defaults 1 1
98 # Prevent all locales from being installed in reference image
99 mkdir -p %{installroot}/etc/rpm
100 cat > %{installroot}/etc/rpm/macros <<EOF
101 %_install_langs en_US:en
104 # Initialize RPM database in reference image
105 mkdir -p %{installroot}/var/lib/rpm
106 rpm --root %{installroot} --initdb
108 # XXX Get yum.conf from PlanetLabConf
110 # Install RPMs in reference image
112 %{?sslcertdir:--sslcertdir=%{sslcertdir}} \
113 --installroot=%{installroot} \
114 -y groupinstall VServer
116 # Clean up /dev in reference image
119 # Configure authentication in reference image
120 chroot %{installroot} authconfig --nostart --kickstart --enablemd5 --enableshadow || :
122 # Disable all services in reference image
123 chroot %{installroot} /bin/sh -c "chkconfig --list | awk '{ print \$1 }' | xargs -i chkconfig {} off"
126 if grep -q %{installroot}/proc /proc/mounts ; then
127 umount %{installroot}/proc
129 if grep -q %{installroot}/dev/pts /proc/mounts ; then
130 umount %{installroot}/dev/pts
135 if grep -q %{installroot}/proc /proc/mounts ; then
136 umount %{installroot}/proc
138 if grep -q %{installroot}/dev/pts /proc/mounts ; then
139 umount %{installroot}/dev/pts
141 chattr -R -i $RPM_BUILD_ROOT
142 rm -rf $RPM_BUILD_ROOT
145 # Copy configuration files from host to reference image
146 for file in /etc/hosts /etc/resolv.conf /etc/yum.conf ; do
147 if [ -f $file ] ; then
148 echo $file | cpio -p -d -u %{vrefdir}
155 %defattr(-,root,root)
159 * Tue Sep 14 2004 Mark Huang <mlhuang@cs.princeton.edu> 3.0-1.planetlab