be smarter when locating myplc rpm, for non i386 archs
[build.git] / build.common
index 255344a..477b52f 100644 (file)
@@ -79,9 +79,6 @@ pl_DISTRO=$(pl_getDistro)
 # 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)
 
@@ -172,23 +169,10 @@ function pl_root_makedevs() {
     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)"
@@ -212,20 +196,13 @@ function pl_root_mkfedora () {
 # 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
@@ -254,17 +231,28 @@ function pl_root_mkfedora () {
 
     # parse pkgsfile and add to local vars
     fcdistro=${pl_DISTRO_NAME}
-    pkgs_packages=(pl_parsePkgs package $fcdistro $pldistro $pkgsfile) 
-    pkgs_groups=(pl_parsePkgs group $fcdistro $pldistro $pkgsfile)
+    pkgs_packages=$(pl_parsePkgs package $fcdistro $pldistro $pkgsfile) 
+    pkgs_groups=$(pl_parsePkgs group $fcdistro $pldistro $pkgsfile)
     # packages to exclude - obsolete, was maybe useful when installing a group
     pkgs_excludes=$(pl_parsePkgs exclude $fcdistro $pldistro $pkgsfile) 
     pkgs_junk=$(pl_parsePkgs junk $fcdistro $pldistro $pkgsfile)
     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 ()
     {
@@ -288,11 +276,11 @@ linux/core/$releasever/$basearch/os
     fi
 
     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
@@ -306,7 +294,7 @@ linux/core/$releasever/$basearch/os
        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
@@ -451,18 +439,18 @@ fi
 
     # Go, baby, go
     if [ -n "$pkgs_packages" ] ; then
-       echo "* Installing optional packages" "$pkgs_packages" 
+       echo "* Installing optional packages" $pkgs_packages
        yum -c $vroot/etc/yum.conf --installroot=$vroot -y $exclude_arg \
-           install "$pkgs_packages"
-       if ! rpm --root $vroot -q "$pkgs_packages" >/dev/null ; then
+           install $pkgs_packages
+       if ! rpm --root $vroot -q $pkgs_packages >/dev/null ; then
            echo "* Warning: Missing packages"
-           rpm --root $vroot -q "$pkgs_packages" | grep "not installed"
+           rpm --root $vroot -q $pkgs_packages | grep "not installed"
        fi
     fi
 
     if [ -n "$pkgs_groups" ] ; then
        ## call yum sequentially to get finer-grained info on dependencies
-       for grp in "$pkgs_groups" ; do
+       for grp in $pkgs_groups ; do
            echo "* Installing optional group $grp" 
            yum -c $vroot/etc/yum.conf --installroot=$vroot -y $exclude_arg \
                groupinstall "$grp"