Makefile 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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. --sign $(BUILD_KEY_APK_SEC) \
  65. --output packages.adb \
  66. *.apk; \
  67. )
  68. else
  69. (cd $(PACKAGE_DIR_ALL) && $(SCRIPT_DIR)/ipkg-make-index.sh . 2>&1 > Packages; )
  70. endif
  71. ifndef SDK
  72. $(curdir)//compile = $(STAGING_DIR)/.prepared $(BIN_DIR)
  73. ifneq ($(CONFIG_USE_APK),)
  74. $(curdir)//compile += $(curdir)/system/apk/host/compile $(BUILD_KEY_APK_SEC) $(BUILD_KEY_APK_PUB)
  75. else
  76. $(curdir)/compile: $(curdir)/system/opkg/host/compile
  77. endif
  78. endif
  79. $(curdir)/install: $(TMP_DIR)/.build $(curdir)/merge $(curdir)/merge-index
  80. - find $(STAGING_DIR_ROOT) -type d | $(XARGS) chmod 0755
  81. rm -rf $(TARGET_DIR) $(TARGET_DIR_ORIG)
  82. mkdir -p $(TARGET_DIR)/tmp
  83. ifneq ($(CONFIG_USE_APK),)
  84. $(file >$(TMP_DIR)/apk_install_list,\
  85. $(foreach pkg,$(shell cat $(PACKAGE_INSTALL_FILES) 2>/dev/null),$(pkg)$(call GetABISuffix,$(pkg))))
  86. $(call apk,$(TARGET_DIR)) add --initdb --no-scripts --arch $(ARCH_PACKAGES) $$(cat $(TMP_DIR)/apk_install_list)
  87. else
  88. $(file >$(TMP_DIR)/opkg_install_list,\
  89. $(call opkg_package_files,\
  90. $(foreach pkg,$(shell cat $(PACKAGE_INSTALL_FILES) 2>/dev/null),$(pkg)$(call GetABISuffix,$(pkg)))))
  91. $(call opkg,$(TARGET_DIR)) install $$(cat $(TMP_DIR)/opkg_install_list)
  92. @for file in $(PACKAGE_INSTALL_FILES); do \
  93. [ -s $$file.flags ] || continue; \
  94. for flag in `cat $$file.flags`; do \
  95. $(call opkg,$(TARGET_DIR)) flag $$flag `cat $$file`; \
  96. done; \
  97. done || true
  98. endif
  99. $(CP) $(TARGET_DIR) $(TARGET_DIR_ORIG)
  100. $(call prepare_rootfs,$(TARGET_DIR),$(TOPDIR)/files)
  101. $(curdir)/index: FORCE
  102. @echo Generating package index...
  103. ifneq ($(CONFIG_USE_APK),)
  104. @for d in $(PACKAGE_SUBDIRS); do \
  105. mkdir -p $$d; \
  106. cd $$d || continue; \
  107. ls *.apk >/dev/null 2>&1 || continue; \
  108. $(STAGING_DIR_HOST)/bin/apk mkndx \
  109. --root $(TOPDIR) \
  110. --keys-dir $(TOPDIR) \
  111. --sign $(BUILD_KEY_APK_SEC) \
  112. --output packages.adb \
  113. *.apk; \
  114. done
  115. else
  116. @for d in $(PACKAGE_SUBDIRS); do ( \
  117. mkdir -p $$d; \
  118. cd $$d || continue; \
  119. $(SCRIPT_DIR)/ipkg-make-index.sh . 2>&1 > Packages.manifest; \
  120. grep -vE '^(Maintainer|LicenseFiles|Source|SourceName|Require|SourceDateEpoch)' Packages.manifest > Packages; \
  121. case "$$(((64 + $$(stat -L -c%s Packages)) % 128))" in 110|111) \
  122. $(call ERROR_MESSAGE,WARNING: Applying padding in $$d/Packages to workaround usign SHA-512 bug!); \
  123. { echo ""; echo ""; } >> Packages;; \
  124. esac; \
  125. echo -n '{"architecture": "$(ARCH_PACKAGES)", "packages":{' > index.json; \
  126. sed -n -e 's/^Package: \(.*\)$$/"\1":/p' -e 's/^Version: \(.*\)$$/"\1",/p' Packages | tr '\n' ' ' >> index.json; \
  127. echo '}}' >> index.json; \
  128. sed -i 's/, }}/}}/' index.json; \
  129. gzip -9nc Packages > Packages.gz; \
  130. ); done
  131. ifdef CONFIG_SIGNED_PACKAGES
  132. @echo Signing package index...
  133. @for d in $(PACKAGE_SUBDIRS); do ( \
  134. [ -d $$d ] && \
  135. cd $$d || continue; \
  136. $(STAGING_DIR_HOST)/bin/usign -S -m Packages -s $(BUILD_KEY); \
  137. ); done
  138. endif
  139. ifdef CONFIG_JSON_CYCLONEDX_SBOM
  140. @echo Creating CycloneDX package SBOMs...
  141. @for d in $(PACKAGE_SUBDIRS); do ( \
  142. [ -d $$d ] && \
  143. cd $$d || continue; \
  144. $(SCRIPT_DIR)/package-metadata.pl pkgcyclonedxsbom Packages.manifest > Packages.bom.cdx.json || true; \
  145. ); done
  146. endif
  147. endif
  148. $(curdir)/flags-install:= -j1
  149. $(eval $(call stampfile,$(curdir),package,prereq,.config))
  150. $(eval $(call stampfile,$(curdir),package,cleanup,$(TMP_DIR)/.build))
  151. $(eval $(call stampfile,$(curdir),package,compile,$(TMP_DIR)/.build))
  152. $(eval $(call stampfile,$(curdir),package,install,$(TMP_DIR)/.build))
  153. $(eval $(call stampfile,$(curdir),package,check,$(TMP_DIR)/.build))
  154. $(eval $(call subdir,$(curdir)))