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
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 # pl_netflow requires third party MySQL RPMs
31 file:///usr/share/mirrors/mysql
32 http://boot.planet-lab.org/install-rpms/3rdparty
35 for mirror in "${mysql_mirrors[@]}" ; do
37 if list $baseurl | grep -q "MySQL-server.*rpm" ; then
43 if [ -z "$baseurl" ] ; then
44 echo "Error: MySQL-server RPM package"
45 echo " could not be found in any of the following locations:"
47 for mirror in ${mysql_mirrors[@]} ; do
54 # Add MySQL mirror to yum.conf
55 if ! grep -q mysql $vroot/etc/yum.conf ; then
56 cat >>$vroot/etc/yum.conf <<EOF
64 # Space separated list of required packages
66 pl_conf="sidewinder-PlanetLab-SCS sidewinder-common"
68 for slice in pl_netflow pl_conf ; do
72 if yum --help | grep -q shell ; then
73 while read -a words ; do
74 if [ ${#words[*]} -lt 5 ] ; then
78 # netflow i386 3.1-23.planetlab.2006.04.04 bootstrap 61 k
82 # Remove the epoch from the version
83 version=${version##*:}
84 repository=${words[3]}
86 if [ -f $rpms/$package-$version.$arch.rpm ] ; then
92 if grep -q "^\[$repository\]" <<<$line ; then
94 elif [ "$baseurl" = "$repository" ] && grep -q "^baseurl=" <<<$line ; then
97 # We could parse headers/header.info and/or
98 # repodata/primary.xml.gz to figure out where the
99 # package actually is within the repository, but
100 # it would be too much trouble. Just try
101 # downloading it from one of the common
103 echo "* $slice: $repository $package-$version.$arch.rpm"
104 for subdirectory in "" Fedora/RPMS $arch ; do
105 if curl --fail --silent --max-time 60 $baseurl/$subdirectory/$package-$version.$arch.rpm \
106 >$rpms/$package-$version.$arch.rpm ; then
109 rm -f $rpms/$package-$version.$arch.rpm
112 # Assert that we got it successfully
113 if [ ! -f $rpms/$package-$version.$arch.rpm ] ; then
114 echo "Failed to fetch $package-$version.$arch.rpm from $repository" >&2
118 dependencies[${#dependencies[*]}]=$package-$version.$arch.rpm
121 done <$vroot/etc/yum.conf
122 done < <(yum -c $vroot/etc/yum.conf --installroot=$vroot shell <<EOF
129 # This is pretty fucked up. Turn on verbose debugging and the
130 # --download-only option, which, contrary to what you might
131 # think the option means, downloads the headers, not the
132 # packages themselves. In any case, verbose debugging prints
133 # out the baseURL and path of each RPM that it would download
134 # if --download-only were not specified.
138 if [ -z "$baseURL" ] ; then
139 baseURL=$(sed -ne 's/failover: baseURL = \(.*\)/\1/p' <<<$line)
140 elif [ -z "$path" ] ; then
141 path=$(sed -ne 's/failover: path = \(.*\)/\1/p' <<<$line)
143 if [ "${path##*.}" = "rpm" ] ; then
144 echo "* $slice: $(basename $path)"
145 curl --fail --silent --max-time 60 $baseURL/$path >$rpms/$(basename $path)
146 dependencies[${#dependencies[*]}]=$(basename $path)
151 done < <(yum -d 3 -c $vroot/etc/yum.conf --installroot=$vroot -y --download-only install $packages 2>&1)
154 for dependency in "${dependencies[@]}" ; do
156 done >$rpms/$slice.lst
160 yum -c $vroot/etc/yum.conf --installroot=$vroot -y \
164 rm -f $vroot/var/lib/rpm/__db*