3 # Download dependencies that would be necessary to build the
4 # pl_netflow and pl_conf root slices from the vserver-reference image.
6 # Mark Huang <mlhuang@cs.princeton.edu>
7 # Copyright (C) 2004-2006 The Trustees of Princeton University
9 # $Id: system-packages.sh,v 1.2 2006/04/10 22:21:48 mlhuang Exp $
12 export PATH=/sbin:/bin:/usr/sbin:/usr/bin
14 vroot=$PWD/vservers/vserver-reference
15 rpms=$PWD/vservers/system-packages
16 install -d -m 755 $rpms
18 # curl can't list file:// URLs
22 if [ -e ${url#file://} ] ; then
23 /bin/ls ${url#file://}
25 curl --fail --silent --max-time 60 $url
29 # Space separated list of required packages
31 pl_conf="sidewinder-PlanetLab-SCS sidewinder-common"
33 for slice in pl_netflow pl_conf ; do
37 if yum --help | grep -q shell ; then
38 while read -a words ; do
39 if [ ${#words[*]} -lt 5 ] ; then
43 # netflow i386 3.1-23.planetlab.2006.04.04 bootstrap 61 k
47 # Remove the epoch from the version
48 version=${version##*:}
49 repository=${words[3]}
53 if [ -z "$line" ] ; then
55 elif grep -q "^\[$repository\]" <<<$line ; then
57 elif [ "$baseurl" = "$repository" ] && grep -q "^baseurl=" <<<$line ; then
60 # We could parse headers/header.info and/or
61 # repodata/primary.xml.gz to figure out where the
62 # package actually is within the repository, but
63 # it would be too much trouble. Just try
64 # downloading it from one of the common
66 echo "* $slice: $repository $package-$version.$arch.rpm"
67 for subdirectory in "" Fedora/RPMS $arch ; do
68 if curl --fail --silent --max-time 60 $baseurl/$subdirectory/$package-$version.$arch.rpm \
69 >$rpms/$package-$version.$arch.rpm ; then
72 rm -f $rpms/$package-$version.$arch.rpm
75 # Assert that we got it successfully
76 if [ ! -f $rpms/$package-$version.$arch.rpm ] ; then
77 echo "Failed to fetch $package-$version.$arch.rpm from $repository" >&2
81 dependencies[${#dependencies[*]}]=$package-$version.$arch.rpm
84 done <$vroot/etc/yum.conf
85 done < <((yum -c $vroot/etc/yum.conf --installroot=$vroot shell <<EOF
90 ) | sed -ne '/^Installing:/,/^Transaction Summary/p'
93 # This is pretty fucked up. Turn on verbose debugging and the
94 # --download-only option, which, contrary to what you might
95 # think the option means, downloads the headers, not the
96 # packages themselves. In any case, verbose debugging prints
97 # out the baseURL and path of each RPM that it would download
98 # if --download-only were not specified.
102 if [ -z "$baseURL" ] ; then
103 baseURL=$(sed -ne 's/failover: baseURL = \(.*\)/\1/p' <<<$line)
104 elif [ -z "$path" ] ; then
105 path=$(sed -ne 's/failover: path = \(.*\)/\1/p' <<<$line)
107 if [ "${path##*.}" = "rpm" ] ; then
108 echo "* $slice: $(basename $path)"
109 curl --fail --silent --max-time 60 $baseURL/$path >$rpms/$(basename $path)
110 dependencies[${#dependencies[*]}]=$(basename $path)
115 done < <(yum -d 3 -c $vroot/etc/yum.conf --installroot=$vroot -y --download-only install $packages 2>&1)
118 for dependency in "${dependencies[@]}" ; do
120 done >$rpms/$slice.lst
124 yum -c $vroot/etc/yum.conf --installroot=$vroot -y \
128 rm -f $vroot/var/lib/rpm/__db*