Skip to content

Commit

Permalink
Merge branch 'main' into lantiq-avm7430
Browse files Browse the repository at this point in the history
  • Loading branch information
dzzinstant authored May 23, 2024
2 parents c8560ad + e83a561 commit 801f97c
Show file tree
Hide file tree
Showing 108 changed files with 7,207 additions and 1,523 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
/*.patch
/llvm-bpf*
key-build*
private-key.pem
public-key.pem
*.orig
*.rej
*~
Expand Down
4 changes: 4 additions & 0 deletions config/Config-build.in
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ menu "Global build settings"
bool "Enable TLS certificate verification during package download"
default y

config USE_APK
bool "Use APK instead of OPKG to build distribution (EXPERIMENTAL)"

comment "General build options"

config TESTING_KERNEL
Expand Down Expand Up @@ -228,6 +231,7 @@ menu "Global build settings"

config STRIP_KERNEL_EXPORTS
bool "Strip unnecessary exports from the kernel image"
depends on !LINUX_6_6
help
Reduces kernel size by stripping unused kernel exports from the kernel
image. Note that this might make the kernel incompatible with any kernel
Expand Down
20 changes: 19 additions & 1 deletion include/feeds.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ opkg_package_files = $(wildcard \
$(foreach dir,$(PACKAGE_SUBDIRS), \
$(foreach pkg,$(1), $(dir)/$(pkg)_*.ipk)))

apk_package_files = $(wildcard \
$(foreach dir,$(PACKAGE_SUBDIRS), \
$(foreach pkg,$(1), $(dir)/$(pkg)_*.apk)))

# 1: package name
define FeedPackageDir
$(strip $(if $(CONFIG_PER_FEED_REPO), \
Expand All @@ -28,7 +32,7 @@ $(strip $(if $(CONFIG_PER_FEED_REPO), \
endef

# 1: destination file
define FeedSourcesAppend
define FeedSourcesAppendOPKG
( \
echo 'src/gz %d_core %U/targets/%S/packages'; \
$(strip $(if $(CONFIG_PER_FEED_REPO), \
Expand All @@ -41,6 +45,20 @@ define FeedSourcesAppend
) >> $(1)
endef

# 1: destination file
define FeedSourcesAppendAPK
( \
echo '%U/targets/%S/packages/packages.adb'; \
$(strip $(if $(CONFIG_PER_FEED_REPO), \
echo '%U/packages/%A/base/packages.adb'; \
$(if $(filter %SNAPSHOT-y,$(VERSION_NUMBER)-$(CONFIG_BUILDBOT)), \
echo '%U/targets/%S/kmods/$(LINUX_VERSION)-$(LINUX_RELEASE)-$(LINUX_VERMAGIC)/packages.adb';) \
$(foreach feed,$(FEEDS_AVAILABLE), \
$(if $(CONFIG_FEED_$(feed)), \
echo '$(if $(filter m,$(CONFIG_FEED_$(feed))),# )%U/packages/%A/$(feed)/packages.adb';)))) \
) >> $(1)
endef

# 1: package name
define GetABISuffix
$(if $(ABIV_$(1)),$(ABIV_$(1)),$(call FormatABISuffix,$(1),$(foreach v,$(wildcard $(STAGING_DIR)/pkginfo/$(1).version),$(shell cat $(v)))))
Expand Down
8 changes: 3 additions & 5 deletions include/host-build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,11 @@ include $(INCLUDE_DIR)/autotools.mk
_host_target:=$(if $(HOST_QUILT),,.)

Host/Patch:=$(Host/Patch/Default)
ifneq ($(strip $(HOST_UNPACK)),)
define Host/Prepare/Default
$(HOST_UNPACK)
define Host/Prepare/Default
$(if $(strip $(HOST_UNPACK)),$(HOST_UNPACK))
[ ! -d ./src/ ] || $(CP) ./src/* $(HOST_BUILD_DIR)
$(Host/Patch)
endef
endif
endef

define Host/Prepare
$(call Host/Prepare/Default)
Expand Down
22 changes: 20 additions & 2 deletions include/image.mk
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,12 @@ define Image/mkfs/ext4
endef

define Image/Manifest
$(call opkg,$(TARGET_DIR_ORIG)) list-installed > \
$(BIN_DIR)/$(IMG_PREFIX)$(if $(PROFILE_SANITIZED),-$(PROFILE_SANITIZED)).manifest
$(if $(CONFIG_USE_APK), \
$(call apk,$(TARGET_DIR_ORIG)) list --quiet --manifest --no-network | sort | sed 's/ / - /' > \
$(BIN_DIR)/$(IMG_PREFIX)$(if $(PROFILE_SANITIZED),-$(PROFILE_SANITIZED)).manifest, \
$(call opkg,$(TARGET_DIR_ORIG)) list-installed > \
$(BIN_DIR)/$(IMG_PREFIX)$(if $(PROFILE_SANITIZED),-$(PROFILE_SANITIZED)).manifest \
)
ifneq ($(CONFIG_JSON_CYCLONEDX_SBOM),)
$(SCRIPT_DIR)/package-metadata.pl imgcyclonedxsbom \
$(if $(IB),$(TOPDIR)/.packageinfo, $(TMP_DIR)/.packageinfo) \
Expand Down Expand Up @@ -328,7 +332,20 @@ opkg_target = \
$(call opkg,$(mkfs_cur_target_dir)) \
-f $(mkfs_cur_target_dir).conf

apk_target = $(call apk,$(mkfs_cur_target_dir)) --no-scripts


target-dir-%: FORCE
ifneq ($(CONFIG_USE_APK),)
rm -rf $(mkfs_cur_target_dir)
$(CP) $(TARGET_DIR_ORIG) $(mkfs_cur_target_dir)
mv $(mkfs_cur_target_dir)/etc/apk/repositories $(mkfs_cur_target_dir).repositories
$(if $(mkfs_packages_remove), \
$(apk_target) del $(mkfs_packages_remove))
$(if $(mkfs_packages_add), \
$(apk_target) add $(mkfs_packages_add))
mv $(mkfs_cur_target_dir).repositories $(mkfs_cur_target_dir)/etc/apk/repositories
else
rm -rf $(mkfs_cur_target_dir) $(mkfs_cur_target_dir).opkg
$(CP) $(TARGET_DIR_ORIG) $(mkfs_cur_target_dir)
-mv $(mkfs_cur_target_dir)/etc/opkg $(mkfs_cur_target_dir).opkg
Expand All @@ -342,6 +359,7 @@ target-dir-%: FORCE
$(call opkg_package_files,$(mkfs_packages_add)))
-$(CP) -T $(mkfs_cur_target_dir).opkg/ $(mkfs_cur_target_dir)/etc/opkg/
rm -rf $(mkfs_cur_target_dir).opkg $(mkfs_cur_target_dir).conf
endif
$(call prepare_rootfs,$(mkfs_cur_target_dir),$(TOPDIR)/files)

$(KDIR)/root.%: kernel_prepare
Expand Down
145 changes: 104 additions & 41 deletions include/package-ipkg.mk → include/package-pack.mk
Original file line number Diff line number Diff line change
@@ -1,35 +1,32 @@
# SPDX-License-Identifier: GPL-2.0-only
#
# Copyright (C) 2006-2020 OpenWrt.org
# Copyright (C) 2006-2022 OpenWrt.org

ifndef DUMP
include $(INCLUDE_DIR)/feeds.mk
endif

IPKG_REMOVE:= \
$(SCRIPT_DIR)/ipkg-remove

IPKG_STATE_DIR:=$(TARGET_DIR)/usr/lib/opkg

# Generates a make statement to return a wildcard for candidate ipkg files
# 1: package name
define gen_ipkg_wildcard
define gen_package_wildcard
$(1)$$(if $$(filter -%,$$(ABIV_$(1))),,[^a-z-])*
endef

# 1: package name
# 2: candidate ipk files
define remove_ipkg_files
$(if $(strip $(2)),$(IPKG_REMOVE) $(1) $(2))
$(if $(strip $(2)),$(SCRIPT_DIR)/ipkg-remove $(1) $(2))
endef

# 1: package name
# 2: variable name
# 3: variable suffix
# 4: file is a script
define BuildIPKGVariable
define BuildPackVariable
ifdef Package/$(1)/$(2)
$$(IPKG_$(1)) : VAR_$(2)$(3)=$$(Package/$(1)/$(2))
$$(PACK_$(1)) : VAR_$(2)$(3)=$$(Package/$(1)/$(2))
$(call shexport,Package/$(1)/$(2))
$(1)_COMMANDS += echo "$$$$$$$$$(call shvar,Package/$(1)/$(2))" > $(2)$(3); $(if $(4),chmod 0755 $(2)$(3);)
endif
Expand All @@ -50,7 +47,7 @@ strip_deps=$(strip $(subst +,,$(filter-out @%,$(1))))
filter_deps=$(foreach dep,$(call strip_deps,$(1)),$(if $(findstring :,$(dep)),$(call dep_if,$(dep)),$(dep)))

define AddDependency
$$(if $(1),$$(if $(2),$$(foreach pkg,$(1),$$(IPKG_$$(pkg))): $$(foreach pkg,$(2),$$(IPKG_$$(pkg)))))
$$(if $(1),$$(if $(2),$$(foreach pkg,$(1),$$(PACK_$$(pkg))): $$(foreach pkg,$(2),$$(PACK_$$(pkg)))))
endef

define FixupReverseDependencies
Expand Down Expand Up @@ -101,8 +98,13 @@ ifeq ($(DUMP),)
define BuildTarget/ipkg
ABIV_$(1):=$(call FormatABISuffix,$(1),$(ABI_VERSION))
PDIR_$(1):=$(call FeedPackageDir,$(1))
IPKG_$(1):=$$(PDIR_$(1))/$(1)$$(ABIV_$(1))_$(VERSION)_$(PKGARCH).ipk
ifeq ($(CONFIG_USE_APK),)
PACK_$(1):=$$(PDIR_$(1))/$(1)$$(ABIV_$(1))_$(VERSION)_$(PKGARCH).ipk
else
PACK_$(1):=$$(PDIR_$(1))/$(1)$$(ABIV_$(1))-$(VERSION).apk
endif
IDIR_$(1):=$(PKG_BUILD_DIR)/ipkg-$(PKGARCH)/$(1)
ADIR_$(1):=$(PKG_BUILD_DIR)/apk-$(PKGARCH)/$(1)
KEEP_$(1):=$(strip $(call Package/$(1)/conffiles))

TARGET_VARIANT:=$$(if $(ALL_VARIANTS),$$(if $$(VARIANT),$$(filter-out *,$$(VARIANT)),$(firstword $(ALL_VARIANTS))))
Expand All @@ -117,8 +119,8 @@ ifeq ($(DUMP),)
ifdef do_install
ifneq ($(CONFIG_PACKAGE_$(1))$(DEVELOPER),)
IPKGS += $(1)
$(_pkg_target)compile: $$(IPKG_$(1)) $(PKG_INFO_DIR)/$(1).provides $(PKG_BUILD_DIR)/.pkgdir/$(1).installed
prepare-package-install: $$(IPKG_$(1))
$(_pkg_target)compile: $$(PACK_$(1)) $(PKG_INFO_DIR)/$(1).provides $(PKG_BUILD_DIR)/.pkgdir/$(1).installed
prepare-package-install: $$(PACK_$(1))
compile: $(STAGING_DIR_ROOT)/stamp/.$(1)_installed
else
$(if $(CONFIG_PACKAGE_$(1)),$$(info WARNING: skipping $(1) -- package not selected))
Expand All @@ -141,11 +143,11 @@ ifeq ($(DUMP),)
$(FixupDependencies)
$(FixupReverseDependencies)

$(eval $(call BuildIPKGVariable,$(1),conffiles))
$(eval $(call BuildIPKGVariable,$(1),preinst,,1))
$(eval $(call BuildIPKGVariable,$(1),postinst,-pkg,1))
$(eval $(call BuildIPKGVariable,$(1),prerm,-pkg,1))
$(eval $(call BuildIPKGVariable,$(1),postrm,,1))
$(eval $(call BuildPackVariable,$(1),conffiles))
$(eval $(call BuildPackVariable,$(1),preinst,,1))
$(eval $(call BuildPackVariable,$(1),postinst,-pkg,1))
$(eval $(call BuildPackVariable,$(1),prerm,-pkg,1))
$(eval $(call BuildPackVariable,$(1),postrm,,1))

$(PKG_BUILD_DIR)/.pkgdir/$(1).installed : export PATH=$$(TARGET_PATH_PKG)
$(PKG_BUILD_DIR)/.pkgdir/$(1).installed: $(STAMP_BUILT)
Expand Down Expand Up @@ -195,14 +197,16 @@ $$(call addfield,Depends,$$(Package/$(1)/DEPENDS)
Installed-Size: 0
$(_endef)

$$(IPKG_$(1)) : export CONTROL=$$(Package/$(1)/CONTROL)
$$(IPKG_$(1)) : export DESCRIPTION=$$(Package/$(1)/description)
$$(IPKG_$(1)) : export PATH=$$(TARGET_PATH_PKG)
$$(IPKG_$(1)) : export PKG_SOURCE_DATE_EPOCH:=$(PKG_SOURCE_DATE_EPOCH)
$(PKG_INFO_DIR)/$(1).provides $$(IPKG_$(1)): $(STAMP_BUILT) $(INCLUDE_DIR)/package-ipkg.mk
@rm -rf $$(IDIR_$(1)); \
$$(call remove_ipkg_files,$(1),$$(call opkg_package_files,$(call gen_ipkg_wildcard,$(1))))
mkdir -p $(PACKAGE_DIR) $$(IDIR_$(1))/CONTROL $(PKG_INFO_DIR)
$$(PACK_$(1)) : export CONTROL=$$(Package/$(1)/CONTROL)
$$(PACK_$(1)) : export DESCRIPTION=$$(Package/$(1)/description)
$$(PACK_$(1)) : export PATH=$$(TARGET_PATH_PKG)
$$(PACK_$(1)) : export PKG_SOURCE_DATE_EPOCH:=$(PKG_SOURCE_DATE_EPOCH)
$(PKG_INFO_DIR)/$(1).provides $$(PACK_$(1)): $(STAMP_BUILT) $(INCLUDE_DIR)/package-pack.mk
rm -rf $$(IDIR_$(1))
ifeq ($$(CONFIG_USE_APK),)
$$(call remove_ipkg_files,$(1),$$(call opkg_package_files,$(call gen_package_wildcard,$(1))))
endif
mkdir -p $(PACKAGE_DIR) $$(IDIR_$(1)) $(PKG_INFO_DIR)
$(call Package/$(1)/install,$$(IDIR_$(1)))
$(if $(Package/$(1)/install-overlay),mkdir -p $(PACKAGE_DIR) $$(IDIR_$(1))/rootfs-overlay)
$(call Package/$(1)/install-overlay,$$(IDIR_$(1))/rootfs-overlay)
Expand All @@ -228,6 +232,24 @@ $(_endef)
) || true \
)
endif

ifneq ($$(KEEP_$(1)),)
@( \
keepfiles=""; \
for x in $$(KEEP_$(1)); do \
[ -f "$$(IDIR_$(1))/$$$$x" ] || keepfiles="$$$${keepfiles:+$$$$keepfiles }$$$$x"; \
done; \
[ -z "$$$$keepfiles" ] || { \
mkdir -p $$(IDIR_$(1))/lib/upgrade/keep.d; \
for x in $$$$keepfiles; do echo $$$$x >> $$(IDIR_$(1))/lib/upgrade/keep.d/$(1); done; \
}; \
)
endif

$(INSTALL_DIR) $$(PDIR_$(1))/tmp

ifeq ($(CONFIG_USE_APK),)
mkdir -p $$(IDIR_$(1))/CONTROL
(cd $$(IDIR_$(1))/CONTROL; \
( \
echo "$$$$CONTROL"; \
Expand All @@ -251,25 +273,66 @@ $(_endef)
$($(1)_COMMANDS) \
)

ifneq ($$(KEEP_$(1)),)
@( \
keepfiles=""; \
for x in $$(KEEP_$(1)); do \
[ -f "$$(IDIR_$(1))/$$$$x" ] || keepfiles="$$$${keepfiles:+$$$$keepfiles }$$$$x"; \
done; \
[ -z "$$$$keepfiles" ] || { \
mkdir -p $$(IDIR_$(1))/lib/upgrade/keep.d; \
for x in $$$$keepfiles; do echo $$$$x >> $$(IDIR_$(1))/lib/upgrade/keep.d/$(1); done; \
}; \
)
endif

$(INSTALL_DIR) $$(PDIR_$(1))
$(FAKEROOT) $(STAGING_DIR_HOST)/bin/bash $(SCRIPT_DIR)/ipkg-build -m "$(FILE_MODES)" $$(IDIR_$(1)) $$(PDIR_$(1))
@[ -f $$(IPKG_$(1)) ]
else
mkdir -p $$(ADIR_$(1))/
mkdir -p $$(IDIR_$(1))/lib/apk/packages/

(cd $$(ADIR_$(1)); $($(1)_COMMANDS))

( \
echo "#!/bin/sh"; \
echo "[ \"\$$$${IPKG_NO_SCRIPT}\" = \"1\" ] && exit 0"; \
echo "[ -s "\$$$${IPKG_INSTROOT}/lib/functions.sh" ] || exit 0"; \
echo ". \$$$${IPKG_INSTROOT}/lib/functions.sh"; \
echo 'export root="$$$${IPKG_INSTROOT}"'; \
echo 'export pkgname="$(1)"'; \
echo "add_group_and_user"; \
[ ! -f $$(ADIR_$(1))/postinst-pkg ] || cat "$$(ADIR_$(1))/postinst-pkg"; \
echo "default_postinst"; \
) > $$(ADIR_$(1))/post-install;

( \
echo "#!/bin/sh"; \
echo "[ -s "\$$$${IPKG_INSTROOT}/lib/functions.sh" ] || exit 0"; \
echo ". \$$$${IPKG_INSTROOT}/lib/functions.sh"; \
echo 'export root="$$$${IPKG_INSTROOT}"'; \
echo 'export pkgname="$(1)"'; \
[ ! -f $$(ADIR_$(1))/prerm-pkg ] || cat "$$(ADIR_$(1))/prerm-pkg"; \
echo "default_prerm"; \
) > $$(ADIR_$(1))/pre-deinstall;

if [ -n "$(USERID)" ]; then echo $(USERID) > $$(IDIR_$(1))/lib/apk/packages/$(1).rusers; fi;
if [ -n "$(ALTERNATIVES)" ]; then echo $(ALTERNATIVES) > $$(IDIR_$(1))/lib/apk/packages/$(1).alternatives; fi;
(cd $$(IDIR_$(1)) && find . -type f,l -printf "/%P\n" > $$(IDIR_$(1))/lib/apk/packages/$(1).list)
if [ -f $$(ADIR_$(1))/conffiles ]; then mv $$(ADIR_$(1))/conffiles $$(IDIR_$(1))/lib/apk/packages/$(1).conffiles; fi;

$(FAKEROOT) $(STAGING_DIR_HOST)/bin/apk mkpkg \
--info "name:$(1)$$(ABIV_$(1))" \
--info "version:$(VERSION)" \
--info "description:" \
--info "arch:$(PKGARCH)" \
--info "license:$(LICENSE)" \
--info "origin:$(SOURCE)" \
--info "provides:$$(foreach prov,$$(filter-out $(1)$$(ABIV_$(1)),$(PROVIDES)$$(if $$(ABIV_$(1)), \
$(1) $(foreach provide,$(PROVIDES),$(provide)$$(ABIV_$(1))))),$$(prov)=$(VERSION) )" \
--script "post-install:$$(ADIR_$(1))/post-install" \
--script "pre-deinstall:$$(ADIR_$(1))/pre-deinstall" \
--info "depends:$$(foreach depends,$$(subst $$(comma),$$(space),$$(subst $$(space),,$$(subst $$(paren_right),,$$(subst $$(paren_left),,$$(Package/$(1)/DEPENDS))))),$$(depends))" \
--files "$$(IDIR_$(1))" \
--output "$$(PACK_$(1))" \
--sign "$(BUILD_KEY_APK_SEC)"
endif

@[ -f $$(PACK_$(1)) ]

$(1)-clean:
$$(call remove_ipkg_files,$(1),$$(call opkg_package_files,$(call gen_ipkg_wildcard,$(1))))
ifeq ($(CONFIG_USE_APK),)
$$(call remove_ipkg_files,$(1),$$(call opkg_package_files,$(call gen_package_wildcard,$(1))))
else
$$(call remove_ipkg_files,$(1),$$(call apk_package_files,$(call gen_package_wildcard,$(1))))
endif


clean: $(1)-clean

Expand Down
2 changes: 1 addition & 1 deletion include/package.mk
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ PKG_INSTALL_STAMP:=$(PKG_INFO_DIR)/$(PKG_DIR_NAME).$(if $(BUILD_VARIANT),$(BUILD

include $(INCLUDE_DIR)/package-defaults.mk
include $(INCLUDE_DIR)/package-dumpinfo.mk
include $(INCLUDE_DIR)/package-ipkg.mk
include $(INCLUDE_DIR)/package-pack.mk
include $(INCLUDE_DIR)/package-bin.mk
include $(INCLUDE_DIR)/autotools.mk

Expand Down
Loading

0 comments on commit 801f97c

Please sign in to comment.