From: Paul Spooren Date: Sat, 1 Feb 2025 23:01:58 +0000 (+0000) Subject: build: lock versions for special APK packages X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=63e178f06740c473e4347dc195f03e7f57ce59a2;p=openwrt%2Fopenwrt.git build: lock versions for special APK packages The three packages base-files, libc and kernel are special, the former can't be upgraded in place since it's content are modified on startup, the latter two are virtual packages only used as constraints for the package manager. Historically base-files was "locked" via a special OPKG function, the latter two were hidden from the package index and thereby never picked as possible upgrade. Time moved forward and we now have APK and tools like OWUT. The latter compares available packages with installed packages and generates user readable output, requiring versions for libc and kernel, too. At the same time, APK uses a different looking mechanism, which is set during installation instead of part of the package metadata. In short, this patch adds version constraints to the three packages, allowing them to be part of the package index. Fixes: #17774 Fixes: #17775 Fixes: efahl/owut#31 Signed-off-by: Paul Spooren --- diff --git a/include/version.mk b/include/version.mk index e9829e860a..b1e414f189 100644 --- a/include/version.mk +++ b/include/version.mk @@ -6,6 +6,9 @@ # Substituted by SDK, do not remove # REVISION:=x # SOURCE_DATE_EPOCH:=x +# BASE_FILES_VERSION:=x +# KERNEL_VERSION:=x +# LIBC_VERSION:=x PKG_CONFIG_DEPENDS += \ CONFIG_VERSION_HOME_URL \ diff --git a/package/Makefile b/package/Makefile index ca43eb7e01..701ed3b13b 100644 --- a/package/Makefile +++ b/package/Makefile @@ -100,7 +100,11 @@ ifneq ($(CONFIG_USE_APK),) $(foreach pkg,$(shell cat $(PACKAGE_INSTALL_FILES) 2>/dev/null),$(pkg)$(call GetABISuffix,$(pkg)))) $(call apk,$(TARGET_DIR)) add --no-cache --initdb --no-scripts --arch $(ARCH_PACKAGES) \ --repositories-file /dev/null --repository file://$(PACKAGE_DIR_ALL)/packages.adb \ - $$(cat $(TMP_DIR)/apk_install_list) + $$(cat $(TMP_DIR)/apk_install_list) \ + "base-files=$(shell cat $(TMP_DIR)/base-files.version)" \ + "libc=$(shell cat $(TMP_DIR)/libc.version)" \ + "kernel=$(shell cat $(TMP_DIR)/kernel.version)" + rm -rf $(TARGET_DIR)/run else $(file >$(TMP_DIR)/opkg_install_list,\ @@ -131,7 +135,7 @@ ifneq ($(CONFIG_USE_APK),) --keys-dir $(TOPDIR) \ --sign $(BUILD_KEY_APK_SEC) \ --output packages.adb \ - $$(ls *.apk | grep -vE '^(base-files-|kernel-|libc-)'); \ + *.apk; \ echo -n '{"architecture": "$(ARCH_PACKAGES)", "packages":{' > index.json; \ $(STAGING_DIR_HOST)/bin/apk adbdump packages.adb | \ awk '/- name: / {pkg = $$NF} ; / version: / {printf "\"%s\": \"%s\", ", pkg, $$NF}' | \ diff --git a/package/base-files/Makefile b/package/base-files/Makefile index b90ee3a64e..693d259ee4 100644 --- a/package/base-files/Makefile +++ b/package/base-files/Makefile @@ -256,6 +256,7 @@ ifneq ($(CONFIG_USE_APK),) rm -f $(1)/etc/uci-defaults/13_fix-group-user rm -f $(1)/sbin/pkg_check + echo $(PKG_RELEASE)~$(lastword $(subst -, ,$(REVISION))) >$(TMP_DIR)/base-files.version else $(if $(CONFIG_CLEAN_IPKG),, \ mkdir -p $(1)/etc/opkg; \ diff --git a/package/kernel/linux/Makefile b/package/kernel/linux/Makefile index 8dfb01ad66..203cf0d128 100644 --- a/package/kernel/linux/Makefile +++ b/package/kernel/linux/Makefile @@ -64,6 +64,7 @@ define Package/kernel/install strings $(LINUX_DIR)/modules.builtin.modinfo | \ grep -E -v "\.(file$(if CONFIG_MODULE_STRIPPED,|parmtype))=" | \ tr '\n' '\0' > $(1)/$(MODULES_SUBDIR)/modules.builtin.modinfo + echo $(LINUX_VERSION)~$(LINUX_VERMAGIC)-r$(LINUX_RELEASE) > $(TMP_DIR)/kernel.version endef define Package/kernel/extra_provides diff --git a/package/libs/toolchain/Makefile b/package/libs/toolchain/Makefile index 7c117b144d..ab0c0545b0 100644 --- a/package/libs/toolchain/Makefile +++ b/package/libs/toolchain/Makefile @@ -578,6 +578,7 @@ ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),) endef define Package/libc/install + echo $(LIBC_VERSION)-r$(PKG_RELEASE) > $(TMP_DIR)/libc.version; \ $(call Package/$(LIBC)/install,$1) endef @@ -697,6 +698,7 @@ else endef define Package/libc/install + echo $(LIBC_VERSION)-r$(PKG_RELEASE) > $(TMP_DIR)/libc.version; \ for file in $(call qstrip,$(CONFIG_LIBC_FILE_SPEC)); do \ $(INSTALL_DIR) $(1)/lib ; \ $(CP) $(call qstrip,$(CONFIG_LIBC_ROOT_DIR))/$$$$file $(1)/lib/ ; \ diff --git a/target/imagebuilder/Makefile b/target/imagebuilder/Makefile index 9181d86a1c..afc97550c1 100644 --- a/target/imagebuilder/Makefile +++ b/target/imagebuilder/Makefile @@ -127,6 +127,9 @@ endif fi $(SED) 's,^# REVISION:=.*,REVISION:=$(REVISION),g' $(PKG_BUILD_DIR)/include/version.mk $(SED) 's,^# SOURCE_DATE_EPOCH:=.*,SOURCE_DATE_EPOCH:=$(SOURCE_DATE_EPOCH),g' $(PKG_BUILD_DIR)/include/version.mk + $(SED) 's,^# BASE_FILES_VERSION:=.*,BASE_FILES_VERSION:=$(shell cat $(TMP_DIR)/base-files.version),g' $(PKG_BUILD_DIR)/include/version.mk + $(SED) 's,^# LIBC_VERSION:=.*,LIBC_VERSION:=$(shell cat $(TMP_DIR)/libc.version),g' $(PKG_BUILD_DIR)/include/version.mk + $(SED) 's,^# KERNEL_VERSION:=.*,KERNEL_VERSION:=$(shell cat $(TMP_DIR)/kernel.version),g' $(PKG_BUILD_DIR)/include/version.mk $(SED) '/LINUX_VERMAGIC:=/ { s,unknown,$(LINUX_VERMAGIC),g }' $(PKG_BUILD_DIR)/include/kernel.mk find $(PKG_BUILD_DIR) -name CVS -o -name .git -o -name .svn \ | $(XARGS) rm -rf diff --git a/target/imagebuilder/files/Makefile b/target/imagebuilder/files/Makefile index 07cca7eea4..b27021d600 100644 --- a/target/imagebuilder/files/Makefile +++ b/target/imagebuilder/files/Makefile @@ -227,7 +227,10 @@ ifeq ($(CONFIG_USE_APK),) $(OPKG) install $(wildcard $(PACKAGE_DIR)/kernel_*.ipk) $(OPKG) install $(BUILD_PACKAGES) else - $(APK) add --arch $(ARCH_PACKAGES) --no-scripts $(BUILD_PACKAGES) + $(APK) add --arch $(ARCH_PACKAGES) --no-scripts $(BUILD_PACKAGES) \ + "base-files=$(BASE_FILES_VERSION)" \ + "libc=$(LIBC_VERSION)" \ + "kernel=$(KERNEL_VERSION)" endif prepare_rootfs: FORCE