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
23 %define debug_package %{nil}
26 This package creates the virtual server (VServer) reference image used
27 as the installation base for new PlanetLab slivers.
29 %define vrootdir /vservers
30 %define vrefdir %{vrootdir}/%{name}
31 %define installroot $RPM_BUILD_ROOT%{vrefdir}
36 # chattr, mknod, mount, yum all require root privileges. Yech.
37 if [ $UID -ne 0 ] ; then
38 echo You must be root to build the %{name} package.
46 export PATH="$PATH:/sbin:/usr/sbin"
49 if grep -q %{installroot}/proc /proc/mounts ; then
50 umount %{installroot}/proc
52 if grep -q %{installroot}/dev/pts /proc/mounts ; then
53 umount %{installroot}/dev/pts
55 chattr -R -i $RPM_BUILD_ROOT
56 rm -rf $RPM_BUILD_ROOT
59 mkdir -p $RPM_BUILD_ROOT%{vrootdir}
60 chmod 000 $RPM_BUILD_ROOT%{vrootdir}
61 chattr +t $RPM_BUILD_ROOT%{vrootdir}
63 # Make /vservers/vserver-reference
64 mkdir -p %{installroot}
65 chattr -t %{installroot}
66 chmod 755 %{installroot}
70 if grep -q %{installroot}/dev/pts /proc/mounts ; then
71 umount %{installroot}/dev/pts
73 rm -rf %{installroot}/dev
74 mkdir -p %{installroot}/dev
75 mknod -m 666 %{installroot}/dev/null c 1 3
76 mknod -m 666 %{installroot}/dev/zero c 1 5
77 mknod -m 666 %{installroot}/dev/full c 1 7
78 mknod -m 644 %{installroot}/dev/random c 1 8
79 mknod -m 644 %{installroot}/dev/urandom c 1 9
80 mknod -m 666 %{installroot}/dev/tty c 5 0
81 mknod -m 666 %{installroot}/dev/ptmx c 5 2
82 touch %{installroot}/dev/hdv1
85 # Initialize /dev in reference image
88 # Mount /dev/pts in reference image
89 mkdir -p %{installroot}/dev/pts
90 mount -t devpts none %{installroot}/dev/pts
92 # Mount /proc in reference image
93 mkdir -p %{installroot}/proc
94 mount -t proc none %{installroot}/proc
96 # Create a dummy /etc/fstab in reference image
97 mkdir -p %{installroot}/etc
98 cat > %{installroot}/etc/fstab <<EOF
99 # This fake fstab exists only to please df and linuxconf.
100 /dev/hdv1 / ext2 defaults 1 1
103 # Prevent all locales from being installed in reference image
104 mkdir -p %{installroot}/etc/rpm
105 cat > %{installroot}/etc/rpm/macros <<EOF
106 %_install_langs en_US:en
109 # Initialize RPM database in reference image
110 mkdir -p %{installroot}/var/lib/rpm
111 rpm --root %{installroot} --initdb
113 # XXX Get yum.conf from PlanetLabConf
115 # Install RPMs in reference image
117 %{?sslcertdir:--sslcertdir=%{sslcertdir}} \
118 --installroot=%{installroot} \
119 -y groupinstall VServer
121 # Clean up /dev in reference image
124 # Configure authentication in reference image
125 chroot %{installroot} authconfig --nostart --kickstart --enablemd5 --enableshadow || :
127 # Disable all services in reference image
128 chroot %{installroot} /bin/sh -c "chkconfig --list | awk '{ print \$1 }' | xargs -i chkconfig {} off"
131 if grep -q %{installroot}/proc /proc/mounts ; then
132 umount %{installroot}/proc
134 if grep -q %{installroot}/dev/pts /proc/mounts ; then
135 umount %{installroot}/dev/pts
140 export PATH="$PATH:/sbin:/usr/sbin"
143 if grep -q %{installroot}/proc /proc/mounts ; then
144 umount %{installroot}/proc
146 if grep -q %{installroot}/dev/pts /proc/mounts ; then
147 umount %{installroot}/dev/pts
149 chattr -R -i $RPM_BUILD_ROOT
150 rm -rf $RPM_BUILD_ROOT
153 # Copy configuration files from host to reference image
154 for file in /etc/hosts /etc/resolv.conf /etc/yum.conf ; do
155 if [ -f $file ] ; then
156 echo $file | cpio -p -d -u %{vrefdir}
163 %defattr(-,root,root)
167 * Tue Sep 14 2004 Mark Huang <mlhuang@cs.princeton.edu> 3.0-1.planetlab