From: Mark Huang Date: Mon, 11 Oct 2004 04:24:42 +0000 (+0000) Subject: - dynamically construct reference image on the target machine in a %post X-Git-Tag: planetlab-3_0-branch-point~9 X-Git-Url: http://git.onelab.eu/?p=vserver-reference.git;a=commitdiff_plain;h=56d33e381ce1e3ca55de06f1f1637db39e296503 - dynamically construct reference image on the target machine in a %post scriplet, instead of building it on the build machine. This solves a couple of problems: 1. RPM databases constructed on a RH9 machine could be corrupt on a FC2 machine because of the LD_ASSUME_KERNEL rpm/glibc NPTL bug. 2. vserver-reference is no longer a 50 MB download. The reference image can be installed from the localhost yum cache most of the time. But introduces a couple of problems: 1. If the %post scriplet fails, the whole installation fails with a warning, but without an error. Not having a complete vserver-reference build is a bad thing. 2. Must zap RPM and YUM locks while installing. --- diff --git a/vserver-reference.spec b/vserver-reference.spec index 40328d5..decb529 100644 --- a/vserver-reference.spec +++ b/vserver-reference.spec @@ -1,6 +1,6 @@ %define name vserver-reference %define version 3.0 -%define release 1.planetlab%{?date:.%{date}} +%define release 2.planetlab%{?date:.%{date}} Vendor: PlanetLab Packager: PlanetLab Central @@ -16,180 +16,113 @@ License: GPL Group: Applications/System BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot BuildArchitectures: noarch -Requires: util-vserver -AutoReqProv: no -BuildRequires: e2fsprogs, yum - -%define debug_package %{nil} +Requires: util-vserver, e2fsprogs, yum %description This package creates the virtual server (VServer) reference image used as the installation base for new PlanetLab slivers. -%define vrootdir /vservers -%define vrefdir %{vrootdir}/%{name} -%define installroot $RPM_BUILD_ROOT%{vrefdir} - %prep %setup -q -# chattr, mknod, mount, yum all require root privileges. Yech. -if [ $UID -ne 0 ] ; then - echo You must be root to build the %{name} package. - false -fi - %build %install -# Running as root -export PATH="$PATH:/sbin:/usr/sbin" +rm -rf $RPM_BUILD_ROOT -# Clean up -if grep -q %{installroot}/proc /proc/mounts ; then - umount %{installroot}/proc -fi -if grep -q %{installroot}/dev/pts /proc/mounts ; then - umount %{installroot}/dev/pts -fi -chattr -R -i $RPM_BUILD_ROOT +%clean rm -rf $RPM_BUILD_ROOT -# Make /vservers -mkdir -p $RPM_BUILD_ROOT%{vrootdir} -chmod 000 $RPM_BUILD_ROOT%{vrootdir} -chattr +t $RPM_BUILD_ROOT%{vrootdir} +%post +. /usr/lib/util-vserver/util-vserver-vars +VROOT=$VROOTDIR/vserver-reference -# Make /vservers/vserver-reference -mkdir -p %{installroot} -chattr -t %{installroot} -chmod 755 %{installroot} +# Pause vcached +service vcached stop -MAKEDEV () -{ - if grep -q %{installroot}/dev/pts /proc/mounts ; then - umount %{installroot}/dev/pts +# Remove old installation first +if [ -d $VROOT ] ; then + if grep -q $VROOT/proc /proc/mounts ; then + umount $VROOT/proc + fi + if grep -q $VROOT/dev/pts /proc/mounts ; then + umount $VROOT/dev/pts fi - rm -rf %{installroot}/dev - mkdir -p %{installroot}/dev - mknod -m 666 %{installroot}/dev/null c 1 3 - mknod -m 666 %{installroot}/dev/zero c 1 5 - mknod -m 666 %{installroot}/dev/full c 1 7 - mknod -m 644 %{installroot}/dev/random c 1 8 - mknod -m 644 %{installroot}/dev/urandom c 1 9 - mknod -m 666 %{installroot}/dev/tty c 5 0 - mknod -m 666 %{installroot}/dev/ptmx c 5 2 - touch %{installroot}/dev/hdv1 -} - -# Initialize /dev in reference image -MAKEDEV + chattr -R -i $VROOT + rm -rf $VROOT +fi + +$PKGLIBDIR/install-pre.sh vserver-reference # Mount /dev/pts in reference image -mkdir -p %{installroot}/dev/pts -mount -t devpts none %{installroot}/dev/pts +mkdir -p $VROOT/dev/pts +mount -t devpts none $VROOT/dev/pts # Mount /proc in reference image -mkdir -p %{installroot}/proc -mount -t proc none %{installroot}/proc - -# Create a dummy /etc/fstab in reference image -mkdir -p %{installroot}/etc -cat > %{installroot}/etc/fstab < %{installroot}/etc/rpm/macros < $VROOT/etc/rpm/macros < 3.0-2.planetlab +- dynamically install reference image + * Tue Sep 14 2004 Mark Huang 3.0-1.planetlab - initial build