From 3878c3b1b026d4c408c192f9d014ca82382585af Mon Sep 17 00:00:00 2001
From: Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Date: Fri, 12 Sep 2008 13:34:50 +0000
Subject: [PATCH] Merging the build trunk onto 4.2 branch new yum repo layout
 uses mirroring skeletons/ rather than hard-coded yumconfs

---
 Makefile                                      |  14 +-
 build.common                                  | 248 ++++++++----------
 .../centos5/yum.repos.d/building.repo.in      |  11 +
 mirroring/f7/yum.repos.d/building.repo.in     |  13 +
 mirroring/f8/yum.repos.d/building.repo.in     |  20 ++
 mirroring/f9/yum.repos.d/building.repo.in     |  21 ++
 mirroring/fc4/yum.repos.d/building.repo.in    |  14 +
 mirroring/fc6/yum.repos.d/building.repo.in    |  20 ++
 mirroring/mirror.sh                           | 154 +++++++++++
 module-tools.py                               |   2 +-
 onelab-install.mk                             |  78 ------
 planetlab-install.mk                          |  72 -----
 vbuild-nightly.sh                             |  25 +-
 13 files changed, 375 insertions(+), 317 deletions(-)
 create mode 100644 mirroring/centos5/yum.repos.d/building.repo.in
 create mode 100644 mirroring/f7/yum.repos.d/building.repo.in
 create mode 100644 mirroring/f8/yum.repos.d/building.repo.in
 create mode 100644 mirroring/f9/yum.repos.d/building.repo.in
 create mode 100644 mirroring/fc4/yum.repos.d/building.repo.in
 create mode 100644 mirroring/fc6/yum.repos.d/building.repo.in
 create mode 100755 mirroring/mirror.sh
 delete mode 100644 onelab-install.mk
 delete mode 100644 planetlab-install.mk

diff --git a/Makefile b/Makefile
index 72e1230c..9b6a7eb3 100644
--- a/Makefile
+++ b/Makefile
@@ -308,8 +308,7 @@ spec2make: spec2make.c
 define target_mk
 MAKE/$(1).mk: $($(1).specpath) spec2make .rpmmacros
 	mkdir -p MAKE
-	./spec2make $($(1)-RPMFLAGS) $($(1).specpath) $(1) > MAKE/$(1).mk
-	@if [ -z MAKE/$(1).mk ] ; then rm MAKE/$(1).mk ; exit 1 ; fi
+	./spec2make $($(1)-RPMFLAGS) $($(1).specpath) $(1) > MAKE/$(1).mk || { rm MAKE/$(1).mk; exit 1; }
 endef
 
 $(foreach package,$(ALL),$(eval $(call target_mk,$(package))))
@@ -651,15 +650,6 @@ $(foreach package,$(sort $(ALL)), $(eval $(call rpm_version_target,$(package))))
 versions: myplc-release version-build version-svns version-rpms
 .PHONY: versions version-build version-rpms version-svns
 
-#################### include install Makefile
-# the default is to use the distro-dependent install file
-# however the main distro file can redefine PLDISTROINSTALL
-ifndef PLDISTROINSTALL
-PLDISTROINSTALL := $(PLDISTRO)-install.mk
-endif
-# only if present
--include $(PLDISTROINSTALL)
-
 #################### package info
 PKGKEYS := tarballs source codebase srpm rpms rpmnames rpm-release rpm-name rpm-version rpm-subversion
 %-pkginfo: package=$(subst -pkginfo,,$@)
@@ -694,7 +684,7 @@ info: packages modules branches
 .PHONY: info packages modules branches module-tools
 
 ####################
-testsvnpath:
+tests_svnpath:
 	@$(if $(TESTS_SVNPATH), echo $(TESTS_SVNPATH) > $@, \
 	echo "http://svn.planet-lab.org/svn/tests/trunk" > $@)
 
diff --git a/build.common b/build.common
index 59fb2f36..153a010d 100644
--- a/build.common
+++ b/build.common
@@ -9,43 +9,31 @@
 # $Id$
 #
 
-function pl_getDefaultDistro() {
-    # FC4 is currently the default release
-    echo "Fedora"
-    return 0
-}
-
-function pl_getDefaultRelease() {
-    # FC4 is currently the default release
-    echo "4"
-    return 0
-}
+# support for fedora and centos only for now
 
 function pl_getDistro() {
-    defaultDistro=$(pl_getDefaultDistro)
     if [ -f "/etc/redhat-release" ] ; then
 	distro=$(awk ' { print $1 } ' /etc/redhat-release)
     else
-	distro=$defaultDistro
+	echo "build.common.pl_getDistro-unknown"
+	exit 1
     fi
     echo "$distro"
     return 0
 }
 
 function pl_getRelease() {
-    defaultRelease=$(pl_getDefaultRelease)
     if [ -f "/etc/redhat-release" ] ; then
 	release=$(awk ' { if ($1=="Fedora" && $2=="Core") print $4 ; if (($1=="Fedora" && $2!="Core")||$1=="CentOS") print $3 } ' /etc/redhat-release)
-	[ $release -lt $defaultRelease ] && release=$defaultRelease
     else
-	release=$defaultRelease
+	echo "build.common.pl_getRelease-unknown"
+	exit 1
     fi
     echo "$release"
     return 0
 }
 
 # vserver expects something like fc4 or f7
-# for fedora and centos only for now
 function pl_getReleaseName () {
     distro=$1; shift
     release=$1; shift
@@ -198,25 +186,15 @@ function pl_root_mkfedora () {
     basearch=$pl_DISTRO_ARCH
 
 # Get options
-    mirrors=""
-    while getopts "l:r:a:vh" opt ; do
+###    mirrors=""
+###    while getopts "l:r:a:vh" opt ; do
+    while getopts "vh" opt ; do
 	case $opt in
-	    l)
-		mirrors="$mirrors $OPTARG"
-		;;
-	    r)
-		releasever=$OPTARG
-		;;
-	    a)
-		basearch=$OPTARG
-		;;
-	    v)
-		verbose=1
-		set -x
-		;;
-	    h|*)
-		mkfedora_usage
-		;;
+###	    l) mirrors="$mirrors $OPTARG" ;;
+###	    r) releasever=$OPTARG ;;
+###	    a) basearch=$OPTARG ;;
+	    v) verbose=1; set -x ;;
+	    h|*) mkfedora_usage ;;
 	esac
     done
 
@@ -245,93 +223,27 @@ function pl_root_mkfedora () {
 	mirrors=$(pl_parsePkgs mirror $fcdistro $pldistro $mirrorsfile)
     fi
 
-    exclude_kernel=""
+    exclude_line=""
     # add them manually as the output of pl_parsePkgs is line-separated
     if [ -n "$pkgs_kexcludes" ] ; then
-	exclude_kernel="exclude="
+	exclude_line="exclude="
 	for kexclude in $pkgs_kexcludes ; do
-	    exclude_kernel="$exclude_kernel $kexclude"
+	    exclude_line="$exclude_line $kexclude"
 	done
     fi
 
-    function mkfedora_fetch ()
-    {
-	curl --fail --silent --max-time 60 "$1"
-    }
-
-    # set list of attempted locations according to target distro
-    # xxx all this should go into mirroring/ somehow
-    case $pl_DISTRO in
-	Fedora)
-	    if [ $releasever -ge 7 ] ; then
-	        # Plain Fedora comes with a new layout
-		attempts="
-fedora/releases/$releasever/Everything/$basearch/os
-linux/releases/$releasever/Everything/$basearch/os
-$releasever/Everything/$basearch/os
-core/$releasever/Everything/$basearch/os
-linux/core/$releasever/$basearch/os
-"
-	    else
-		# Fedora Core
-		attempts="
-fedora/core/$releasever/$basearch/os 
-linux/core/$releasever/$basearch/os 
-core/$releasever/$basearch/os 
-$releasever/$basearch/os
-"
-	    fi 
-	    public_gpg_key=RPM-GPG-KEY-fedora
-	    ;;
-	CentOS)
-	    # xxx hacky for now
-	    # you can use vbuild-fedora-mirror with -f centos5.2
-	    # which is hard-coded in mirroring/centos as well
-	    # for now I do the mapping here, mmhh
-	    case $releasever in
-		4) actual=4.6 ;;
-		# getrelease.sh returns 5.2, used to be simply 5
-		5*) releasever=5; actual=5.2 ;;
-		*) actual=$releasever ;;
-	    esac
-	    attempts="
-centos/$actual/os/$basearch
-"
-	    public_gpg_key=RPM-GPG-KEY-CentOS-$releasever
-	    ;;
-	*)
-	    echo "distro $pl_DISTRO not supported in build.common / mkfedora" ; exit 1
-    esac
-
     echo "$0: candidate mirrors"
     for mirror in $mirrors ; do
 	echo "* candidate mirror $mirror"
     done
-    baseurl=""
-    for mirror in $mirrors ; do
-	for attempt in $attempts; do 
-	    attempturl=$mirror/$attempt
-	    if mkfedora_fetch $attempturl/repodata/repomd.xml >/dev/null ; then
-		baseurl=$attempturl
-		break 2
-	    fi
-	done
-    done
 
-    if [ -z "$baseurl" ] ; then
-	echo "Error: $releasever/$basearch/os/repodata/repomd.xml"
-	echo "       could not be found in any of the following locations:"
-	echo
-	for mirror in $mirrors ; do
-	    for attempt in $attempts ; do
-		echo $mirror/$attempt
-	    done
-	done
-	echo
-	mkfedora_usage
-    else
-	echo "* selecting mirror with baseurl=$baseurl"
+    # the repo part of the final yum.conf
+    yum_conf_repos=$vroot/xxxmkfedora-repos.confxxx
+    if ! yumconf_mirrors $yum_conf_repos ../build/ $fcdistro "$exclude_line" $mirrors ; then
+	echo xxx -- error ; return 1
     fi
+    
+    public_gpg_key=$(yumconf_gpgkey $yum_conf_repos)
 
     # Do not tolerate errors
     set -e
@@ -386,15 +298,10 @@ EOF
     # Initialize RPM database in reference image
     mkdir -p $vroot/var/lib/rpm
     rpm --root $vroot --initdb
-    rpm --root $vroot --import $baseurl/$public_gpg_key
+    rpm --root $vroot --import $public_gpg_key
 
     # Initialize yum in reference image
     mkdir -p $vroot/var/cache/yum $vroot/var/log
-    if [ $releasever -lt 7 ] ; then
-	corename="Core "
-    else
-	corename=""
-    fi
 
 # yum.conf is for building only - store in different location than /etc/yum.conf
     yum_conf=$vroot/etc/mkfedora-yum.conf
@@ -413,32 +320,9 @@ gpgcheck=0
 # Prevent yum-2.4 from loading additional repository definitions
 # (e.g., from /etc/yum.repos.d/)
 reposdir=/dev/null
-
-[base]
-name=Fedora ${corename}${releasever} - $basearch - base
-baseurl=$baseurl/
-$exclude_kernel
 EOF
-
-    for optional in updates extras ; do
-	for optionalurl in \
-	    $mirror/fedora/$optional/$releasever/$basearch \
-	    $mirror/linux/core/$optional/$releasever/$basearch \
-	    $mirror/core/$optional/$releasever/$basearch \
-	    $mirror/linux/$optional/$releasever/$basearch \
-	    $mirror/$optional/$releasever/$basearch ; do
-            if mkfedora_fetch $optionalurl/repodata/repomd.xml ; then
-		cat >> $yum_conf <<EOF
-
-[$(basename $optional)]
-name=Fedora ${corename}${releasever} - $basearch - $(basename $optional)
-baseurl=$optionalurl/
-$exclude_kernel
-EOF
-                break
-	    fi
-	done
-    done
+    
+    cat $yum_conf_repos >> $yum_conf
 
     # If we are being built as part of an automated RPM build, solve the
     # bootstrap problem by including any just built packages in the yum
@@ -452,8 +336,8 @@ EOF
 	fi
 	cat >> $yum_conf <<EOF
 
-[bootstrap]
-name=Bootstrap - $basearch - $RPM_RPMS_DIR/
+[building]
+name=Building - $basearch - $RPM_RPMS_DIR/
 baseurl=file://$RPM_RPMS_DIR/
 EOF
 fi
@@ -743,3 +627,81 @@ cat <<__footer
 </comps>
 __footer
 }
+
+
+function build_fetch () {
+    curl --fail --silent --max-time 60 --output /dev/null "$1" 
+}
+
+# tries to compute a valid yum.conf for that pldistro from the template in mirroring/
+# returns 0 and writes <dest_yumconf> on success
+# returns 1 on failure, in which case <dest_yumconf> is deleted
+function yumconf_mirrors () {
+    dest_yumconf=$1; shift
+    builddir=$1; shift
+    fcdistro=$1; shift
+    exclude_line="$1" ; shift
+    mirrors="$@"
+
+    template=$builddir/mirroring/$fcdistro/yum.repos.d/building.repo.in
+    
+    if [ ! -f $template ] ; then
+	echo "yumconf_mirrors: cannot locate template $template"
+	rm -f $dest_yumconf
+	return 1
+    fi
+
+    for mirror in $mirrors; do
+	if yumconf_mirror $dest_yumconf $template "$exclude_line" $mirror; then
+	    return 0
+	fi
+    done
+    rm -f $dest_yumconf
+    return 1
+}
+
+# computes a yum.conf from the template, and checks that all baseurl defined in there are valid repos
+# returns 0 on success and 1 on failure
+function yumconf_mirror () {
+    dest_yumconf=$1; shift
+    template=$1; shift
+    exclude_line="$1" ; shift
+    mirror=$1; shift
+
+    sed -e "s,@MIRRORURL@,$mirror,g" \
+	-e "/baseurl=/i\\
+$exclude_line" $template > $dest_yumconf
+    
+    # capture all lines defining baseurl
+    baseurl_defs=$(grep '^baseurl=' $dest_yumconf)
+    if [ -z "$baseurl_defs" ] ; then
+	return 1
+    fi
+
+    for baseurl_def in $baseurl_defs; do
+	baseurl=$(echo $baseurl_def | sed \
+	    -e s,baseurl=,, \
+	    -e 's,$basearch,'"$pl_DISTRO_ARCH",g)
+	repomd=$baseurl/repodata/repomd.xml
+
+	echo "* Trying to fetch $repomd"
+	if ! build_fetch $repomd ; then
+	    echo "* Failed to fetch $repomd"
+	    return 1
+	fi
+    done
+    echo "* Selected mirror $mirror"
+    return 0
+}
+
+# from a yum.conf as generated above, computes the (first) gpgkey url
+function yumconf_gpgkey () {
+    dest_yumconf=$1; shift
+
+    first_line=$(grep '^gpgkey=' $dest_yumconf | head -1)
+    values=$(echo $first_line | sed -e s,gpgkey=,,)
+    value=$(echo $values | awk '{print $1;}' | sed -e 's,$basearch,'"$pl_DISTRO_ARCH",g)
+    [ -n "$value" ] || return 1
+    echo $value
+    return 0
+}
diff --git a/mirroring/centos5/yum.repos.d/building.repo.in b/mirroring/centos5/yum.repos.d/building.repo.in
new file mode 100644
index 00000000..35f3b0c5
--- /dev/null
+++ b/mirroring/centos5/yum.repos.d/building.repo.in
@@ -0,0 +1,11 @@
+[base]
+name=CentOS 5.2 - $basearch - Base
+baseurl=@MIRRORURL@/centos/5.2/os/$basearch/
+gpgcheck=1
+gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
+
+[updates]
+name=CentOS 5.2 - $basearch - Released Updates
+baseurl=@MIRRORURL@/centos/5.2/updates/$basearch/
+gpgcheck=1
+gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
diff --git a/mirroring/f7/yum.repos.d/building.repo.in b/mirroring/f7/yum.repos.d/building.repo.in
new file mode 100644
index 00000000..0023f34d
--- /dev/null
+++ b/mirroring/f7/yum.repos.d/building.repo.in
@@ -0,0 +1,13 @@
+[base]
+name=Fedora 7 - $basearch - Base
+baseurl=@MIRRORURL@/fedora/releases/7/Everything/$basearch/os/
+enabled=1
+gpgcheck=1
+gpgkey=http://redhat.download.fedoraproject.org/pub/fedora/linux/releases/7/Everything/$basearch/os/RPM-GPG-KEY-fedora
+
+[updates]
+name=Fedora 7 - $basearch - Updates
+baseurl=@MIRRORURL@/fedora/updates/7/$basearch/
+enabled=1
+gpgcheck=1
+gpgkey=http://redhat.download.fedoraproject.org/pub/fedora/linux/releases/7/Everything/$basearch/os/RPM-GPG-KEY-fedora
diff --git a/mirroring/f8/yum.repos.d/building.repo.in b/mirroring/f8/yum.repos.d/building.repo.in
new file mode 100644
index 00000000..57eca103
--- /dev/null
+++ b/mirroring/f8/yum.repos.d/building.repo.in
@@ -0,0 +1,20 @@
+[fedora]
+name=Fedora 8 - $basearch
+baseurl=@MIRRORURL@/fedora/releases/8/Everything/$basearch/os/
+enabled=1
+gpgcheck=1
+gpgkey=http://redhat.download.fedoraproject.org/pub/fedora/linux/releases/8/Everything/$basearch/os/RPM-GPG-KEY-fedora http://redhat.download.fedoraproject.org/pub/fedora/linux/releases/8/Everything/$basearch/os/RPM-GPG-KEY
+
+[updates]
+name=Fedora 8 - $basearch - Updates
+baseurl=@MIRRORURL@/fedora/updates/8/$basearch/
+enabled=1
+gpgcheck=1
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora
+
+[updates-newkey]
+name=Fedora 8 - $basearch - Updates Newkey
+baseurl=@MIRRORURL@/fedora/updates/8/$basearch.newkey/
+enabled=1
+gpgcheck=1
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-8-and-9
diff --git a/mirroring/f9/yum.repos.d/building.repo.in b/mirroring/f9/yum.repos.d/building.repo.in
new file mode 100644
index 00000000..060a670f
--- /dev/null
+++ b/mirroring/f9/yum.repos.d/building.repo.in
@@ -0,0 +1,21 @@
+[fedora]
+name=Fedora 9 - $basearch
+baseurl=@MIRRORURL@/fedora/releases/9/Everything/$basearch/os/
+enabled=1
+gpgcheck=1
+# xxx cannot locate key in f9 downloads - temporary - using the key from f8 
+gpgkey=http://redhat.download.fedoraproject.org/pub/fedora/linux/releases/8/Everything/$basearch/os/RPM-GPG-KEY-fedora
+
+[updates]
+name=Fedora 9 - $basearch - Updates
+baseurl=@MIRRORURL@/fedora/updates/9/$basearch/
+enabled=1
+gpgcheck=1
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora
+
+[updates-newkey]
+name=Fedora 9 - $basearch - Updates Newkey
+baseurl=@MIRRORURL@/fedora/updates/9/$basearch.newkey/
+enabled=1
+gpgcheck=1
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-8-and-9
diff --git a/mirroring/fc4/yum.repos.d/building.repo.in b/mirroring/fc4/yum.repos.d/building.repo.in
new file mode 100644
index 00000000..dbac2e39
--- /dev/null
+++ b/mirroring/fc4/yum.repos.d/building.repo.in
@@ -0,0 +1,14 @@
+[base]
+name=Fedora Core 4 - $basearch - Base
+baseurl=@MIRRORURL@/fedora/core/4/$basearch/os/
+gpgcheck=1
+
+[updates]
+name=Fedora Core 4 - $basearch - Released Updates
+baseurl=@MIRRORURL@/fedora/core/updates/4/$basearch/
+gpgcheck=1
+
+#[extras]
+#name=Fedora Extras 4 - $basearch
+#baseurl=@MIRRORURL@/fedora/extras/4/$basearch/
+#gpgcheck=1
diff --git a/mirroring/fc6/yum.repos.d/building.repo.in b/mirroring/fc6/yum.repos.d/building.repo.in
new file mode 100644
index 00000000..25df468c
--- /dev/null
+++ b/mirroring/fc6/yum.repos.d/building.repo.in
@@ -0,0 +1,20 @@
+[core]
+name=Fedora Core 6 - $basearch
+baseurl=@MIRRORURL@/fedora/core/6/$basearch/os/
+enabled=1
+gpgcheck=1
+gpgkey=http://redhat.download.fedoraproject.org/pub/fedora/linux/core/6/$basearch/os/RPM-GPG-KEY-fedora http://redhat.download.fedoraproject.org/pub/fedora/linux/core/6/$basearch/os/RPM-GPG-KEY
+
+[updates]
+name=Fedora Core 6 - $basearch - Updates
+baseurl=@MIRRORURL@/fedora/core/updates/6/$basearch/
+enabled=1
+gpgcheck=1
+gpgkey=http://redhat.download.fedoraproject.org/pub/fedora/linux/core/6/$basearch/os/RPM-GPG-KEY-fedora
+
+[extras]
+name=Fedora Extras 6 - $basearch
+baseurl=@MIRRORURL@/fedora/extras/6/$basearch/
+enabled=1
+gpgcheck=1
+gpgkey=http://redhat.download.fedoraproject.org/pub/fedora/linux/core/6/$basearch/os/RPM-GPG-KEY-fedora-extras
diff --git a/mirroring/mirror.sh b/mirroring/mirror.sh
new file mode 100755
index 00000000..a8b30549
--- /dev/null
+++ b/mirroring/mirror.sh
@@ -0,0 +1,154 @@
+#!/bin/bash
+# $Id: mirror.sh 10344 2008-08-28 16:54:46Z thierry $
+
+COMMAND=$(basename $0)
+DIRNAME=$(dirname $0)
+
+default_url="http://localhost/mirror/"
+default_distro="f8"
+all_distros="fc4 fc6 f7 f8 f9 centos5"
+
+function check_distro () {
+    local distro=$1; shift
+    if [ ! -d $DIRNAME/$distro/yum.repos.d ] ; then
+	echo "Distro $distro not supported - skipped"
+	return 1
+    fi
+    return 0
+}
+
+function do_repo () {
+    local distro=$1; shift
+    sedargs="-e s,@MIRRORURL@,$URL,"
+    [ -n "$GPGOFF" ] && sedargs="$sedargs -e "'s,gpgcheck\W*=\W*1,gpgcheck=0,'
+    sed $sedargs $DIRNAME/$distro/yum.repos.d/building.repo.in
+}
+
+function do_init () { 
+    local distro=$1; shift
+    repo=/etc/vservers/.distributions/$distro/yum.repos.d/building.repo
+    dir=/etc/vservers/.distributions/$distro/yum.repos.d/
+    if [ ! -d $dir ] ; then
+	[ -n "$VERBOSE" ] && echo Creating dir $dir
+	mkdir -p $dir
+    fi
+    [ -n "$VERBOSE" ] && echo "Creating $repo"
+    do_repo $distro > $repo
+}
+
+function do_diff () {
+    local distro=$1; shift
+    repo=/etc/vservers/.distributions/$distro/yum.repos.d/building.repo
+    if [ ! -f $repo ] ; then
+	echo "Cannot find $repo"
+    else
+	would=/tmp/$COMMAND.$$
+	do_repo $distro > $would
+	echo "==================== DIFF for $distro" '(current <-> would be)'
+	diff $repo $would 
+	rm $would
+    fi
+}
+
+function do_display () {
+    local distro=$1; shift
+    dir=/etc/vservers/.distributions/$distro/yum.repos.d/
+    if [ -d $dir ] ; then
+	echo "====================" Contents of $dir
+	ls $dir/*.repo 2> /dev/null | xargs head --verbose --lines=1000
+    else
+	echo "====================" $dir does not exist
+    fi
+}
+
+function do_clean () {
+    local distro=$1; shift
+    repo=/etc/vservers/.distributions/$distro/yum.repos.d/building.repo
+    [ -n "$VERBOSE" ] && echo Removing $repo
+    rm $repo
+}
+
+function do_superclean () {
+    local distro=$1; shift
+    dir=/etc/vservers/.distributions/$distro/yum.repos.d/
+    [ -n "$VERBOSE" ] && echo Removing all repo files in $dir
+    rm $dir/*.repo
+}
+
+function usage () {
+    echo "Usage $COMMAND [options] <command>"
+    echo "  a help to manage the yum.repos.d template in /etc/vservers/.distributions/<distro>"
+    echo "Available commands"
+    echo "  display: shows content (default if <command> is missing)"
+    echo "  diff: shows diff between current and what init would do"
+    echo "  init: creates /etc/vservers/.distributions/<distro>/yum.repos.d/building.repo"
+    echo "  clean: removes building.repo"
+    echo "  superclean: removes yum.repos.d altogether"
+    echo "Options"
+    echo "  -u URL to specify another location"
+    echo "     default is to use mirror root at $default_url"
+    echo "  -f <distro> : defaults to $default_distro"
+    echo "  -a : runs on all distros $all_distros"
+    echo "  -0 : turns off gpgcheck"
+    echo "  -v : verbose"
+    echo "Examples"
+    echo "  $COMMAND -a display "
+    echo "  $COMMAND -a superclean"
+    echo "  $COMMAND -a -u http://mirror.one-lab.org/ init"
+    echo "  $COMMAND -a display"
+    exit 1
+}
+    
+DISTROS=""
+URL=""
+VERBOSE=""
+GPGOFF=""
+
+function main () {
+
+    while getopts "u:f:a0v" opt; do
+	case $opt in
+	    u) URL=$OPTARG ;;
+	    f) DISTROS="$DISTROS $OPTARG" ;;
+	    a) DISTROS="$DISTROS $all_distros" ;;
+	    0) GPGOFF=true ;;
+	    v) VERBOSE=true ;;
+	    *) usage ;;
+	esac
+    done
+
+    shift $(($OPTIND - 1))
+    
+    # no action = display
+    case "$#" in 
+	0)
+	    action=display ;;
+	1) 
+	    action=$1; shift
+	    case $action in
+		disp*) action=display ;;
+		init*) action=init ;;
+		diff*) action=diff ;;
+		clea*) action=clean ;;
+		super*) action=superclean ;;
+		*) usage ;;
+	    esac ;;
+	*)
+	    usage ;;
+    esac
+
+    [ -z "$URL" ] && URL=$default_url
+    [ -z "$DISTROS" ] && DISTROS="$default_distro"
+
+    # remove trailing slash
+    URL=$(echo $URL | sed -e 's,/$,,')
+
+    for distro in $DISTROS; do
+	[ -n "$VERBOSE" ] && echo ==================== Running $action for $distro
+	check_distro $distro && do_$action $distro
+    done
+
+    exit 0
+}
+
+main "$@"
diff --git a/module-tools.py b/module-tools.py
index 1a7ad8e2..85c4510c 100755
--- a/module-tools.py
+++ b/module-tools.py
@@ -532,7 +532,7 @@ that for other purposes than tagging"""%topdir
 
 ##############################
     sync_warning="""*** WARNING
-The module-init function has the following limitations
+The module-sync function has the following limitations
 * it does not handle changelogs
 * it does not scan the -tags*.mk files to adopt the new tags"""
 
diff --git a/onelab-install.mk b/onelab-install.mk
deleted file mode 100644
index 0d54a306..00000000
--- a/onelab-install.mk
+++ /dev/null
@@ -1,78 +0,0 @@
-#
-# Thierry Parmentelat - INRIA Sophia Antipolis 
-#
-### $Id$
-# 
-# Installation rules
-# 
-
-install:
-	@echo WARNING: this target is deprecated
-	@echo you might siwh to use the noderepo rpm instead
-	@echo former behaviour is available throuhg make install-obsolete
-
-# make install :
-# 	uses $(PLCSSH) as an ssh address for the destination host
-# 	first copies everything on a separate rpm repo, prepares it, 
-#	and then renames it into planetlab
-
-# Upload packages to boot server
-
-# use PLCHOST if set
-ifdef PLCHOST
-PLCSSH:=root@$(PLCHOST)
-endif
-# if nothing's defined : use this default
-ifndef PLCSSH
-PLCSSH		:= root@private.one-lab.org
-endif
-
-RPMSAREA	:= /var/www/html/install-rpms/
-
-BUILD_BASE	:= $(shell cat .base 2> /dev/null || echo base-undefined)
-BASENEW		:= build-$(BUILD_BASE)
-BASEBAK		:= planetlab-bak
-BASE		:= planetlab
-
-##########
-# if make is invoked with -n, run rsync, but with --dry-run
-RSYNC_COND_DRY_RUN	:= $(if $(findstring n,$(MAKEFLAGS)),--dry-run,)
-RSYNC			:= rsync $(RSYNC_COND_DRY_RUN) 
-
-INSTALL-TARGETS := install-rpms install-index install-adopt install-bootstrap
-install-obsolete: $(INSTALL-TARGETS)
-.PHONY: install install-obsolete $(INSTALL-TARGETS)
-
-install-help:
-	@echo install-obsolete: $(INSTALL-TARGETS)
-
-# compute the exact set of rpms to install - we do not need bootstrapfs nor myplc here
-node_packages=$(sort $(IN_VSERVER) $(IN_BOOTSTRAPFS))
-node_rpms=$(foreach package,$(node_packages),$($(package).rpms))
-
-install-rpms:RPMS/yumgroups.xml
-        # create repository
-	ssh $(PLCSSH) mkdir -p /plc/data/$(RPMSAREA)/$(BASENEW)
-	# populate
-	+$(RSYNC) -v --perms --times --group --compress --rsh=ssh \
-	   RPMS/yumgroups.xml $(node_rpms) $(PLCSSH):/plc/data/$(RPMSAREA)/$(BASENEW)/
-
-install-index:
-	# sign and index new repository
-	ssh $(PLCSSH) chroot /plc/root /etc/plc.d/packages start $(RPMSAREA)/$(BASENEW)/ 2>> install-index.log
-
-install-clean-index:
-	# sign and index new repository
-	ssh $(PLCSSH) chroot /plc/root /etc/plc.d/packages clean $(RPMSAREA)/$(BASENEW)/ 2>> install-index.log
-
-install-adopt:
-	# cleanup former bak
-	ssh $(PLCSSH) rm -rf /plc/data/$(RPMSAREA)/$(BASEBAK)
-	# bak previous repo
-	ssh $(PLCSSH) mv /plc/data/$(RPMSAREA)/$(BASE) /plc/data/$(RPMSAREA)/$(BASEBAK)
-	# install new repo
-	ssh $(PLCSSH) mv /plc/data/$(RPMSAREA)/$(BASENEW) /plc/data/$(RPMSAREA)/$(BASE)
-
-install-bootstrap:
-	# install node image
-	ssh $(PLCSSH) chroot /plc/root yum -y update bootstrapfs
diff --git a/planetlab-install.mk b/planetlab-install.mk
deleted file mode 100644
index d1a289a4..00000000
--- a/planetlab-install.mk
+++ /dev/null
@@ -1,72 +0,0 @@
-#XXX We need to rethink this installation support for several reasons:
-# 1) it is pldistro specific
-# 2) may involve installing files for different node groups (e.g., alpha, beta, etc.)
-# 3) may involve N rpm repositories to where it should be uploaded
-#
-# Not clear to me at all that this should be incorporated into a
-# Makefile at all.  Instead it should be something that gets wrapped
-# into a myplc (sub) rpm package and then is installed by that way.
-
-#
-# Installation rules
-# 
-
-# Upload packages to boot server
-SERVERA := build@boot1.planet-lab.org
-SERVERB := build@boot2.planet-lab.org
-ARCHIVE := /plc/data/var/www/html/install-rpms/archive
-
-# Put nightly alpha builds in a subdirectory
-ifeq ($(TAG),HEAD)
-ARCHIVE := $(ARCHIVE)/planetlab-alpha
-REPOS := /plc/data/var/www/html/install-rpms/planetlab-alpha
-endif
-
-install:
-ifeq ($(BASE),)
-	@echo make install is only meant to be called from ./build.sh
-else
-ifneq ($(wildcard /etc/planetlab/secring.gpg),)
-        # Sign all RPMS. setsid detaches rpm from the terminal,
-        # allowing the (hopefully blank) GPG password to be entered
-        # from stdin instead of /dev/tty. Obviously, the build server
-        # should be secure.
-	echo | setsid rpm \
-	--define "_signature gpg" \
-	--define "_gpg_path /etc/planetlab" \
-	--define "_gpg_name PlanetLab <info@planet-lab.org>" \
-	--resign RPMS/*/*.rpm
-endif
-ifneq ($(BUILDS),)
-        # Remove old runs
-	echo "cd $(ARCHIVE) && ls -t | sed -n $(BUILDS)~1p | xargs rm -rf" | ssh $(SERVERA) /bin/bash -s
-	echo "cd $(ARCHIVE) && ls -t | sed -n $(BUILDS)~1p | xargs rm -rf" | ssh $(SERVERB) /bin/bash -s
-endif
-        # Create package manifest
-	sh ./packages.sh -b "http://build.planet-lab.org/$(subst $(HOME)/,,$(shell pwd))/RPMS" RPMS > packages.xml
-        # Update yum metadata
-	yum-arch RPMS >/dev/null
-	createrepo -g yumgroups.xml RPMS >/dev/null
-        # Populate repository
-	rsync \
-	--exclude '*-debuginfo-*' \
-	--recursive --links --perms --times --group --compress --rsh=ssh \
-	RPMS/ $(SERVERA):$(ARCHIVE)/$(BASE)
-	rsync \
-	--exclude '*-debuginfo-*' \
-	--recursive --links --perms --times --group --compress --rsh=ssh \
-	RPMS/ $(SERVERB):$(ARCHIVE)/$(BASE)
-ifeq ($(TAG),HEAD)
-        # Update nightly alpha symlink if it does not exist or is broken, or it is Monday
-	if ! ssh $(SERVERA) "[ -e $(REPOS) ] && exit 0 || exit 1" || [ "$(shell date +%A)" = "Monday" ] ; then \
-	    ssh $(SERVERA) ln -nsf archive/$(BASE) $(REPOS) ; \
-	fi
-        # Update nightly alpha symlink if it does not exist or is broken, or it is Monday
-	if ! ssh $(SERVERB) "[ -e $(REPOS) ] && exit 0 || exit 1" || [ "$(shell date +%A)" = "Monday" ] ; then \
-	    ssh $(SERVERB) ln -nsf archive/$(BASE) $(REPOS) ; \
-	fi
-
-endif
-endif
-
-.PHONY: install
diff --git a/vbuild-nightly.sh b/vbuild-nightly.sh
index adcea1fc..8e86a3da 100755
--- a/vbuild-nightly.sh
+++ b/vbuild-nightly.sh
@@ -10,7 +10,6 @@ DEFAULT_PLDISTRO=planetlab
 DEFAULT_PERSONALITY=linux32
 DEFAULT_BASE="@DATE@--@PLDISTRO@-@FCDISTRO@-@PERSONALITY@"
 DEFAULT_SVNPATH="http://svn.planet-lab.org/svn/build/trunk"
-# TESTSVNPATH to be computed from the -tags.mk file - no default anymore
 DEFAULT_TESTCONFIG="default"
 DEFAULT_IFNAME=eth0
 
@@ -157,8 +156,8 @@ function build () {
     make -C /build $DRY_RUN "${MAKEVARS[@]}" stage1=true 
     # versions
     make -C /build $DRY_RUN "${MAKEVARS[@]}" versions
-    # store testsvnpath
-    make -C /build $DRY_RUN "${MAKEVARS[@]}" stage1=true testsvnpath
+    # store tests_svnpath
+    make -C /build $DRY_RUN "${MAKEVARS[@]}" stage1=true tests_svnpath
     # actual stuff
     make -C /build $DRY_RUN "${MAKEVARS[@]}" $MAKETARGETS
 
@@ -173,16 +172,18 @@ function runtest () {
 
     echo -n "============================== Starting $COMMAND:runtest on $(date)"
 
-    # where to find TESTSVNPATH
-    stamp=/vservers/$BASE/build/testsvnpath
+    # where to find TESTS_SVNPATH
+    stamp=/vservers/$BASE/build/tests_svnpath
     if [ ! -f $stamp ] ; then
-	echo "$COMMAND: Cannot figure TESTSVNPATH from missing $stamp"
+	echo "$COMMAND: Cannot figure TESTS_SVNPATH from missing $stamp"
 	failure
 	exit 1
     fi
-    TESTSVNPATH=$(cat $stamp)
-    # use only this pat of the tests right now
-    TESTSVNPATH=${TESTSVNPATH}/system
+    TESTS_SVNPATH=$(cat $stamp)
+    # xxx - Thierry - need to rework the test framework in tests/system so it can work
+    # with the entire tests/ module checked out, rather than only tests/system/ 
+    # ugly workaround for now
+    SYSTEM_SVNPATH=${TESTS_SVNPATH}/system
 
     ### the URL to the RPMS/<arch> location
     url=""
@@ -204,8 +205,10 @@ function runtest () {
     testdir=${BASE}
     # clean it
     ssh -n ${TESTBOXSSH} rm -rf ${testdir}
-    # check it out
-    ssh -n ${TESTBOXSSH} svn co ${TESTSVNPATH} ${testdir}
+    # check it out 
+    ssh -n ${TESTBOXSSH} svn co ${SYSTEM_SVNPATH} ${testdir}
+    # check out the entire tests/ module (with system/ duplicated) as a subdir - see xxx above
+    ssh -n ${TESTBOXSSH} svn co ${TESTS_SVNPATH} ${testdir}/tests
     # invoke test on testbox - pass url and build url - so the tests can use vtest-init-vserver.sh
     configs=""
     for config in ${TESTCONFIG} ; do
-- 
2.47.0