2
0

Makefile 5.7 KB

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