f75c0a23f3d2019b745e27bc205abb00140c3853
[openwrt.git] / include / package-ipkg.mk
1 #
2 # Copyright (C) 2006,2007 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 # where to build (and put) .ipk packages
9 IPKG:= \
10 IPKG_TMP=$(TMP_DIR)/ipkg \
11 IPKG_INSTROOT=$(TARGET_DIR) \
12 IPKG_CONF_DIR=$(STAGING_DIR)/etc \
13 IPKG_OFFLINE_ROOT=$(TARGET_DIR) \
14 $(SCRIPT_DIR)/ipkg -force-defaults -force-depends
15
16 # invoke ipkg-build with some default options
17 IPKG_BUILD:= \
18 ipkg-build -c -o 0 -g 0
19
20 define BuildIPKGVariable
21 $(call shexport,Package/$(1)/$(2))
22 $(1)_COMMANDS += var2file "$(call shvar,Package/$(1)/$(2))" $(2);
23 endef
24
25 ifeq ($(DUMP),)
26 define BuildIPKG
27 IPKG_$(1):=$(PACKAGE_DIR)/$(1)_$(VERSION)_$(PKGARCH).ipk
28 IDIR_$(1):=$(PKG_BUILD_DIR)/ipkg/$(1)
29 INFO_$(1):=$(IPKG_STATE_DIR)/info/$(1).list
30
31 ifdef Package/$(1)/install
32 ifneq ($(CONFIG_PACKAGE_$(1))$(SDK)$(DEVELOPER),)
33 compile: $$(IPKG_$(1))
34
35 ifeq ($(CONFIG_PACKAGE_$(1)),y)
36 install: $$(INFO_$(1))
37 endif
38 else
39 compile: $(1)-disabled
40 $(1)-disabled:
41 @echo "WARNING: skipping $(1) -- package not selected"
42 endif
43 endif
44
45 IDEPEND_$(1):=$$(strip $$(DEPENDS))
46
47 $(eval $(call BuildIPKGVariable,$(1),conffiles))
48 $(eval $(call BuildIPKGVariable,$(1),preinst))
49 $(eval $(call BuildIPKGVariable,$(1),postinst))
50 $(eval $(call BuildIPKGVariable,$(1),prerm))
51 $(eval $(call BuildIPKGVariable,$(1),postrm))
52 $$(IDIR_$(1))/CONTROL/control: $(PKG_BUILD_DIR)/.version-$(1)_$(VERSION)_$(PKGARCH)
53 @rm -f $(PACKAGE_DIR)/$(1)_*
54 mkdir -p $$(IDIR_$(1))/CONTROL
55 echo "Package: $(1)" > $$(IDIR_$(1))/CONTROL/control
56 echo "Version: $(VERSION)" >> $$(IDIR_$(1))/CONTROL/control
57 ( \
58 DEPENDS='$(EXTRA_DEPENDS)'; \
59 for depend in $$(filter-out @%,$$(IDEPEND_$(1))); do \
60 DEPENDS=$$$${DEPENDS:+$$$$DEPENDS, }$$$${depend##+}; \
61 done; \
62 echo "Depends: $$$$DEPENDS"; \
63 echo "Provides: $(PROVIDES)"; \
64 echo "Source: $(SOURCE)"; \
65 echo "Section: $(SECTION)"; \
66 echo "Priority: $(PRIORITY)"; \
67 echo "Maintainer: $(MAINTAINER)"; \
68 echo "Architecture: $(PKGARCH)"; \
69 echo -n "Description: "; getvar $(call shvar,Package/$(1)/description) | sed -e 's,^[[:space:]]*, ,g'; \
70 ) >> $$(IDIR_$(1))/CONTROL/control
71 chmod 644 $$(IDIR_$(1))/CONTROL/control
72 (cd $$(IDIR_$(1))/CONTROL; \
73 $($(1)_COMMANDS) \
74 )
75
76 $$(IPKG_$(1)): $(STAGING_DIR)/etc/ipkg.conf $(PKG_BUILD_DIR)/.built $$(IDIR_$(1))/CONTROL/control
77 $(call Package/$(1)/install,$$(IDIR_$(1)))
78 mkdir -p $(PACKAGE_DIR)
79 -find $$(IDIR_$(1)) -name 'CVS' -o -name '.svn' -o -name '.#*' | $(XARGS) rm -rf
80 $(RSTRIP) $$(IDIR_$(1))
81 $(IPKG_BUILD) $$(IDIR_$(1)) $(PACKAGE_DIR)
82 @[ -f $$(IPKG_$(1)) ] || false
83
84 $$(INFO_$(1)): $$(IPKG_$(1))
85 $(IPKG) install $$(IPKG_$(1))
86
87 $(1)-clean:
88 rm -f $(PACKAGE_DIR)/$(1)_*
89
90 clean: $(1)-clean
91
92 $(PKG_BUILD_DIR)/.version-$(1)_$(VERSION)_$(PKGARCH): $(STAMP_PREPARED)
93 -@rm -f $(PKG_BUILD_DIR)/.version-$(1)_* 2>/dev/null
94 @touch $$@
95
96 $$(eval $$(call Build/DefaultTargets,$(1)))
97
98 endef
99
100 $(STAGING_DIR)/etc/ipkg.conf:
101 mkdir -p $(STAGING_DIR)/etc
102 echo "dest root /" > $(STAGING_DIR)/etc/ipkg.conf
103 echo "option offline_root $(TARGET_DIR)" >> $(STAGING_DIR)/etc/ipkg.conf
104
105 endif
This page took 0.040187 seconds and 3 git commands to generate.