From b58b916dbc985d21b6dd2b9199881c8512e13dcd Mon Sep 17 00:00:00 2001 From: Steve Baker Date: Wed, 5 Sep 2018 16:14:05 +1200 Subject: [PATCH] Don't yum update files which are not installed This change builds the packages_for_update list by intersecting installed packages with the packages available, which avoids passing uninstalled packages to the yum update call. For some reason doing a yum update with packages which are not installed causes a delay for each uninstalled package. For my test case this gave a speed improvement of 35s vs 45s for the whole image build. This would accumulate to decent time savings for all images in CI. Change-Id: I338d9881d5a05dd7b1fbc5efea1145349f0997a6 --- files/yum_update.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/files/yum_update.sh b/files/yum_update.sh index 69722ed..1ea99a1 100755 --- a/files/yum_update.sh +++ b/files/yum_update.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash set -eux @@ -11,7 +11,9 @@ fi packages_for_update= if [ -n "$1" ] && command -v repoquery >/dev/null 2>&1; then - packages_for_update=("$(repoquery --disablerepo='*' --enablerepo=$1 --qf %{NAME} -a)") + installed=$(rpm -qa --qf "%{NAME}\n" | sort) + available=$(repoquery --disablerepo='*' --enablerepo=$1 --qf %{NAME} -a | sort) + packages_for_update=$(comm -12 <(printf "%s\n" $installed) <(printf "%s\n" $available)) fi if [ -z "$packages_for_update" ]; then