# Mark Huang <mlhuang@cs.princeton.edu>
# Copyright (C) 2004-2006 The Trustees of Princeton University
#
-# $Id: mkfedora,v 1.33 2007/08/31 02:23:08 mef Exp $
+# $Id$
#
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
+echo "* Entering mkfedora " "$@"
+
# Verbosity
verbose=0
# Default yum repositories to try
mirrors=(
file:///data/fedora
-ftp://smoke.cs.princeton.edu/pub/mirrors/fedora
+http://localhost/fedora
+http://build.planet-lab.org/fedora
http://coblitz.codeen.org/coblitz.planet-lab.org/pub/fedora
ftp://mirror.cs.princeton.edu/pub/mirrors/fedora
-http://coblitz.planet-lab.org/pub/fedora
ftp://mirror.stanford.edu/pub/mirrors/fedora
ftp://rpmfind.net/linux/fedora
-http://fedora.laptop.org/fedora-linux-releases
)
# Release and architecture to install
if [ -f /etc/planetlab/plc_config ] ; then
. /etc/planetlab/plc_config
if [ -n "$PLC_DEVEL_FEDORA_URL" ] ; then
+ echo "* mkfedora : setting mirrors from /etc/planetlab/config"
mirrors=($PLC_DEVEL_FEDORA_URL)
fi
fi
curl --fail --silent --max-time 60 "$1"
}
+# hard to find two mirrors with a similar layout
+# set list of attempted locations according to releasever
+if [ $releasever -ge 7 ] ; then
+ attempts="
+linux/releases/$releasever/Everything/$basearch/os
+$releasever/Everything/$basearch/os
+core/$releasever/Everything/$basearch/os
+linux/core/$releasever/$basearch/os
+"
+else
+ attempts="
+linux/core/$releasever/$basearch/os
+core/$releasever/$basearch/os
+$releasever/$basearch/os
+"
+fi
+
+echo "$0: candidate mirrors"
for mirror in "${mirrors[@]}" ; do
- if [ $releasever -ge 7 ] ; then
- for baseurl in \
- $mirror/$releasever/Everything/$basearch/os ; do
- if fetch $baseurl/repodata/repomd.xml >/dev/null ; then
- break
- fi
- unset baseurl
- done
- else
- for baseurl in \
- $mirror/linux/core/$releasever/$basearch/os \
- $mirror/core/$releasever/$basearch/os \
- $mirror/$releasever/$basearch/os ; do
- if fetch $baseurl/repodata/repomd.xml >/dev/null ; then
- break
- fi
- unset baseurl
- done
- fi
- if [ -n "$baseurl" ] ; then
- break
- fi
- unset baseurl
+ echo "* candidate mirror $mirror"
+done
+baseurl=""
+for mirror in "${mirrors[@]}" ; do
+ for attempt in $attempts; do
+ attempturl=$mirror/$attempt
+ if fetch $attempturl/repodata/repomd.xml >/dev/null ; then
+ baseurl=$attempturl
+ break 2
+ fi
+ done
done
if [ -z "$baseurl" ] ; then
- if [ $releasever -ge 7 ] ; then
- echo "Error: $releasever/Everything/$basearch/os/repodata/repomd.xml"
- echo " could not be found in any of the following locations:"
- echo
- for mirror in ${mirrors[@]} ; do
- echo $mirror/linux
- done
- else
- 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
- echo $mirror/linux/core
- echo $mirror/core
- echo $mirror
- done
- fi
+ 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
usage
fi
# Do not tolerate errors
set -e
-# Mount /dev/pts and /dev/shm in reference image
+## make rpms ignore installing stuff to special fs entries like /proc
+# Because of https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=52725
+# you have to use at least one language beside 'C'
+# xxx fixme - this must be reviewed once we get the stuff running
+cat > /etc/rpm/macros <<EOF
+%_install_langs C:de:en:es:fr
+%_netsharedpath /proc:/dev/pts
+%_excludedocs yes
+EOF
+# copy to the vserver's rpm macros
+mkdir -p $vroot/etc/rpm
+cp /etc/rpm/macros $vroot/etc/rpm/macros
+
+# Mount in reference image
mount -t devpts none $vroot/dev/pts
mount -t tmpfs none $vroot/dev/shm
-
-# Mount /proc in reference image
mkdir -p $vroot/proc
mount -t proc none $vroot/proc
# Clean up before exiting if anything goes wrong
trap "cleanup" ERR INT
+# Create a /var/lib dirs for yum & rpm
+mkdir -p $vroot/var/lib/yum
+mkdir -p $vroot/var/lib/rpm
+mkdir -p $vroot/usr/share/info
+
# Create a dummy /etc/fstab in reference image
mkdir -p $vroot/etc
cat >$vroot/etc/fstab <<EOF