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.5 2007/08/24 06:06:04 mef Exp $
12 export PATH=/sbin:/bin:/usr/sbin:/usr/bin
14 vroot=$PWD/vservers/.vref/default
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
32 for vref in planetflow ; do
36 if yum --help | grep -q shell ; then
37 while read -a words ; do
38 if [ ${#words[*]} -lt 5 ] ; then
42 # netflow i386 3.1-23.planetlab.2006.04.04 bootstrap 61 k
46 # Remove the epoch from the version
47 version=${version##*:}
48 repository=${words[3]}
52 if [ -z "$line" ] ; then
54 elif grep -q "^\[$repository\]" <<<$line ; then
56 elif [ "$baseurl" = "$repository" ] && grep -q "^baseurl=" <<<$line ; then
59 # We could parse headers/header.info and/or
60 # repodata/primary.xml.gz to figure out where the
61 # package actually is within the repository, but
62 # it would be too much trouble. Just try
63 # downloading it from one of the common
65 echo "* $vref: $repository $package-$version.$arch.rpm"
66 for subdirectory in "" Fedora/RPMS Fedora $arch ; do
67 if curl --fail --silent --max-time 60 $baseurl/$subdirectory/$package-$version.$arch.rpm \
68 >$rpms/$package-$version.$arch.rpm ; then
71 rm -f $rpms/$package-$version.$arch.rpm
74 # Assert that we got it successfully
75 if [ ! -f $rpms/$package-$version.$arch.rpm ] ; then
76 echo "Failed to fetch $package-$version.$arch.rpm from $repository ($baseurl/$subdirectory)" >&2
80 dependencies[${#dependencies[*]}]=$package-$version.$arch.rpm
83 done <$vroot/etc/yum.conf
84 done < <((yum -c $vroot/etc/yum.conf --installroot=$vroot shell <<EOF
89 ) | sed -ne '/^Installing:/,/^Transaction Summary/p'
92 # This is pretty fucked up. Turn on verbose debugging and the
93 # --download-only option, which, contrary to what you might
94 # think the option means, downloads the headers, not the
95 # packages themselves. In any case, verbose debugging prints
96 # out the baseURL and path of each RPM that it would download
97 # if --download-only were not specified.
101 if [ -z "$baseURL" ] ; then
102 baseURL=$(sed -ne 's/failover: baseURL = \(.*\)/\1/p' <<<$line)
103 elif [ -z "$path" ] ; then
104 path=$(sed -ne 's/failover: path = \(.*\)/\1/p' <<<$line)
106 if [ "${path##*.}" = "rpm" ] ; then
107 echo "* $vref: $(basename $path)"
108 curl --fail --silent --max-time 60 $baseURL/$path >$rpms/$(basename $path)
109 dependencies[${#dependencies[*]}]=$(basename $path)
114 done < <(yum -d 3 -c $vroot/etc/yum.conf --installroot=$vroot -y --download-only install $packages 2>&1)
117 for dependency in "${dependencies[@]}" ; do
119 done >$rpms/$vref.lst
123 yum -c $vroot/etc/yum.conf --installroot=$vroot -y \
127 rm -f $vroot/var/lib/rpm/__db*