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 export PATH="$PATH:/sbin:/usr/sbin"
47 if grep -q %{installroot}/proc /proc/mounts ; then
48 umount %{installroot}/proc
50 if grep -q %{installroot}/dev/pts /proc/mounts ; then
51 umount %{installroot}/dev/pts
53 chattr -R -i $RPM_BUILD_ROOT
54 rm -rf $RPM_BUILD_ROOT
57 mkdir -p $RPM_BUILD_ROOT%{vrootdir}
58 chmod 000 $RPM_BUILD_ROOT%{vrootdir}
59 chattr +t $RPM_BUILD_ROOT%{vrootdir}
61 # Make /vservers/vserver-reference
62 mkdir -p %{installroot}
63 chattr -t %{installroot}
64 chmod 755 %{installroot}
68 if grep -q %{installroot}/dev/pts /proc/mounts ; then
69 umount %{installroot}/dev/pts
71 rm -rf %{installroot}/dev
72 mkdir -p %{installroot}/dev
73 mknod -m 666 %{installroot}/dev/null c 1 3
74 mknod -m 666 %{installroot}/dev/zero c 1 5
75 mknod -m 666 %{installroot}/dev/full c 1 7
76 mknod -m 644 %{installroot}/dev/random c 1 8
77 mknod -m 644 %{installroot}/dev/urandom c 1 9
78 mknod -m 666 %{installroot}/dev/tty c 5 0
79 mknod -m 666 %{installroot}/dev/ptmx c 5 2
80 touch %{installroot}/dev/hdv1
83 # Initialize /dev in reference image
86 # Mount /dev/pts in reference image
87 mkdir -p %{installroot}/dev/pts
88 mount -t devpts none %{installroot}/dev/pts
90 # Mount /proc in reference image
91 mkdir -p %{installroot}/proc
92 mount -t proc none %{installroot}/proc
94 # Create a dummy /etc/fstab in reference image
95 mkdir -p %{installroot}/etc
96 cat > %{installroot}/etc/fstab <<EOF
97 # This fake fstab exists only to please df and linuxconf.
98 /dev/hdv1 / ext2 defaults 1 1
101 # Prevent all locales from being installed in reference image
102 mkdir -p %{installroot}/etc/rpm
103 cat > %{installroot}/etc/rpm/macros <<EOF
104 %_install_langs en_US:en
107 # Initialize RPM database in reference image
108 mkdir -p %{installroot}/var/lib/rpm
109 rpm --root %{installroot} --initdb
111 # XXX Get yum.conf from PlanetLabConf
113 # Install RPMs in reference image
115 %{?sslcertdir:--sslcertdir=%{sslcertdir}} \
116 --installroot=%{installroot} \
117 -y groupinstall VServer
119 # Clean up /dev in reference image
122 # Configure authentication in reference image
123 chroot %{installroot} authconfig --nostart --kickstart --enablemd5 --enableshadow || :
125 # Disable all services in reference image
126 chroot %{installroot} /bin/sh -c "chkconfig --list | awk '{ print \$1 }' | xargs -i chkconfig {} off"
129 if grep -q %{installroot}/proc /proc/mounts ; then
130 umount %{installroot}/proc
132 if grep -q %{installroot}/dev/pts /proc/mounts ; then
133 umount %{installroot}/dev/pts
138 export PATH="$PATH:/sbin:/usr/sbin"
141 if grep -q %{installroot}/proc /proc/mounts ; then
142 umount %{installroot}/proc
144 if grep -q %{installroot}/dev/pts /proc/mounts ; then
145 umount %{installroot}/dev/pts
147 chattr -R -i $RPM_BUILD_ROOT
148 rm -rf $RPM_BUILD_ROOT
151 # Copy configuration files from host to reference image
152 for file in /etc/hosts /etc/resolv.conf /etc/yum.conf ; do
153 if [ -f $file ] ; then
154 echo $file | cpio -p -d -u %{vrefdir}
161 %defattr(-,root,root)
165 * Tue Sep 14 2004 Mark Huang <mlhuang@cs.princeton.edu> 3.0-1.planetlab