2 # Copyright (C) 2006-2010 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
10 include $(INCLUDE_DIR
)/feeds.mk
11 include $(INCLUDE_DIR
)/rootfs.mk
13 -include $(TMP_DIR
)/.packagedeps
14 package-y
+= kernel
/linux
15 $(curdir
)/autoremove
:=1
16 $(curdir
)/builddirs
:=$(sort $(package-
) $(package-y
) $(package-m
))
17 $(curdir
)/builddirs-default
:=.
$(sort $(package-y
) $(package-m
))
18 $(curdir
)/builddirs-prereq
:=.
$(sort $(prereq-y
) $(prereq-m
))
20 $(curdir
)/builddirs-check
:=$($(curdir
)/builddirs
)
21 $(curdir
)/builddirs-download
:=$($(curdir
)/builddirs
)
23 ifneq ($(IGNORE_ERRORS
),)
24 package-y-filter
:= $(package-y
)
25 package-m-filter
:= $(filter-out $(package-y
),$(package-m
))
26 package-n-filter
:= $(filter-out $(package-y
) $(package-m
),$(package-
))
27 package-ignore-errors
:= $(filter n m y
,$(IGNORE_ERRORS
))
28 package-ignore-errors
:= $(if
$(package-ignore-errors
),$(package-ignore-errors
),n m
)
29 package-ignore-subdirs
:= $(sort $(foreach m
,$(package-ignore-errors
),$(package-
$(m
)-filter)))
30 $(curdir
)/builddirs-ignore-download
:= $(package-ignore-subdirs
)
31 $(curdir
)/builddirs-ignore-compile
:= $(package-ignore-subdirs
)
32 $(curdir
)/builddirs-ignore-host-download
:= $(package-ignore-subdirs
)
33 $(curdir
)/builddirs-ignore-host-compile
:= $(package-ignore-subdirs
)
36 PACKAGE_INSTALL_FILES
:= \
37 $(foreach pkg
,$(sort $(package-y
)), \
39 $(if
$(strip $(package
/$(pkg
)/variants
)), \
40 $(package
/$(pkg
)/variants
), \
41 $(if
$(package
/$(pkg
)/default-variant
), \
42 $(package
/$(pkg
)/default-variant
), \
46 $(PKG_INFO_DIR
)/$(lastword
$(subst /,$(space
),$(pkg
))).
$(variant
).
install \
50 $(curdir
)/cleanup
: $(TMP_DIR
)/.build
51 rm -rf
$(STAGING_DIR_ROOT
)
54 rm -rf
$(PACKAGE_DIR_ALL
)
55 mkdir
-p
$(PACKAGE_DIR_ALL
)
56 ifneq ($(CONFIG_USE_APK
),)
57 -$(foreach pdir
,$(PACKAGE_SUBDIRS
),$(if
$(wildcard $(pdir
)/*.apk
),ln
-s
$(pdir
)/*.apk
$(PACKAGE_DIR_ALL
);))
59 -$(foreach pdir
,$(PACKAGE_SUBDIRS
),$(if
$(wildcard $(pdir
)/*.ipk
),ln
-s
$(pdir
)/*.ipk
$(PACKAGE_DIR_ALL
);))
62 $(curdir
)/merge-index
: $(curdir
)/merge
63 ifneq ($(CONFIG_USE_APK
),)
64 (cd
$(PACKAGE_DIR_ALL
) && $(STAGING_DIR_HOST
)/bin
/apk mkndx \
66 --keys-dir
$(TOPDIR
) \
67 --sign
$(BUILD_KEY_APK_SEC
) \
68 --output packages.adb \
72 (cd
$(PACKAGE_DIR_ALL
) && $(SCRIPT_DIR
)/ipkg-make-index.sh .
2>&1 > Packages
; )
76 $(curdir
)//compile
= $(STAGING_DIR
)/.prepared
$(BIN_DIR
)
77 ifneq ($(CONFIG_USE_APK
),)
78 $(curdir
)/compile
: $(curdir
)/system
/apk
/host
/compile
80 $(curdir
)/compile
: $(curdir
)/system
/opkg
/host
/compile
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
--initdb
--no-scripts
--arch
$(ARCH_PACKAGES
) $$(cat
$(TMP_DIR
)/apk_install_list
)
93 $(file
>$(TMP_DIR
)/opkg_install_list
,\
94 $(call opkg_package_files
,\
95 $(foreach pkg
,$(shell cat
$(PACKAGE_INSTALL_FILES
) 2>/dev
/null
),$(pkg
)$(call GetABISuffix
,$(pkg
)))))
96 $(call opkg
,$(TARGET_DIR
)) install $$(cat
$(TMP_DIR
)/opkg_install_list
)
97 @for file in
$(PACKAGE_INSTALL_FILES
); do \
98 [ -s
$$file.flags
] || continue
; \
99 for flag in
`cat $$file.flags`; do \
100 $(call opkg
,$(TARGET_DIR
)) flag
$$flag `cat $$file`; \
105 $(CP
) $(TARGET_DIR
) $(TARGET_DIR_ORIG
)
107 $(call prepare_rootfs
,$(TARGET_DIR
),$(TOPDIR
)/files
)
109 $(curdir
)/index
: FORCE
110 @echo Generating package index...
111 ifneq ($(CONFIG_USE_APK
),)
112 @for d in
$(PACKAGE_SUBDIRS
); do \
114 cd
$$d || continue
; \
115 ls
*.apk
>/dev
/null
2>&1 || continue
; \
116 $(STAGING_DIR_HOST
)/bin
/apk mkndx \
118 --keys-dir
$(TOPDIR
) \
119 --sign
$(BUILD_KEY_APK_SEC
) \
120 --output packages.adb \
124 @for d in
$(PACKAGE_SUBDIRS
); do
( \
126 cd
$$d || continue
; \
127 $(SCRIPT_DIR
)/ipkg-make-index.sh .
2>&1 > Packages.manifest
; \
128 grep
-vE
'^(Maintainer|LicenseFiles|Source|SourceName|Require|SourceDateEpoch)' Packages.manifest
> Packages
; \
129 case
"$$(((64 + $$(stat -L -c%s Packages)) % 128))" in
110|
111) \
130 $(call ERROR_MESSAGE
,WARNING
: Applying padding in
$$d/Packages to workaround usign SHA-512 bug
!); \
131 { echo
""; echo
""; } >> Packages
;; \
133 echo
-n
'{"architecture": "$(ARCH_PACKAGES)", "packages":{' > index.json
; \
134 sed
-n
-e
's/^Package: \(.*\)$$/"\1":/p' -e
's/^Version: \(.*\)$$/"\1",/p' Packages | tr
'\n' ' ' >> index.json
; \
135 echo
'}}' >> index.json
; \
136 sed
-i
's/, }}/}}/' index.json
; \
137 gzip
-9nc Packages
> Packages.gz
; \
139 ifdef CONFIG_SIGNED_PACKAGES
140 @echo Signing package index...
141 @for d in
$(PACKAGE_SUBDIRS
); do
( \
143 cd
$$d || continue
; \
144 $(STAGING_DIR_HOST
)/bin
/usign
-S
-m Packages
-s
$(BUILD_KEY
); \
147 ifdef CONFIG_JSON_CYCLONEDX_SBOM
148 @echo Creating CycloneDX package SBOMs...
149 @for d in
$(PACKAGE_SUBDIRS
); do
( \
151 cd
$$d || continue
; \
152 $(SCRIPT_DIR
)/package-metadata.pl pkgcyclonedxsbom Packages.manifest
> Packages.bom.cdx.json || true
; \
157 $(curdir
)/flags-install
:= -j1
159 $(eval
$(call stampfile
,$(curdir
),package
,prereq
,.config
))
160 $(eval
$(call stampfile
,$(curdir
),package
,cleanup
,$(TMP_DIR
)/.build
))
161 $(eval
$(call stampfile
,$(curdir
),package
,compile
,$(TMP_DIR
)/.build
))
162 $(eval
$(call stampfile
,$(curdir
),package
,install,$(TMP_DIR
)/.build
))
163 $(eval
$(call stampfile
,$(curdir
),package
,check,$(TMP_DIR
)/.build
))
165 $(eval
$(call subdir
,$(curdir
)))