I'm not entirely sure what you mean by "branch". If you mean that a separate SDK instance is needed to build packages for each OpenWrt release then there are 2 aspects to this.
First: this makes it very hard to provide updates for a package on older OpenWrt versions. So this would strongly discourage me from supporting anything but the most recent OpenWrt version. I understand that updating a package in the OpenWrt repository for an older version is problematic, but at least I can provide updates via my own Github page. If I have to use a separate SDK for each version then this becomes completely not feasible.
Second: in practice, I haven't encountered any problems with my current approach of compiling opkg packages on a recent-ish SDK and installing them on old'ish systems. Just now I tested the toolchain/SDK in the current snapshot, and the built opkg packages install and uninstall just fine on a system running an OpenWrt snapshot from around 2021, and on a system running OpenWrt 23.05.2. Maybe this works for my project because the packages are fairly simple (just some shell scripts and text files), and it won't work for someone else. But as long as it works for me and no problems are reported, I will continue to use this method because the benefit of providing updates to older systems is way too big to give up easily.
While this may come across as being stubborn, my goal is to better serve people who are using older versions of OpenWrt and to avoid being part of the 'use-latest-or-get-lost' software development culture.
Because my general approach, as explained above, is to support the widest range of systems possible via the Releases page in my Github repo.
In the meantime, it dawned on me that rather than doing the quite fragile modifications to the logic in package-pack.mk
, I can simply set the CONFIG_USE_APK
variable in the beginning of package-pack.mk
. I also figured out that the provides
directive needs to be changed. So the diffs are simple:
$ diff include/package-pack.mk include/package-pack-apk.mk
4a5,6
> CONFIG_USE_APK=y
>
215c217
< $(PKG_INFO_DIR)/$(1).provides $$(PACK_$(1)): $(STAMP_BUILT) $(INCLUDE_DIR)/package-pack.mk
---
> $(PKG_INFO_DIR)/$(1).provides $$(PACK_$(1)): $(STAMP_BUILT) $(INCLUDE_DIR)/package-pack-apk.mk
$ diff include/package-pack.mk include/package-pack-ipk.mk
4a5,6
> CONFIG_USE_APK=
>
215c217
< $(PKG_INFO_DIR)/$(1).provides $$(PACK_$(1)): $(STAMP_BUILT) $(INCLUDE_DIR)/package-pack.mk
---
> $(PKG_INFO_DIR)/$(1).provides $$(PACK_$(1)): $(STAMP_BUILT) $(INCLUDE_DIR)/package-pack-ipk.mk
$ diff include/package.mk /tmp/package.mk
139c139,140
< include $(INCLUDE_DIR)/package-pack.mk
---
> include $(INCLUDE_DIR)/package-pack-apk.mk
> include $(INCLUDE_DIR)/package-pack-ipk.mk
When the above diffs are applied, only one package type is built, and the type depends on the order in which the includes are specified in package.mk. If apk is specified last then it builds apk, otherwise it builds ipk. So I think that this is a namespace issue, i.e. same-named functions are defined twice and only the last definition sticks.