[PATCH] Take advantage of yum repos being available

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Instead of doing tricks with find, use repoquery and yumdownloader to download
things like anaconda-runtime and kernels and firmware packages.  This also
has the nice side effect of letting us run buildinstall against an http repo
---
 scripts/buildinstall |   59 ++++++++++++++++++++++++++++++++++---------------
 scripts/mk-images    |   40 +++++++++++++--------------------
 scripts/upd-instroot |   27 +++++-----------------
 3 files changed, 63 insertions(+), 63 deletions(-)

diff --git a/scripts/buildinstall b/scripts/buildinstall
index f6c1489..5866ae2 100755
--- a/scripts/buildinstall
+++ b/scripts/buildinstall
@@ -19,7 +19,7 @@
 #
 
 usage() {
-	echo "Usage: buildinstall --version <version> --product <product> --release <comment> [--discs <discstring>] <root>" >&2
+	echo "Usage: buildinstall --version <version> --product <product> --release <comment> [--output outputdir] [--discs <discstring>] <root>" >&2
 	exit 1
 }
 
@@ -59,8 +59,13 @@ while [ $# -gt 0 ]; do
 	    shift; shift
 	    ;;
 
+	--output)
+	    OUTPUT=$2
+	    shift; shift
+	    ;;
+
 	*)
-	    DIR=$1
+	    REPO=$1
 	    shift
 	    ;;
     esac
@@ -74,7 +79,7 @@ if [ -z "$VERSION" ]; then
     usage
 fi
 
-if [ -z "$DIR" ]; then
+if [ -z "$REPO" ]; then
     usage
 fi
 
@@ -86,24 +91,40 @@ if [ -z "$BUGURL" ]; then
     BUGURL="your distribution provided bug reporting tool."
 fi
 
-DIR=`cd $DIR > /dev/null; /bin/pwd`
+if [[ "$REPO" =~ ^/ ]]; then
+    [ -n "$OUTPUT" ] || OUTPUT=$REPO
+    REPO="file://$REPO"
+fi
+
+if [ -z "$OUTPUT" ]; then
+    usage
+fi
+
+yumconf=$(mktemp /tmp/yum.conf.XXXXXX)
+cat > $yumconf <<EOF 
+[main]
+keepcache=0
+gpgcheck=0
+plugins=0
+reposdir=
+tsflags=nodocs
+
+[anacondarepo]
+name=anaconda repo
+baseurl=$REPO
+enabled=1
+EOF
 
 BUILDINSTDIR=`mktemp -d ${TMPDIR:-/tmp}/buildinstall.tree.XXXXXX`
 TREEDIR=`mktemp -d ${TMPDIR:-/tmp}/treedir.XXXXXX`
 
-ANACONDARUNTIME=`find -L $DIR -name "anaconda-runtime-[0-9]*" |head -n 1`
-BUILDARCH=`rpm -qp --qf "%{ARCH}\n" $ANACONDARUNTIME`
-
 echo "Running buildinstall..."
 
-echo "Checking for repository metadata..."
-if ! [ -d $DIR/repodata ]; then
-    echo "Repodata must exist in the tree!" >&2
-    exit 1 
-fi
-
 pushd $BUILDINSTDIR
-rpm2cpio $ANACONDARUNTIME | cpio --quiet -iumd './usr*'
+BUILDARCH=`repoquery -c $yumconf --qf "%{ARCH}\n" anaconda-runtime`
+yumdownloader -c $yumconf anaconda-runtime || exit 1
+rpm2cpio anaconda-runtime*rpm | cpio --quiet -iumd './usr*'
+rm -f anaconda-runtime*rpm
 popd
 
 UPD_INSTROOT=./upd-instroot
@@ -127,15 +148,17 @@ MK_STAMP=$BUILDINSTDIR/makestamp.py
 BUILDINSTALL=$BUILDINSTDIR/buildinstall
 
 echo "Building images..."
-$UPD_INSTROOT $DEBUGSTR $NOGRSTR --arch $BUILDARCH --mindir $TREEDIR/minstg2 --stg2dir $TREEDIR/stage2 $DIR
+$UPD_INSTROOT $DEBUGSTR $NOGRSTR --arch $BUILDARCH --mindir $TREEDIR/minstg2 --stg2dir $TREEDIR/stage2 $yumconf
 
 echo "Writing .treeinfo file..."
-$MK_TREEINFO --family="$PRODUCTSTR" ${VARIANT:+--variant="$VARIANT"} --version=$VERSION --arch=$BUILDARCH --outfile=$DIR/.treeinfo
+$MK_TREEINFO --family="$PRODUCTSTR" ${VARIANT:+--variant="$VARIANT"} --version=$VERSION --arch=$BUILDARCH --outfile=$OUTPUT/.treeinfo
 
+# FIXME: need to update mk-images to take the yumconf
 echo "Making images..."
-$MK_IMAGES $DEBUGSTR $NOGRSTR --mindir $TREEDIR/minstg2 --stg2dir $TREEDIR/stage2 --arch $BUILDARCH --product "$PRODUCTSTR" --version $VERSION --bugurl "$BUGURL" $DIR
+$MK_IMAGES $DEBUGSTR $NOGRSTR --mindir $TREEDIR/minstg2 --stg2dir $TREEDIR/stage2 --arch $BUILDARCH --product "$PRODUCTSTR" --version $VERSION --bugurl "$BUGURL" --output $OUTPUT $yumconf
 
 echo "Writing .discinfo file"
-$MK_STAMP --releasestr="$RELEASESTR" --arch=$BUILDARCH --discNum="ALL"  --outfile=$DIR/.discinfo
+$MK_STAMP --releasestr="$RELEASESTR" --arch=$BUILDARCH --discNum="ALL"  --outfile=$OUTPUT/.discinfo
 
 rm -rf $TREEDIR $BUILDINSTDIR
+rm -f $yumconf
diff --git a/scripts/mk-images b/scripts/mk-images
index 8a2c747..98659e5 100755
--- a/scripts/mk-images
+++ b/scripts/mk-images
@@ -80,17 +80,13 @@ while [ $# -gt 0 ]; do
 	    ;;
 
 	*)
-	    DISTROPATH=$1
+	    yumconf=$1
 	    shift
 	    ;;
     esac
 done
 
-if [ -z "$TOPDESTPATH" ]; then
-    TOPDESTPATH=$DISTROPATH
-fi
-
-if [ -z "$TOPDESTPATH" -o -z "$DISTROPATH" -o -z "$INSTIMGTEMPLATE" -o -z "$IMGPATH" -o -z "$PRODUCT" -o -z "$VERSION" ]; then usage; fi
+if [ -z "$TOPDESTPATH" -o -z "$INSTIMGTEMPLATE" -o -z "$IMGPATH" -o -z "$PRODUCT" -o -z "$VERSION" ]; then usage; fi
 
 TOPDIR=$(echo $0 | sed "s,/[^/]*$,,")
 if [ $TOPDIR = $0 ]; then
@@ -212,21 +208,14 @@ INITRDMODS="$USBMODS $FIREWIREMODS $IDEMODS $SCSIMODS $FSMODS $LVMMODS $RAIDMODS
     fi
  
 findPackage() {
-    dir=$1
-    name=$2
-
-    for n in $(find -L $dir -name "$name*$KERNELARCH.rpm"); do
-	thisName=$(rpm --nodigest --nosignature --qf '%{NAME}' -qp $n)
-	if [ -z "$thisName" ]; then
-	    continue
-	fi
-	if [ $thisName = $name ]; then
-	    echo $n
-	    return
-	fi
-    done
+    name=$1
 
-    echo "cannot find package $name in path $dir" >&2
+    pkg=$(repoquery --qf "%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}" -c $yumconf $name.$KERNELARCH)
+    if [ -n "$pkg" ]; then
+	echo $pkg
+	return
+    fi
+    echo "cannot find package $name" >&2
 }
 
 rundepmod () {
@@ -760,13 +749,15 @@ fi
 foundakernel=""
 for KERNELARCH in $arches; do
   for kernelvers in $kerneltags; do
-    kpackage=$(findPackage $DISTROPATH $kernelvers)
+    kpackage=$(findPackage $kernelvers)
     if [ "$KERNELARCH" = "i586" -a ! -f "$kpackage" ]; then
 	echo "No i586 kernel, trying i686..."
 	KERNELARCH="i686"
-	kpackage=$(findPackage $DISROPATH $kernelvers)
+	kpackage=$(findPackage $kernelvers)
     fi
 
+    yumdownloader -c $yumconf $kpackage
+    kpackage="$kpackage.rpm"
     if [ ! -f "$kpackage" ]; then
 	echo "kernel ($kernelvers) doesn't exist for $KERNELARCH.  skipping"
 	continue
@@ -781,11 +772,12 @@ for KERNELARCH in $arches; do
 
     version=$(rpm --nodigest --nosignature --qf '%{VERSION}-%{RELEASE}' -qp $kpackage)${kerneltag}
     arch=$(rpm --nodigest --nosignature --qf '%{ARCH}\n' -qp $kpackage)
-    echo "unpacking $kpackage.$arch"
+    echo "unpacking $kpackage"
 
     rpm2cpio $kpackage | (cd $KERNELROOT; cpio --quiet -iumd)
+    rm -f $kpackage
     # expand out any available firmware too
-    for p in $(find -L $DISTROPATH -name '*firmware*.rpm') ; do rpm2cpio $p | (cd $KERNELROOT; cpio --quiet -iumd) ; done
+    for p in $(repoquery -c $yumconf '*firmware*') ; do yumdownloader -c $yumconf $p ; rpm2cpio *firmware*.rpm | (cd $KERNELROOT; cpio --quiet -iumd) ; rm -f *firmware*.rpm ; done
 
     if [ ! -d "$KERNELROOT/lib/modules/$version" ]; then
 	echo "$KERNELROOT/lib/modules/$version is not a valid modules directory" 2>&1
diff --git a/scripts/upd-instroot b/scripts/upd-instroot
index 71a76b8..045eeb2 100755
--- a/scripts/upd-instroot
+++ b/scripts/upd-instroot
@@ -50,15 +50,15 @@ while [ $# -gt 0 ]; do
 	    ;;
 
 	*)
-	    TOPDIR=$1
+	    yumconf=$1
 	    shift
 	    ;;
     esac
 done
 
-if [ -z "$TOPDIR" ]; then
+if [ -z "$yumconf" ]; then
 	echo "upd-instroot: updates instimage from a Red Hat RPMS directory"
-	echo "usage:        $0 [--nogr] [--debug] [--arch arch] <packagedir> [templatedir] [instroot]"
+	echo "usage:        $0 [--nogr] [--debug] [--arch arch] [--mindir mindir] [--stg2dir stg2dir] [yumconf]"
 	exit 1
 fi
 
@@ -76,8 +76,8 @@ if [ -z "$DESTGR" ]; then
     DESTGR=`mktemp -d ${TMPDIR:-/tmp}/destgr.XXXXXX`
 fi
 
-if [ ! -d $TOPDIR/repodata ]; then
-    echo "Unable to find repodata!"
+if [ ! -f $yumconf ]; then
+    echo "Unable to find yum repo information!"
     exit 1
 fi
 
@@ -862,21 +862,6 @@ ln -s /tmp $DESTGR/var/lib/xkb
 cat $KEEPFILERESCUE >> $KEEPFILEGR
 cat $KEEPFILE >> $KEEPFILEGR
 
-yumconf=$(mktemp /tmp/yum.conf.XXXXXX)
-cat > $yumconf <<EOF 
-[main]
-keepcache=0
-gpgcheck=0
-plugins=0
-reposdir=
-tsflags=nodocs
-
-[anacondarepo]
-name=anaconda repo
-baseurl=file://$TOPDIR
-enabled=1
-EOF
-
 echo `date` "Expanding text packages..."
 YUMDIR=${TMPDIR:-/tmp}/yumdir.$$
 mkdir -p $YUMDIR/var/log
@@ -905,7 +890,7 @@ if [ -n "$NEEDGR" ]; then
 EOF
 fi
 
-rm -rf $yumconf $YUMDIR
+rm -rf $YUMDIR
 
 chown -R root:root $DEST $DESTGR
 chmod -R a+rX-w $DEST $DESTGR
-- 
1.5.4.3

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux