build: add ABI_VERSION to binary package names

Add the ABI_VERSION source makefile variable to the binary package basename
and resolve source dependencies on packages with ABI_VERSION set to such
expanded names.

If for example a package specifies DEPENDS:=libopenssl while the OpenSSL
Makefile specifies ABI_VERSION:=1.0.0, the resulting ipk control data
dependency will be "Depends: libopenssl1.0.0" and the libopenssl ipk file
will be called "libopenssl1.0.0_<version>_<arch>.ipk".

The next time a library such as OpenSSL is updated to an incompatible
version, the ABI_VERSION shall be changed accordingly to prevent opkg from
simply upgrading to an incompatible library without considering the
dependencies of already installed packages.

Also introduce another "SourceName" control field which is required by
the newly introduced "scritps/ipkg-remove" to determine the proper related
.ipk files to delete upon buildroot package clean operations.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
Jo-Philipp Wich 2019-01-17 17:31:09 +01:00
parent e3d5b384aa
commit e6bcf1e4ac
5 changed files with 35 additions and 10 deletions

View File

@ -41,3 +41,8 @@ define FeedSourcesAppend
echo '$(if $(filter m,$(CONFIG_FEED_$(feed))),# )src/gz %d_$(feed) %U/packages/%A/$(feed)';)))) \ echo '$(if $(filter m,$(CONFIG_FEED_$(feed))),# )src/gz %d_$(feed) %U/packages/%A/$(feed)';)))) \
) >> $(1) ) >> $(1)
endef endef
# 1: package name
define GetABISuffix
$(if $(filter-out kmod-%,$(1)),$(if $(Package/$(1)/abiversion),$(if $(filter %0 %1 %2 %3 %4 %5 %6 %7 %8 %9,$(1)),-)$(Package/$(1)/abiversion)))
endef

View File

@ -279,8 +279,8 @@ ifdef CONFIG_TARGET_ROOTFS_CPIOGZ
endif endif
mkfs_packages = $(filter-out @%,$(PACKAGES_$(call param_get,pkg,pkg=$(target_params)))) mkfs_packages = $(filter-out @%,$(PACKAGES_$(call param_get,pkg,pkg=$(target_params))))
mkfs_packages_add = $(filter-out -%,$(mkfs_packages)) mkfs_packages_add = $(foreach pkg,$(filter-out -%,$(mkfs_packages)),$(pkg)$(call GetABISuffix,$(pkg)))
mkfs_packages_remove = $(patsubst -%,%,$(filter -%,$(mkfs_packages))) mkfs_packages_remove = $(foreach pkg,$(patsubst -%,%,$(filter -%,$(mkfs_packages))),$(pkg)$(call GetABISuffix,$(pkg)))
mkfs_cur_target_dir = $(call mkfs_target_dir,pkg=$(target_params)) mkfs_cur_target_dir = $(call mkfs_target_dir,pkg=$(target_params))
opkg_target = \ opkg_target = \

View File

@ -13,6 +13,9 @@ endif
IPKG_BUILD:= \ IPKG_BUILD:= \
$(SCRIPT_DIR)/ipkg-build -c -o 0 -g 0 $(SCRIPT_DIR)/ipkg-build -c -o 0 -g 0
IPKG_REMOVE:= \
$(SCRIPT_DIR)/ipkg-remove
IPKG_STATE_DIR:=$(TARGET_DIR)/usr/lib/opkg IPKG_STATE_DIR:=$(TARGET_DIR)/usr/lib/opkg
# 1: package name # 1: package name
@ -90,8 +93,9 @@ _endef=endef
ifeq ($(DUMP),) ifeq ($(DUMP),)
define BuildTarget/ipkg define BuildTarget/ipkg
ABIV_$(1):=$(call GetABISuffix,$(1))
PDIR_$(1):=$(call FeedPackageDir,$(1)) PDIR_$(1):=$(call FeedPackageDir,$(1))
IPKG_$(1):=$$(PDIR_$(1))/$(1)_$(VERSION)_$(PKGARCH).ipk IPKG_$(1):=$$(PDIR_$(1))/$(1)$$(ABIV_$(1))_$(VERSION)_$(PKGARCH).ipk
IDIR_$(1):=$(PKG_BUILD_DIR)/ipkg-$(PKGARCH)/$(1) IDIR_$(1):=$(PKG_BUILD_DIR)/ipkg-$(PKGARCH)/$(1)
KEEP_$(1):=$(strip $(call Package/$(1)/conffiles)) KEEP_$(1):=$(strip $(call Package/$(1)/conffiles))
@ -148,19 +152,20 @@ ifeq ($(DUMP),)
$(call locked,$(CP) $(PKG_BUILD_DIR)/.pkgdir/$(1)/. $(STAGING_DIR_ROOT)/,root-copy) $(call locked,$(CP) $(PKG_BUILD_DIR)/.pkgdir/$(1)/. $(STAGING_DIR_ROOT)/,root-copy)
touch $$@ touch $$@
Package/$(1)/DEPENDS := $$(call mergelist,$$(filter-out @%,$$(IDEPEND_$(1)))) Package/$(1)/DEPENDS := $$(call mergelist,$$(foreach dep,$$(filter-out @%,$$(IDEPEND_$(1))),$$(dep)$$(call GetABISuffix,$$(dep))))
ifneq ($$(EXTRA_DEPENDS),) ifneq ($$(EXTRA_DEPENDS),)
Package/$(1)/DEPENDS := $$(EXTRA_DEPENDS)$$(if $$(Package/$(1)/DEPENDS),$$(comma) $$(Package/$(1)/DEPENDS)) Package/$(1)/DEPENDS := $$(EXTRA_DEPENDS)$$(if $$(Package/$(1)/DEPENDS),$$(comma) $$(Package/$(1)/DEPENDS))
endif endif
$(_define) Package/$(1)/CONTROL $(_define) Package/$(1)/CONTROL
Package: $(1) Package: $(1)$$(ABIV_$(1))
Version: $(VERSION) Version: $(VERSION)
$$(call addfield,Depends,$$(Package/$(1)/DEPENDS) $$(call addfield,Depends,$$(Package/$(1)/DEPENDS)
)$$(call addfield,Conflicts,$$(call mergelist,$(CONFLICTS)) )$$(call addfield,Conflicts,$$(call mergelist,$(CONFLICTS))
)$$(call addfield,Provides,$$(call mergelist,$(PROVIDES)) )$$(call addfield,Provides,$$(call mergelist,$(PROVIDES)$$(if $$(ABIV_$(1)), $(1)))
)$$(call addfield,Alternatives,$$(call mergelist,$(ALTERNATIVES)) )$$(call addfield,Alternatives,$$(call mergelist,$(ALTERNATIVES))
)$$(call addfield,Source,$(SOURCE) )$$(call addfield,Source,$(SOURCE)
)$$(call addfield,SourceName,$(1)
)$$(call addfield,License,$(LICENSE) )$$(call addfield,License,$(LICENSE)
)$$(call addfield,LicenseFiles,$(LICENSE_FILES) )$$(call addfield,LicenseFiles,$(LICENSE_FILES)
)$$(call addfield,Section,$(SECTION) )$$(call addfield,Section,$(SECTION)
@ -176,7 +181,7 @@ $(_endef)
$$(IPKG_$(1)) : export DESCRIPTION=$$(Package/$(1)/description) $$(IPKG_$(1)) : export DESCRIPTION=$$(Package/$(1)/description)
$$(IPKG_$(1)) : export PATH=$$(TARGET_PATH_PKG) $$(IPKG_$(1)) : export PATH=$$(TARGET_PATH_PKG)
$(PKG_INFO_DIR)/$(1).provides $$(IPKG_$(1)): $(STAMP_BUILT) $(INCLUDE_DIR)/package-ipkg.mk $(PKG_INFO_DIR)/$(1).provides $$(IPKG_$(1)): $(STAMP_BUILT) $(INCLUDE_DIR)/package-ipkg.mk
@rm -rf $$(IDIR_$(1)) $$(call opkg_package_files,$(1)) @rm -rf $$(IDIR_$(1)) $$(if $$(call opkg_package_files,$(1)*),; $$(IPKG_REMOVE) $(1) $$(call opkg_package_files,$(1)*))
mkdir -p $(PACKAGE_DIR) $$(IDIR_$(1))/CONTROL $(PKG_INFO_DIR) mkdir -p $(PACKAGE_DIR) $$(IDIR_$(1))/CONTROL $(PKG_INFO_DIR)
$(call Package/$(1)/install,$$(IDIR_$(1))) $(call Package/$(1)/install,$$(IDIR_$(1)))
$(if $(Package/$(1)/install-overlay),mkdir -p $(PACKAGE_DIR) $$(IDIR_$(1))/rootfs-overlay) $(if $(Package/$(1)/install-overlay),mkdir -p $(PACKAGE_DIR) $$(IDIR_$(1))/rootfs-overlay)
@ -235,7 +240,7 @@ $(_endef)
@[ -f $$(IPKG_$(1)) ] @[ -f $$(IPKG_$(1)) ]
$(1)-clean: $(1)-clean:
$$(if $$(call opkg_package_files,$(1)),rm -f $$(call opkg_package_files,$(1))) $$(if $$(call opkg_package_files,$(1)*),$$(IPKG_REMOVE) $(1) $$(call opkg_package_files,$(1)*))
clean: $(1)-clean clean: $(1)-clean

View File

@ -66,7 +66,7 @@ $(curdir)/install: $(TMP_DIR)/.build $(curdir)/merge $(if $(CONFIG_TARGET_PER_DE
rm -rf $(TARGET_DIR) $(TARGET_DIR_ORIG) rm -rf $(TARGET_DIR) $(TARGET_DIR_ORIG)
mkdir -p $(TARGET_DIR)/tmp mkdir -p $(TARGET_DIR)/tmp
$(call opkg,$(TARGET_DIR)) install \ $(call opkg,$(TARGET_DIR)) install \
$(call opkg_package_files,$(shell cat $(PACKAGE_INSTALL_FILES) 2>/dev/null)) $(call opkg_package_files,$(foreach pkg,$(shell cat $(PACKAGE_INSTALL_FILES) 2>/dev/null),$(pkg)$(call GetABISuffix,$(pkg))))
@for file in $(PACKAGE_INSTALL_FILES); do \ @for file in $(PACKAGE_INSTALL_FILES); do \
[ -s $$file.flags ] || continue; \ [ -s $$file.flags ] || continue; \
for flag in `cat $$file.flags`; do \ for flag in `cat $$file.flags`; do \
@ -84,7 +84,7 @@ $(curdir)/index: FORCE
mkdir -p $$d; \ mkdir -p $$d; \
cd $$d || continue; \ cd $$d || continue; \
$(SCRIPT_DIR)/ipkg-make-index.sh . 2>&1 > Packages.manifest; \ $(SCRIPT_DIR)/ipkg-make-index.sh . 2>&1 > Packages.manifest; \
grep -vE '^(Maintainer|LicenseFiles|Source|Require)' Packages.manifest > Packages && \ grep -vE '^(Maintainer|LicenseFiles|Source|SourceName|Require)' Packages.manifest > Packages && \
gzip -9nc Packages > Packages.gz; \ gzip -9nc Packages > Packages.gz; \
); done ); done
ifdef CONFIG_SIGNED_PACKAGES ifdef CONFIG_SIGNED_PACKAGES

15
scripts/ipkg-remove Executable file
View File

@ -0,0 +1,15 @@
#!/usr/bin/env bash
sourcename="$1"; shift
for pkg in "$@"; do
tar -Ozxf "$pkg" ./control.tar.gz 2>/dev/null | tar -Ozxf - ./control 2>/dev/null | \
while read field value; do
if [ "$field" = "SourceName:" ] && [ "$value" = "$sourcename" ]; then
rm -vf "$pkg"
break
fi
done
done
exit 0