# select basearch of the host devel environment - protected for macos for local tests
pl_DISTRO_ARCH=$(uname -i 2>/dev/null|| echo unknownarch)
-# let mkfedora select one of its mirrors
-pl_DISTRO_URL=""
-
# the release number (plain number)
pl_DISTRO_RELEASE=$(pl_getRelease)
done
}
-# Default yum repositories to try
-mirrors=(
- file:///data/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
- ftp://mirror.stanford.edu/pub/mirrors/fedora
- ftp://rpmfind.net/linux/fedora
- )
-
function mkfedora_usage() {
echo "Usage: pl_root_mkfedora [OPTION]... basedir pldistro pkgsfile(s)"
- echo " -l url Fedora mirror location. Default is to try:"
- for mirror in "${mirrors[@]}" ; do
- echo " $mirror"
- done
+ echo " -l url Fedora mirror location."
+ echo " Defaults are searched in <pldistro>.mirrors"
echo " -v Be verbose"
echo " -h This message"
echo " target selection (defaults based on current build vserver)"
# Release and architecture to install : defaults to current vserver's settings or previously parsed fedora_options
releasever=$pl_DISTRO_RELEASE
basearch=$pl_DISTRO_ARCH
- [ -n "$pl_DISTRO_URL" ] && mirrors=($pl_DISTRO_URL)
# Get options
+ mirrors=""
while getopts "l:r:a:vh" opt ; do
case $opt in
l)
- if echo $OPTARG | grep -q -i '^\(file\|http[s]*\)://' ; then
- mirrors=($OPTARG)
- else
- # xxx rather use this as a .mirrors file, searched in config.pldistro/
- # that would use the pkgs syntax with mirror:
- #mirrors=($(pl_parsePkgs mirror <fcdistro> <pldistro> $(pl_locateDistroFile ../build/ <pldistro> $OPTARG.mirrors)))
- mirrors=(file://$OPTARG)
- fi
+ mirrors="$mirrors $OPTARG"
;;
r)
releasever=$OPTARG
pkgs_precious=$(pl_parsePkgs precious $fcdistro $pldistro $pkgsfile)
# formerly related to mkfedora -k
pkgs_kexcludes=$(pl_parsePkgs kexclude $fcdistro $pldistro $pkgsfile)
+ # get mirrors if not specified with -l
+ if [ -z "$mirrors" ] ; then
+ mirrorsfile=$(pl_locateDistroFile ../build/ $pldistro "$pldistro.mirrors")
+ mirrors=$(pl_parsePkgs mirror $fcdistro $pldistro $mirrorsfile)
+ fi
exclude_kernel=""
- [ -n "$pkgs_kexcludes" ] && exclude_kernel="exclude=$pkgs_excludes"
+ # add them manually as the output of pl_parsePkgs is line-separated
+ if [ -n "$pkgs_kexcludes" ] ; then
+ exclude_kernel="exclude="
+ for kexclude in $pkgs_kexcludes ; do
+ exclude_kernel="$exclude_kernel $kexclude"
+ done
+ fi
function mkfedora_fetch ()
{
curl --fail --silent --max-time 60 "$1"
}
- # set list of attempted locations according to releasever
- if [ $releasever -ge 7 ] ; then
- attempts="
+ # set list of attempted locations according to target distro
+ # xxx all this should go into mirroring/ somehow
+ case $pl_DISTRO in
+ Fedora)
+ if [ $releasever -ge 7 ] ; then
+ # Plain Fedora comes with a new layout
+ attempts="
+fedora/releases/$releasever/Everything/$basearch/os
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
+ else
+ # Fedora Core
+ attempts="
+fedora/core/$releasever/$basearch/os
+linux/core/$releasever/$basearch/os
+core/$releasever/$basearch/os
+$releasever/$basearch/os
+"
+ fi
+ public_gpg_key=RPM-GPG-KEY-fedora
+ ;;
+ CentOS)
+ # xxx hacky for now
+ # you can use vbuild-fedora-mirror with -f centos5.1
+ # which is hard-coded in mirroring/centos as well
+ # for now I do the mapping here, mmhh
+ case $releasever in
+ 4) actual=4.6 ;;
+ 5) actual=5.1 ;;
+ *) actual=$releasever ;;
+ esac
+ attempts="
+centos/$actual/os/$basearch
+"
+ public_gpg_key=RPM-GPG-KEY-CentOS-$releasever
+ ;;
+ *)
+ echo "distro $pl_DISTRO not supported in build.common / mkfedora" ; exit 1
+ esac
echo "$0: candidate mirrors"
- for mirror in "${mirrors[@]}" ; do
+ for mirror in $mirrors ; do
echo "* candidate mirror $mirror"
done
baseurl=""
- for mirror in "${mirrors[@]}" ; do
+ for mirror in $mirrors ; do
for attempt in $attempts; do
attempturl=$mirror/$attempt
if mkfedora_fetch $attempturl/repodata/repomd.xml >/dev/null ; then
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 mirror in $mirrors ; do
for attempt in $attempts ; do
echo $mirror/$attempt
done
# Initialize RPM database in reference image
mkdir -p $vroot/var/lib/rpm
rpm --root $vroot --initdb
- rpm --root $vroot --import $baseurl/RPM-GPG-KEY-fedora
+ rpm --root $vroot --import $baseurl/$public_gpg_key
# Initialize yum in reference image
mkdir -p $vroot/var/cache/yum $vroot/var/log