Skip to content

Commit

Permalink
build: lock versions for special APK packages
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
aparcar committed Feb 4, 2025
1 parent f628467 commit 63e178f
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 3 deletions.
3 changes: 3 additions & 0 deletions include/version.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
8 changes: 6 additions & 2 deletions package/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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,\
Expand Down Expand Up @@ -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}' | \
Expand Down
1 change: 1 addition & 0 deletions package/base-files/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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; \
Expand Down
1 change: 1 addition & 0 deletions package/kernel/linux/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions package/libs/toolchain/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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/ ; \
Expand Down
3 changes: 3 additions & 0 deletions target/imagebuilder/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion target/imagebuilder/files/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 63e178f

Please sign in to comment.