author | kergoth <kergoth> | 2003-04-22 20:12:04 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2003-04-22 20:12:04 (UTC) |
commit | ccec87cf3e7192c0a3987aa3486668e89b1662a4 (patch) (unidiff) | |
tree | 2d1135ed639410fe1a75486bfdeae8083e1682a2 | |
parent | 2134672b0a731415bfd50f2ff22de59b78709e5c (diff) | |
download | opie-ccec87cf3e7192c0a3987aa3486668e89b1662a4.zip opie-ccec87cf3e7192c0a3987aa3486668e89b1662a4.tar.gz opie-ccec87cf3e7192c0a3987aa3486668e89b1662a4.tar.bz2 |
you can now 'make ipks' :)
-rw-r--r-- | Makefile | 26 | ||||
-rw-r--r-- | Vars.make | 63 | ||||
-rwxr-xr-x | scripts/mkipkg | 371 |
3 files changed, 451 insertions, 9 deletions
@@ -1,125 +1,133 @@ | |||
1 | #!/usr/bin/make -f | 1 | #!/usr/bin/make -f |
2 | ifndef QTDIR | ||
3 | $(error QTDIR not set) | ||
4 | endif | ||
5 | 2 | ||
6 | export OPIEDIR:=$(shell pwd) | 3 | export TOPDIR:=$(shell pwd) |
7 | export TOPDIR:=$(OPIEDIR) | ||
8 | export QMAKE:=$(OPIEDIR)/qmake/qmake | ||
9 | 4 | ||
10 | export QMAKESPECSDIR=$(OPIEDIR)/mkspecs | 5 | include $(TOPDIR)/Vars.make |
11 | 6 | ||
12 | noconfig_targets := xconfig menuconfig config oldconfig randconfig \ | 7 | noconfig_targets := xconfig menuconfig config oldconfig randconfig \ |
13 | defconfig allyesconfig allnoconfig allmodconfig \ | 8 | defconfig allyesconfig allnoconfig allmodconfig \ |
14 | clean-configs | 9 | clean-configs |
15 | 10 | ||
16 | configs += $(TOPDIR)/core/applets/config.in $(TOPDIR)/core/apps/config.in $(TOPDIR)/core/multimedia/config.in $(TOPDIR)/core/pim/config.in $(TOPDIR)/core/pim/today/plugins/config.in $(TOPDIR)/core/settings/config.in $(TOPDIR)/development/config.in $(TOPDIR)/inputmethods/config.in $(TOPDIR)/libopie/ofileselector/config.in $(TOPDIR)/libopie/pim/config.in $(TOPDIR)/libsql/config.in $(TOPDIR)/noncore/applets/config.in $(TOPDIR)/noncore/apps/opie-console/test/config.in $(TOPDIR)/noncore/apps/config.in $(TOPDIR)/noncore/comm/config.in $(TOPDIR)/noncore/decorations/config.in $(TOPDIR)/noncore/games/config.in $(TOPDIR)/noncore/graphics/config.in $(TOPDIR)/noncore/multimedia/config.in $(TOPDIR)/noncore/net/config.in $(TOPDIR)/noncore/net/opietooth/config.in $(TOPDIR)/noncore/settings/config.in $(TOPDIR)/noncore/styles/config.in $(TOPDIR)/noncore/tools/calc2/config.in $(TOPDIR)/noncore/tools/config.in $(TOPDIR)/noncore/todayplugins/config.in | 11 | configs += $(TOPDIR)/core/applets/config.in $(TOPDIR)/core/apps/config.in $(TOPDIR)/core/multimedia/config.in $(TOPDIR)/core/pim/config.in $(TOPDIR)/core/pim/today/plugins/config.in $(TOPDIR)/core/settings/config.in $(TOPDIR)/development/config.in $(TOPDIR)/inputmethods/config.in $(TOPDIR)/libopie/ofileselector/config.in $(TOPDIR)/libopie/pim/config.in $(TOPDIR)/libsql/config.in $(TOPDIR)/noncore/applets/config.in $(TOPDIR)/noncore/apps/opie-console/test/config.in $(TOPDIR)/noncore/apps/config.in $(TOPDIR)/noncore/comm/config.in $(TOPDIR)/noncore/decorations/config.in $(TOPDIR)/noncore/games/config.in $(TOPDIR)/noncore/graphics/config.in $(TOPDIR)/noncore/multimedia/config.in $(TOPDIR)/noncore/net/config.in $(TOPDIR)/noncore/net/opietooth/config.in $(TOPDIR)/noncore/settings/config.in $(TOPDIR)/noncore/styles/config.in $(TOPDIR)/noncore/tools/calc2/config.in $(TOPDIR)/noncore/tools/config.in $(TOPDIR)/noncore/todayplugins/config.in |
17 | 12 | ||
18 | # $(TOPDIR)/.config depends on .depends.cfgs, as it depends on $(configs) | 13 | # $(TOPDIR)/.config depends on .depends.cfgs, as it depends on $(configs) |
19 | # in order to have a full set of config.in files. | 14 | # in order to have a full set of config.in files. |
20 | # .depends depends on $(TOPDIR)/.config | 15 | # .depends depends on $(TOPDIR)/.config |
21 | # everything else depends on .depends, to ensure the dependencies are | 16 | # everything else depends on .depends, to ensure the dependencies are |
22 | # intact. | 17 | # intact. |
23 | # | 18 | # |
24 | # NOTE: The order in which things happen in this makefile is | 19 | # NOTE: The order in which things happen in this makefile is |
25 | # -critical-. Do not rearrange this! | 20 | # -critical-. Do not rearrange this! |
26 | 21 | ||
27 | all : $(TOPDIR)/.config | 22 | all : $(TOPDIR)/.config |
28 | 23 | ||
24 | STRIP=arm-linux-strip | ||
25 | |||
26 | ipks: $(OPIEDIR)/scripts/subst $(OPIEDIR)/scripts/filesubst FORCE | ||
27 | @find $(OPIEDIR)/ -type f -name \*.control | ( for ctrl in `cat`; do \ | ||
28 | prerm=`echo $$ctrl|sed -e 's,\.control$$,.prerm,'`; \ | ||
29 | preinst=`echo $$ctrl|sed -e 's,\.control$$,.preinst,'`; \ | ||
30 | postrm=`echo $$ctrl|sed -e 's,\.control$$,.postrm,'`; \ | ||
31 | postinst=`echo $$ctrl|sed -e 's,\.control$$,.postinst,'`; \ | ||
32 | echo "Building ipk of $$ctrl"; \ | ||
33 | cd $(OPIEDIR); $(OPIEDIR)/scripts/mkipkg --subst=$(OPIEDIR)/scripts/subst --filesubst=$(OPIEDIR)/scripts/filesubst --control=$$ctrl --prerm=$$prerm --preinst=$$preinst --postrm=$$postrm --postinst=$$postinst --strip=$(STRIP) $(OPIEDIR); \ | ||
34 | done ) | ||
35 | |||
29 | $(TOPDIR)/.config : $(TOPDIR)/.depends.cfgs | 36 | $(TOPDIR)/.config : $(TOPDIR)/.depends.cfgs |
30 | 37 | ||
31 | all menuconfig xconfig oldconfig config randconfig allyesconfig allnoconfig defconfig : $(TOPDIR)/.depends.cfgs | 38 | all menuconfig xconfig oldconfig config randconfig allyesconfig allnoconfig defconfig : $(TOPDIR)/.depends.cfgs |
32 | 39 | ||
33 | clean-configs : | 40 | clean-configs : |
34 | @echo "Wiping generated config.in files..." | 41 | @echo "Wiping generated config.in files..." |
35 | @-rm -f $(configs) | 42 | @-rm -f $(configs) |
36 | 43 | ||
37 | -include $(TOPDIR)/.depends.cfgs | 44 | ifneq ($(wildcard $(TOPDIR)/.depends.cfgs),) |
45 | include $(TOPDIR)/.depends.cfgs | ||
46 | endif | ||
38 | 47 | ||
39 | all menuconfig xconfig oldconfig config randconfig allyesconfig allnoconfig defconfig : $(configs) | 48 | all menuconfig xconfig oldconfig config randconfig allyesconfig allnoconfig defconfig : $(configs) |
40 | 49 | ||
41 | $(TOPDIR)/.config: $(TOPDIR)/.depends.cfgs $(configs) | 50 | $(TOPDIR)/.config: $(TOPDIR)/.depends.cfgs $(configs) |
42 | $(call descend,scripts/kconfig,conf) | 51 | $(call descend,scripts/kconfig,conf) |
43 | @if [ ! -e $@ ]; then \ | 52 | @if [ ! -e $@ ]; then \ |
44 | cp $(TOPDIR)/def-configs/opie $@; \ | 53 | cp $(TOPDIR)/def-configs/opie $@; \ |
45 | fi; | 54 | fi; |
46 | @$(MAKE) -C scripts/kconfig conf; | 55 | @$(MAKE) -C scripts/kconfig conf; |
47 | ./scripts/kconfig/conf -s ./config.in | 56 | ./scripts/kconfig/conf -s ./config.in |
48 | 57 | ||
49 | # config rules must have the $(configs) var defined | 58 | # config rules must have the $(configs) var defined |
50 | # at the time that they run. we must ensure that .depends.cfgs | 59 | # at the time that they run. we must ensure that .depends.cfgs |
51 | # is built and included by the time we reach this point. | 60 | # is built and included by the time we reach this point. |
52 | 61 | ||
53 | xconfig : | 62 | xconfig : |
54 | $(call descend,scripts/kconfig,qconf) | 63 | $(call descend,scripts/kconfig,qconf) |
55 | LD_LIBRARY_PATH=$$LD_LIBRARY_PATH:$(TOPDIR)/scripts/kconfig \ | 64 | LD_LIBRARY_PATH=$$LD_LIBRARY_PATH:$(TOPDIR)/scripts/kconfig \ |
56 | ./scripts/kconfig/qconf ./config.in | 65 | ./scripts/kconfig/qconf ./config.in |
57 | 66 | ||
58 | menuconfig : scripts/lxdialog/lxdialog | 67 | menuconfig : scripts/lxdialog/lxdialog |
59 | $(call descend,scripts/kconfig,mconf) | 68 | $(call descend,scripts/kconfig,mconf) |
60 | ./scripts/kconfig/mconf ./config.in | 69 | ./scripts/kconfig/mconf ./config.in |
61 | 70 | ||
62 | config : | 71 | config : |
63 | $(call descend,scripts/kconfig,conf) | 72 | $(call descend,scripts/kconfig,conf) |
64 | ./scripts/kconfig/conf ./config.in | 73 | ./scripts/kconfig/conf ./config.in |
65 | 74 | ||
66 | oldconfig : | 75 | oldconfig : |
67 | $(call descend,scripts/kconfig,conf) | 76 | $(call descend,scripts/kconfig,conf) |
68 | ./scripts/kconfig/conf -o ./config.in | 77 | ./scripts/kconfig/conf -o ./config.in |
69 | 78 | ||
70 | randconfig : | 79 | randconfig : |
71 | $(call descend,scripts/kconfig,conf) | 80 | $(call descend,scripts/kconfig,conf) |
72 | ./scripts/kconfig/conf -r ./config.in | 81 | ./scripts/kconfig/conf -r ./config.in |
73 | 82 | ||
74 | allyesconfig : | 83 | allyesconfig : |
75 | $(call descend,scripts/kconfig,conf) | 84 | $(call descend,scripts/kconfig,conf) |
76 | ./scripts/kconfig/conf -y ./config.in | 85 | ./scripts/kconfig/conf -y ./config.in |
77 | 86 | ||
78 | allnoconfig : | 87 | allnoconfig : |
79 | $(call descend,scripts/kconfig,conf) | 88 | $(call descend,scripts/kconfig,conf) |
80 | ./scripts/kconfig/conf -n ./config.in | 89 | ./scripts/kconfig/conf -n ./config.in |
81 | 90 | ||
82 | defconfig : | 91 | defconfig : |
83 | $(call descend,scripts/kconfig,conf) | 92 | $(call descend,scripts/kconfig,conf) |
84 | ./scripts/kconfig/conf -d ./config.in | 93 | ./scripts/kconfig/conf -d ./config.in |
85 | 94 | ||
86 | 95 | ||
87 | export | 96 | export |
88 | 97 | ||
89 | ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),) | 98 | ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),) |
90 | 99 | ||
91 | export include-config := 1 | 100 | export include-config := 1 |
92 | 101 | ||
93 | -include $(TOPDIR)/.config | 102 | -include $(TOPDIR)/.config |
94 | -include $(TOPDIR)/.depends | 103 | -include $(TOPDIR)/.depends |
95 | |||
96 | endif | 104 | endif |
97 | 105 | ||
98 | -include $(TOPDIR)/.config.cmd | 106 | -include $(TOPDIR)/.config.cmd |
99 | 107 | ||
100 | SUBDIRS = $(subdir-y) | 108 | SUBDIRS = $(subdir-y) |
101 | 109 | ||
102 | export QMAKESPEC=$(QMAKESPECSDIR)/$(patsubst "%",%,$(CONFIG_SPECFILE)) | 110 | export QMAKESPEC=$(QMAKESPECSDIR)/$(patsubst "%",%,$(CONFIG_SPECFILE)) |
103 | 111 | ||
104 | ifdef CONFIG_OPTIMIZATIONS | 112 | ifdef CONFIG_OPTIMIZATIONS |
105 | export CFLAGS_RELEASE=$(patsubst "%,%,$(CONFIG_OPTIMIZATIONS)) | 113 | export CFLAGS_RELEASE=$(patsubst "%,%,$(CONFIG_OPTIMIZATIONS)) |
106 | export CFLAGS_RELEASE:=$(patsubst %",%,$(CFLAGS_RELEASE)) | 114 | export CFLAGS_RELEASE:=$(patsubst %",%,$(CFLAGS_RELEASE)) |
107 | endif | 115 | endif |
108 | 116 | ||
109 | all clean install ipk: $(SUBDIRS) | 117 | all clean install ipk: $(SUBDIRS) |
110 | 118 | ||
111 | lupdate lrelease: | 119 | lupdate lrelease: |
112 | @for i in $(SUBDIRS); do $(MAKE) -C $$i $@; done; | 120 | @for i in $(SUBDIRS); do $(MAKE) -C $$i $@; done; |
113 | 121 | ||
114 | opie-lupdate opie-lrelease: | 122 | opie-lupdate opie-lrelease: |
115 | @for i in $(SUBDIRS); do $(MAKE) -C $$i $@; done; | 123 | @for i in $(SUBDIRS); do $(MAKE) -C $$i $@; done; |
116 | 124 | ||
117 | $(subdir-y) : $(if $(CONFIG_LIBQPE),$(QTDIR)/stamp-headers $(OPIEDIR)/stamp-headers) \ | 125 | $(subdir-y) : $(if $(CONFIG_LIBQPE),$(QTDIR)/stamp-headers $(OPIEDIR)/stamp-headers) \ |
118 | $(if $(CONFIG_LIBQPE-X11),$(QTDIR)/stamp-headers-x11 $(OPIEDIR)/stamp-headers-x11 ) \ | 126 | $(if $(CONFIG_LIBQPE-X11),$(QTDIR)/stamp-headers-x11 $(OPIEDIR)/stamp-headers-x11 ) \ |
119 | $(TOPDIR)/library/custom.h | 127 | $(TOPDIR)/library/custom.h |
120 | 128 | ||
121 | clean : $(TOPDIR)/.config | 129 | clean : $(TOPDIR)/.config |
122 | 130 | ||
123 | apidox : doc/generate_apidox | 131 | apidox : doc/generate_apidox |
124 | 132 | ||
125 | include $(TOPDIR)/Rules.make | 133 | include $(TOPDIR)/Rules.make |
diff --git a/Vars.make b/Vars.make new file mode 100644 index 0000000..eac5cea --- a/dev/null +++ b/Vars.make | |||
@@ -0,0 +1,63 @@ | |||
1 | ifndef QTDIR | ||
2 | $(error QTDIR not set) | ||
3 | endif | ||
4 | |||
5 | prefix=/opt/QtPalmtop | ||
6 | |||
7 | ifeq ($(OPIEDIR),) | ||
8 | export OPIEDIR:=$(TOPDIR) | ||
9 | endif | ||
10 | ifeq ($(IPK_DIR),) | ||
11 | export IPK_DIR:=$(OPIEDIR) | ||
12 | endif | ||
13 | |||
14 | export QMAKE:=$(OPIEDIR)/qmake/qmake | ||
15 | export QMAKESPECSDIR=$(OPIEDIR)/mkspecs | ||
16 | |||
17 | ifeq ($(QPE_VERSION),) | ||
18 | VERSION_MAJ:=$(shell echo $$(sed -n -e 's/.*QPE_VERSION "\([0-9]*\)\..*\..*".*/\1/p' <$(OPIEDIR)/library/version.h)) | ||
19 | VERSION_MIN:=$(shell echo $$(sed -n -e 's/.*QPE_VERSION ".*\.\([0-9]*\)\..*".*/\1/p' <$(OPIEDIR)/library/version.h)) | ||
20 | VERSION_PAT:=$(shell echo $$(sed -n -e 's/.*QPE_VERSION ".*\..*\.\([0-9]*\).*/\1/p' <$(OPIEDIR)/library/version.h)) | ||
21 | QPE_VERSION:=$(VERSION_MAJ).$(VERSION_MIN).$(VERSION_PAT) | ||
22 | |||
23 | ifeq ($(QPE_VERSION),..) | ||
24 | QPE_VERSION=0.9.3 | ||
25 | endif | ||
26 | endif | ||
27 | export QPE_VERSION | ||
28 | |||
29 | SUB_VERSION=$(shell echo $$(sed -n -e 's,.*SUB_VERSION \"\(.*\)\".*,\1,p' <$(OPIEDIR)/library/version.h)) | ||
30 | ifeq ($(VERSION_CVS),) | ||
31 | VERSION_CVS:=$(shell date +%Y%m%d) | ||
32 | endif | ||
33 | ifneq ($(filter %snapshot",$(shell cat $(OPIEDIR)/library/version.h|grep QPE_VERSION)),) | ||
34 | SUB_VERSION:=$(VERSION_CVS) | ||
35 | endif | ||
36 | export SUB_VERSION | ||
37 | |||
38 | ifeq ($(QTE_REVISION),) | ||
39 | QTE_REVISION=4 | ||
40 | endif | ||
41 | export QTE_REVISION | ||
42 | |||
43 | export DEB_VERSION=2.0 | ||
44 | |||
45 | ifeq ($(QTE_BASEVERSION),) | ||
46 | ifneq ($(shell ls $(QTDIR)/include/qglobal.h 2>/dev/null),) | ||
47 | QTE_BASEVERSION:=$(shell cat $(QTDIR)/include/qglobal.h|grep '^\#define QT_VERSION'|grep -v STR|sed -e 's/\#define QT_VERSION\t*//; s/.*\([0-9]\)\([0-9]\)\([0-9]\).*/\1.\2.\3/;') | ||
48 | else | ||
49 | QTE_BASEVERSION=2.3.5 | ||
50 | endif | ||
51 | endif | ||
52 | export QTE_BASEVERSION | ||
53 | |||
54 | ifeq ($(QTE_VERSION),) | ||
55 | ifneq ($(shell ls $(QTDIR)/include/qglobal.h 2>/dev/null),) | ||
56 | QTE_VERSION:=$(shell cat $(QTDIR)/include/qglobal.h|grep '^\#define QT_VERSION_STR'|sed -e 's/\#define QT_VERSION_STR\t*//;' -e 's/.*"\([^"]*\)".*/\1/;') | ||
57 | else | ||
58 | QTE_VERSION=2.3.5 | ||
59 | endif | ||
60 | endif | ||
61 | export QTE_VERSION | ||
62 | |||
63 | export PATH:=$(OPIEDIR)/scripts:$(PATH) | ||
diff --git a/scripts/mkipkg b/scripts/mkipkg new file mode 100755 index 0000000..54651af --- a/dev/null +++ b/scripts/mkipkg | |||
@@ -0,0 +1,371 @@ | |||
1 | #!/bin/sh | ||
2 | # vim: et sw=4 | ||
3 | |||
4 | # TODO: srcdir!=builddir | ||
5 | |||
6 | usage() | ||
7 | { | ||
8 | echo "usage: $self --destdir=[destination installation directory]" | ||
9 | echo "usage: $self [destination installation directory]" | ||
10 | exit 1 | ||
11 | } | ||
12 | |||
13 | self=mkipkg | ||
14 | destdir= | ||
15 | strip=strip | ||
16 | control= | ||
17 | builddir= | ||
18 | srcdir= | ||
19 | prefix= | ||
20 | preinst= | ||
21 | postinst= | ||
22 | prerm= | ||
23 | postrm= | ||
24 | mkfsjffs2= | ||
25 | ipkgbuild=ipkg-build | ||
26 | buildversion= | ||
27 | subst= | ||
28 | user=root | ||
29 | group=root | ||
30 | filesubst= | ||
31 | |||
32 | oldpwd= | ||
33 | |||
34 | for option | ||
35 | do | ||
36 | case "$option" in | ||
37 | -*=*) | ||
38 | arg=`echo "$option" | sed 's/[-_a-zA-Z0-9]*=//'` | ||
39 | ;; | ||
40 | esac | ||
41 | |||
42 | case "$option" in | ||
43 | --destdir=*) | ||
44 | destdir=$arg | ||
45 | ;; | ||
46 | --strip=*) | ||
47 | strip=$arg | ||
48 | ;; | ||
49 | --control=*) | ||
50 | control=$arg | ||
51 | ;; | ||
52 | --preinst=*) | ||
53 | preinst=$arg | ||
54 | ;; | ||
55 | --postinst=*) | ||
56 | postinst=$arg | ||
57 | ;; | ||
58 | --prerm=*) | ||
59 | prerm=$arg | ||
60 | ;; | ||
61 | --postrm=*) | ||
62 | postrm=$arg | ||
63 | ;; | ||
64 | --builddir=*) | ||
65 | builddir=$arg | ||
66 | ;; | ||
67 | --srcdir=*) | ||
68 | srcdir=$arg | ||
69 | ;; | ||
70 | --prefix=*) | ||
71 | prefix=$arg | ||
72 | ;; | ||
73 | --mkfsjffs2=*) | ||
74 | mkfsjffs2=$arg | ||
75 | ;; | ||
76 | --ipkgbuild=*) | ||
77 | ipkgbuild=$arg | ||
78 | ;; | ||
79 | --buildversion=*) | ||
80 | buildversion=$arg | ||
81 | ;; | ||
82 | --subst=*) | ||
83 | subst=$arg | ||
84 | ;; | ||
85 | --user=*) | ||
86 | user=$arg | ||
87 | ;; | ||
88 | --group=*) | ||
89 | group=$arg | ||
90 | ;; | ||
91 | --filesubst=*) | ||
92 | filesubst=$arg | ||
93 | ;; | ||
94 | --classic) | ||
95 | classic=-c | ||
96 | ;; | ||
97 | -*) | ||
98 | usage | ||
99 | ;; | ||
100 | *) | ||
101 | destdir=$option | ||
102 | ;; | ||
103 | esac | ||
104 | done | ||
105 | |||
106 | if [ -z "$control" ]; then | ||
107 | control=$destdir/CONTROL/control | ||
108 | fi | ||
109 | if [ -z "$prerm" ]; then | ||
110 | prerm=$destdir/CONTROL/prerm | ||
111 | fi | ||
112 | if [ -z "$postrm" ]; then | ||
113 | postrm=$destdir/CONTROL/postrm | ||
114 | fi | ||
115 | if [ -z "$preinst" ]; then | ||
116 | preinst=$destdir/CONTROL/preinst | ||
117 | fi | ||
118 | if [ -z "$postinst" ]; then | ||
119 | postinst=$destdir/CONTROL/postinst | ||
120 | fi | ||
121 | |||
122 | # remove leading slash from prefix (to fix globbing) | ||
123 | if [ -n "$prefix" ]; then | ||
124 | prefix=`echo $prefix | sed -e "s,/\(.*\),\\1,"` | ||
125 | fi | ||
126 | |||
127 | if [ -z "$destdir" ]; then | ||
128 | usage | ||
129 | fi | ||
130 | |||
131 | if [ ! -r $control ]; then | ||
132 | echo "$self: cannot find $control, exiting..." | ||
133 | exit 1 | ||
134 | fi | ||
135 | |||
136 | if [ -z "`which $ipkgbuild 2>/dev/null`" ]; then | ||
137 | echo "$self: cannot find ipkg-build, exiting..." | ||
138 | exit 1 | ||
139 | fi | ||
140 | |||
141 | findFile() | ||
142 | { | ||
143 | local path= | ||
144 | if [ $# = 1 ]; then | ||
145 | find $1 -type f -o -type b -o -type c -o -type l -o -type d | ||
146 | else | ||
147 | find . -type f -o -type b -o -type c -o -type l -o -type d | \ | ||
148 | sed -e "s,\./\(.*\),\\1,g" | ||
149 | fi | ||
150 | |||
151 | } | ||
152 | |||
153 | _pushd() { oldpwd=`pwd`; cd $1; } | ||
154 | _popd() { cd $oldpwd; } | ||
155 | |||
156 | setVar() | ||
157 | { | ||
158 | eval "$1='$2'" | ||
159 | } | ||
160 | |||
161 | expandMaskToList() | ||
162 | { | ||
163 | local _list=`echo $1` | ||
164 | local _tmpFileList= | ||
165 | for f in $_list; do | ||
166 | if [ -d $f ]; then | ||
167 | find="`findFile $f`" | ||
168 | if [ -z "$find" ]; then | ||
169 | find="$f" | ||
170 | fi | ||
171 | f="$f `findFile $f`" | ||
172 | fi | ||
173 | _tmpFileList=$f" $_tmpFileList" | ||
174 | done | ||
175 | setVar $2 "$_tmpFileList" | ||
176 | } | ||
177 | |||
178 | createFileList() | ||
179 | { | ||
180 | local excludeMask | ||
181 | local includeMask | ||
182 | if (cat $1|grep -q ^FileExcludeMask); then | ||
183 | excludemaskpresent=1 | ||
184 | excludeMask=$(eval echo '"'$(sed -n -e "s,^FileExcludeMask: *,,p" $1)'"') | ||
185 | fi | ||
186 | if (cat $1|grep -q ^FileIncludeMask); then | ||
187 | includemaskpresent=1 | ||
188 | includeMask=$(eval echo '"'$(sed -n -e "s,^FileIncludeMask: *,,p" $1)'"') | ||
189 | else | ||
190 | if (cat $1|grep -q ^Files:); then | ||
191 | includemaskpresent=1 | ||
192 | includeMask=$(eval echo '"'$(sed -n -e "s,^Files: *,,p" $1)'"') | ||
193 | fi | ||
194 | fi | ||
195 | |||
196 | excludeMask="$excludeMask CONTROL/* usr/share/* CVS/* SCCS/*" | ||
197 | |||
198 | if [ $includemaskpresent == 1 ]; then | ||
199 | if [ -z "$includeMask" ]; then | ||
200 | setVar $2 "" | ||
201 | return 0 | ||
202 | fi | ||
203 | _pushd $destdir | ||
204 | expandMaskToList "$includeMask" _fileList | ||
205 | _popd | ||
206 | else | ||
207 | _fileList=`cd $destdir && findFile` | ||
208 | fi | ||
209 | |||
210 | _excludeList= | ||
211 | if [ -n "$excludeMask" ]; then | ||
212 | _pushd $destdir | ||
213 | expandMaskToList "$excludeMask" _excludeList | ||
214 | _popd | ||
215 | fi | ||
216 | |||
217 | local realFileList= | ||
218 | local missing=0 | ||
219 | for file in $_fileList; do | ||
220 | local containedInList=0 | ||
221 | for i in $_excludeList; do | ||
222 | if [ $file = $i ]; then | ||
223 | containedInList=1 | ||
224 | fi | ||
225 | done | ||
226 | if [ $containedInList = 0 ]; then | ||
227 | if [ ! -e $file ]; then | ||
228 | # echo "$self: $file not found" | ||
229 | missing=1 | ||
230 | fi | ||
231 | realFileList=$file" $realFileList" | ||
232 | fi | ||
233 | done | ||
234 | |||
235 | if [ $missing = 1 ]; then | ||
236 | return 1 | ||
237 | fi | ||
238 | |||
239 | setVar $2 "$realFileList" | ||
240 | } | ||
241 | |||
242 | stripFile() | ||
243 | { | ||
244 | if [ -f $1 -a -x $1 ]; then | ||
245 | $strip --strip-all $1 | ||
246 | fi | ||
247 | } | ||
248 | |||
249 | substFile() | ||
250 | { | ||
251 | local oldfile=$1 | ||
252 | |||
253 | if [ ! -e $2 ]; then return 1; fi | ||
254 | |||
255 | if [ -e $oldfile ]; then | ||
256 | newfile=./`echo $1|sed -f $2|sed -e's,^/,,g'` | ||
257 | olddir=./`dirname $1` | ||
258 | newdir=`dirname $newfile` | ||
259 | |||
260 | if [ "$newdir" = "$olddir" ]; then | ||
261 | return 0 | ||
262 | fi | ||
263 | |||
264 | mkdir -p $newdir | ||
265 | mv $1 $newfile | ||
266 | rmdir -p $olddir 2>/dev/null | ||
267 | fi | ||
268 | } | ||
269 | |||
270 | stripFiles() | ||
271 | { | ||
272 | for f in $1; do | ||
273 | stripFile $f | ||
274 | done | ||
275 | } | ||
276 | |||
277 | substFiles() | ||
278 | { | ||
279 | for f in $1; do | ||
280 | substFile $f | ||
281 | done | ||
282 | } | ||
283 | |||
284 | substAndStripFiles() | ||
285 | { | ||
286 | for f in $1; do | ||
287 | stripFile $f | ||
288 | substFile $f $2 | ||
289 | done | ||
290 | } | ||
291 | |||
292 | installScript() | ||
293 | { | ||
294 | if [ -n "$1" -a -f "$1" ]; then | ||
295 | destfile=`basename $1` | ||
296 | if [ -n "$subst" ]; then | ||
297 | sed -f $subst < $1 > $ctrldir/$destfile | ||
298 | else | ||
299 | cat $1 > $ctrldir/$destfile | ||
300 | fi | ||
301 | chmod +x $ctrldir/$destfile | ||
302 | fi | ||
303 | } | ||
304 | |||
305 | tempDir=/tmp/`basename $self`.$$ | ||
306 | mkdir -p $tempDir | ||
307 | if [ $? != 0 ]; then | ||
308 | echo "$self: cannot create $tempDir, exiting..." | ||
309 | exit 1 | ||
310 | fi | ||
311 | |||
312 | cd $destdir; createFileList $control ipkgFileList | ||
313 | if [ "$?" != "0" ]; then | ||
314 | echo "$self: ERROR: missing files, not building $control" | ||
315 | exit 1 | ||
316 | fi | ||
317 | |||
318 | ( cd $destdir && tar cf - $ipkgFileList 2>/dev/null ) | \ | ||
319 | ( cd $tempDir && tar xf - 2>/dev/null ) | ||
320 | |||
321 | if [ -z "$filesubst" ]; then | ||
322 | ( cd $tempDir && stripFiles "$ipkgFileList" ) | ||
323 | else | ||
324 | if ! (echo $filesubst|grep -q '^/'); then | ||
325 | filesubst="$oldpwd/$filesubst" | ||
326 | fi | ||
327 | ( cd $tempDir && substAndStripFiles "$ipkgFileList" $filesubst ) | ||
328 | fi | ||
329 | |||
330 | path="`echo "$PATH" | sed -e "s/\:/ /g"`" | ||
331 | if [ -z "$mkfsjffs2" ]; then | ||
332 | for i in $path; do | ||
333 | if [ -x "$i/mkfs.jffs2" ]; then | ||
334 | mkfsjffs2="$i/mkfs.jffs2" | ||
335 | break | ||
336 | fi | ||
337 | done | ||
338 | fi | ||
339 | |||
340 | if [ -z "$mkfsjffs2" ]; then | ||
341 | echo "$self: WARNING: no mkjfs.jffs2 found in path. Falling back to using du" | ||
342 | echo "for size calculation. mkfs.jffs2 is recommended for size calculation" | ||
343 | echo "as it calculates the real package size on the compressed file system," | ||
344 | echo "in contrast to du calculating the uncompressed size!" | ||
345 | buildsize=`du -h -s $tempDir | awk '{print $1}'` | ||
346 | else | ||
347 | buildsize=`$mkfsjffs2 -r $tempDir | wc -c` | ||
348 | fi | ||
349 | |||
350 | ctrldir=$tempDir/CONTROL | ||
351 | |||
352 | mkdir -p $ctrldir | ||
353 | |||
354 | if [ ! -e $subst ] || [ -z "$subst" ]; then | ||
355 | cat $control | egrep -v '^(FileIncludeMask|FileExcludeMask|Files):' > $ctrldir/control | ||
356 | else | ||
357 | sed -f $subst < $control | egrep -v '^(FileIncludeMask|FileExcludeMask|Files):' > $ctrldir/control | ||
358 | fi | ||
359 | |||
360 | if [ "$buildsize" != "0" ]; then | ||
361 | echo "Installed-Size: $buildsize" >> $ctrldir/control | ||
362 | fi | ||
363 | |||
364 | installScript $preinst | ||
365 | installScript $postinst | ||
366 | installScript $prerm | ||
367 | installScript $posrm | ||
368 | |||
369 | $ipkgbuild $classic -o $user -g $group $tempDir | ||
370 | |||
371 | rm -rf $tempDir | ||