X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=mkfedora;h=9dc3cac9bba9d7e9235dabd67b15ae06391fbf75;hb=df819bfec0030da5865e017d9c1fa298835d80e2;hp=7465ce37816f45fe49f76d85994e17ce3cbf0475;hpb=d98c204c0aefefd6466604181bd57258dc56f7d8;p=build.git diff --git a/mkfedora b/mkfedora index 7465ce37..9dc3cac9 100755 --- a/mkfedora +++ b/mkfedora @@ -1,6 +1,6 @@ #!/bin/bash # -# Builds a Fedora Core reference image. Requires the build server to +# Builds a Fedora reference image. Requires the build server to # host a local yum repository in one of: # # /usr/share/mirrors/fedora @@ -13,18 +13,22 @@ # Mark Huang # Copyright (C) 2004-2006 The Trustees of Princeton University # -# $Id: mkfedora,v 1.21 2006/08/22 12:37:08 thierry 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 -http://coblitz.planet-lab.org/pub/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 @@ -50,6 +54,7 @@ exclude_kernel= 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 @@ -75,12 +80,6 @@ usage() exit 1 } -### post-process output of createrepo --quiet or of yum-arch -# replaces ^M with ^J, and removes whitespace-only lines -function post-filter () { - tr '\r' '\n' | grep -v '^ *$' -} - # Get options while getopts "l:r:a:g:p:x:kvh" opt ; do case $opt in @@ -136,20 +135,36 @@ fetch () 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 - 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 + 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 - unset baseurl done - if [ -n "$baseurl" ] ; then - break - fi - unset baseurl done if [ -z "$baseurl" ] ; then @@ -157,9 +172,9 @@ if [ -z "$baseurl" ] ; then 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 + for attempt in $attempts ; do + echo $mirror/$attempt + done done echo usage @@ -172,50 +187,42 @@ if [ $verbose -eq 0 ] ; then exec 2>/dev/null fi -# Minimally initialize /dev in reference image. If installed, the dev -# or udev RPMs will fill in the rest. -mkdir -p $vroot/dev -mknod -m 666 $vroot/dev/null c 1 3 -mknod -m 666 $vroot/dev/zero c 1 5 -mknod -m 666 $vroot/dev/full c 1 7 -mknod -m 644 $vroot/dev/random c 1 8 -mknod -m 644 $vroot/dev/urandom c 1 9 -mknod -m 666 $vroot/dev/tty c 5 0 -mknod -m 666 $vroot/dev/ptmx c 5 2 -# For bash command substitution -ln -nsf ../proc/self/fd $vroot/dev/fd -# For df and linuxconf -touch $vroot/dev/hdv1 -# For mkinitrd (in case a kernel is being installed) -for i in $(seq 0 7) ; do - mknod -m 640 $vroot/dev/loop$i b 7 $i -done - # Do not tolerate errors set -e -# Mount /dev/pts in reference image -mkdir -p $vroot/dev/pts -mount -t devpts none $vroot/dev/pts +## 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' +cat > /etc/rpm/macros <$vroot/etc/fstab <$vroot/etc/yum.conf <>$vroot/etc/yum.conf <