summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Spooren2025-02-01 23:01:58 +0000
committerPaul Spooren2025-02-04 13:48:59 +0000
commit63e178f06740c473e4347dc195f03e7f57ce59a2 (patch)
tree12447c9fb368370e770e2e36522b2aee2e5f3560
parentf628467dfd6b32ead172d33a2593f04901395343 (diff)
downloadopenwrt-63e178f06740c473e4347dc195f03e7f57ce59a2.tar.gz
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 <mail@aparcar.org>
-rw-r--r--include/version.mk3
-rw-r--r--package/Makefile8
-rw-r--r--package/base-files/Makefile1
-rw-r--r--package/kernel/linux/Makefile1
-rw-r--r--package/libs/toolchain/Makefile2
-rw-r--r--target/imagebuilder/Makefile3
-rw-r--r--target/imagebuilder/files/Makefile5
7 files changed, 20 insertions, 3 deletions
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