Browse Source

build: generate private key for APK early

Other than OPKG which only uses signed package list, APK uses
individually signed packages in addition to signed package lists. Hence,
in order to be able to generate package, the private key needs to be
generated before compiling packages. Express that dependency and
generate the private key before building any packages instead of doing
so as part of the base-files package build.

Fixes: d788ab376f ("build: add APK package build capabilities")
Signed-off-by: Daniel Golle <[email protected]>
Daniel Golle 1 year ago
parent
commit
9a11bc3682
2 changed files with 7 additions and 7 deletions
  1. 7 1
      package/Makefile
  2. 0 6
      package/base-files/Makefile

+ 7 - 1
package/Makefile

@@ -59,6 +59,12 @@ else
 	-$(foreach pdir,$(PACKAGE_SUBDIRS),$(if $(wildcard $(pdir)/*.ipk),ln -s $(pdir)/*.ipk $(PACKAGE_DIR_ALL);))
 	-$(foreach pdir,$(PACKAGE_SUBDIRS),$(if $(wildcard $(pdir)/*.ipk),ln -s $(pdir)/*.ipk $(PACKAGE_DIR_ALL);))
 endif
 endif
 
 
+$(BUILD_KEY_APK_SEC):
+	$(STAGING_DIR_HOST)/bin/openssl ecparam -name prime256v1 -genkey -noout -out $(BUILD_KEY_APK_SEC)
+
+$(BUILD_KEY_APK_PUB): $(BUILD_KEY_APK_SEC)
+	$(STAGING_DIR_HOST)/bin/openssl ec -in $(BUILD_KEY_APK_SEC) -pubout > $(BUILD_KEY_APK_PUB)
+
 $(curdir)/merge-index: $(curdir)/merge
 $(curdir)/merge-index: $(curdir)/merge
 ifneq ($(CONFIG_USE_APK),)
 ifneq ($(CONFIG_USE_APK),)
 	(cd $(PACKAGE_DIR_ALL) && $(STAGING_DIR_HOST)/bin/apk mkndx \
 	(cd $(PACKAGE_DIR_ALL) && $(STAGING_DIR_HOST)/bin/apk mkndx \
@@ -75,7 +81,7 @@ endif
 ifndef SDK
 ifndef SDK
   $(curdir)//compile = $(STAGING_DIR)/.prepared $(BIN_DIR)
   $(curdir)//compile = $(STAGING_DIR)/.prepared $(BIN_DIR)
 ifneq ($(CONFIG_USE_APK),)
 ifneq ($(CONFIG_USE_APK),)
-  $(curdir)/compile: $(curdir)/system/apk/host/compile
+  $(curdir)/compile: $(curdir)/system/apk/host/compile $(BUILD_KEY_APK_SEC) $(BUILD_KEY_APK_PUB)
 else
 else
   $(curdir)/compile: $(curdir)/system/opkg/host/compile
   $(curdir)/compile: $(curdir)/system/opkg/host/compile
 endif
 endif

+ 0 - 6
package/base-files/Makefile

@@ -117,12 +117,6 @@ endef
 Build/Compile = $(Build/Compile/Default)
 Build/Compile = $(Build/Compile/Default)
 
 
 ifneq ($(CONFIG_USE_APK),)
 ifneq ($(CONFIG_USE_APK),)
-  define Build/Configure
-	[ -s $(BUILD_KEY_APK_SEC) -a -s $(BUILD_KEY_APK_PUB) ] || \
-		$(STAGING_DIR_HOST)/bin/openssl ecparam -name prime256v1 -genkey -noout -out $(BUILD_KEY_APK_SEC); \
-		$(STAGING_DIR_HOST)/bin/openssl ec -in $(BUILD_KEY_APK_SEC) -pubout > $(BUILD_KEY_APK_PUB)
-  endef
-
 ifndef CONFIG_BUILDBOT
 ifndef CONFIG_BUILDBOT
   define Package/base-files/install-key
   define Package/base-files/install-key
 	mkdir -p $(1)/etc/apk/keys
 	mkdir -p $(1)/etc/apk/keys