build: rework opkg command invocation
[openwrt/staging/chunkeey.git] / package / Makefile
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
8 curdir:=package
9
10 include $(INCLUDE_DIR)/rootfs.mk
11
12 -include $(TMP_DIR)/.packagedeps
13 $(curdir)/builddirs:=$(sort $(package-) $(package-y) $(package-m))
14 $(curdir)/builddirs-install:=.
15 $(curdir)/builddirs-default:=. $(sort $(package-y) $(package-m))
16 $(curdir)/builddirs-prereq:=. $(sort $(prereq-y) $(prereq-m))
17 ifneq ($(IGNORE_ERRORS),)
18 package-y-filter := $(package-y)
19 package-m-filter := $(filter-out $(package-y),$(package-m))
20 package-n-filter := $(filter-out $(package-y) $(package-m),$(package-))
21 package-ignore-errors := $(filter n m y,$(IGNORE_ERRORS))
22 package-ignore-errors := $(if $(package-ignore-errors),$(package-ignore-errors),n m)
23 package-ignore-subdirs := $(sort $(foreach m,$(package-ignore-errors),$(package-$(m)-filter)))
24 $(curdir)/builddirs-ignore-download := $(package-ignore-subdirs)
25 $(curdir)/builddirs-ignore-compile := $(package-ignore-subdirs)
26 $(curdir)/builddirs-ignore-host-download := $(package-ignore-subdirs)
27 $(curdir)/builddirs-ignore-host-compile := $(package-ignore-subdirs)
28 endif
29
30 PACKAGE_INSTALL_FILES:= \
31 $(foreach pkg,$(sort $(package-y)), \
32 $(foreach variant, \
33 $(if $(strip $(package/$(pkg)/variants)), \
34 $(package/$(pkg)/variants), \
35 $(if $(package/$(pkg)/default-variant), \
36 $(package/$(pkg)/default-variant), \
37 default \
38 ) \
39 ), \
40 $(PKG_INFO_DIR)/$(lastword $(subst /,$(space),$(pkg))).$(variant).install \
41 ) \
42 )
43
44 $(curdir)/cleanup: $(TMP_DIR)/.build
45 rm -rf $(STAGING_DIR_ROOT)
46
47 $(curdir)/install: $(TMP_DIR)/.build $(curdir)/system/opkg/host/install
48 - find $(STAGING_DIR_ROOT) -type d | $(XARGS) chmod 0755
49 rm -rf $(TARGET_DIR)
50 [ -d $(TARGET_DIR)/tmp ] || mkdir -p $(TARGET_DIR)/tmp
51 $(call opkg,$(TARGET_DIR)) install \
52 $(wildcard \
53 $(foreach dir,$(PACKAGE_SUBDIRS), \
54 $(foreach pkg, \
55 $(shell cat $(PACKAGE_INSTALL_FILES) 2>/dev/null), \
56 $(dir)/$(pkg)_*.ipk)))
57 @for file in $(PACKAGE_INSTALL_FILES); do \
58 [ -s $$file.flags ] || continue; \
59 for flag in `cat $$file.flags`; do \
60 $(call opkg,$(TARGET_DIR)) flag $$flag `cat $$file`; \
61 done; \
62 done || true
63 @-$(MAKE) package/preconfig
64 $(call prepare_rootfs,$(TARGET_DIR))
65
66 PASSOPT=""
67 PASSARG=""
68 ifndef CONFIG_OPKGSMIME_PASSPHRASE
69 ifneq ($(call qstrip,$(CONFIG_OPKGSMIME_PASSFILE)),)
70 PASSOPT="-passin"
71 PASSARG="file:$(call qstrip,$(CONFIG_OPKGSMIME_PASSFILE))"
72 endif
73 endif
74
75 $(curdir)/index: FORCE
76 @echo Generating package index...
77 @for d in $(PACKAGE_SUBDIRS); do ( \
78 mkdir -p $$d; \
79 cd $$d || continue; \
80 $(SCRIPT_DIR)/ipkg-make-index.sh . 2>&1 > Packages && \
81 gzip -9nc Packages > Packages.gz; \
82 ); done
83 ifdef CONFIG_SIGNED_PACKAGES
84 @echo Signing package index...
85 @for d in $(PACKAGE_SUBDIRS); do ( \
86 [ -d $$d ] && \
87 cd $$d || continue; \
88 $(STAGING_DIR_HOST)/bin/usign -S -m Packages -s $(BUILD_KEY); \
89 ); done
90 else
91 ifeq ($(call qstrip,$(CONFIG_OPKGSMIME_KEY)),)
92 @echo Signing key has not been configured
93 else
94 ifeq ($(call qstrip,$(CONFIG_OPKGSMIME_CERT)),)
95 @echo Certificate has not been configured
96 else
97 @echo Signing package index...
98 @for d in $(PACKAGE_SUBDIRS); do ( \
99 [ -d $$d ] && \
100 cd $$d || continue; \
101 openssl smime -binary -in Packages.gz \
102 -out Packages.sig -outform PEM -sign \
103 -signer $(CONFIG_OPKGSMIME_CERT) \
104 -inkey $(CONFIG_OPKGSMIME_KEY) \
105 $(PASSOPT) $(PASSARG); \
106 ); done
107 endif
108 endif
109 endif
110
111 $(curdir)/preconfig:
112
113 $(curdir)/flags-install:= -j1
114
115 $(eval $(call stampfile,$(curdir),package,prereq,.config))
116 $(eval $(call stampfile,$(curdir),package,cleanup,$(TMP_DIR)/.build))
117 $(eval $(call stampfile,$(curdir),package,compile,$(TMP_DIR)/.build))
118 $(eval $(call stampfile,$(curdir),package,install,$(TMP_DIR)/.build))
119
120 $(eval $(call subdir,$(curdir)))