|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH OSSTEST v3 02/22] mg-*: Make package fetching common in new mgi-debian
This pattern appears several times in mg-debian-installer-update and
I'm about to add another script which uses it.
The centralised version always does "sort -n -r | head -n" to pick out
only the newest version, which only some of the open coded sites did.
Likewise the centralised version checks that $pkgfile is non-empty,
unlike some of the open coded sites.
Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---
v3: New patch
---
mg-debian-installer-update | 34 +++++++++-------------------------
mgi-debian | 38 ++++++++++++++++++++++++++++++++++++++
2 files changed, 47 insertions(+), 25 deletions(-)
create mode 100644 mgi-debian
diff --git a/mg-debian-installer-update b/mg-debian-installer-update
index 770022c..dcbe568 100755
--- a/mg-debian-installer-update
+++ b/mg-debian-installer-update
@@ -23,6 +23,7 @@ set -e
. cri-getconfig
. mgi-common
+. mgi-debian
suite=$1
arch=$2
@@ -59,8 +60,6 @@ case ${suite}_${arch} in
;;
esac
-pfile=$sbase/non-free/binary-$arch/Packages.gz
-
dstroot=`getconfig TftpPath`/`getconfig TftpDiBase`/
date=`date +%Y-%m-%d`-$suite
dst=$arch/$date
@@ -85,16 +84,13 @@ if [ "x$dtbs" != "x" ] ; then
gzip -9nf dtbs.tar
fi
+pfile=$sbase/non-free/binary-$arch/Packages.gz
+
fetch $pfile >Packages.gz
for p in $packages; do
- set +e
echo >&2 "collecting $p"
- pkgfile=`zcat Packages.gz | grep-dctrl -PX $p -nsFilename`
- rc=$?
- set -e
- if [ $rc != 0 ]; then fail "package $p not found"; fi
- fetch "$site/$pkgfile" >$p.deb
+ fetch_package "$site" Packages.gz -PX $p >$p.deb
rm -rf x
dpkg-deb -x $p.deb x
cd x; pax -x sv4cpio -s '%lib%/lib%' -w -M norm lib >../cpio; cd ..
@@ -117,30 +113,18 @@ if [ x$bpok != x ]; then
if [ x$need_initramfs = xy ]; then
# Newer kernel often needs a newer initramfs-tools. Make that
- # available
+ # is available
echo >&2 "collecting backports initramfs-tools"
- pkgfile=`zcat Packages.gz \
- | grep-dctrl -PX initramfs-tools -nsFilename \
- | sort -n -r | head -n1`
- rc=$?
- set -e
- if [ $rc -ne 0 ] || [ x$pkgfile = x ]; then
- fail "initramfs-tools package not found";
- fi
- fetch "$site/$pkgfile" >initramfs-tools.deb
+ fetch_package $site Packages.gz -PX initramfs-tools \
+ >initramfs-tools.deb
fi
set +e
echo >&2 "collecting backports kernel"
# Be careful to pickup the actual kernel package from the 'linux'
# source and not a meta package from 'linux-latest'
- pkgfile=`zcat Packages.gz | grep-dctrl -S linux \
- | grep-dctrl -Pe ^linux-image-.*-${bpok}$ -nsFilename \
- | sort -n -r | head -n1`
- rc=$?
- set -e
- if [ $rc != 0 ]; then fail "backports kernel package not found"; fi
- fetch "$site/$pkgfile" >backports.deb
+ fetch_package $site Packages.gz -Pe ^linux-image-.*-${bpok}$ \
+ >backports.deb
dpkg-deb -x backports.deb x
cp x/boot/vmlinuz-* linux.backports
# The full set of modules is pretty large and not that
diff --git a/mgi-debian b/mgi-debian
new file mode 100644
index 0000000..3b2d2c5
--- /dev/null
+++ b/mgi-debian
@@ -0,0 +1,38 @@
+# -*- bash -*-
+
+# Helpers for mg-* dealing with Debian.
+#
+# This is part of "osstest", an automated testing framework for Xen.
+# Copyright (C) 2015 Citrix Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Arguments: <Base URL> <Packages.gz> <grep-dctrl arguments>
+#
+# nb: -nsFilename argument to grep-dctrl is supplied here
+fetch_package () {
+ local site=$1 ; shift 1
+ local pgz=$1 ; shift 1
+
+ set +e
+ pkgfile=`zcat $pgz | grep-dctrl $@ -nsFilename | sort -n -r | head -n1`
+ rc=$?
+ set -e
+
+ if [ $rc -ne 0 ] || [ x$pkgfile = x ]; then
+ fail "package matching $@ not found";
+ fi
+
+ fetch "$site/$pkgfile"
+}
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |