[Libguestfs] [PATCH ubuntu] ubuntu: Ignore packages in packagelist.in which are missing.

Richard W.M. Jones rjones at redhat.com
Thu May 20 13:16:03 UTC 2010


-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://et.redhat.com/~rjones/virt-top
-------------- next part --------------
>From 0ffd0ad7f5c7496ca98b5c801e5e85d674a81de9 Mon Sep 17 00:00:00 2001
From: Richard Jones <rjones at redhat.com>
Date: Thu, 20 May 2010 11:04:30 +0100
Subject: [PATCH 3/5] ubuntu: Ignore packages in packagelist.in which are missing.

For distros using 'yum', packages which cannot be found are just
ignored.  This allows us to include for example 'e4fsprogs' on the
list even though that only exists on RHEL 5.

However for Debian-derived distros, missing packages would cause
apt to fail.  This was particularly a problem when building Ubuntu
since it doesn't have as complete a list of packages, and the list
changed a lot between releases.

This commit adds a check first for missing packages, ignoring those
and thus acting more like 'yum'.
---
 appliance/debian/modules/y0_install-guestfsd |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/appliance/debian/modules/y0_install-guestfsd b/appliance/debian/modules/y0_install-guestfsd
index 3eb8ba9..2d895a0 100755
--- a/appliance/debian/modules/y0_install-guestfsd
+++ b/appliance/debian/modules/y0_install-guestfsd
@@ -13,8 +13,16 @@ exec 5<&-
 echo "Module whitelist: $whitelist"
 find $DEBIRF_ROOT/lib/modules/*/kernel -name '*.ko' $whitelist -a -exec rm '{}' \;
 
-# install additional packages:
-PKGLIST=$(< packagelist)
+# install additional packages from the package list, but
+# only ones which exist in the repository
+PKGLIST=
+for pkg in $(< packagelist); do
+  if [ "$(debirf_exec apt-get -s install $pkg 3>&1 1>&2 2>&3 1>&- | grep '^E:' | wc -l)" -gt 0 ]; then
+    echo "Ignoring package $pkg, because it was not found in this repository."
+  else
+    PKGLIST="$PKGLIST $pkg"
+  fi
+done
 echo "Will add $PKGLIST"
 debirf_exec apt-get --assume-yes install $PKGLIST
 debirf_exec apt-get --assume-yes remove vim-tiny dhcp3-client iptables
-- 
1.6.3.3



More information about the Libguestfs mailing list