Makefile 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. #
  2. # Copyright (C) 2006-2010 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. curdir:=package
  8. include $(INCLUDE_DIR)/feeds.mk
  9. include $(INCLUDE_DIR)/rootfs.mk
  10. -include $(TMP_DIR)/.packagedeps
  11. package-y += kernel/linux
  12. $(curdir)/autoremove:=1
  13. $(curdir)/builddirs:=$(sort $(package-) $(package-y) $(package-m))
  14. $(curdir)/builddirs-default:=. $(sort $(package-y) $(package-m))
  15. $(curdir)/builddirs-prereq:=. $(sort $(prereq-y) $(prereq-m))
  16. ifdef CHECK_ALL
  17. $(curdir)/builddirs-check:=$($(curdir)/builddirs)
  18. $(curdir)/builddirs-download:=$($(curdir)/builddirs)
  19. endif
  20. ifneq ($(IGNORE_ERRORS),)
  21. package-y-filter := $(package-y)
  22. package-m-filter := $(filter-out $(package-y),$(package-m))
  23. package-n-filter := $(filter-out $(package-y) $(package-m),$(package-))
  24. package-ignore-errors := $(filter n m y,$(IGNORE_ERRORS))
  25. package-ignore-errors := $(if $(package-ignore-errors),$(package-ignore-errors),n m)
  26. package-ignore-subdirs := $(sort $(foreach m,$(package-ignore-errors),$(package-$(m)-filter)))
  27. $(curdir)/builddirs-ignore-download := $(package-ignore-subdirs)
  28. $(curdir)/builddirs-ignore-compile := $(package-ignore-subdirs)
  29. $(curdir)/builddirs-ignore-host-download := $(package-ignore-subdirs)
  30. $(curdir)/builddirs-ignore-host-compile := $(package-ignore-subdirs)
  31. endif
  32. PACKAGE_INSTALL_FILES:= \
  33. $(foreach pkg,$(sort $(package-y)), \
  34. $(foreach variant, \
  35. $(if $(strip $(package/$(pkg)/variants)), \
  36. $(package/$(pkg)/variants), \
  37. $(if $(package/$(pkg)/default-variant), \
  38. $(package/$(pkg)/default-variant), \
  39. default \
  40. ) \
  41. ), \
  42. $(PKG_INFO_DIR)/$(lastword $(subst /,$(space),$(pkg))).$(variant).install \
  43. ) \
  44. )
  45. $(curdir)/cleanup: $(TMP_DIR)/.build
  46. rm -rf $(STAGING_DIR_ROOT)
  47. $(curdir)/merge:
  48. rm -rf $(PACKAGE_DIR_ALL)
  49. mkdir -p $(PACKAGE_DIR_ALL)
  50. ifneq ($(CONFIG_USE_APK),)
  51. -$(foreach pdir,$(PACKAGE_SUBDIRS),$(if $(wildcard $(pdir)/*.apk),ln -s $(pdir)/*.apk $(PACKAGE_DIR_ALL);))
  52. else
  53. -$(foreach pdir,$(PACKAGE_SUBDIRS),$(if $(wildcard $(pdir)/*.ipk),ln -s $(pdir)/*.ipk $(PACKAGE_DIR_ALL);))
  54. endif
  55. $(BUILD_KEY_APK_SEC):
  56. $(STAGING_DIR_HOST)/bin/openssl ecparam -name prime256v1 -genkey -noout -out $(BUILD_KEY_APK_SEC)
  57. $(BUILD_KEY_APK_PUB): $(BUILD_KEY_APK_SEC)
  58. $(STAGING_DIR_HOST)/bin/openssl ec -in $(BUILD_KEY_APK_SEC) -pubout > $(BUILD_KEY_APK_PUB)
  59. $(curdir)/merge-index: $(curdir)/merge
  60. ifneq ($(CONFIG_USE_APK),)
  61. (cd $(PACKAGE_DIR_ALL) && $(STAGING_DIR_HOST)/bin/apk mkndx \
  62. --root $(TOPDIR) \
  63. --keys-dir $(TOPDIR) \
  64. --allow-untrusted \
  65. $(if $(CONFIG_SIGNED_PACKAGES),--sign $(BUILD_KEY_APK_SEC),) \
  66. --output packages.adb \
  67. *.apk; \
  68. )
  69. else
  70. (cd $(PACKAGE_DIR_ALL) && $(SCRIPT_DIR)/ipkg-make-index.sh . 2>&1 > Packages; )
  71. endif
  72. ifndef SDK
  73. $(curdir)//compile = $(STAGING_DIR)/.prepared $(BIN_DIR)
  74. ifneq ($(CONFIG_USE_APK),)
  75. $(curdir)//compile += $(curdir)/system/apk/host/compile $(BUILD_KEY_APK_SEC) $(BUILD_KEY_APK_PUB)
  76. else
  77. $(curdir)/compile: $(curdir)/system/opkg/host/compile
  78. endif
  79. else
  80. ifneq ($(CONFIG_USE_APK),)
  81. $(curdir)//compile += $(BUILD_KEY_APK_SEC) $(BUILD_KEY_APK_PUB)
  82. endif
  83. endif
  84. $(curdir)/install: $(TMP_DIR)/.build $(curdir)/merge $(curdir)/merge-index
  85. - find $(STAGING_DIR_ROOT) -type d | $(XARGS) chmod 0755
  86. rm -rf $(TARGET_DIR) $(TARGET_DIR_ORIG)
  87. mkdir -p $(TARGET_DIR)/tmp
  88. ifneq ($(CONFIG_USE_APK),)
  89. $(file >$(TMP_DIR)/apk_install_list,\
  90. $(foreach pkg,$(shell cat $(PACKAGE_INSTALL_FILES) 2>/dev/null),$(pkg)$(call GetABISuffix,$(pkg))))
  91. $(call apk,$(TARGET_DIR)) add --no-cache --initdb --no-scripts --arch $(ARCH_PACKAGES) \
  92. --repositories-file /dev/null --repository file://$(PACKAGE_DIR_ALL)/packages.adb \
  93. $(if $(CONFIG_SIGNED_PACKAGES),,--allow-untrusted) \
  94. $$(cat $(TMP_DIR)/apk_install_list) \
  95. "base-files=$(shell cat $(TMP_DIR)/base-files.version)" \
  96. "libc=$(shell cat $(TMP_DIR)/libc.version)" \
  97. "kernel=$(shell cat $(TMP_DIR)/kernel.version)"
  98. rm -rf $(TARGET_DIR)/run
  99. else
  100. $(file >$(TMP_DIR)/opkg_install_list,\
  101. $(call opkg_package_files,\
  102. $(foreach pkg,$(shell cat $(PACKAGE_INSTALL_FILES) 2>/dev/null),$(pkg)$(call GetABISuffix,$(pkg)))))
  103. $(call opkg,$(TARGET_DIR)) install $$(cat $(TMP_DIR)/opkg_install_list)
  104. @for file in $(PACKAGE_INSTALL_FILES); do \
  105. [ -s $$file.flags ] || continue; \
  106. for flag in `cat $$file.flags`; do \
  107. $(call opkg,$(TARGET_DIR)) flag $$flag `cat $$file`; \
  108. done; \
  109. done || true
  110. endif
  111. $(CP) $(TARGET_DIR) $(TARGET_DIR_ORIG)
  112. $(call prepare_rootfs,$(TARGET_DIR),$(TOPDIR)/files)
  113. $(curdir)/index: FORCE
  114. @echo Generating package index...
  115. ifneq ($(CONFIG_USE_APK),)
  116. @for d in $(PACKAGE_SUBDIRS); do \
  117. mkdir -p $$d; \
  118. cd $$d || continue; \
  119. ls *.apk >/dev/null 2>&1 || continue; \
  120. $(STAGING_DIR_HOST)/bin/apk mkndx \
  121. --root $(TOPDIR) \
  122. --keys-dir $(TOPDIR) \
  123. --allow-untrusted \
  124. $(if $(CONFIG_SIGNED_PACKAGES),--sign $(BUILD_KEY_APK_SEC),) \
  125. --output packages.adb \
  126. *.apk; \
  127. $(STAGING_DIR_HOST)/bin/apk adbdump --format json packages.adb | \
  128. $(SCRIPT_DIR)/make-index-json.py -f apk -a "$(ARCH_PACKAGES)" - > index.json; \
  129. done
  130. else
  131. @for d in $(PACKAGE_SUBDIRS); do ( \
  132. mkdir -p $$d; \
  133. cd $$d || continue; \
  134. $(SCRIPT_DIR)/ipkg-make-index.sh . 2>&1 > Packages.manifest; \
  135. grep -vE '^(Maintainer|LicenseFiles|Source|SourceName|Require|SourceDateEpoch)' Packages.manifest > Packages; \
  136. case "$$(((64 + $$(stat -L -c%s Packages)) % 128))" in 110|111) \
  137. $(call ERROR_MESSAGE,WARNING: Applying padding in $$d/Packages to workaround usign SHA-512 bug!); \
  138. { echo ""; echo ""; } >> Packages;; \
  139. esac; \
  140. $(SCRIPT_DIR)/make-index-json.py -f opkg -a "$(ARCH_PACKAGES)" Packages > index.json; \
  141. gzip -9nc Packages > Packages.gz; \
  142. ); done
  143. ifdef CONFIG_SIGNED_PACKAGES
  144. @echo Signing package index...
  145. @for d in $(PACKAGE_SUBDIRS); do ( \
  146. [ -d $$d ] && \
  147. cd $$d || continue; \
  148. $(STAGING_DIR_HOST)/bin/usign -S -m Packages -s $(BUILD_KEY); \
  149. ); done
  150. endif
  151. ifdef CONFIG_JSON_CYCLONEDX_SBOM
  152. @echo Creating CycloneDX package SBOMs...
  153. @for d in $(PACKAGE_SUBDIRS); do ( \
  154. [ -d $$d ] && \
  155. cd $$d || continue; \
  156. $(SCRIPT_DIR)/package-metadata.pl pkgcyclonedxsbom Packages.manifest > Packages.bom.cdx.json || true; \
  157. ); done
  158. endif
  159. endif
  160. $(call sha256sums,$(OUTPUT_DIR)/packages/$(ARCH_PACKAGES),1)
  161. $(curdir)/flags-install:= -j1
  162. $(eval $(call stampfile,$(curdir),package,prereq,.config))
  163. $(eval $(call stampfile,$(curdir),package,cleanup,$(TMP_DIR)/.build))
  164. $(eval $(call stampfile,$(curdir),package,compile,$(TMP_DIR)/.build))
  165. $(eval $(call stampfile,$(curdir),package,install,$(TMP_DIR)/.build))
  166. $(eval $(call stampfile,$(curdir),package,check,$(TMP_DIR)/.build))
  167. $(eval $(call subdir,$(curdir)))