From mboxrd@z Thu Jan 1 00:00:00 1970 From: George Dunlap Subject: [PATCH 1/5] raisin: Handle aliases for packages, add pciutils-dev / libpci-dev alias Date: Wed, 14 Oct 2015 17:21:43 +0100 Message-ID: <1444839707-2339-2-git-send-email-george.dunlap@eu.citrix.com> References: <1444839707-2339-1-git-send-email-george.dunlap@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1444839707-2339-1-git-send-email-george.dunlap@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: George Dunlap , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org It's not uncommon for packages to be renamed, and for package managers to know the translation from old packages to new packages. For example: # apt-get install pciutils-dev Reading package lists... Done Building dependency tree Reading state information... Done Note, selecting 'libpci-dev' instead of 'pciutils-dev' libpci-dev is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. So the command succeeds, but the subsequent package check still fails, cince "pciutils-dev" wasn't actually installed. This means that even after running "install-builddep", "build" will prompt you to install the old package every time. Allow components to specify known aliases for a given package by speficying a a|b|c. Check-package will check consecutively for a, b, and c; if it finds any of them, it will stop looking and install nothing. If it finds nothing, it will add the first package to the missing_packages list. Assuming that package managers are backwards-compatible, components should put the oldest known package first for maximum compatibility. Also add such an alias for pciutils-dev|libpci-dev in qemu_traditional Signed-off-by: George Dunlap --- components/qemu_traditional | 2 +- lib/common-functions.sh | 25 ++++++++++++++++++++----- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/components/qemu_traditional b/components/qemu_traditional index 3150c3e..d73c6b8 100644 --- a/components/qemu_traditional +++ b/components/qemu_traditional @@ -10,7 +10,7 @@ function qemu_traditional_skip() { } function qemu_traditional_check_package() { - local DEP_Debian_common="build-essential zlib1g-dev pciutils-dev pkg-config \ + local DEP_Debian_common="build-essential zlib1g-dev pciutils-dev|libpci-dev pkg-config \ libncurses5-dev" local DEP_Debian_x86_32="$DEP_Debian_common" local DEP_Debian_x86_64="$DEP_Debian_common" diff --git a/lib/common-functions.sh b/lib/common-functions.sh index 03642ae..a389054 100644 --- a/lib/common-functions.sh +++ b/lib/common-functions.sh @@ -233,14 +233,29 @@ function _install-package-unknown() { # Modifies inherited variable "missing" function check-package() { + local OIFS=${IFS} + local p + local x + for p in $* do - if ! _check-package-${PKGTYPE} $p - then - missing+=("$p") - fi + local found=false + IFS='|' + for x in $p + do + if _check-package-${PKGTYPE} $x + then + found=true + fi + done + IFS="$OIFS" + if ! $found + then + # Add the first of the aliases, on the assumption that the package + # manager will be backwards-compatible + missing+=("${p%%|*}") + fi done - } function install-package() { -- 2.1.4