author | wimpie <wimpie> | 2005-01-06 03:51:04 (UTC) |
---|---|---|
committer | wimpie <wimpie> | 2005-01-06 03:51:04 (UTC) |
commit | 807241b7466840034a5284b0202705b096d41458 (patch) (unidiff) | |
tree | e4007fbafd33d1529c4c1d1cf307a85bfe89ecb0 /scripts/GeneratePackageMake | |
parent | 88d721b0636cee01399fe1179622feb2781b57b0 (diff) | |
download | opie-807241b7466840034a5284b0202705b096d41458.zip opie-807241b7466840034a5284b0202705b096d41458.tar.gz opie-807241b7466840034a5284b0202705b096d41458.tar.bz2 |
This script collects all control files
locates Files and Package entrie
and generates using that information a makefile (on stdout)
SOME DOCUMENTATION (sent to all developers)
That makefile generates a new packages for a particular control file
ONLY IF
1. the control file changed
2. one of the files in the control file changed (including
support for wildcards).
The script is called automatically when needed by the main makefile
when either
make packages-mt
make packages
make package-SomeControlBaseName
is called.
if a goal that does not begin with package... is called (like calling
make clean or just make) then the generation is NOT performed (even if
the special makefile to be generated does not exist) NOR will that
special makefile be included (if it exists).
This guarantees the performance of the build to remain the same
packages built are generated to the Packages subdirectory in $(TOPDIR)
The makefile does not try to package applications that are not compiled
mkipk might fail if files are missing. However the makefile is written
such that the packaging continues
Old packages of the same control are removed
EXTRAVERSION is updated automatically (and updated ONLY for packages
that need to be rebuilt).
IMPORTANT :
Because of the dangling link to /opt/QtPalmtop/bin/quicklauncher
in bin for all quicklauncher apps. the makefile exists with
an error message if /opt... does not exist. to make the makefile
work issue
mkdir /opt
ln -sf $(OPIEDIR) /opt/QtPalmtop
-rwxr-xr-x | scripts/GeneratePackageMake | 228 |
1 files changed, 228 insertions, 0 deletions
diff --git a/scripts/GeneratePackageMake b/scripts/GeneratePackageMake new file mode 100755 index 0000000..d5ccee5 --- a/dev/null +++ b/scripts/GeneratePackageMake | |||
@@ -0,0 +1,228 @@ | |||
1 | # generate file containg control name / package name / files | ||
2 | find . -name *.control | grep -v -- "-mt.control" | while read i | ||
3 | do | ||
4 | i=${i/.\//} | ||
5 | CDIR=${i%/*} | ||
6 | BNAME=${i##*/} | ||
7 | BNAME=${BNAME/.control/} | ||
8 | echo "cdir: ${CDIR}" | ||
9 | echo "bname: ${BNAME}" | ||
10 | grep -e "Package:" -e "Files:" ./${i} | ||
11 | done > /tmp/ALL | ||
12 | |||
13 | # | ||
14 | # makefile header | ||
15 | # | ||
16 | |||
17 | cat << MAKEFILEHEADER | ||
18 | |||
19 | # | ||
20 | # generate -mt.control file from regular control | ||
21 | # arg 1 : path to control file to convert | ||
22 | # | ||
23 | |||
24 | define GenerateMTControl | ||
25 | @echo "Generating -mt control file for \$(basename \$<)" | ||
26 | @\$(OPIEDIR)/scripts/tothreaded \$< \$(OPIEDIR)/AllThreadedPackages | ||
27 | endef | ||
28 | |||
29 | # | ||
30 | # package one control file | ||
31 | # arg 1 : directory from OPIEROOT where control file resides | ||
32 | # arg 2 : control file basename without -mt (no .control) | ||
33 | # arg 3 : control file basename with -mt if needed | ||
34 | # arg 4 : package name (value specified by Package: ...) | ||
35 | # | ||
36 | |||
37 | define DoPackage | ||
38 | @echo \"Building ipk of \$(4)\" | ||
39 | @( \$(ForSubst) ) > \$(TOPDIR)/scripts/subst | ||
40 | @( \$(ForFileSubst) ) > \$(TOPDIR)/scripts/Filesubst | ||
41 | @( cd \$(OPIEDIR); \\ | ||
42 | \$(OPIEDIR)/scripts/mkipkg \\ | ||
43 | --subst=\$(OPIEDIR)/scripts/subst \\ | ||
44 | --filesubst=\$(OPIEDIR)/scripts/filesubst \\ | ||
45 | --control=\$(OPIEDIR)/\$(1)/\$(3).control \\ | ||
46 | --prerm=\$(OPIEDIR)/\$(1)/\$(2).prerm \\ | ||
47 | --preinst=\$(OPIEDIR)/\$(1)/\$(2).preinst \\ | ||
48 | --postrm=\$(OPIEDIR)/\$(1)/\$(2).postrm \\ | ||
49 | --postinst=\$(OPIEDIR)/\$(1)/\$(2).postinst \\ | ||
50 | --strip=\$(STRIP) \$(OPIEDIR); \\ | ||
51 | rm -f \$(OPIEDIR)/Packages/\$(4)_*.ipk; \\ | ||
52 | mv *.ipk \$(OPIEDIR)/Packages; \\ | ||
53 | touch \$(OPIEDIR)/Packages/\$(4) \\ | ||
54 | ) || true | ||
55 | endef | ||
56 | |||
57 | # | ||
58 | # prepared for generating the substfile for every build | ||
59 | # | ||
60 | |||
61 | define ForSubst | ||
62 | echo 's,\\\$\$QPE_VERSION,\$(QPE_VERSION),g'; \\ | ||
63 | echo 's,\\\$\$OPIE_VERSION,\$(OPIE_VERSION),g'; \\ | ||
64 | echo 's,\\\$\$QTE_VERSION,\$(QTE_VERSION),g'; \\ | ||
65 | echo 's,\\\$\$QTE_REVISION,\$(QTE_REVISION),g'; \\ | ||
66 | echo 's,\\\$\$SUB_VERSION,\$(SUB_VERSION),g'; \\ | ||
67 | echo 's,\\\$\$EXTRAVERSION,\$(EXTRAVERSION),g'; \\ | ||
68 | echo 's,\\\$\$QTE_BASEVERSION,\$(QTE_BASEVERSION),g' | ||
69 | endef | ||
70 | |||
71 | define ForFileSubst | ||
72 | echo 's,\\\$\$OPIEDIR/root/,/,g'; \\ | ||
73 | echo 's,\$(OPIEDIR)/root/,/,g'; \\ | ||
74 | echo 's,\\\$\$OPIEDIR,\$(prefix),g'; \\ | ||
75 | echo 's,\$(OPIEDIR),\$(prefix),g'; \\ | ||
76 | echo 's,\\\$\$QTDIR,\$(prefix),g'; \\ | ||
77 | echo 's,\$(QTDIR),\$(prefix),g'; \\ | ||
78 | echo 's,^\(\./\)*root/,/,g'; \\ | ||
79 | echo 's,^\(\./\)*etc/,\$(prefix)/etc/,g'; \\ | ||
80 | echo 's,^\(\./\)*lib/,\$(prefix)/lib/,g'; \\ | ||
81 | echo 's,^\(\./\)*bin/,\$(prefix)/bin/,g'; \\ | ||
82 | echo 's,^\(\./\)*pics/,\$(prefix)/pics/,g'; \\ | ||
83 | echo 's,^\(\./\)*sounds/,\$(prefix)/sounds/,g'; \\ | ||
84 | echo 's,^\(\./\)*i18n/,\$(prefix)/i18n/,g'; \\ | ||
85 | echo 's,^\(\./\)*plugins/,\$(prefix)/plugins/,g'; \\ | ||
86 | echo 's,^\(\./\)*apps/,\$(prefix)/apps/,g'; \\ | ||
87 | echo 's,^\(\./\)*share/,\$(prefix)/share/,g'; \\ | ||
88 | echo 's,^\(\./\)*i18n/,\$(prefix)/i18n/,g'; \\ | ||
89 | echo 's,^\(\./\)*help/,\$(prefix)/help/,g' | ||
90 | endef | ||
91 | |||
92 | # | ||
93 | # Will contain a list of all non-mt control files | ||
94 | ALLCONTROLFILES= | ||
95 | |||
96 | # | ||
97 | # Will contain a list of all packaging targets | ||
98 | ALLPACKAGES= | ||
99 | |||
100 | # s contains now single space | ||
101 | s=\$(x) \$(x) | ||
102 | |||
103 | # | ||
104 | # for convenience : generate AllTh | ||
105 | ATP=\$(OPIEDIR)/AllThreadedPackages | ||
106 | |||
107 | MAKEFILEHEADER | ||
108 | |||
109 | while read k | ||
110 | do | ||
111 | CDIR="${k#* }" | ||
112 | read k | ||
113 | BNAME="${k#* }" | ||
114 | read k | ||
115 | case $k in | ||
116 | *"ackage:"*) | ||
117 | Pkg="${k#* }" | ||
118 | Pkg="${Pkg// }" | ||
119 | ;; | ||
120 | *"iles:"*) | ||
121 | Files="${k/Files:/}" | ||
122 | ;; | ||
123 | esac | ||
124 | read k | ||
125 | case $k in | ||
126 | *"ackage:"*) | ||
127 | Pkg="${k#* }" | ||
128 | Pkg="${Pkg// }" | ||
129 | ;; | ||
130 | *"iles:"*) | ||
131 | Files="${k/Files:/}" | ||
132 | ;; | ||
133 | esac | ||
134 | |||
135 | cat << HERE | ||
136 | # | ||
137 | # package $Pkg in ${BNAME} | ||
138 | # | ||
139 | |||
140 | package-${Pkg} : \$(OPIEDIR)/Packages/$Pkg | ||
141 | package-${Pkg}-mt : \$(OPIEDIR)/Packages/$Pkg-mt | ||
142 | |||
143 | # collect control files and package targets | ||
144 | |||
145 | ALLCONTROLFILES += ${CDIR}/${BNAME}.control | ||
146 | ALLPACKAGES += $Pkg | ||
147 | |||
148 | # to generate -mt control file | ||
149 | \$(OPIEDIR)/${CDIR}/${BNAME}-mt.control : \$(OPIEDIR)/${CDIR}/${BNAME}.control | ||
150 | \$(GenerateMTControl) | ||
151 | |||
152 | HERE | ||
153 | |||
154 | if [ ! -z "${Files}" ] | ||
155 | then | ||
156 | |||
157 | cat << HERE | ||
158 | # optimize speed | ||
159 | .phony : \$(wildcard \$(addprefix \$(OPIEDIR)/,${Files})) | ||
160 | |||
161 | # capture missing files (because not built) | ||
162 | \$(OPIEDIR)/Packages/$Pkg \$(OPIEDIR)/Packages/$Pkg-mt \$(SUBSTFILES): \$(wildcard \$(addprefix \$(OPIEDIR)/,${Files})) | ||
163 | HERE | ||
164 | |||
165 | # echo "\$(wildcard \$(addprefix \$(OPIEDIR)/,${Files})) : " | ||
166 | |||
167 | fi | ||
168 | |||
169 | cat << HERE | ||
170 | \$(OPIEDIR)/Packages/$Pkg : \$(OPIEDIR)/${CDIR}/${BNAME}.control | ||
171 | @\$(call DoPackage,${CDIR},${BNAME},${BNAME},${Pkg}) | ||
172 | \$(OPIEDIR)/Packages/$Pkg-mt : \$(OPIEDIR)/${CDIR}/${BNAME}-mt.control | ||
173 | @\$(call DoPackage,${CDIR},${BNAME},${BNAME}-mt,${Pkg}-mt) | ||
174 | |||
175 | HERE | ||
176 | |||
177 | done < /tmp/ALL | ||
178 | |||
179 | cat << HERE | ||
180 | # | ||
181 | # regenerate package file if control files are modified | ||
182 | # | ||
183 | |||
184 | Package.make : \$(addprefix \$(OPIEDIR)/,\$(ALLCONTROLFILES)) | ||
185 | |||
186 | # | ||
187 | # make targets to build packages | ||
188 | # needs quicklauncher link in location (because dangling | ||
189 | # links are not considered as true files by the wildcard command) | ||
190 | # | ||
191 | # if you want to build one package only then use | ||
192 | # make package-<basenameof control> | ||
193 | # or make package-<basenameof control>-mt | ||
194 | # | ||
195 | |||
196 | packages : /opt/QtPalmtop/bin/quicklauncher \\ | ||
197 | \$(OPIEDIR)/Packages \\ | ||
198 | \$(add prefix \$(OPIEDIR)/Packages/,\$(ALLPACKAGES)) | ||
199 | packages-mt : /opt/QtPalmtop/bin/quicklauncher \\ | ||
200 | \$(ATP) \\ | ||
201 | \$(OPIEDIR)/Packages \\ | ||
202 | \$(addprefix \$(OPIEDIR)/Packages/,\$(addsuffix -mt,\$(ALLPACKAGES))) | ||
203 | |||
204 | # | ||
205 | # capture missing quichlauncher link | ||
206 | # | ||
207 | |||
208 | /opt/QtPalmtop/bin/quicklauncher : | ||
209 | @echo "create a link from /opt/QtPalmtop to \$(OPIEDIR) for this target to work" | ||
210 | exit 2 | ||
211 | |||
212 | # | ||
213 | # Create Packages directory | ||
214 | # | ||
215 | |||
216 | \$(OPIEDIR)/Packages : | ||
217 | @mkdir \$(OPIEDIR)/Packages | ||
218 | |||
219 | # | ||
220 | # update file containing all packages | ||
221 | # | ||
222 | |||
223 | \$(ATP) : \$(addprefix \$(OPIEDIR)/,\$(ALLCONTROLFILES)) | ||
224 | @echo "Generating \$(notdir \$(ATP))" | ||
225 | @echo -e "\$(subst \$(s),,\$(foreach i,\$(ALLPACKAGES),\$(i)\n))" > \$@ | ||
226 | HERE | ||
227 | |||
228 | rm /tmp/ALL | ||