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
108 %%__file_context_path /dev/null
111 # Initialize RPM database in reference image
112 mkdir -p %{installroot}/var/lib/rpm
113 rpm --root %{installroot} --initdb
115 # XXX Get yum.conf from PlanetLabConf
117 # Install RPMs in reference image
119 %{?sslcertdir:--sslcertdir=%{sslcertdir}} \
120 --installroot=%{installroot} \
121 -y groupinstall VServer
123 # Freshen any new RPMs
124 find %{_topdir}/RPMS -type f | xargs rpm --root %{installroot} -F
126 # Clean up /dev in reference image
129 # Configure authentication in reference image
130 chroot %{installroot} authconfig --nostart --kickstart --enablemd5 --enableshadow || :
132 # Disable all services in reference image
133 chroot %{installroot} /bin/sh -c "chkconfig --list | awk '{ print \$1 }' | xargs -i chkconfig {} off"
136 if grep -q %{installroot}/proc /proc/mounts ; then
137 umount %{installroot}/proc
139 if grep -q %{installroot}/dev/pts /proc/mounts ; then
140 umount %{installroot}/dev/pts
145 export PATH="$PATH:/sbin:/usr/sbin"
148 if grep -q %{installroot}/proc /proc/mounts ; then
149 umount %{installroot}/proc
151 if grep -q %{installroot}/dev/pts /proc/mounts ; then
152 umount %{installroot}/dev/pts
154 chattr -R -i $RPM_BUILD_ROOT
155 rm -rf $RPM_BUILD_ROOT
157 # Make sure the original user can remove the generated files
158 if [ -n "$SUDO_UID" ] ; then
159 chown -R $SUDO_UID.$SUDO_GID .
162 %{_topdir}/RPMS/noarch/%{name}-%{version}-%{release}.noarch.rpm \
163 %{_topdir}/RPMS/noarch \
165 %{_topdir}/SRPMS/%{name}-%{version}-%{release}.src.rpm \
166 %{_topdir}/SRPMS/ ; do
168 chown $SUDO_UID.$SUDO_GID $i
174 # 1 = install, 2 = upgrade/reinstall
175 if [ $1 -eq 2 ] ; then
176 chattr -R -i %{vrefdir}
180 # Copy configuration files from host to reference image
181 for file in /etc/hosts /etc/resolv.conf /etc/yum.conf ; do
182 if [ -f $file ] ; then
183 echo $file | cpio -p -d -u %{vrefdir}
190 %defattr(-,root,root)
194 * Tue Sep 14 2004 Mark Huang <mlhuang@cs.princeton.edu> 3.0-1.planetlab