feeds: use common macro "FeedSourcesAppend" to populate opkg configurations
authorJo-Philipp Wich <jow@openwrt.org>
Thu, 28 May 2015 09:47:37 +0000 (09:47 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Thu, 28 May 2015 09:47:37 +0000 (09:47 +0000)
This introduces a common macro to assemble the correct url templates to
avoid code duplication and have the feed config handling in a central place.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
SVN-Revision: 45799

include/feeds.mk
package/system/opkg/Makefile
target/imagebuilder/Makefile

index 695b03b145e8046b6a4d0b94d0632066cad51989..b1a8f81da924270ca7fae2fc55840fa239795896 100644 (file)
@@ -24,3 +24,16 @@ $(strip $(if $(CONFIG_PER_FEED_REPO), \
   $(abspath $(PACKAGE_DIR)/$(if $(Package/$(1)/feed),$(Package/$(1)/feed),base)), \
   $(PACKAGE_DIR)))
 endef
+
+# 1: destination file
+define FeedSourcesAppend
+( \
+  $(strip $(if $(CONFIG_PER_FEED_REPO), \
+       $(foreach feed,base $(FEEDS_ENABLED),echo "src/gz %n_$(feed) %U/$(feed)";) \
+       $(if $(CONFIG_PER_FEED_REPO_ADD_DISABLED), \
+               $(foreach feed,$(FEEDS_DISABLED),echo "$(if $(CONFIG_PER_FEED_REPO_ADD_COMMENTED),# )src/gz %n_$(feed) %U/$(feed)";)) \
+  , \
+       echo "src/gz %n %U"; \
+  )) \
+) >> $(1)
+endef
index 1b1f3f19e433fcc94375479bfc954bf364d0b113..d313c442ddb5fe46b676449dc7a03a747656e95f 100644 (file)
@@ -115,18 +115,7 @@ define Package/opkg/Default/install
   ifneq ($(CONFIG_SIGNED_PACKAGES),)
        echo "option check_signature 1" >> $(1)/etc/opkg.conf
   endif
-  ifeq ($(CONFIG_PER_FEED_REPO),)
-       echo "src/gz %n %U" >> $(1)/etc/opkg.conf
-  else
-       for d in base $(FEEDS_ENABLED); do \
-               echo "src/gz %n_$$$$d %U/$$$$d" >> $(1)/etc/opkg.conf; \
-       done
-    ifneq ($(CONFIG_PER_FEED_REPO_ADD_DISABLED),)
-       for d in $(FEEDS_DISABLED); do \
-               echo "$(if $(CONFIG_PER_FEED_REPO_ADD_COMMENTED),# )src/gz %n_$$$$d %U/$$$$d" >> $(1)/etc/opkg.conf; \
-       done
-    endif
-  endif
+       $(call FeedSourcesAppend,$(1)/etc/opkg.conf)
        $(VERSION_SED) $(1)/etc/opkg.conf
        $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/opkg-cl $(1)/bin/opkg
 endef
index 218def7e1df10f4f5e247f804a3337b1fac2ab11..7f48ed885f4e0d49abee9c62bb5af48a764b22b1 100644 (file)
@@ -37,20 +37,10 @@ $(BIN_DIR)/$(IB_NAME).tar.bz2: clean
 
 ifeq ($(CONFIG_IB_STANDALONE),)
        echo '## Remote package repositories' >> $(PKG_BUILD_DIR)/repositories.conf
-  ifeq ($(CONFIG_PER_FEED_REPO),)
-       echo "src/gz %n %U" >> $(PKG_BUILD_DIR)/repositories.conf
-  else
-       for d in base $(FEEDS_ENABLED); do \
-               echo "src/gz %n_$$d %U/$$d" >> $(PKG_BUILD_DIR)/repositories.conf; \
-       done
-    ifneq ($(CONFIG_PER_FEED_REPO_ADD_DISABLED),)
-       for d in $(FEEDS_DISABLED); do \
-               echo "$(if $(CONFIG_PER_FEED_REPO_ADD_COMMENTED),# )src/gz %n_$$d %U/$$d" >> $(PKG_BUILD_DIR)/repositories.conf; \
-       done
-    endif
-  endif
+       $(call FeedSourcesAppend,$(PKG_BUILD_DIR)/repositories.conf)
 endif
 
+       echo ''                                                        >> $(PKG_BUILD_DIR)/repositories.conf
        echo '## This is the local package repository, do not remove!' >> $(PKG_BUILD_DIR)/repositories.conf
        echo 'src imagebuilder file:packages'                          >> $(PKG_BUILD_DIR)/repositories.conf