moving the plc.d scripts for bootcd where they belong
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Mon, 18 Jan 2010 14:14:44 +0000 (14:14 +0000)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Mon, 18 Jan 2010 14:14:44 +0000 (14:14 +0000)
bootcd.spec
plc.d/bootcd [new file with mode: 0755]
plc.d/bootcd-kernel [new file with mode: 0755]

index 834490e..625478b 100644 (file)
 #%define release %{taglevel}%{?pldistro:.%{pldistro}}%{?date:.%{date}}
 %define release %{taglevel}%{?date:.%{date}}
 
+# structure - this results in 2 packages
+# bootcd-initscripts - has the plc.d/ scripts
+# bootcd-<nodefamily> - has the actual stuff for a given nodefamily
+
 Vendor: PlanetLab
 Packager: PlanetLab Central <support@planet-lab.org>
 Distribution: PlanetLab %{plrelease}
@@ -38,7 +42,19 @@ AutoReqProv: no
 
 %description
 The Boot CD securely boots PlanetLab nodes into an immutable
-environment.
+environment. This package is designed to be installed on a MyPLC
+installation and provide the basics for the PLC to able to compute
+BootCDs for its attached nodes. 
+See http://svn.planet-lab.org/wiki/NodeFamily
+
+
+%package -n bootcd-initscripts
+Summary: initscripts for the MyPLC installation
+Group: System Environment/Base
+%description -n bootcd-initscripts
+This package contains the init scripts that get fired when the PLC is
+restarted.
+
 
 %prep
 %setup -q
@@ -69,26 +85,22 @@ tar cpf - \
     configurations | \
     tar -C $RPM_BUILD_ROOT/%{_datadir}/%{name}/ -xpf -
 
+for script in bootcd bootcd-kernel; do 
+    install -D -m 755 plc.d/$script $RPM_BUILD_ROOT/etc/plc.d/$script
+done
 popd
     
 %clean
 rm -rf $RPM_BUILD_ROOT
 
-# If run under sudo
-if [ -n "$SUDO_USER" ] ; then
-    # Allow user to delete the build directory
-    chown -h -R $SUDO_USER .
-    # Some temporary cdroot files like /var/empty/sshd and
-    # /usr/bin/sudo get created with non-readable permissions.
-    find . -not -perm +0600 -exec chmod u+rw {} \;
-    # Allow user to delete the built RPM(s)
-    chown -h -R $SUDO_USER %{_rpmdir}/*
-fi
-
 %files
 %defattr(-,root,root,-)
 %{_datadir}/%{name}
 
+%files -n bootcd-initscripts
+%defattr(-,root,root,-)
+/etc/plc.d
+
 %post
 [ -f /etc/planetlab/nodefamily ] || { mkdir -p /etc/planetlab ; echo %{nodefamily} > /etc/planetlab/nodefamily ; }
 
@@ -104,7 +116,7 @@ fi
 - repeated in the bootmanager to handle all CDs without this operation
 
 * Mon Jun 29 2009 Marc Fiuczynski <mef@cs.princeton.edu> - BootCD-4.2-14
-- Daniel's update to generalize the kvariant support.
+- Daniel''s update to generalize the kvariant support.
 
 * Wed Apr 08 2009 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - BootCD-4.2-13
 - robust to node config file specified with a relative path
diff --git a/plc.d/bootcd b/plc.d/bootcd
new file mode 100755 (executable)
index 0000000..e628dd7
--- /dev/null
@@ -0,0 +1,71 @@
+#!/bin/bash
+#
+# priority: 1000
+#
+# Rebuild the Boot CD
+#
+# Mark Huang <mlhuang@cs.princeton.edu>
+# Copyright (C) 2006 The Trustees of Princeton University
+#
+# $Id$
+#
+
+# Source function library and configuration
+. /etc/plc.d/functions
+. /etc/planetlab/plc_config
+
+# Be verbose
+set -x
+
+case "$1" in
+    start)
+       if [ "$PLC_BOOT_ENABLED" != "1" -a \
+            "$PLC_WWW_ENABLED" != "1" ] ; then
+           exit 0
+       fi
+
+       MESSAGE=$"Rebuilding Boot CD"
+       dialog "$MESSAGE"
+
+       ########## legacy myplcs - temporary code
+       # create /etc/planetlab/nodefamily if missing
+       [ -f /etc/planetlab/nodefamily ] || { mkdir -p /etc/planetlab ; echo "planetlab-i386" > /etc/planetlab/nodefamily ; }
+       # move if plain directories
+       for legacydir in /usr/share/bootcd /var/www/html/download ; do
+           if [ -d "${legacydir}" ] && [ ! -h ${legacydir} ] ; then
+               rm -rf ${legacydir}-legacy
+               mv -f ${legacydir} ${legacydir}-legacy
+           fi
+       done
+       ########## end
+
+       # get the default nodefamily
+       def_nodefamily=$(cat /etc/planetlab/nodefamily)
+       
+       # Customize the Boot CD : run build.sh on all available bootcd's
+       shopt -s nullglob
+       for bootcd in /usr/share/bootcd-* ; do
+           name=$(basename $bootcd)
+           nodefamily=$(echo $name | sed -e s,bootcd-,,)
+           download=/var/www/html/download-${nodefamily}
+           [ -d ${download} ] || mkdir -p ${download}
+
+           pushd ${download}
+           ${bootcd}/build.sh ${PLC_BUILD_ALL_BOOTCDS:+-a}
+           check
+           popd
+       
+           # the default: create symlinks to the actual locations
+           if [ "${nodefamily}" == "${def_nodefamily}" ] ; then
+               rm -rf /usr/share/bootcd
+               ln -s /usr/share/bootcd-${nodefamily} /usr/share/bootcd
+               rm -rf /var/www/html/download
+               ln -s /var/www/html/download-${nodefamily} /var/www/html/download
+           fi
+       done
+
+       result "$MESSAGE"
+       ;;
+esac
+
+exit $ERRORS
diff --git a/plc.d/bootcd-kernel b/plc.d/bootcd-kernel
new file mode 100755 (executable)
index 0000000..5125ada
--- /dev/null
@@ -0,0 +1,59 @@
+#!/bin/bash
+#
+# priority: 0999
+#
+# $Id$
+# Build BootCD variants with kernels specified in /etc/planetlab/bootcd-variants
+
+# Source function library and configuration
+. /etc/plc.d/functions
+
+# Be verbose
+set -x
+
+case "$1" in
+    start)
+       MESSAGE=$"Creating BootCD variants"
+       dialog "$MESSAGE"
+
+       success=0
+       for i in /usr/share/bootcd-*; do
+               pushd $i
+               basearch=$(echo $i | awk -F- '{ print $NF }')
+               arch=$(echo $basearch | sed 's/i386/i686/')
+               for j in /etc/planetlab/bootcd-variants/*; do
+                       name="${j##*/}"
+                       url=$(cat "$j" | sed "s!@BASEARCH@!$basearch!g;s!@ARCH@!$arch!g")
+                       if test -d "$name"; then
+                               test build/isofs/bootcd.img -nt "$name/isofs/bootcd.img" || continue
+                       elif test "$name" = default; then
+                               # Not ideal, but...
+                               grep -q support@planet-lab.org build/isofs/kernel || continue
+                       fi
+                       if test "$url" != $(echo "$url" | sed s#[:/]##); then
+                               ./kvariant.sh "$name" "$url"
+                       else
+                               dir=$(mktemp -d -p /var/tmp)
+                               yumdownloader --disablerepo='*' \
+                                       --enablerepo=base \
+                                       --enablerepo=updates \
+                                       --destdir "$dir" "$url"
+                               ./kvariant.sh "$name" "$dir"/"$url"*
+                               rm -fr "$dir"
+                       fi
+                       if test "$name" = default; then
+                               rm -fr orig
+                               mv build orig
+                               mv default build
+                       fi
+               done
+               popd
+       done
+       test $success = 0
+       check
+
+       result "$MESSAGE"
+       ;;
+esac
+
+exit $ERRORS