[LEDE-DEV] added package_list function to imagebuilder

Submitted by Paul Spooren on June 5, 2017, 1:18 p.m.

Details

Message ID 20170605131801.ts5zin5cj4dbh6rj@led
State New
Headers show

Commit Message

Paul Spooren June 5, 2017, 1:18 p.m.
imagebuilder: the imagebuilder can now post all available
packages by using make package_list. This is usefull to see all packages
with versions (and size)

Signed-off-by: Paul Spooren <paul@spooren.de>
---
 target/imagebuilder/files/Makefile | 32 ++++++++++++++++++++------------
 1 file changed, 20 insertions(+), 12 deletions(-)

Patch hide | download patch | download mbox

diff --git a/target/imagebuilder/files/Makefile b/target/imagebuilder/files/Makefile
index f0e2bd1281..2c787544c0 100644
--- a/target/imagebuilder/files/Makefile
+++ b/target/imagebuilder/files/Makefile
@@ -13,7 +13,7 @@  export TOPDIR LC_ALL LANG
 export OPENWRT_VERBOSE=s
 all: help
 
-export PATH:=$(TOPDIR)/staging_dir/host/bin:$(PATH)
+include $(TOPDIR)/include/host.mk
 
 ifneq ($(OPENWRT_BUILD),1)
   override OPENWRT_BUILD=1
@@ -82,6 +82,7 @@  PROFILE_LIST = $(foreach p,$(PROFILE_NAMES), \
 
 staging_dir/host/.prereq-build: include/prereq-build.mk
 	mkdir -p tmp
+	rm -f tmp/.host.mk
 	@$(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f $(TOPDIR)/include/prereq-build.mk prereq 2>/dev/null || { \
 		echo "Prerequisite check failed. Use FORCE=1 to override."; \
 		false; \
@@ -111,20 +112,14 @@  _call_image: staging_dir/host/.prereq-build
 	echo
 	rm -rf $(TARGET_DIR)
 	mkdir -p $(TARGET_DIR) $(BIN_DIR) $(TMP_DIR) $(DL_DIR)
-	if [ ! -f "$(PACKAGE_DIR)/Packages" ] || [ ! -f "$(PACKAGE_DIR)/Packages.gz" ] || [ "`find $(PACKAGE_DIR) -cnewer $(PACKAGE_DIR)/Packages.gz`" ]; then \
-		echo "Package list missing or not up-to-date, generating it.";\
-		$(MAKE) package_index; \
-	else \
-		mkdir -p $(TARGET_DIR)/tmp; \
-		$(OPKG) update || true; \
-	fi
+	$(MAKE) package_reload
 	$(MAKE) package_install
 ifneq ($(USER_FILES),)
 	$(MAKE) copy_files
 endif
-	$(MAKE) -s package_postinst
-	$(MAKE) -s build_image
-	$(MAKE) -s checksum
+	$(MAKE) package_postinst
+	$(MAKE) build_image
+	$(MAKE) checksum
 
 package_index: FORCE
 	@echo
@@ -135,6 +130,19 @@  package_index: FORCE
 	) >/dev/null 2>/dev/null
 	$(OPKG) update || true
 
+package_reload:
+	if [ ! -f "$(PACKAGE_DIR)/Packages" ] || [ ! -f "$(PACKAGE_DIR)/Packages.gz" ] || [ "`find $(PACKAGE_DIR) -cnewer $(PACKAGE_DIR)/Packages.gz`" ]; then \
+		echo "Package list missing or not up-to-date, generating it.";\
+		$(MAKE) package_index; \
+	else \
+		mkdir -p $(TARGET_DIR)/tmp; \
+		$(OPKG) update || true; \
+	fi
+
+package_list: FORCE
+	@$(MAKE) package_reload |:
+	@$(OPKG) list --size 2>/dev/null | awk -F" - " '{printf "%s %s %s\n", $$1, $$2, $$3}'
+
 package_install: FORCE
 	@echo
 	@echo Installing packages...
@@ -193,7 +201,7 @@  ifneq ($(PROFILE),)
   endif
 endif
 	(unset PROFILE FILES PACKAGES MAKEFLAGS; \
-	$(MAKE) -s _call_image \
+	$(MAKE) _call_image \
 		$(if $(PROFILE),USER_PROFILE="$(PROFILE_FILTER)") \
 		$(if $(FILES),USER_FILES="$(FILES)") \
 		$(if $(PACKAGES),USER_PACKAGES="$(PACKAGES)") \