From 29ad240c2d42d242489c35b7fe371a3e0eea3357 Mon Sep 17 00:00:00 2001 From: Anton Midyukov Date: Thu, 21 Nov 2019 12:14:40 +0700 Subject: [PATCH] pkgpriorities: also needed for rootfs This should have better been done through some shared code but it's not that obvious... --- .../rootfs/lib/50-pkgpriorities.mk | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 features.in/pkgpriorities/rootfs/lib/50-pkgpriorities.mk diff --git a/features.in/pkgpriorities/rootfs/lib/50-pkgpriorities.mk b/features.in/pkgpriorities/rootfs/lib/50-pkgpriorities.mk new file mode 100644 index 00000000..63848de1 --- /dev/null +++ b/features.in/pkgpriorities/rootfs/lib/50-pkgpriorities.mk @@ -0,0 +1,26 @@ +_IMAGE_APTBOX_ = $(WORKDIR)/chroot/$(WORKDIRNAME)/aptbox + +# Add prerequisite to the build-image target of +# $(MKIMAGE_PREFIX)/targets.mk. +build-image: $(_IMAGE_APTBOX_)/etc/apt/pkgpriorities + +_PINNED_PACKAGES_ = $(foreach pp,$(PINNED_PACKAGES),$(if $(findstring :,$(pp)),$(pp),$(pp):$(PIN_PRIORITY))) +_PIN_PRIORITIES_ = $(sort $(foreach pp,$(_PINNED_PACKAGES_),$(lastword $(subst :, ,$(pp))))) +_PKGPRIORITIES_ = $(subst \n ,\n,$(foreach pri,$(_PIN_PRIORITIES_),$(pri):$(patsubst %:$(pri),\n %,$(filter %:$(pri),$(_PINNED_PACKAGES_)))\n)) + +$(_IMAGE_APTBOX_)/etc/apt/pkgpriorities: prepare-image-workdir + @echo -e '$(_PKGPRIORITIES_)' | sed -e 's,[[:space:]]\+$$,,' >$@ + @if [ -s $@ ]; then \ + if grep -q '^\(APT::\)\?Dir::Etc::pkgpriorities[[:space:]]' \ + $(_IMAGE_APTBOX_)/etc/apt/apt.conf; \ + then \ + sed -i -e 's,\(Dir::Etc::pkgpriorities\)[[:space:]].*$$,\1 "$@";,g' \ + $(_IMAGE_APTBOX_)/etc/apt/apt.conf; \ + else \ + echo 'Dir::Etc::pkgpriorities "$@";' \ + >>$(_IMAGE_APTBOX_)/etc/apt/apt.conf; \ + fi; \ + echo "--- Package priorities ---" >&2; \ + cat $@ >&2; \ + echo "---" >&2; \ + fi