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.1 2006/04/05 20:32:28 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 # 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]}
88 if [ -z "$line" ] ; then
90 elif grep -q "^\[$repository\]" <<<$line ; then
92 elif [ "$baseurl" = "$repository" ] && grep -q "^baseurl=" <<<$line ; then
95 # We could parse headers/header.info and/or
96 # repodata/primary.xml.gz to figure out where the
97 # package actually is within the repository, but
98 # it would be too much trouble. Just try
99 # downloading it from one of the common
101 echo "* $slice: $repository $package-$version.$arch.rpm"
102 for subdirectory in "" Fedora/RPMS $arch ; do
103 if curl --fail --silent --max-time 60 $baseurl/$subdirectory/$package-$version.$arch.rpm \
104 >$rpms/$package-$version.$arch.rpm ; then
107 rm -f $rpms/$package-$version.$arch.rpm
110 # Assert that we got it successfully
111 if [ ! -f $rpms/$package-$version.$arch.rpm ] ; then
112 echo "Failed to fetch $package-$version.$arch.rpm from $repository" >&2
116 dependencies[${#dependencies[*]}]=$package-$version.$arch.rpm
119 done <$vroot/etc/yum.conf
120 done < <((yum -c $vroot/etc/yum.conf --installroot=$vroot shell <<EOF
125 ) | sed -ne '/^Installing:/,/^Transaction Summary/p'
128 # This is pretty fucked up. Turn on verbose debugging and the
129 # --download-only option, which, contrary to what you might
130 # think the option means, downloads the headers, not the
131 # packages themselves. In any case, verbose debugging prints
132 # out the baseURL and path of each RPM that it would download
133 # if --download-only were not specified.
137 if [ -z "$baseURL" ] ; then
138 baseURL=$(sed -ne 's/failover: baseURL = \(.*\)/\1/p' <<<$line)
139 elif [ -z "$path" ] ; then
140 path=$(sed -ne 's/failover: path = \(.*\)/\1/p' <<<$line)
142 if [ "${path##*.}" = "rpm" ] ; then
143 echo "* $slice: $(basename $path)"
144 curl --fail --silent --max-time 60 $baseURL/$path >$rpms/$(basename $path)
145 dependencies[${#dependencies[*]}]=$(basename $path)
150 done < <(yum -d 3 -c $vroot/etc/yum.conf --installroot=$vroot -y --download-only install $packages 2>&1)
153 for dependency in "${dependencies[@]}" ; do
155 done >$rpms/$slice.lst
159 yum -c $vroot/etc/yum.conf --installroot=$vroot -y \
163 rm -f $vroot/var/lib/rpm/__db*