imagebuilder: add function to show manifest

Tested with 18.06.0-rc2/ar71xx/generic/tl-wdr4300-v1, image & list

This PR is based on the work of @fewckert[1] with slight improvements.

Add function `manifest` to show the manifest of the produced image,
before actually building it. The manifest contains an orderd list of
package name and version.

This is usefull to check package dependencies but also determine a
unique and reproducible image name before building the package. The
sysupgrade server[2] builds images on request with individual package
selection. To distignish between created images which contain differnt
packages, the EXTRA_IMAGE_NAME is set to a shortend hash of the
manifest's content. So far the image was renamed afterwards as the
manifests content was unknown, however this corrupts the signed
sha256sums. This patch allows a clean solution as to dtermine the
manifest in advance and set the EXTRA_IMAGE_NAME accordingly.

[1]: https://github.com/lede-project/source/pull/1591
[2]: https://github.com/aparcar/attendedsysupgrade-server

Signed-off-by: Paul Spooren <mail@aparcar.org>
This commit is contained in:
Paul Spooren 2018-07-20 17:32:12 +09:00 committed by John Crispin
parent 8492ad0cc1
commit 869b0d11db

View File

@ -45,6 +45,14 @@ Building images:
make image FILES="<path>" # include extra files from <path>
make image BIN_DIR="<path>" # alternative output directory for the images
make image EXTRA_IMAGE_NAME="<string>" # Add this to the output image filename (sanitized)
Print manifest:
List "all" packages which get installed into the image.
You can use the following parameters:
make manifest PROFILE="<profilename>" # override the default target profile
make manifest PACKAGES="<pkg1> [<pkg2> [<pkg3> ...]]" # include extra packages
endef
$(eval $(call shexport,Helptext))
@ -108,6 +116,13 @@ _call_image: staging_dir/host/.prereq-build
$(MAKE) -s build_image
$(MAKE) -s checksum
_call_manifest: FORCE
rm -rf $(TARGET_DIR)
mkdir -p $(TARGET_DIR) $(BIN_DIR) $(TMP_DIR) $(DL_DIR)
$(MAKE) package_reload >/dev/null 2>/dev/null
$(MAKE) package_install >/dev/null 2>/dev/null
$(OPKG) list-installed
package_index: FORCE
@echo >&2
@echo Building package index... >&2
@ -164,7 +179,7 @@ info:
PROFILE_FILTER = $(filter DEVICE_$(PROFILE) $(PROFILE),$(PROFILE_NAMES))
image:
_check_profile: FORCE
ifneq ($(PROFILE),)
ifeq ($(PROFILE_FILTER),)
@echo 'Profile "$(PROFILE)" does not exist!'
@ -172,6 +187,9 @@ ifneq ($(PROFILE),)
@exit 1
endif
endif
image:
$(MAKE) -s _check_profile
(unset PROFILE FILES PACKAGES MAKEFLAGS; \
$(MAKE) -s _call_image \
$(if $(PROFILE),USER_PROFILE="$(PROFILE_FILTER)") \
@ -179,4 +197,11 @@ endif
$(if $(PACKAGES),USER_PACKAGES="$(PACKAGES)") \
$(if $(BIN_DIR),BIN_DIR="$(BIN_DIR)"))
.SILENT: help info image
manifest: FORCE
$(MAKE) -s _check_profile
(unset PROFILE FILES PACKAGES MAKEFLAGS; \
$(MAKE) -s _call_manifest \
$(if $(PROFILE),USER_PROFILE="$(PROFILE_FILTER)") \
$(if $(PACKAGES),USER_PACKAGES="$(PACKAGES)"))
.SILENT: help info image manifest