]> git.pld-linux.org Git - packages/rpm-build-tools.git/blame - adapter.awk
- remove cvs leftover: $id in at line 1
[packages/rpm-build-tools.git] / adapter.awk
CommitLineData
acf3b940 1#!/usr/bin/gawk -f
16397458 2#
b8f9e95a 3# Adapter adapts .spec files for PLD Linux.
73e1a9a3 4#
d742efc5 5# Copyright (C) 1999-2012 PLD-Team <feedback@pld-linux.org>
73e1a9a3 6# Authors:
d3da6a6e 7# Michał Kuratczyk <kura@pld.org.pl>
b741d74d 8# Sebastian Zagrodzki <s.zagrodzki@mimuw.edu.pl>
d3da6a6e 9# Tomasz Kłoczko <kloczek@rudy.mif.pg.gda.pl>
fb9ab58f 10# Artur Frysiak <wiget@pld-linux.org>
2873c9d1 11# Michal Kochanowicz <mkochano@pld.org.pl>
f3a8d634 12# Jakub Bogusz <qboosh@pld-linux.org>
d3da6a6e 13# Elan Ruusamäe <glen@pld-linux.org>
d5f65bb3
ER
14#
15# See cvs log adapter{,.awk} for list of contributors
16#
73e1a9a3 17# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
3b100864 18
3f6918f6 19# TODO
a73cc8a9 20# - really long sourceX make preamble sorting totally fcked up (try snake.spec r1.1)
3f6918f6
ER
21# - parse ../PLD-doc/BuildRequires.txt and setup proper BR epoches?
22# - add "-nc" option to skip CVS interaction
a3ca2c50
ER
23# - sort Summary(XX)
24# - sort Requires, BuildRequires
2e214691 25# - check if %description (lang=C) contains 8bit
a3ad3d2b 26# - desc wrapping is totally fucked up on global.spec,1.25, dosemu.spec,1.115-
8921159f
ER
27# - it should change: /%source([0-9]+)/i to %{SOURCE\1}
28# - extra quote on LDFLAGS line: https://bugs.launchpad.net/pld-linux/+bug/385836
512524be
AG
29# - %{with_foo:%attr()...} gets converted to %attr() %{with_foo:...} [vlc.spec]
30# - 'R: foo ' (with traliling space) gets coverted to "R: foo\nR: " [vlc.spec @ 1.199 ]
3f6918f6 31
16397458 32BEGIN {
b7ab5ec4 33 RPM_SECTIONS = "package|build|changelog|clean|description|install|post|posttrans|postun|pre|prep|pretrans|preun|triggerin|triggerpostun|triggerun|verifyscript|check"
41c24376 34 SECTIONS = "^%(" RPM_SECTIONS ")"
37403736 35
a8d10697
ER
36 rev = "1.514"
37 VERSION = "0.36/" rev
b8f9e95a 38
7a5425d8 39 PREAMBLE_TAGS = "(R|BR|Summary|Name|Version|Release|Epoch|License|Group|URL|BuildArch|BuildRoot|Obsoletes|Conflicts|Provides|ExclusiveArch|ExcludeArch|Pre[Rr]eq|(Build)?Requires|Suggests|Auto(Req|Prov))"
7c43f31c 40
8271f9dc
PZ
41 usedigest = 0 # Enable to switch to rpm 4.4.6+ md5 digests
42
a3c6bbce 43 preamble = 1 # Is it part of preamble? Default - yes
a3ad3d2b
ER
44 boc = 4 # Beginning of %changelog
45 bod = 0 # Beginning of %description
2b4c59bc 46 tw = 70 # Descriptions width
d2bcf054 47
a5e4249b 48 b_idx = 0 # index of BR/R arrays
42cd9911 49 BR_count = 0 # number of additional BuildRequires
a5e4249b 50
2f46ef70 51 # If variable removed, then 1 (for removing it from export)
52 removed["LDFLAGS"] = 0
53 removed["CFLAGS"] = 0
54 removed["CXXFLAGS"] = 0
308c7423 55
337741dd 56 # If 1, we are inside of comment block (started with /^#%/)
57 comment_block = 0
d2bcf054 58
dfff3476
ER
59 import_rpm_macros()
60
e496dbf5 61 packages_dir = topdir
202b96a2 62 groups_file = packages_dir "/rpm.groups"
dfff3476 63
202b96a2 64 system("cd "packages_dir"; [ -f rpm.groups ] || cvs up rpm.groups > /dev/null")
7df3947d 65 system("[ -d ../PLD-doc ] && cd ../PLD-doc && ([ -f BuildRequires.txt ] || cvs up BuildRequires.txt >/dev/null)");
6b02d821 66
308c7423 67 # Temporary file for changelog section
a91eec5c 68 changelog_file = mktemp("adapter.changelogXXXXXX")
16397458 69}
70
a9f3f77c 71# If the latest line matched /%files/
72defattr == 1 {
ff9e2987
ER
73 if (ENVIRON["SKIP_DEFATTR"] != 1) {
74 if ($0 !~ /defattr/) { # If no %defattr
75 print "%defattr(644,root,root,755)" # Add it
76 } else {
77 $0 = "%defattr(644,root,root,755)" # Correct mistakes (if any)
78 }
79 }
32bb73d8 80 defattr = 0
a9f3f77c 81}
82
a91eec5c
ER
83# call mktemp(1) and return the value
84function mktemp(template, tmp) {
85 "mktemp " template | getline tmp
86 return tmp
87}
88
a5e4249b
ER
89function b_makekey(a, b, s) {
90 s = a "" b;
91 # kill bcond
42cd9911 92 gsub(/[#%]+{[!?]+[_a-zA-Z0-9]+:/, "", s);
f24835a8 93
f51e180c 94 # kill commented out items
42cd9911 95 gsub(/^#[ \t]*/, "", s);
f24835a8 96
7c43f31c 97 # force order
7a5425d8 98 gsub(/^Summary\(/, "11Summary(", s);
661f0bb5 99 gsub(/^Summary/, "10Summary", s);
7a5425d8 100
c2de2587
ER
101 gsub(/^Name/, "2Name", s);
102 gsub(/^Version/, "3Version", s);
103 gsub(/^Release/, "4Release", s);
104 gsub(/^Epoch/, "5Epoch", s);
105 gsub(/^License/, "5License", s);
106 gsub(/^Group/, "6Group", s);
107 gsub(/^URL/, "7URL", s);
108
109 gsub(/^BuildRequires/, "B1BuildRequires", s);
110 gsub(/^BuildConflicts/, "B2BuildConflicts", s);
2f89c197 111
2f89c197 112 gsub(/^Suggests/, "X1Suggests", s);
1f042910
JB
113 gsub(/^Provides/, "X2Provides", s);
114 gsub(/^Obsoletes/, "X3Obsoletes", s);
115 gsub(/^Conflicts/, "X4Conflicts", s);
116 gsub(/^BuildArch/, "X5BuildArch", s);
c2de2587
ER
117 gsub(/^ExclusiveArch/, "X6ExclusiveArch", s);
118 gsub(/^ExcludeArch/, "X7ExcludeArch", s);
119 gsub(/^BuildRoot/, "X9BuildRoot", s);
c0bcd06f 120
7a5425d8
ER
121 gsub(/^AutoProv/, "Xx1AutoProv", s);
122 gsub(/^AutoReq/, "Xx2AutoReq", s);
123
c0bcd06f 124# printf("%s -> %s\n", a""b, s);
a5e4249b
ER
125 return s;
126}
127
0bbcf6b4 128# Comments
2f97d8ea 129/^#/ && (description == 0) {
0bbcf6b4 130 if (/This file does not like to be adapterized!/) {
131 print # print this message
132 while (getline) # print the rest of spec as it is
133 print
134 do_not_touch_anything = 1 # do not touch anything in END()
0314a444 135 exit(rc = 0)
0bbcf6b4 136 }
337741dd 137
0bbcf6b4 138 # Generally, comments are printed without touching
62565bd5 139 sub(/[ \t]+$/, "")
003a22bc 140
8271f9dc
PZ
141 if (/#[ \t]*Source.*md5/) {
142 if (usedigest == 1) {
143 sub(/^#[ \t]*Source/, "BuildRequires:\tdigest(%SOURCE", $0)
144 sub(/-md5[ \t]*:[ \t]*/, ") = ", $0)
145 }
003a22bc
ER
146 print $0
147 next
148 }
337741dd 149}
150
d71e64d1 151/^%define/ {
37403736 152 # Remove defining _applnkdir (this macro has been included in rpm-3.0.4)
17bd16f3 153 if ($2 == "_applnkdir") {
6e01f9db 154 next
17bd16f3
ER
155 }
156 if ($2 == "date") {
6e01f9db 157 date = 1
6cfaf341
ER
158 if (did_files == 0) {
159 print "%files"
160 print ""
161 did_files = 1
162 }
17bd16f3
ER
163 }
164
165 # Do not add %define of _prefix if it already is.
166 if ($2 ~ /^_prefix/) {
167 sub("^"prefix, $3, bindir)
168 sub("^"prefix, $3, sbindir)
169 sub("^"prefix, $3, libdir)
170 sub("^"prefix, $3, datadir)
171 sub("^"prefix, $3, includedir)
172 prefix = $3
173 }
174
175 if ($2 ~ /_bindir/ && !/_sbindir/)
176 bindir = $3
177 if ($2 ~ /_sbindir/)
178 sbindir = $3
5dc7f4ee
ER
179 if ($2 ~ /_libdir/) {
180 if ($3 ~ /^%\(/) {
181 # TODO: should escape for latter checks like: ($c ~ sysconfdir "/{?cron.")
182 libdir = "%%%%%%%%%%%%%%"
183 } else {
184 libdir = $3
185 }
186 }
37403736
ER
187 if ($2 ~ /_sysconfdir/) {
188 if ($3 ~ /^%\(/) {
189 # TODO: should escape for latter checks like: ($c ~ sysconfdir "/{?cron.")
190 sysconfdir = "%%%%%%%%%%%%%%"
191 } else {
192 sysconfdir = $3
193 }
194 }
5dc7f4ee
ER
195 if ($2 ~ /_datadir/) {
196 if ($3 ~ /^%\(/) {
197 # TODO: should escape for latter checks like: ($c ~ sysconfdir "/{?cron.")
198 datadir = "%%%%%%%%%%%%%%"
199 } else {
200 datadir = $3
201 }
202 }
17bd16f3
ER
203 if ($2 ~ /_includedir/)
204 includedir = $3
205 if ($2 ~ /_mandir/)
206 mandir = $3
207 if ($2 ~ /_infodir/)
208 infodir = $3
99b02f64
ER
209 if ($2 ~ /_docdir/)
210 docdir = $3
17bd16f3
ER
211
212 # version related macros
213 if ($2 ~ /^_beta$/)
214 _beta = $3
215 if ($2 ~ /^_rc$/)
216 _rc = $3
f8281d0c
ER
217 if ($2 ~ /^_pre$/)
218 _pre = $3
17bd16f3
ER
219 if ($2 ~ /^_snap$/)
220 _snap = $3
88c76b14
ER
221 if ($2 ~ /^subver$/)
222 subver = $3
17bd16f3
ER
223
224 # these are used usually when adapterizing external spec
225 if ($2 ~ /^name$/)
226 name = $3
227 if ($2 ~ /^version$/)
228 version = $3
229 if ($2 ~ /^release$/)
230 release = $3
5fd6c8d4 231
0311af17
ER
232 if ($2 ~ /^mod_name$/)
233 mod_name = $3
bff32a15
ER
234 if ($2 ~ /^_?pearname$/)
235 pearname = $3
da1f781c
ER
236 if ($2 ~ /^_class$/)
237 pear_class = $3
238 if ($2 ~ /^_subclass$/)
239 pear_subclass = $3
240
241 # kill the _class and _subclass pear macros
242 if ($2 == "_pearname" || $2 == "pearname") {
243 if (pear_class) {
244 gsub("%{_class}", pear_class, $3);
245 }
246 if (pear_subclass) {
247 gsub("%{_subclass}", pear_subclass, $3);
248 }
249 }
0311af17 250
f0c5c231 251 sub(/[ \t]+$/, "");
5fd6c8d4
ER
252 # do nothing further, otherwise adapter thinks we're at preamble
253 print
254 next
d71e64d1
SZ
255}
256
a3ca2c50
ER
257# Obsolete
258/^%include.*\/usr\/lib\/rpm\/macros\.python$/ {
259 next
260}
261
337741dd 262################
263# %description #
264################
37403736 265/^%description/, (!/^%description/ && $0 ~ SECTIONS) {
32bb73d8 266 preamble = 0
948cad9c 267
3b100864 268 if (/^%description/) {
32bb73d8 269 bod++
73e1a9a3 270 format_line = ""
271 format_indent = -1
3b100864
SZ
272 }
273
73e1a9a3 274 # Format description
db167e61 275 if (ENVIRON["SKIP_DESC"] != 1 && description == 1 && !/^%[a-z]+/ && !/^%description/) {
3b100864 276 if (/^[ \t]*$/) {
73e1a9a3 277 format_flush(format_line, format_indent)
3b100864 278 print ""
73e1a9a3 279 format_line = ""
280 format_indent = -1
3b100864 281 } else if (/^[ \t]*[-\*][ \t]*/) {
73e1a9a3 282 format_flush(format_line, format_indent)
d2bcf054 283 match($0, /^[ \t]*/)
73e1a9a3 284 format_indent = RLENGTH
285 match($0, /^[ \t]*[-\*][ \t]/)
286 format_line = substr($0, RLENGTH)
d2bcf054 287 } else
73e1a9a3 288 format_line = format_line " " $0
32bb73d8 289 next
948cad9c 290 }
d2bcf054 291
d71e64d1 292 if (/^%[a-z]+/ && (!/^%description/ || bod == 2)) {
4bd1116d 293 if (NF > 3 && $2 == "-l") {
294 ll = $1
295 for (i = 4; i <= NF; i++)
296 ll = ll " " $i
297 $0 = ll " -l " $3
298 }
73e1a9a3 299 format_flush(format_line, format_indent)
948cad9c 300 if (bod == 2) {
32bb73d8
SZ
301 bod = 1
302 description = 1
948cad9c 303 } else {
32bb73d8
SZ
304 bod = 0
305 description = 0
948cad9c 306 }
307 } else
32bb73d8 308 description = 1
16397458 309}
310
337741dd 311#########
312# %prep #
313#########
37403736 314/^%prep/, (!/^%prep/ && $0 ~ SECTIONS) {
32bb73d8 315 preamble = 0
6cfaf341 316 did_prep = 1
d2bcf054 317
e62422da
ER
318 use_macros()
319
a9f3f77c 320 # Add '-q' to %setup
ef56a1ca 321 if (/^%setup/ && !/-q/) {
d71e64d1 322 sub(/^%setup/, "%setup -q")
ef56a1ca
ER
323 }
324
671ba17b 325 if (/^%setup/ && name != "setup") {
928c2651
ER
326 $0 = fixedsub(name, "%{name}", $0);
327 $0 = fixedsub(version, "%{version}", $0);
3e20c912 328 if (_beta) {
928c2651 329 $0 = fixedsub(_beta, "%{_beta}", $0);
3e20c912
ER
330 }
331 if (_rc) {
928c2651 332 $0 = fixedsub(_rc, "%{_rc}", $0);
3e20c912 333 }
f8281d0c
ER
334 if (_pre) {
335 $0 = fixedsub(_pre, "%{_pre}", $0);
336 }
3e20c912 337 if (_snap) {
928c2651 338 $0 = fixedsub(_snap, "%{_snap}", $0);
3e20c912 339 }
88c76b14
ER
340 if (subver) {
341 $0 = fixedsub(subver, "%{subver}", $0);
342 }
d769e78f
ER
343 }
344
6f7b0e46 345 if (/^%setup/ && /-n %{name}-%{version}( |$)/) {
928c2651 346 $0 = fixedsub(" -n %{name}-%{version}", "", $0)
ef56a1ca 347 }
42cd9911 348 sub("^%patch ", "%patch0 ");
e62422da 349
b7b03087
ER
350 # fedora extras
351 if (/^%apply/) {
352 sub("^%apply -n", "%patch");
353 }
354
e62422da
ER
355 # invalid in %prep
356 sub("^rm -rf \$RPM_BUILD_ROOT.*", "");
16397458 357}
358
337741dd 359##########
360# %build #
361##########
37403736 362/^%build/, (!/^%build/ && $0 ~ SECTIONS) {
32bb73d8 363 preamble = 0
16397458 364
6cfaf341
ER
365 if (did_prep == 0) {
366 print "%prep"
367 print ""
368 did_prep = 1
369 }
370
32bb73d8 371 use_macros()
035bfa01 372 use_tabs()
d2bcf054 373
68694f00 374 if (/^automake$/)
375 sub(/$/, " -a -c")
376
0972e97d 377 if (/LDFLAGS/) {
2f46ef70 378 if (/LDFLAGS="-s"/) {
379 removed["LDFLAGS"] = 1
380 next
381 } else {
382 split($0, tmp, "LDFLAGS=")
0972e97d 383 count = split(tmp[2], flags, "\"")
2f46ef70 384 if (flags[1] != "" && flags[1] !~ "!?debug") {
fe9a6f09 385 sub(/-s[" ]?/, "%{rpmldflags} ", flags[1])
2f46ef70 386 $0 = tmp[1] line[1] "LDFLAGS=" flags[1] "\""
387 for (i = 2; i < count; i++)
388 $0 = $0 flags[i] "\""
389 }
0972e97d 390 }
391 }
392
393 if (/CFLAGS=/)
394 if (cflags("CFLAGS") == 0)
395 next
396
397 if (/CXXFLAGS=/)
398 if (cflags("CXXFLAGS") == 0)
399 next
d2bcf054 400
2f46ef70 401 if (/^export /) {
402 if (removed["LDFLAGS"])
403 sub(" LDFLAGS", "")
404 if (removed["CFLAGS"])
405 sub(" CFLAGS", "")
406 if (removed["CXXFLAGS"])
407 sub(" CXXFLAGS", "")
408 # Is there still something?
409 if (/^export[ ]*$/)
410 next
411 }
02c61abb 412
b5f420e4 413 # quote CC
02c61abb
ER
414 if (/CC=%{__cc} /) {
415 sub("CC=%{__cc}", "CC=\"%{__cc}\"")
416 }
d92d1e4f 417
6702f869 418 # use PLD Linux macros
d92d1e4f
ER
419 $0 = fixedsub("glib-gettextize --copy --force","%{__glib_gettextize}", $0);
420 $0 = fixedsub("intltoolize --copy --force", "%{__intltoolize}", $0);
b5f420e4 421 $0 = fixedsub("automake --add-missing --copy", "%{__automake}", $0);
438df441 422 $0 = fixedsub("automake -a --foreign --copy", "%{__automake}", $0);
a5ab7844 423 $0 = fixedsub("automake -a -c --foreign", "%{__automake}", $0);
82e1c3ee 424 $0 = fixedsub("automake -a -c", "%{__automake}", $0);
438df441
ER
425 $0 = fixedsub("libtoolize --force --automake --copy", "%{__libtoolize}", $0);
426 $0 = fixedsub("libtoolize -c -f --automake", "%{__libtoolize}", $0);
b5f420e4
ER
427
428 sub(/^aclocal$/, "%{__aclocal}");
429 sub(/^autoheader$/, "%{__autoheader}");
430 sub(/^autoconf$/, "%{__autoconf}");
431 sub(/^automake$/, "%{__automake}");
82e1c3ee 432 sub(/^libtoolize$/, "%{__libtoolize}");
d2bcf054 433
023aea7a
ER
434 # atrpms
435 $0 = fixedsub("%perl_configure", "%{__perl} Makefile.PL \\\n\tINSTALLDIRS=vendor", $0);
436 $0 = fixedsub("%perl_makecheck", "%{?with_tests:%{__make} test}", $0);
fa5bc15c
ER
437
438 # alt linux
439 $0 = fixedsub("%make_build", "%{__make}", $0);
16397458 440}
441
337741dd 442##########
443# %clean #
444##########
37403736 445/^%clean/, (!/^%clean/ && $0 ~ SECTIONS) {
aa666779 446 did_clean = 1
6702f869 447
42cd9911 448 use_macros()
aa666779
SZ
449}
450
337741dd 451############
452# %install #
453############
37403736 454/^%install/, (!/^%install/ && $0 ~ SECTIONS) {
d2bcf054 455
32bb73d8 456 preamble = 0
d2bcf054 457
43042a15 458 # foreign rpms
6af280a5 459 sub("^%{__rm} -rf %{buildroot}", "rm -rf $RPM_BUILD_ROOT")
42cd9911
ER
460 sub("%buildroot", "$RPM_BUILD_ROOT");
461 sub("%{buildroot}", "$RPM_BUILD_ROOT");
43042a15 462
6af280a5 463 if (/^[ \t]*rm([ \t]+-[rf]+)*[ \t]+(\${?RPM_BUILD_ROOT}?|%{?buildroot}?)/ && did_rmroot==0) {
aa666779 464 did_rmroot=1
b741d74d
SZ
465 print "rm -rf $RPM_BUILD_ROOT"
466 next
467 }
a9f3f77c 468
aa666779 469 if (!/^(#?[ \t]*)$/ && !/^%install/ && did_rmroot==0) {
b741d74d 470 print "rm -rf $RPM_BUILD_ROOT"
aa666779 471 did_rmroot=1
b741d74d 472 }
d2bcf054 473
42cd9911
ER
474 if (tmpdir) {
475 buildroot = tmpdir "/" name "-" version "-root-" ENVIRON["USER"]
ab73bfb4 476 gsub(buildroot, "$RPM_BUILD_ROOT")
42cd9911 477 }
ab73bfb4 478
42cd9911
ER
479 if (!/%{_lib}/) {
480 sub("\$RPM_BUILD_ROOT/%", "$RPM_BUILD_ROOT%")
481 }
1f948ece 482
b741d74d 483 use_macros()
d2bcf054 484
16397458 485 # 'install -d' instead 'mkdir -p'
486 if (/mkdir -p/)
32bb73d8 487 sub(/mkdir -p/, "install -d")
0071ffb3 488
96b01e16 489 # cp -a already implies cp -r
42cd9911 490 sub(/^cp -ar/, "cp -a")
d2bcf054 491
a9f3f77c 492 # No '-u root' or '-g root' for 'install'
7d285e55 493 if (/^install/ && /-[ug][ \t]*root/)
32bb73d8 494 gsub(/-[ug][ \t]*root /, "")
d2bcf054 495
db929c93
ER
496 if (/^install/ && /-m[ \t]*[0-9]+/)
497 gsub(/-m[ \t]*[0-9]+ /, "")
d2bcf054 498
6b02d821 499 # No lines contain 'chown' or 'chgrp' if owner/group is 'root'
a9f3f77c 500 if (($1 ~ /chown/ && $2 ~ /root\.root/) || ($1 ~ /chgrp/ && $2 ~ /root/))
32bb73d8 501 next
d2bcf054 502
a9f3f77c 503 # No lines contain 'chmod' if it sets the modes to '644'
7d285e55 504 if ($1 ~ /chmod/ && $2 ~ /644/)
32bb73d8 505 next
023aea7a 506
023aea7a
ER
507 # atrpms
508 $0 = fixedsub("%perl_makeinstall", "%{__make} pure_install \\\n\tDESTDIR=$RPM_BUILD_ROOT", $0);
fa5bc15c
ER
509
510 # alt linux
511 $0 = fixedsub("%make_install DESTDIR=$RPM_BUILD_ROOT install", "%{__make} install \\\n\tDESTDIR=$RPM_BUILD_ROOT", $0);
16397458 512}
513
337741dd 514##########
515# %files #
516##########
37403736 517/^%files/, (!/^%files/ && $0 ~ SECTIONS) {
32bb73d8 518 preamble = 0
6cfaf341 519 did_files = 1
d2bcf054 520
d71e64d1 521 if ($0 ~ /^%files/)
32bb73d8 522 defattr = 1
d2bcf054 523
11dd9628
ER
524 if (!use_files_macros()) {
525 next
526 }
16397458 527}
528
337741dd 529##############
530# %changelog #
531##############
37403736 532/^%changelog/, (!/^%changelog/ && $0 ~ SECTIONS) {
32bb73d8 533 preamble = 0
b741d74d 534 has_changelog = 1
dae2a065 535 skip = 0
16397458 536 # There should be some CVS keywords on the first line of %changelog.
dae2a065 537 if (boc == 3) {
a5e6295e 538 if ($0 !~ _cvsmailfeedback) {
e0ab434c 539 print "* %{date} " _cvsmailfeedback > changelog_file
a5e6295e 540 } else {
dae2a065 541 skip = 1
a5e6295e 542 }
dae2a065 543 boc = 2
1fefb3da 544 }
dae2a065 545 if (boc == 2 && !skip) {
1fefb3da 546 if (!/All persons listed below/) {
e6ca8854 547 printf "All persons listed below can be reached at " > changelog_file
e0ab434c 548 print "<cvs_login>" _cvsmaildomain "\n" > changelog_file
a5e6295e 549 } else {
dae2a065 550 skip = 1
a5e6295e 551 }
7bfb8673 552 boc = 1
16397458 553 }
dae2a065
JB
554 if (boc == 1 && !skip) {
555 if (!/^$/) {
a5e6295e 556 if (!/\$.*Log:.*\$/) {
dae2a065 557 print "$" "Log:$" > changelog_file
a5e6295e 558 }
dae2a065
JB
559 boc = 0
560 }
1fefb3da 561 }
6544a775 562 # Define date macro.
1fefb3da 563 if (boc == 4) {
57862255 564 if (date == 0) {
308c7423 565 printf "%%define date\t%%(echo `LC_ALL=\"C\"" > changelog_file
566 print " date +\"%a %b %d %Y\"`)" > changelog_file
1a2653e7 567 date = 1
57862255 568 }
1fefb3da 569 boc = 3
6544a775 570 }
308c7423 571
a5e6295e
ER
572 sub(/[ \t]+$/, "");
573 if (!/^%[a-z]+$/ || /changelog/) {
574 # stop changelog if "real" changelog starts
575 if (boc == 0 && /^\* /) {
576 boc = -1
577 }
578 if (boc == -1) {
579 next;
580 }
308c7423 581 print > changelog_file
a5e6295e 582 } else {
308c7423 583 print
a5e6295e 584 }
308c7423 585 next
16397458 586}
587
337741dd 588###########
589# SCRIPTS #
590###########
37403736 591/^%pre/, (!/^%pre/ && $0 ~ SECTIONS) {
337741dd 592 preamble = 0
c6aa1f63 593
afca35ce
ER
594 if (gsub("/usr/sbin/useradd", "%useradd")) {
595 sub(" 2> /dev/null \|\| :", "");
596 sub(" >/dev/null 2>&1 \|\|:", "");
597 }
598
b7b03087
ER
599 # fedora extras macros
600 if (/%__fe_useradd/) {
601 sub("%__fe_useradd", "%useradd -u ");
602 sub(" 2> /dev/null \|\| :", "");
603 sub(" >/dev/null 2>&1 \|\|:", "");
604 sub(" &>/dev/null \\|\\| :", "");
605 }
606
607 if (/%__fe_groupadd/) {
608 sub("%__fe_groupadd", "%groupadd -g ");
609 sub(" &>/dev/null \\|\\| :", "");
610 }
611
c6aa1f63
ER
612 # %useradd and %groupadd may not be wrapped
613 if (/%(useradd|groupadd).*\\$/) {
614 a = $0; getline;
615 sub(/^[\s\t]*/, "");
616 $0 = substr(a, 1, length(a) - 1) $0;
617 }
afca35ce 618 use_script_macros()
337741dd 619}
c6aa1f63 620
37403736 621/^%post/, (!/^%post/ && $0 ~ SECTIONS) {
337741dd 622 preamble = 0
b7b03087
ER
623
624 # fedora extras macros
625 sub("%__chkconfig", "/sbin/chkconfig");
626
9161cfe7
ER
627 sub("update-desktop-database &> /dev/null \\|\\| :", "%update_desktop_database");
628 sub("touch --no-create %{_datadir}/icons/hicolor", "%update_icon_cache_post hicolor");
629 sub("if \\[ -x %{_bindir}/gtk-update-icon-cache \\]; then\n\t%{_bindir}/gtk-update-icon-cache -q %{_datadir}/icons/hicolor \|\| :\nfi", "");
630
631 sub("export GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source`", "")
632 if (/gconftool-2 --makefile-install-rule/) {
633 sub("gconftool-2 --makefile-install-rule %{_sysconfdir}/gconf/schemas/", "%gconf_schema_install ")
75adc57d 634 sub("> /dev/null", "");
9161cfe7
ER
635 }
636
99b02f64 637 use_macros()
337741dd 638}
37403736 639/^%preun/, (!/^%preun/ && $0 ~ SECTIONS) {
337741dd 640 preamble = 0
eba571c8 641 use_macros()
337741dd 642}
37403736 643/^%postun/, (!/^%postun/ && $0 ~ SECTIONS) {
337741dd 644 preamble = 0
b7b03087
ER
645
646 # fedora extras macros
647 if (/%__fe_userdel|%__fe_groupdel/) {
648 sub("%__fe_groupdel", "%groupremove");
649 sub("%__fe_userdel", "%userremove");
650 sub(" &>/dev/null \\|\\| :", "");
651 }
652
afca35ce 653 use_script_macros()
337741dd 654}
37403736 655/^%triggerin/, (!/^%triggerin/ && $0 ~ SECTIONS) {
74e9aad8 656 preamble = 0
afca35ce 657 use_script_macros()
74e9aad8 658}
37403736 659/^%triggerun/, (!/^%triggerun/ && $0 ~ SECTIONS) {
74e9aad8 660 preamble = 0
afca35ce 661 use_script_macros()
74e9aad8 662}
37403736 663/^%triggerpostun/, (!/^%triggerpostun/ && $0 ~ SECTIONS) {
74e9aad8 664 preamble = 0
afca35ce 665 use_script_macros()
74e9aad8 666}
37403736 667/^%pretrans/, (!/^%pretrans/ && $0 ~ SECTIONS) {
74e9aad8 668 preamble = 0
afca35ce 669 use_script_macros()
74e9aad8 670}
37403736 671/^%posttrans/, (!/^%posttrans/ && $0 ~ SECTIONS) {
74e9aad8 672 preamble = 0
afca35ce 673 use_script_macros()
74e9aad8 674}
b7ab5ec4
ER
675/^%verifyscript/, (!/^%verifyscript/ && $0 ~ SECTIONS) {
676 preamble = 0
afca35ce 677 use_script_macros()
b7ab5ec4
ER
678}
679/^%check/, (!/^%check/ && $0 ~ SECTIONS) {
680 preamble = 0
afca35ce 681 use_script_macros()
b7ab5ec4 682}
337741dd 683
684#############
685# PREAMBLES #
686#############
16397458 687preamble == 1 {
7d285e55 688 # There should not be a space after the name of field
689 # and before the colon.
32bb73d8 690 sub(/[ \t]*:/, ":")
d2bcf054 691
1ea917a3
ER
692 if (/^%perl_module_wo_prefix/) {
693 name = $2
694 version = $3
695 release = "0." fixedsub(".%{disttag}.at", "", $4)
696 }
697
32bb73d8 698 field = tolower($1)
8538dc99 699 if (field ~ /summary:/ && !/etc\.$/ && !/Inc\.$/) {
61182440
ER
700 sub(/\.$/, "", $0);
701 }
2873c9d1 702 if (field ~ /group(\([^)]+\)):/)
5b95e677 703 next
2873c9d1 704 if (field ~ /group:/) {
705 format_preamble()
c0bcd06f
ER
706 group = $0;
707 sub(/^[^ \t]*[ \t]*/, "", group);
eddfcbd4 708 group = replace_groupnames(group);
c0bcd06f
ER
709 $0 = "Group:\t\t" group
710
711 if (group ~ /^X11/ && x11 == 0) # Is it X11 application?
2b4c59bc 712 x11 = 1
b2ba29bc 713
c0bcd06f 714 byl_plik_z_groupmi = 0
b2ba29bc
SZ
715 byl_opis_grupy = 0
716 while ((getline linia_grup < groups_file) > 0) {
c0bcd06f
ER
717 byl_plik_z_groupmi = 1
718 if (linia_grup == group) {
b2ba29bc
SZ
719 byl_opis_grupy = 1
720 break
721 }
722 }
ada044b5 723
c0bcd06f 724 if (!byl_plik_z_groupmi)
b2ba29bc
SZ
725 print "######\t\t" groups_file ": no such file"
726 else if (!byl_opis_grupy)
727 print "######\t\t" "Unknown group!"
d2bcf054 728
b2ba29bc 729 close(groups_file)
6cfaf341 730 did_groups = 1
b2ba29bc 731 }
d2bcf054 732
7f2507f0 733 if (field ~ /prereq:/) {
37457756 734 sub(/Pre[Rr]eq:/, "Requires:", $1);
7f2507f0
ER
735 }
736
6639ea54 737 # split (build)requires, obsoletes on commas
d8e87618 738 if (field ~ /(obsoletes|requires|provides|conflicts|suggests):/ && NF > 2) {
9911efc1
ER
739 value = substr($0, index($0, $2));
740 $0 = format_requires($1, value);
2776dcb6 741 }
42cd9911 742
7198ba75
ER
743 # BR: tar (and others) is to common (rpm-build requires it)
744 if (field ~ /^buildrequires:/) {
a3adad27
ER
745 l = substr($0, index($0, $2));
746 if (l == "awk" ||
747 l == "binutils" ||
748 l == "bzip2" ||
749 l == "cpio" ||
750 l == "diffutils" ||
751 l == "elfutils" ||
752 l == "fileutils" ||
753 l == "findutils" ||
754 l == "glibc-devel" ||
755 l == "grep" ||
756 l == "gzip" ||
757 l == "make" ||
758 l == "patch" ||
759 l == "sed" ||
760 l == "sh-utils" ||
761 l == "tar" ||
762 l == "textutils") {
7198ba75
ER
763 next
764 }
15677f60 765
485540f7 766 replace_requires();
7198ba75
ER
767 }
768
5005c892 769 if (field ~ /^requires:/ || field ~ /^requires\(/) {
485540f7 770 replace_requires();
42cd9911 771 }
cdf38256
ER
772
773
ea66cafb 774 # obsolete/unwanted tags
98125519 775 if (field ~ /vendor:|packager:|distribution:|docdir:|prefix:|icon:|author:|author-email:|metadata-version:/) {
32bb73d8 776 next
9911efc1 777 }
d2bcf054 778
6cfaf341 779 if (field ~ /buildroot:/) {
faabbd89 780 $0 = $1 "%{tmpdir}/%{name}-%{version}-root-%(id -u -n)"
6cfaf341
ER
781 did_build_root = 1
782 }
7d285e55 783
7d285e55 784 # Use "License" instead of "Copyright" if it is (L)GPL or BSD
89411bba 785 if (field ~ /copyright:/ && $2 ~ /GPL|BSD/) {
32bb73d8 786 $1 = "License:"
89411bba 787 }
d2bcf054 788
1a35d71c
ER
789 # ease updating from debian .dsc
790 if (field ~ /homepage:/) {
791 $1 = "URL:"
792 }
793
a6b4adc9
ER
794 # suse
795 if (field ~ /recommends:/) {
796 $1 = "Suggests:"
797 }
798
692116a3 799 if ($3 == "==" && $1 !~ /%/) {
a6b4adc9
ER
800 $3 = "="
801 }
802
baec8afd
ER
803 if (field ~ /license:/) {
804 l = substr($0, index($0, $2));
805 if (l == "Python Software Foundation License") {
806 l = "PSF"
807 }
4f02884b
ER
808 if (l == "Apache License 2.0" || l == "Apache 2.0" || l == "Apache License Version 2.0" || l == "Apache License, Version 2.0" || l == "Apache Software License v2") {
809 l = "Apache v2.0"
810 }
811 if (l == "Apache Group License" || l == "Apache Software License" || l == "Apache License") {
812 l = "Apache"
813 }
814 if (l == "Apache-style License" || l == "Apache-style Software License") {
815 l = "Apache-like"
816 }
817 if (l == "Apache Software License 1.1" || l == "Apache 1.1") {
818 l = "Apache v1.1"
819 }
5e624f99
ER
820 if (l == "GPLv2") {
821 l = "GPL v2"
822 }
823 if (l == "GPLv2+") {
824 l = "GPL v2+"
825 }
7643e340
ER
826 if (l == "GPL v2 or later") {
827 l = "GPL v2+"
828 }
a6b4adc9
ER
829 if (l == "LGPL v2.0 only") {
830 l = "LGPL v2"
831 }
1a296ebe
ER
832 if (l == "LGPLv2+") {
833 l = "LGPL v2+"
834 }
f6187a9d
ER
835 if (l == "GPLv3") {
836 l = "GPL v3"
837 }
838 if (l == "GPLv3+") {
839 l = "GPL v3+"
840 }
eb9c5afa
ER
841 if (l == "MPLv1.1") {
842 l = "MPL v1.1"
843 }
baec8afd
ER
844 $0 = "License:\t" l;
845 }
846
847
1ea917a3 848 if (field ~ /name:/) {
95266981 849 if ($2 == "%{name}" && name) {
2fce9750
ER
850 $2 = name
851 }
32bb73d8 852 name = $2
1ea917a3
ER
853 name_seen = 1;
854 }
7d285e55 855
1ea917a3 856 if (field ~ /version:/) {
2fce9750
ER
857 if ($2 == "%{version}" && version) {
858 $2 = version
859 }
32bb73d8 860 version = $2
1ea917a3
ER
861 version_seen = 1;
862 }
863
864 if (field ~ /release:/) {
2fce9750
ER
865 if ($2 == "%{release}" && release) {
866 $2 = release
867 }
6cfaf341 868 sub(/%atrelease /, "0.", $0)
1ea917a3
ER
869 release = $2
870 release_seen = 1;
871 }
7d285e55 872
98125519 873
246dbfc6
SZ
874 if (field ~ /serial:/)
875 $1 = "Epoch:"
017fc990 876
98125519
ER
877 if (field ~ /home-page:/)
878 $1 = "URL:"
879
4edf81f6 880 # proper caps
7e50ffd2 881 if (field ~ /^url:$/)
4edf81f6
ER
882 $1 = "URL:"
883
f6187a9d
ER
884 if (field ~ /^patch/)
885 $1 = "Patch" substr(field, 6);
886
98125519
ER
887 if (field ~ /^description:$/)
888 $1 = "\n%description\n"
889
7d285e55 890 # Use %{name} and %{version} in the filenames in "Source:"
93ad28bc 891 if (field ~ /^source/ || field ~ /patch/) {
32bb73d8 892 n = split($2, url, /\//)
66437059
SZ
893 if (url[n] ~ /\.gz$/) {
894 url[n+1] = ".gz" url[n+1]
895 sub(/\.gz$/,"",url[n])
896 }
897 if (url[n] ~ /\.zip$/) {
898 url[n+1] = ".zip" url[n+1]
899 sub(/\.zip$/,"",url[n])
900 }
901 if (url[n] ~ /\.tar$/) {
902 url[n+1] = ".tar" url[n+1]
903 sub(/\.tar$/,"",url[n])
904 }
905 if (url[n] ~ /\.patch$/) {
906 url[n+1] = ".patch" url[n+1]
907 sub(/\.patch$/,"",url[n])
908 }
909 if (url[n] ~ /\.bz2$/) {
910 url[n+1] = ".bz2" url[n+1]
911 sub(/\.bz2$/,"",url[n])
912 }
45465264
SZ
913 if (url[n] ~ /\.logrotate$/) {
914 url[n+1] = ".logrotate" url[n+1]
915 sub(/\.logrotate$/,"",url[n])
916 }
917 if (url[n] ~ /\.pamd$/) {
918 url[n+1] = ".pamd" url[n+1]
919 sub(/\.pamd$/,"",url[n])
920 }
921
bf246f77 922 # allow %{name} only in last url component
ccb3335c
ER
923 s = ""
924 for (i = 1; i <= n; i++) {
925 url[i] = fixedsub("%{name}", name, url[i])
926 if (s) {
927 s = s "/" url[i]
928 } else {
929 s = url[i]
930 }
931 }
932 $2 = s url[n+1]
933
32bb73d8 934 filename = url[n]
4c237f9d
ER
935 if (name) {
936 url[n] = fixedsub(name, "%{name}", url[n])
937 }
85bbdbed 938 if (field ~ /source/) {
4c237f9d
ER
939 if (version) {
940 url[n] = fixedsub(version, "%{version}", url[n])
941 }
85bbdbed
ER
942 if (_beta) {
943 url[n] = fixedsub(_beta, "%{_beta}", url[n])
944 }
945 if (_rc) {
946 url[n] = fixedsub(_rc, "%{_rc}", url[n])
947 }
f8281d0c
ER
948 if (_pre) {
949 url[n] = fixedsub(_pre, "%{_pre}", url[n])
950 }
85bbdbed
ER
951 if (_snap) {
952 url[n] = fixedsub(_snap, "%{_snap}", url[n])
953 }
88c76b14
ER
954 if (subver) {
955 url[n] = fixedsub(subver, "%{subver}", url[n])
956 }
85bbdbed 957 }
f175a699 958 # assigning to $2 kills preamble formatting
66437059 959 $2 = fixedsub(filename, url[n], $2)
d2bcf054 960
0b8c0588 961 $2 = unify_url($2)
7d285e55 962 }
be7dead6 963
d2bcf054 964
93ad28bc 965 if (field ~ /^source:/)
d2bcf054 966 $1 = "Source0:"
32bb73d8 967
ff9e2987 968 if (field ~ /^patch:/)
32bb73d8 969 $1 = "Patch0:"
d2bcf054 970
0311af17 971 kill_preamble_macros();
32bb73d8 972 format_preamble()
d2bcf054 973
12d9b2b2
ER
974 if (field ~ /requires/) {
975 # atrpms
976 $0 = fixedsub("%{eversion}", "%{epoch}:%{version}-%{release}", $0);
977 }
16397458 978}
979
8671b2a2
ER
980/^%bcond_/ {
981 # do nothing
982 print
983 next
984}
7c43f31c
ER
985
986# sort BR/R!
987#
988# NOTES:
989# - mixing BR/R and anything else confuses this (all will be sorted together)
42cd9911 990# so don't do that.
7c43f31c 991# - comments leading the BR/R can not be associated,
42cd9911 992# so don't adapterize when the BR/R are mixed with comments
4169482f 993ENVIRON["SKIP_SORTBR"] != 1 && preamble == 1 && $0 ~ PREAMBLE_TAGS ":", $0 ~ PREAMBLE_TAGS ":"{
f175a699 994 if ($1 ~ /Pre[Rr]eq:/) {
37457756 995 sub(/Pre[Rr]eq:/, "Requires:", $1);
7c43f31c 996 }
8be3cbda
ER
997 if ($1 == "BR:" ) {
998 $1 = "BuildRequires:"
999 }
1000 if ($1 == "R:" ) {
1001 $1 = "Requires:"
1002 }
7c43f31c 1003 format_preamble()
73eaf7b6 1004# kill_preamble_macros(); # breaks tabbing
7c43f31c
ER
1005
1006 b_idx++;
1007 l = substr($0, index($0, $2));
1008 b_ktmp = b_makekey($1, l);
1009 b_key[b_idx] = b_ktmp;
1010 b_val[b_ktmp] = $0;
1011
1012 next;
1013}
1014
7c43f31c
ER
1015preamble == 1 {
1016 if (b_idx > 0) {
1017 isort(b_key, b_idx);
1018 for (i = 1; i <= b_idx; i++) {
89411bba
ER
1019 v = b_val[b_key[i]];
1020 sub(/[ \t]+$/, "", v);
1021 print "" v;
7c43f31c
ER
1022 }
1023 b_idx = 0
1024 }
1025}
1026
2b4c59bc 1027# main() ;-)
16397458 1028{
32bb73d8 1029 preamble = 1
d2bcf054 1030
62565bd5 1031 sub(/[ \t]+$/, "")
32bb73d8 1032 print
1ea917a3
ER
1033
1034 if (name_seen == 0 && name) {
bd313400 1035 print "Name:\t\t" name
1ea917a3
ER
1036 name_seen = 1
1037 }
1038
1039 if (version_seen == 0 && version) {
1040 print "Version:\t" version
1041 version_seen = 1
1042 }
1043
1044 if (release_seen == 0 && release) {
1045 print "Release:\t" release
1046 release_seen = 1
1047 }
98125519
ER
1048
1049 if (did_build_root == 0) {
6cfaf341 1050# print "BuildRoot:\t%{tmpdir}/%{name}-%{version}-root-%(id -u -n)"
98125519
ER
1051 did_build_root = 1
1052 }
6cfaf341
ER
1053 if (did_groups == 0) {
1054# print "Group:\t\tunknown"
1055 did_groups = 1
1056 }
57862255 1057}
1058
6b02d821 1059
57862255 1060END {
0314a444
ER
1061 if (do_not_touch_anything) {
1062 exit(rc)
1063 }
d2bcf054 1064
42cd9911
ER
1065 # TODO: need to output these in proper place
1066 if (BR_count > 0) {
1067 for (i = 0; i <= BR_count; i++) {
1068 print BR[i];
1069 }
1070 }
a3c6bbce 1071
6b02d821 1072 close(changelog_file)
1073 while ((getline < changelog_file) > 0)
1074 print
1075 system("rm -f " changelog_file)
3c6a8648 1076
aa666779
SZ
1077 if (did_clean == 0) {
1078 print ""
1079 print "%clean"
1080 print "rm -rf $RPM_BUILD_ROOT"
1081 }
1082
b741d74d
SZ
1083 if (date == 0) {
1084 print ""
1085 print "%define date\t%(echo `LC_ALL=\"C\" date +\"%a %b %d %Y\"`)"
1086 }
d2bcf054 1087
a3c6bbce 1088 if (has_changelog == 0) {
1a2653e7 1089 print "%changelog"
42cd9911 1090 }
b741d74d 1091
a3c6bbce 1092 if (boc > 2) {
99f2e2ca 1093 print "* %{date} PLD Team <feedback@pld-linux.org>"
42cd9911 1094 }
1fefb3da 1095 if (boc > 1) {
9b223e29 1096 printf "All persons listed below can be reached at "
99f2e2ca 1097 print "<cvs_login>@pld-linux.org\n"
57862255 1098 }
a3c6bbce 1099 if (boc > 0) {
1fefb3da 1100 print "$" "Log:$"
42cd9911 1101 }
16397458 1102}
1103
66437059 1104# substitutes fixed strings (not regexps)
57900eb0 1105function fixedsub(s1,s2,t, ind) {
2b4c59bc 1106 if (ind = index(t,s1))
1107 t = substr(t, 1, ind-1) s2 substr(t, ind+length(s1))
1108 return t
66437059
SZ
1109}
1110
57900eb0
ER
1111# replace s with s2 if it equals to s1
1112function replace(s, s1, s2) {
1113 if (s == s1) {
1114 return s2;
1115 } else {
1116 return s;
1117 }
1118}
1119
be7dead6 1120# There should be one or two tabs after the colon.
1121function format_preamble()
1122{
f175a699 1123 if (/^#/ || /^%bcond_with/) {
c74a804a
ER
1124 return;
1125 }
32bb73d8 1126 sub(/:[ \t]*/, ":")
13dda4dc
ER
1127 if (match($0, /[A-Za-z0-9(),#_ \t.-]+[ \t]*:[ \t]*/) == 1) {
1128 if (RLENGTH < 8) {
32bb73d8 1129 sub(/:/, ":\t\t")
42cd9911 1130 } else {
32bb73d8 1131 sub(/:/, ":\t")
42cd9911 1132 }
be7dead6 1133 }
1134}
1135
a9f3f77c 1136# Replace directly specified directories with macros
1137function use_macros()
1138{
ff9e2987
ER
1139 # -m, --skip-macros, --no-macros -- skip macros subst
1140 if (ENVIRON["SKIP_MACROS"]) {
1141 return
1142 }
1143
5110bd60
ER
1144 # leave inline sed lines alone
1145 if (/(%{__sed}|sed) -i -e/) {
1146 return;
1147 }
1148
42cd9911
ER
1149 sub("%{_defaultdocdir}", "%{_docdir}");
1150 sub("%{_bindir}/perl", "%{__perl}");
1151 sub("%{_bindir}/python", "%{__python}");
32b4e718 1152
bf42735e
ER
1153 gsub(infodir, "%{_infodir}")
1154
c9cb5723
ER
1155 gsub(perl_sitearch, "%{perl_sitearch}")
1156 gsub(perl_archlib, "%{perl_archlib}")
1157 gsub(perl_privlib, "%{perl_privlib}")
c9cb5723
ER
1158 gsub(perl_vendorlib, "%{perl_vendorlib}")
1159 gsub(perl_vendorarch, "%{perl_vendorarch}")
1160 gsub(perl_sitelib, "%{perl_sitelib}")
f9ae8d4e
ER
1161
1162 gsub(py_sitescriptdir, "%{py_sitescriptdir}")
6cfaf341 1163 gsub(py_sitedir, "%{py_sitedir}")
96c9c215 1164 gsub(py_scriptdir, "%{py_scriptdir}")
a8e7eb6a
ER
1165
1166 gsub(py3_sitescriptdir, "%{py3_sitescriptdir}")
1167 gsub(py3_sitedir, "%{py3_sitedir}")
1168 gsub(py3_scriptdir, "%{py3_scriptdir}")
9f2514dd
ER
1169
1170 gsub(ruby_archdir, "%{ruby_archdir}")
1171 gsub(ruby_ridir, "%{ruby_ridir}")
1172 gsub(ruby_rubylibdir, "%{ruby_rubylibdir}")
1173 gsub(ruby_sitearchdir, "%{ruby_sitearchdir}")
1174 gsub(ruby_sitelibdir, "%{ruby_sitelibdir}")
5fbedd3e 1175 gsub(ruby_rdocdir, "%{ruby_rdocdir}")
9f2514dd 1176
73746589
ER
1177 gsub(systemdunitdir, "%{systemdunitdir}")
1178 gsub(systemdtmpfilesdir, "%{systemdtmpfilesdir}")
1179
9086b883
ER
1180 gsub("%{_datadir}/applications", "%{_desktopdir}")
1181 gsub("%{_datadir}/pixmaps", "%{_pixmapsdir}")
5e624f99 1182 gsub("%{_datadir}/java", "%{_javadir}")
c9cb5723 1183
0314a444
ER
1184 gsub("%{_libdir}/pkgconfig", "%{_pkgconfigdir}")
1185 gsub(pkgconfigdir, "%{_pkgconfigdir}")
1186
62466386
ER
1187 gsub("%{_datadir}/pkgconfig", "%{_npkgconfigdir}")
1188 gsub(npkgconfigdir, "%{_npkgconfigdir}")
1189
639225be
ER
1190 gsub("%{_datadir}/locale", "%{_localedir}")
1191 gsub(localedir, "%{_localedir}")
1192
6dd2a429 1193 gsub(libdir, "%{_libdir}")
5e624f99 1194 gsub(javadir, "%{_javadir}")
6dd2a429 1195
32bb73d8 1196 gsub(bindir, "%{_bindir}")
60e168c3 1197 gsub("%{prefix}/bin", "%{_bindir}")
5110bd60 1198 if (prefix"/bin" == bindir)
f0eca444 1199 gsub("%{_prefix}/bin", "%{_bindir}")
60e168c3 1200
ec98fa64 1201 for (c = 1; c <= NF; c++) {
1202 if ($c ~ sbindir "/fix-info-dir")
1203 continue;
61780b93
ER
1204 if ($c ~ sbindir "/webapp")
1205 continue;
bf42735e
ER
1206 if ($c ~ sbindir "/ldconfig")
1207 continue;
eb4e6786
ER
1208 if ($c ~ sbindir "/chsh")
1209 continue;
1210 if ($c ~ sbindir "/usermod")
1211 continue;
377c83f8
ER
1212 if ($c ~ sbindir "/chkconfig")
1213 continue;
519b18fb
ER
1214 if ($c ~ sbindir "/installzope(product|3package)")
1215 continue;
ec98fa64 1216 gsub(sbindir, "%{_sbindir}", $c)
1217 }
1218
60e168c3 1219 gsub("%{prefix}/sbin", "%{_sbindir}")
519b18fb 1220 if (prefix"/sbin" == sbindir) {
5d0dc6ec 1221 gsub("%{_prefix}/sbin", "%{_sbindir}")
519b18fb 1222 }
60e168c3 1223
38504ae2 1224 for (c = 1; c <= NF; c++) {
de2f7a1a 1225 if ($c ~ sysconfdir "/{?cron.")
ec98fa64 1226 continue;
f0eca444 1227 if ($c ~ sysconfdir "/{?crontab.d")
af3306cc 1228 continue;
269161f4
ER
1229 if ($c ~ sysconfdir "/{?env.d")
1230 continue;
66f4bdaa 1231 if ($c ~ sysconfdir "/{?modprobe.(d|conf)")
791430b4 1232 continue;
3c1352be
ER
1233 if ($c ~ sysconfdir "/{?udev")
1234 continue;
1235 if ($c ~ sysconfdir "/{?hotplug")
7a1926d6 1236 continue;
f0eca444 1237 if ($c ~ sysconfdir "/{?logrotate.d")
38504ae2 1238 continue;
f0eca444 1239 if ($c ~ sysconfdir "/{?pam.d")
a56e8186 1240 continue;
f0eca444 1241 if ($c ~ sysconfdir "/{?profile.d")
3849d745 1242 continue;
f0eca444 1243 if ($c ~ sysconfdir "/{?rc.d")
d95318c3 1244 continue;
f0eca444 1245 if ($c ~ sysconfdir "/{?security")
a56e8186 1246 continue;
f0eca444 1247 if ($c ~ sysconfdir "/{?skel")
1021eb9a 1248 continue;
f0eca444 1249 if ($c ~ sysconfdir "/{?sysconfig")
3849d745 1250 continue;
a3ad3d2b
ER
1251 if ($c ~ sysconfdir "/{?shrc.d")
1252 continue;
7666ea52
ER
1253 if ($c ~ sysconfdir "/{?certs")
1254 continue;
3c475044
ER
1255 if ($c ~ sysconfdir "/{?X11")
1256 continue;
7e2a6e20
ER
1257 if ($c ~ sysconfdir "/{?ld.so.conf.d")
1258 continue;
ea66cafb
ER
1259 if ($c ~ sysconfdir "/{?rpm")
1260 continue;
f175a699 1261 if ($c ~ sysconfdir "/{?bash_completion.d")
a3ad3d2b 1262 continue;
f175a699 1263 if ($c ~ sysconfdir "/{?samba")
9fb04ca3 1264 continue;
5919d837
ER
1265 if ($c ~ sysconfdir "/{?xdg")
1266 continue;
e4339f15
ER
1267 if ($c ~ sysconfdir "/shells")
1268 continue;
5919d837
ER
1269 if ($c ~ sysconfdir "/inittab")
1270 continue;
a0b7bf7d
ER
1271 if ($c ~ sysconfdir "/init")
1272 continue;
f2bc05a6
ER
1273 if ($c ~ sysconfdir "/ppp")
1274 continue;
318fa94a
ER
1275 if ($c ~ sysconfdir "/dbus-1")
1276 continue;
5319da4e
ER
1277 if ($c ~ sysconfdir "/tmpwatch")
1278 continue;
f6187a9d
ER
1279 if ($c ~ sysconfdir "/acpi")
1280 continue;
1281 if ($c ~ sysconfdir "/apm")
1282 continue;
38504ae2 1283 gsub(sysconfdir, "%{_sysconfdir}", $c)
1284 }
60e168c3 1285
99b02f64 1286 gsub(docdir, "%{_docdir}")
3d5e7b27
ER
1287
1288 gsub(kdedocdir, "%{_kdedocdir}")
1289
1290 gsub(gtkdocdir, "%{_gtkdocdir}")
1291 gsub("%{_docdir}/gtk-doc/html", "%{_gtkdocdir}")
1292
f175a699 1293 gsub(php_pear_dir, "%{php_pear_dir}")
6d542d59 1294 gsub(php_data_dir, "%{php_data_dir}")
99b02f64 1295
10592e33
ER
1296 for (c = 1; c <= NF; c++) {
1297 if ($c ~ datadir "/automake")
1298 continue;
5d60467e
ER
1299 if ($c ~ datadir "/unsermake")
1300 continue;
a0e6069a
ER
1301 if ($c ~ datadir "/file/magic.mime")
1302 continue;
10592e33
ER
1303 gsub(datadir, "%{_datadir}", $c)
1304 }
1305
60e168c3 1306 gsub("%{prefix}/share", "%{_datadir}")
10592e33 1307 if (prefix"/share" == datadir)
f0eca444 1308 gsub("%{_prefix}/share", "%{_datadir}")
60e168c3 1309
03fbe002
ER
1310 # CFLAGS="-I/usr/include/ncurses is usually correct.
1311 if (!/-I\/usr\/include/) {
1312 gsub(includedir, "%{_includedir}")
1313 }
1314
60e168c3 1315 gsub("%{prefix}/include", "%{_includedir}")
03fbe002 1316 if (prefix"/include" == includedir) {
f0eca444 1317 gsub("%{_prefix}/include", "%{_includedir}")
03fbe002 1318 }
60e168c3 1319
32bb73d8 1320 gsub(mandir, "%{_mandir}")
03fbe002 1321 if ($0 !~ "%{_datadir}/manual") {
5d0dc6ec 1322 gsub("%{_datadir}/man", "%{_mandir}")
03fbe002 1323 }
cd1437c2 1324 gsub("%{_prefix}/share/man", "%{_mandir}")
1325 gsub("%{prefix}/share/man", "%{_mandir}")
60e168c3 1326 gsub("%{prefix}/man", "%{_mandir}")
1327 gsub("%{_prefix}/man", "%{_mandir}")
1328
32bb73d8 1329 gsub(infodir, "%{_infodir}")
60e168c3 1330 gsub("%{prefix}/info", "%{_infodir}")
1331 gsub("%{_prefix}/info", "%{_infodir}")
1332
de2f7a1a 1333 if (prefix !~ "/X11R6") {
1334 gsub("%{_datadir}/aclocal", "%{_aclocaldir}")
1335 }
bd4a2113 1336
33957389 1337 gsub(examplesdir, "%{_examplesdir}")
d6255e69 1338
982b68ad 1339 if (prefix != "/") {
a0e6069a
ER
1340 # leave --with-foo=/usr alone
1341 if ($0 !~ "--with.*=.*" prefix) {
1342 for (c = 1; c <= NF; c++) {
1343 if ($c ~ prefix "/sbin/fix-info-dir")
1344 continue;
61780b93
ER
1345 if ($c ~ prefix "/sbin/webapp")
1346 continue;
eb4e6786
ER
1347 if ($c ~ prefix "/sbin/chsh")
1348 continue;
1349 if ($c ~ prefix "/sbin/usermod")
1350 continue;
519b18fb
ER
1351 if ($c ~ prefix "/sbin/installzope(product|3package)")
1352 continue;
a0e6069a
ER
1353 if ($c ~ prefix "/share/automake")
1354 continue;
1355 if ($c ~ prefix "/share/unsermake")
1356 continue;
1357 if ($c ~ prefix "/lib/sendmail")
1358 continue;
c0ae0d40
ER
1359 if ($c ~ prefix "/lib/pkgconfig")
1360 continue;
03fbe002 1361
589bf4b3
ER
1362 # CFLAGS="-I/usr..." is usually correct.
1363 if (/-I\/usr/)
03fbe002 1364 continue;
4e1f12b2
ER
1365 # same for LDFLAGS="-L/usr..."
1366 if (/-L\/usr/)
1367 continue;
03fbe002 1368
a0e6069a
ER
1369 gsub(prefix, "%{_prefix}", $c)
1370 }
ec98fa64 1371 }
982b68ad 1372 gsub("%{prefix}", "%{_prefix}")
1373 }
9a43821c 1374
77b6d1ab
ER
1375 # replace back
1376 gsub("%{_includedir}/ncurses", "/usr/include/ncurses")
1377 gsub("%{_includedir}/freetype", "/usr/include/freetype")
1378
9a43821c 1379 gsub("%{PACKAGE_VERSION}", "%{version}")
1380 gsub("%{PACKAGE_NAME}", "%{name}")
92bd39c6 1381
7f5aa63a 1382 gsub("^make$", "%{__make}")
1383 gsub("^make ", "%{__make} ")
ca0c404d 1384 gsub("^gcc ", "%{__cc} ")
8be48373 1385 gsub("^rm --interactive=never ", "%{__rm} ")
58ca7d6b 1386
f6187a9d
ER
1387 # fedora
1388 gsub("%{ruby_sitearch}", "%{ruby_sitearchdir}")
1389 gsub("%{python_sitearch}", "%{py_sitedir}")
eb9c5afa
ER
1390 gsub("%{python_sitelib}", "%{py_sitescriptdir}")
1391
1392 # alt linux
1393 gsub("%_man1dir", "%{_mandir}/man1")
f6187a9d 1394
3353e0d5
ER
1395 # mandrake specs
1396 gsub("^%make$", "%{__make}")
1397 gsub("^%make ", "%{__make} ")
1398 gsub("^%makeinstall_std", "%{__make} install \\\n\tDESTDIR=$RPM_BUILD_ROOT")
8705c1a9 1399 gsub("^%{makeinstall}", "%{__make} install \\\n\tDESTDIR=$RPM_BUILD_ROOT")
2fce9750 1400 gsub("^%makeinstall", "%{__make} install \\\n\tDESTDIR=$RPM_BUILD_ROOT")
3353e0d5 1401 gsub("^%{__rm} -rf %{buildroot}", "rm -rf $RPM_BUILD_ROOT")
8705c1a9 1402 gsub("^%{__install}", "install")
3353e0d5
ER
1403 gsub("%optflags", "%{rpmcflags}")
1404 gsub("%{compat_perl_vendorarch}", "%{perl_vendorarch}")
1405
32d93636 1406 gsub("^%{__make} install DESTDIR=\$RPM_BUILD_ROOT", "%{__make} install \\\n\tDESTDIR=$RPM_BUILD_ROOT")
eba571c8 1407 gsub("^fix-info-dir$", "[ ! -x /usr/sbin/fix-info-dir ] || /usr/sbin/fix-info-dir -c %{_infodir} >/dev/null 2>\\&1")
023aea7a
ER
1408 $0 = fixedsub("%buildroot", "$RPM_BUILD_ROOT", $0)
1409 $0 = fixedsub("%{buildroot}", "$RPM_BUILD_ROOT", $0)
2fce9750 1410 $0 = fixedsub("CXXFLAGS=%{rpmcflags} %configure", "CXXFLAGS=%{rpmcflags}\n%configure", $0);
2f89c197 1411 $0 = fixedsub("%__install", "install", $0);
2fce9750 1412
807cdd98 1413 # split configure line to multiple lines
8bb66b1c 1414 if (/%configure +$/) {
1415 sub( / +$/, "" );
1416 } else if (/%configure / && !/\\$/) {
807cdd98
ER
1417 $0 = format_configure($0);
1418 }
1419
e62422da
ER
1420 gsub("%_bindir", "%{_bindir}")
1421 gsub("%_datadir", "%{_datadir}")
1422 gsub("%_iconsdir", "%{_iconsdir}")
99b02f64
ER
1423 gsub("%_sbindir", "%{_sbindir}")
1424 gsub("%_mandir", "%{_mandir}")
1425 gsub("%name", "%{name}")
42cd9911
ER
1426 gsub(/%__rm/, "rm");
1427 gsub(/%__mkdir_p/, "install -d");
1428 gsub(/%__cp/, "cp");
1429 gsub(/%__ln_s/, "ln -s");
1430 gsub(/%__sed/, "%{__sed}");
1431 gsub(/%__cat/, "cat");
1432 gsub(/%__chmod/, "chmod");
32d93636 1433
58ca7d6b 1434 gsub("/usr/src/linux", "%{_kernelsrcdir}")
1435 gsub("%{_prefix}/src/linux", "%{_kernelsrcdir}")
a3c6bbce 1436
caa01c58 1437 if (/^ant / || /^%{ant}/) {
a3c6bbce 1438 sub(/^ant/, "%ant")
caa01c58 1439 sub(/^%{ant}/, "%ant")
42cd9911
ER
1440 add_br("BuildRequires: jpackage-utils");
1441 add_br("BuildRequires: rpmbuild(macros) >= 1.300");
1442 }
a3c6bbce 1443
9b8d82c1
ER
1444 $0 = fixedsub("%(%{__cc} -dumpversion)", "%{cc_version}", $0);
1445 $0 = fixedsub("%(%{__cxx} -dumpversion)", "%{cxx_version}", $0);
da1f781c
ER
1446
1447 # kill the _class and _subclass pear macros
1448 if (pear_class) {
1449 gsub("%{_class}", pear_class);
1450 }
1451 if (pear_subclass) {
1452 gsub("%{_subclass}", pear_subclass);
1453 }
b6979c9c 1454}
d2bcf054 1455
807cdd98
ER
1456function format_configure(line, n, a, s) {
1457 n = split(line, a, / /);
1458 s = a[1] " \\\n";
1459 for (i = 2; i <= n; i++) {
1460 s = s "\t" a[i] " \\\n"
1461 }
1462 return s
1463}
1464
c490069b
ER
1465
1466# insertion sort of A[1..n]
1467# copied from mawk manual
1468function isort(A,n, i,j,hold) {
1469 for (i = 2; i <= n; i++) {
1470 hold = A[j = i]
1471 while (A[j-1] > hold) {
e8e4542f 1472 j-- ; A[j+1] = A[j]
1473 }
c490069b
ER
1474 A[j] = hold
1475 }
1476 # sentinel A[0] = "" will be created if needed
1477}
1478
1479
a3296e40 1480function use_files_macros( i, n, t, a, l)
0bbcf6b4 1481{
6702f869
ER
1482 use_macros()
1483
2a10aeb5
ER
1484 # skip comments
1485 if (/^#/) {
11dd9628 1486 return 1;
2a10aeb5
ER
1487 }
1488
3210b282
ER
1489 sub("^%doc %{_mandir}", "%{_mandir}")
1490
0bbcf6b4 1491 gsub("^%{_sbindir}", "%attr(755,root,root) %{_sbindir}")
1492 gsub("^%{_bindir}", "%attr(755,root,root) %{_bindir}")
c490069b 1493
bb7ad876
ER
1494 # uid/gid nobody is not valid in %files
1495 if (/%attr([^)]*nobody[^)]*)/ && !/FIXME/) {
1496 $0 = $0 " # FIXME nobody user/group can't own files! -adapter.awk"
1497 }
1498
07aced3a
JB
1499 # s[gu]id programs with globs are evil
1500 if (/%attr\([246]...,.*\*/ && !/FIXME/) {
1501 $0 = $0 " # FIXME no globs for suid/sgid files"
ca68f0c3
ER
1502 }
1503
aedb74de 1504 # replace back
16590ec6 1505 gsub("%{_sysconfdir}/cron\.d", "/etc/cron.d")
d7018013 1506 gsub("%{_sysconfdir}/crontab\.d", "/etc/crontab.d")
16590ec6
ER
1507 gsub("%{_sysconfdir}/logrotate\.d", "/etc/logrotate.d")
1508 gsub("%{_sysconfdir}/pam\.d", "/etc/pam.d")
1509 gsub("%{_sysconfdir}/profile\.d", "/etc/profile.d")
1510 gsub("%{_sysconfdir}/rc\.d", "/etc/rc.d")
1511 gsub("%{_sysconfdir}/security", "/etc/security")
1512 gsub("%{_sysconfdir}/skel", "/etc/skel")
1513 gsub("%{_sysconfdir}/sysconfig", "/etc/sysconfig")
1514 gsub("%{_sysconfdir}/certs", "/etc/certs")
aedb74de 1515 gsub("%{_sysconfdir}/init.d", "/etc/init.d")
318fa94a 1516 gsub("%{_sysconfdir}/dbus-1", "/etc/dbus-1")
5319da4e
ER
1517 gsub("%{_sysconfdir}/pki", "/etc/pki")
1518 gsub("%{_sysconfdir}/tmpwatch", "/etc/tmpwatch")
fc100b2c 1519
aedb74de
ER
1520 # /etc/init.d -> /etc/rc.d/init.d
1521 if (!/^\/etc\/init\.d$/) {
1522 gsub("/etc/init.d", "/etc/rc.d/init.d")
1523 }
1524
1525 if (/\/etc\/rc\.d\/init\.d\// && !/functions/) {
fc100b2c
ER
1526 if (!/%attr.*\/etc\/rc\.d\/init\.d/) {
1527 $0 = "%attr(754,root,root) " $0
1528 }
1529 if (/^%attr.*\/etc\/rc\.d\/init\.d/ && !/^%attr\(754 *,/) {
a5e4249b 1530 gsub("^%attr\\(... *,", "%attr(754,");
fc100b2c 1531 }
eeb15f12
ER
1532 }
1533
62466386 1534 if (/lib.+\.so\b/ && !/\.so$/ && !/^%attr.*/ && !/%exclude/) {
d749eebf
ER
1535 $0 = "%attr(755,root,root) " $0
1536 }
1537
46e31fbb
ER
1538 if (/%{perl_vendorarch}.*\.so$/ && !/^%attr.*/) {
1539 $0 = "%attr(755,root,root) " $0
1540 }
1541
1a296ebe
ER
1542 # remove attrs from man pages
1543 if (/%{_mandir}/ && /^%attr/) {
1544 sub("^%attr\\(.*\\) *", "");
1545 }
1546
f12fb504
ER
1547 # /etc/sysconfig files
1548 # %attr(640,root,root) %config(noreplace) %verify(not size mtime md5) /etc/sysconfig/*
feb42f71 1549 # attr not required, allow default 644 attr
646a62fc 1550 if (!/network-scripts/ && !/%dir/ && !/\.d$/ && !/functions/ && !/\/etc\/sysconfig\/wmstyle/) {
9f60b463 1551 if (/\/etc\/sysconfig\// && /%config/ && !/%config\(noreplace/) {
aedb74de
ER
1552 gsub("%config", "%config(noreplace)")
1553 }
f12fb504 1554
9f60b463 1555 if (/\/etc\/sysconfig\// && !/%config\(noreplace/) {
aedb74de
ER
1556 $NF = "%config(noreplace) " $NF
1557 }
f12fb504 1558
aedb74de 1559 if (/\/etc\/sysconfig\// && /%attr\(755/) {
a5e4249b 1560 gsub("^%attr\\(... *,", "%attr(640,");
aedb74de 1561 }
f12fb504 1562
aedb74de
ER
1563 if (/\/etc\/sysconfig\// && !/%verify/) {
1564 gsub("/etc/sysconfig", "%verify(not size mtime md5) /etc/sysconfig");
1565 }
feb42f71
ER
1566 }
1567
f12fb504 1568 # kill leading zeros
6ac67f5b
ER
1569 if (/%attr\(0[1-9]/) {
1570 gsub("%attr\\(0", "%attr(")
1571 }
7dd00833 1572
5844653b 1573 # kill leading whitespace
bcf3f2ca 1574 gsub(/^ +/, "");
5844653b 1575
42cd9911
ER
1576 # kill default attrs
1577 gsub(/%dir %attr\(755,root,root\)/, "%dir");
1578 gsub(/%attr\(755,root,root\) %dir/, "%dir");
1579 if (!/%dir/) {
1580 gsub(/%attr\(644,root,root\) /, "");
1581 }
68618e24 1582
c490069b 1583 # sort %verify attrs
91e497a5 1584 if (match($0, /%verify\(not([^)]+)\)/)) {
c490069b 1585 t = substr($0, RSTART, RLENGTH)
f51e180c
ER
1586 # kill commas: %verify(not,md5,size,mtime)
1587 gsub(/,/, " ", t);
1588
c490069b
ER
1589 gsub(/^%verify\(not |\)$/, "", t)
1590 n = split(t, a, / /)
1591 isort(a, n)
1592
1593 s = "%verify(not"
1594 for (i = 1 ; i <= n; i++) {
1595 s = s " " a[i]
1596 }
1597 s = s ")"
1598
91e497a5 1599 gsub(/%verify\(not[^)]+\)/, s)
c490069b 1600 }
35a7a211
ER
1601
1602 if (/%{_mandir}/) {
1dfac985 1603 gsub("\.gz$", "*")
f142c82f 1604 gsub("%ext_man$", "*")
35a7a211 1605 }
023aea7a 1606
5b33a6a1 1607 # locale dir and no %lang -> bad
d8a3c08f 1608 if (/%{_datadir}\/locale\/.*\// && !/%(dir|lang)/) {
5b33a6a1
ER
1609 $(NF + 1) = "# FIXME consider using %find_lang"
1610 }
1611
a3296e40 1612 # python egg-infos
fb78b6a9 1613 if (match($0, "^%{py_site(script)?dir}/.+-py"py_ver".egg-info$")) {
11dd9628
ER
1614 # tests:
1615 #%{py_sitedir}/*-py2.4.egg-info
1616 #%{py_sitescriptdir}/GnuPGInterface-%{version}-py2.4.egg-info
1617 #%{py_sitescriptdir}/python_mpd-%{version}-py2.4.egg-info
1618 #%{py_sitescriptdir}/mechanize-0.1.6b-py2.4.egg-info
1619
fb78b6a9 1620 l = index($0, "/");
11dd9628 1621 t = substr($0, 0, l);
a3296e40 1622 s = substr($0, l + 1, RLENGTH - l - length("-py"py_ver".egg-info"));
fb78b6a9 1623 if (match(s, "[^-]+$")) {
11dd9628
ER
1624 if (RSTART > 1) {
1625 s = substr(s, 0, RSTART - 1);
f50f83ff 1626 }
a3296e40 1627 print "%if \"%{py_ver}\" > \"2.4\""
fb78b6a9 1628 gsub(t "/.+.egg-info", t "/" s "-*.egg-info");
a3296e40
ER
1629 print
1630 print "%endif"
11dd9628 1631 return 0;
a3296e40
ER
1632 }
1633 }
1634
023aea7a
ER
1635 # atrpms
1636 $0 = fixedsub("%{perl_man1dir}", "%{_mandir}/man1", $0);
1637 $0 = fixedsub("%{perl_man3dir}", "%{_mandir}/man3", $0);
1638 $0 = fixedsub("%{perl_bin}", "%{_bindir}", $0);
c0ae0d40
ER
1639
1640 gsub(libdir "/pkgconfig", "%{_pkgconfigdir}");
1641 gsub("%{_libdir}/pkgconfig", "%{_pkgconfigdir}");
1642 gsub("%{_prefix}/lib/pkgconfig", "%{_pkgconfigdir}");
a83ba4f8
ER
1643
1644 gsub("%{_datadir}/applications", "%{_desktopdir}");
195fd300 1645 gsub("%{_datadir}/icons", "%{_iconsdir}");
6190dc2e 1646 gsub("%{_datadir}/pixmaps", "%{_pixmapsdir}");
6d542d59
ER
1647 gsub("%{_datadir}/pear", "%{php_pear_dir}");
1648 gsub("%{_datadir}/php", "%{php_data_dir}");
11dd9628
ER
1649
1650 return 1
0bbcf6b4 1651}
73e1a9a3 1652
afca35ce
ER
1653function use_script_macros()
1654{
1655 if (gsub("/sbin/service", "%service")) {
1656 sub(" >/dev/null 2>&1 \|\|:", "");
1657 sub(" 2> /dev/null \|\| :", "");
1658 }
1659}
1660
73e1a9a3 1661function fill(ch, n, i) {
1662 for (i = 0; i < n; i++)
1663 printf("%c", ch)
1664}
1665
1666function format_flush(line, indent, newline, word, first_word) {
1667 first_word = 1
d2bcf054 1668 if (format_indent == -1)
73e1a9a3 1669 newline = ""
1670 else
1671 newline = fill(" ", format_indent) "- "
1672
1673 while (match(line, /[^\t ]+/)) {
1674 word = substr(line, RSTART, RLENGTH)
1675 if (length(newline) + length(word) + 1 > tw) {
1676 print newline
d2bcf054 1677
73e1a9a3 1678 if (format_indent == -1)
1679 newline = ""
1680 else
1681 newline = fill(" ", format_indent + 2)
1682 first_word = 1
1683 }
1684
1685 if (first_word) {
1686 newline = newline word
1687 first_word = 0
1688 } else
1689 newline = newline " " word
d2bcf054 1690
73e1a9a3 1691 line = substr(line, RSTART + RLENGTH)
1692 }
1693 if (newline ~ /[^\t ]/) {
1694 print newline
1695 }
1696}
1697
0972e97d 1698function cflags(var)
1699{
2f46ef70 1700 if ($0 == var "=\"$RPM_OPT_FLAGS\"") {
1701 removed[var] = 1
0972e97d 1702 return 0
2f46ef70 1703 }
d2bcf054 1704
337741dd 1705 if (!/!\?debug/)
fe9a6f09 1706 sub("\$RPM_OPT_FLAGS", "%{rpmcflags}")
0972e97d 1707 return 1
1708}
0311af17 1709
4401d130
ER
1710# return whole matched pattern
1711function matchstr(str, pat)
1712{
1713 match(str, "[^/]+$");
1714 return substr(str, RSTART, RLENGTH);
1715}
1716
0b8c0588
ER
1717function unify_url(url)
1718{
1719
1720 # sourceforge urls
ca5cfdea 1721 # Docs about sourceforge mirror system: http://sourceforge.net/apps/trac/sourceforge/wiki/Mirrors
1526cc0b
ER
1722
1723 # 1. unify domains
ca5cfdea
JB
1724 sub("^http://prdownloads\.sourceforge\.net/", "http://downloads.sourceforge.net/", url)
1725 sub("^http://download\.sf\.net/", "http://downloads.sourceforge.net/", url)
1726 sub("^http://download\.sourceforge\.net/", "http://downloads.sourceforge.net/", url)
1727 sub("^http://dl\.sourceforge\.net/", "http://downloads.sourceforge.net/", url)
1728 sub("^http://.*\.dl\.sourceforge\.net/", "http://downloads.sourceforge.net/", url)
1729 sub("^http://dl\.sf\.net/", "http://downloads.sourceforge.net/", url)
1730 sub("^http://downloads\.sourceforge\.net/sourceforge/", "http://downloads.sourceforge.net/", url)
1526cc0b 1731
1526cc0b 1732 # 3. unify urls
284edbde
ER
1733 if (url ~ /sourceforge.net/) {
1734 sub("[?&]big_mirror=.*$", "", url);
1735 sub("[?&]modtime=.*$", "", url);
1736 sub("[?]use_mirror=.*$", "", url);
1737 sub("[?]download$", "", url);
1738 sub("/download$", "", url);
1739 }
0b8c0588 1740
4401d130
ER
1741 # SF: new style urls, strip "files/" between and prepend dl.
1742 if (match(url, "^http://sourceforge.net/projects/[^/]+/files/")) {
1743 url = substr(url, 1, RLENGTH - length("files/")) substr(url, RSTART + RLENGTH);
1744 sub("^http://sourceforge.net/projects/", "http://downloads.sourceforge.net/project/", url);
1745 }
1746
1747 # SF unify: http://downloads.sourceforge.net/PROJECT/TARBALL
1748 # http://downloads.sourceforge.net/project/PROJECT/FILE/VERSION/%{name}-%{version}.zip
1749 if (match(url, "^http://downloads.sourceforge.net/project/[^/]+")) {
1750 url = sprintf("http://downloads.sourceforge.net/%s/%s", substr(url, 42, RLENGTH - 41), matchstr(url, "[^/]+$"));
1751 }
1752
0b8c0588
ER
1753 sub("^ftp://ftp\.gnome\.org/", "http://ftp.gnome.org/", url)
1754 sub("^http://ftp\.gnome\.org/pub/gnome/", "http://ftp.gnome.org/pub/GNOME/", url)
1755
1756 # apache urls
1757 sub("^http://apache.zone-h.org/", "http://www.apache.org/dist/", url)
1758
8d69f95f 1759 # gnu.org
ce803f28
ER
1760 sub("^ftp://ftp\.gnu\.org/", "http://ftp.gnu.org/", url)
1761 sub("^http://ftp\.gnu\.org/pub/gnu/", "http://ftp.gnu.org/gnu/", url)
1762
1763 # debian.org
1764 sub("^ftp://ftp\.[^.]+\.debian\.org/", "ftp://ftp.debian.org/", url)
1765 sub("^http://ftp\.[^.]+\.debian\.org/", "ftp://ftp.debian.org/", url)
1766 sub("^ftp://ftp\.debian\.org/pub/debian/", "ftp://ftp.debian.org/debian/", url)
8d69f95f 1767
0b8c0588
ER
1768 return url
1769}
1770
a5ab7844
ER
1771function demacroize(str)
1772{
73eaf7b6
ER
1773 if (mod_name) {
1774 sub("%{mod_name}", mod_name, str);
1775 }
bff32a15
ER
1776 if (pearname) {
1777 sub("%{_pearname}", pearname, str);
1778 }
1779 if (pearname) {
1780 sub("%{pearname}", pearname, str);
1781 }
73eaf7b6
ER
1782 if (name) {
1783 sub("%{name}", name, str);
1784 }
a5ab7844
ER
1785 if (version) {
1786 sub("%{version}", version, str);
1787 }
1788 if (_beta) {
1789 sub("%{_beta}", _beta, str);
1790 }
1791 if (_rc) {
1792 sub("%{_rc}", _rc, str);
1793 }
f8281d0c
ER
1794 if (_pre) {
1795 sub("%{_pre}", _pre, str);
1796 }
a5ab7844
ER
1797 if (_snap) {
1798 sub("%{_snap}", _snap, str);
1799 }
88c76b14
ER
1800 if (subver) {
1801 sub("%{subver}", subver, str);
1802 }
a5ab7844
ER
1803 return str;
1804}
1805
0311af17
ER
1806function kill_preamble_macros()
1807{
a90171f0
ER
1808 if ($1 ~ /^Obsoletes:/) {
1809 # NB! assigning $2 a value breaks tabbing
1810 $2 = demacroize($2);
1811 }
1812 if ($1 ~ /^URL:/) {
73eaf7b6 1813 # NB! assigning $2 a value breaks tabbing
a5ab7844 1814 $2 = demacroize($2);
d57766c4 1815 $2 = unify_url($2)
0311af17 1816 }
b7b03087
ER
1817
1818 # fedora extras
1819 if (/%{\?FE_USERADD_REQ}/) {
1820 $0 = "";
1821 print "BuildRequires: rpmbuild(macros) >= 1.202"
1822 print "Provides: user(xxx)"
1823 print "Requires(postun): /usr/sbin/userdel"
1824 print "Requires(pre): /bin/id"
1825 print "Requires(pre): /usr/sbin/useradd"
1826 }
0311af17 1827}
9911efc1 1828
18cdb713
ER
1829function get_epoch(pkg, ver, epoch)
1830{
2a50ce70
ER
1831 return
1832# should parse the BR lines more adequately:
1833# freetype = 2.0.0 -> correct
1834# freetype = 2.1.9 -> with epoch 1, as epoch 1 was added in 2.1.7
1835
18cdb713
ER
1836 shell = "grep -o '^" pkg ":[^:]\+' ../PLD-doc/BuildRequires.txt | awk '{print $NF}'";
1837 shell | getline epoch;
1838 return epoch;
1839}
1840
9911efc1 1841function format_requires(tag, value, n, p, i, deps, ndeps) {
83c487a0
ER
1842 # skip any formatting for commented out items or some weird macros
1843 if (/^#/ || /%\(/) {
f3b115ea
ER
1844 return tag "\t" value
1845 }
9911efc1
ER
1846 n = split(value, p, / *,? */);
1847 for (i = 1; i <= n; i++) {
1848 if (p[i+1] ~ /[<=>]/) {
18cdb713
ER
1849 # add epoch if the version doesn't have it but BuildRequires.txt has
1850 if (p[i] ~ /^[a-z]/ && p[i+2] !~ /^[0-9]+:/) {
1851 epoch = get_epoch(p[i], p[i+2])
1852 if (epoch) {
1853 p[i+2] = epoch ":" p[i+2];
1854 }
1855 }
9911efc1
ER
1856 deps[ndeps++] = p[i] " " p[i+1] " " p[i+2];
1857 i += 2;
1858 } else {
1859 deps[ndeps++] = p[i];
1860 }
1861 }
1862 s = ""
1863 for (i in deps) {
1864 s = s sprintf("%s\t%s\n", tag, deps[i]);
1865 }
1866 return substr(s, 1, length(s)-1);
1867}
035bfa01
ER
1868
1869function use_tabs()
1870{
1871 # reverse vim: ts=4 sw=4 et
1872 gsub(/ /, "\t");
1873}
a3c6bbce
ER
1874
1875function add_br(br)
1876{
42cd9911 1877 BR[BR_count++] = br
a3c6bbce
ER
1878}
1879
d0c7fe0c
ER
1880# Load rpm macros
1881# you should update the list also in adapter when making changes here
4b5840f3 1882function import_rpm_macros( v) {
d0c7fe0c
ER
1883 # File with rpm groups
1884 topdir = ENVIRON["_topdir"]
1885
1886 if (!topdir) {
1887 print "adapter.awk should not not be invoked directly, but via adapter script" > "/dev/stderr"
1888 do_not_touch_anything = 1
0314a444
ER
1889 exit(rc = 1);
1890 }
1891
70661105 1892 # update this version dep each time some new macro export is added
4b5840f3
ER
1893 v = 1.49
1894 if (!ENVIRON["ADAPTER_REVISION"] || ENVIRON["ADAPTER_REVISION"] < v) {
1895 printf("adapter shell script is outdated: Need %s, got %s. Please update it.\n", v, ENVIRON["ADAPTER_REVISION"]) > "/dev/stderr"
0314a444
ER
1896 do_not_touch_anything = 1
1897 exit(rc = 1);
d0c7fe0c
ER
1898 }
1899
1900 # get cvsaddress for changelog section
1901 # using rpm macros as too lazy to add ~/.adapterrc parsing support.
1902 _cvsmaildomain = ENVIRON["_cvsmaildomain"]
1903 _cvsmailfeedback = ENVIRON["_cvsmailfeedback"]
1904
1905 prefix = ENVIRON["_prefix"]
1906 bindir = ENVIRON["_bindir"]
1907 sbindir = ENVIRON["_sbindir"]
1908 libdir = ENVIRON["_libdir"]
1909 sysconfdir = ENVIRON["_sysconfdir"]
1910 datadir = ENVIRON["_datadir"]
1911 includedir = ENVIRON["_includedir"]
1912 mandir = ENVIRON["_mandir"]
1913 infodir = ENVIRON["_infodir"]
1914 examplesdir = ENVIRON["_examplesdir"]
1915 docdir = ENVIRON["_defaultdocdir"]
1916 kdedocdir = ENVIRON["_kdedocdir"]
1917 gtkdocdir = ENVIRON["_gtkdocdir"]
1918 desktopdir = ENVIRON["_desktopdir"]
1919 pixmapsdir = ENVIRON["_pixmapsdir"]
1920 javadir = ENVIRON["_javadir"]
0314a444 1921 pkgconfigdir = ENVIRON["_pkgconfigdir"]
62466386 1922 npkgconfigdir = ENVIRON["_npkgconfigdir"]
639225be 1923 localedir = ENVIRON["_localedir"]
d0c7fe0c
ER
1924
1925 perl_sitearch = ENVIRON["perl_sitearch"]
1926 perl_archlib = ENVIRON["perl_archlib"]
1927 perl_privlib = ENVIRON["perl_privlib"]
1928 perl_vendorlib = ENVIRON["perl_vendorlib"]
1929 perl_vendorarch = ENVIRON["perl_vendorarch"]
1930 perl_sitelib = ENVIRON["perl_sitelib"]
1931
1932 py_sitescriptdir = ENVIRON["py_sitescriptdir"]
1933 py_sitedir = ENVIRON["py_sitedir"]
1934 py_scriptdir = ENVIRON["py_scriptdir"]
1935 py_ver = ENVIRON["py_ver"]
1936
70661105
ER
1937 py3_sitescriptdir = ENVIRON["py3_sitescriptdir"]
1938 py3_sitedir = ENVIRON["py3_sitedir"]
1939 py3_scriptdir = ENVIRON["py3_scriptdir"]
1940 py3_ver = ENVIRON["py3_ver"]
1941
d0c7fe0c
ER
1942 ruby_archdir = ENVIRON["ruby_archdir"]
1943 ruby_ridir = ENVIRON["ruby_ridir"]
1944 ruby_rubylibdir = ENVIRON["ruby_rubylibdir"]
1945 ruby_sitearchdir = ENVIRON["ruby_sitearchdir"]
1946 ruby_sitelibdir = ENVIRON["ruby_sitelibdir"]
1947 ruby_rdocdir = ENVIRON["ruby_rdocdir"]
1948
1949 php_pear_dir = ENVIRON["php_pear_dir"]
1950 php_data_dir = ENVIRON["php_data_dir"]
1951 tmpdir = ENVIRON["tmpdir"]
99956d12
JR
1952
1953 systemdunitdir = ENVIRON["systemdunitdir"]
1954 systemdtmpfilesdir = ENVIRON["systemdtmpfilesdir"]
d0c7fe0c
ER
1955}
1956
d0c7fe0c
ER
1957# php virtual deps as discussed in devel-en
1958function replace_php_virtual_deps() {
1959 pkg = $2
1960# if (pkg == "php-program") {
1961# $0 = $1 "\t/usr/bin/php"
1962# return
1963# }
1964
1965# if (pkg ~ /^php-[a-z]/ && pkg !~ /^php-(pear|common|cli|devel|fcgi|cgi|dirs|program|pecl-)/) {
1966# sub(/^php-/, "php(", pkg);
1967# sub(/$/, ") # verify this correctness -- it may be wanted to use specific not virtual dep", pkg);
1968# $2 = pkg
1969# }
1970
1971 if (pkg ~/^php$/) {
1972 $2 = "webserver(php)";
1973 if ($4 ~ /^[0-9]:/) {
1974 $4 = substr($4, 3);
1975 }
1976 }
1977
1978 if (pkg ~/^php4$/) {
1979 $2 = "webserver(php)";
1980 if ($4 ~ /^[0-9]:/) {
1981 $4 = substr($4, 3);
1982 }
1983 }
1984}
1985
9f2dada8
ER
1986function replace_groupnames(group) {
1987 group = replace(group, "Amusements/Games", "Applications/Games");
1988 group = replace(group, "Amusements/Games/Strategy/Real Time", "X11/Applications/Games/Strategy");
1989 group = replace(group, "Application/Multimedia", "Applications/Multimedia");
1990 group = replace(group, "Application/System", "Applications/System");
1991 group = replace(group, "Applications/Compilers", "Development/Languages");
1992 group = replace(group, "Applications/Daemons", "Daemons");
1993 group = replace(group, "Applications/Internet", "Applications/Networking");
1994 group = replace(group, "Applications/Internet/Peer to Peer", "Applications/Networking");
1995 group = replace(group, "Applications/Productivity", "X11/Applications");
1996 group = replace(group, "Applications/Security", "Applications/System");
1997 group = replace(group, "Applications/Web", "Applications/WWW");
1998 group = replace(group, "Database", "Applications/Databases");
1999 group = replace(group, "Development/C", "Development/Libraries");
2000 group = replace(group, "Development/Code Generators", "Development");
2001 group = replace(group, "Development/Docs", "Documentation");
2002 group = replace(group, "Development/Documentation", "Documentation");
2003 group = replace(group, "Development/Java", "Development/Languages/Java");
2004 group = replace(group, "Development/Languages/C and C++", "Libraries");
2005 group = replace(group, "Development/Languages/Other", "Development/Languages");;
2006 group = replace(group, "Development/Languages/Ruby", "Development/Languages");
2007 group = replace(group, "Development/Libraries/C and C++", "Development/Libraries");
2008 group = replace(group, "Development/Libraries/Java", "Development/Languages/Java");
2009 group = replace(group, "Development/Libraries/Python", "Development/Languages/Python");
2010 group = replace(group, "Development/Libraries/TCL", "Development/Languages/Tcl");;
2011 group = replace(group, "Development/Other", "Development");
2012 group = replace(group, "Development/Python", "Development/Languages/Python");
2013 group = replace(group, "Development/Testing", "Development");
2014 group = replace(group, "Editors", "Applications/Text");
2015 group = replace(group, "Emulators", "Applications/Emulators");
2016 group = replace(group, "File tools", "Applications/File");
2017 group = replace(group, "Games", "Applications/Games");
2018 group = replace(group, "Library/Development", "Development/Libraries");
2019 group = replace(group, "Networking/Deamons", "Networking/Daemons");
2020 group = replace(group, "Networking/Mail", "Applications/Mail");
2021 group = replace(group, "Networking/Other", "Networking");
2022 group = replace(group, "Productivity/Databases/Servers", "Applications/Databases");
2023 group = replace(group, "Productivity/Multimedia/Other", "X11/Applications/Multimedia");
2024 group = replace(group, "Productivity/Networking/Web/Servers", "Networking/Daemons/HTTP");;
2025 group = replace(group, "Shells", "Applications/Shells");
2026 group = replace(group, "System Environment/Base", "Base");
2027 group = replace(group, "System Environment/Daemons", "Daemons");
2028 group = replace(group, "System Environment/Kernel", "Base/Kernel");
2029 group = replace(group, "System Environment/Libraries", "Libraries");
2030 group = replace(group, "System Tools", "Applications/System");
2031 group = replace(group, "System", "Base");
2032 group = replace(group, "System/Base", "Base");
2033 group = replace(group, "System/Kernel and hardware", "Base/Kernel");
2034 group = replace(group, "System/Libraries", "Libraries");
2035 group = replace(group, "System/Servers", "Daemons");
2036 group = replace(group, "Text Processing/Markup/HTML", "Applications/Text");
2037 group = replace(group, "Text Processing/Markup/XML", "Applications/Text");
2038 group = replace(group, "Text tools", "Applications/Text");
2039 group = replace(group, "User Interface/Desktops", "X11/Applications");
bd49d9cd 2040 group = replace(group, "User Interface/X", "X11/Applications");
9f2dada8
ER
2041 group = replace(group, "Utilities/System", "Applications/System");
2042 group = replace(group, "Web/Database", "Applications/WWW");
2043 group = replace(group, "X11/GNOME", "X11/Applications");
2044 group = replace(group, "X11/GNOME/Applications", "X11/Applications");
2045 group = replace(group, "X11/GNOME/Development/Libraries", "X11/Development/Libraries");
2046 group = replace(group, "X11/Games", "X11/Applications/Games");
2047 group = replace(group, "X11/Games/Strategy", "X11/Applications/Games/Strategy");
2048 group = replace(group, "X11/Library", "X11/Libraries");
2049 group = replace(group, "X11/Utilities", "X11/Applications");
2050 group = replace(group, "X11/XFree86", "X11");
2051 group = replace(group, "X11/Xserver", "X11/Servers");
2052
2053 return group;
2054}
2055
5005c892 2056function replace_requires() {
485540f7 2057
a6b4adc9 2058 sub(/^python-setuptools-devel$/, "python-distribute", $2);
7850eda3 2059 sub(/^gcc-g77/, "gcc-fortran", $2);
791e241c
ER
2060
2061 # use virtual, not package name
2062 sub(/^rpm-build-macros$/, "rpmbuild(macros)", $2);
2063
94f4b277
ER
2064 # bad package.xml, see http://pear.php.net/bugs/bug.php?id=17779
2065 sub(/^php-php-gtk/, "php-gtk2", $2);
2066
5a157eb9 2067 # jpackages / fedora java packages
cda1ace5 2068 sub(/^antlr3$/, "java-antlr3", $2);
d742efc5 2069 sub(/^aqute-bnd$/, "java-bnd", $2);
84549bd3 2070 sub(/^avalon-framework$/, "java-avalon-framework", $2);
2071 sub(/^avalon-logkit$/, "java-avalon-logkit", $2);
e441e70d 2072 sub(/^axis$/, "java-axis", $2);
5a157eb9
ER
2073 sub(/^bouncycastle$/, "java-bcprov", $2);
2074 sub(/^bouncycastle-mail$/, "java-bcmail", $2);
d742efc5 2075 sub(/^bouncycastle-pg$/, "java-bcpg", $2);
5a157eb9 2076 sub(/^bouncycastle-tsp$/, "java-bctsp", $2);
cda1ace5 2077 sub(/^bsf$/, "java-bsf", $2);
5a157eb9
ER
2078 sub(/^dom4j$/, "java-dom4j", $2);
2079 sub(/^flute$/, "java-flute", $2);
1e44ff46
ER
2080 sub(/^gnu-regexp$/, "java-gnu-regexp", $2);
2081 sub(/^gnu.regexp$/, "java-gnu-regexp", $2);
cbd68959 2082 sub(/^hamcrest$/, "java-hamcrest", $2);
5a157eb9 2083 sub(/^itext$/, "java-itext", $2);
e210d877 2084 sub(/^jaas$/, "java(jaas)", $2);
2085 sub(/^jaf$/, "java(jaf)", $2);
e441e70d 2086 sub(/^jakarta-ant$/, "ant", $2);
5a157eb9 2087 sub(/^jakarta-commons-codec$/, "java-commons-codec", $2);
e441e70d 2088 sub(/^jakarta-commons-httpclient$/, "java-commons-httpclient", $2);
5a157eb9 2089 sub(/^jakarta-commons-logging$/, "java-commons-logging", $2);
e441e70d 2090 sub(/^jakarta-log4j$/, "java-log4j", $2);
2091 sub(/^jakarta-oro$/, "java-oro", $2);
84549bd3 2092 sub(/^jakarta-servletapi$/, "java(servlet)", $2);
8962c9c4
ER
2093 sub(/^java-devel$/, "jdk", $2);
2094 sub(/^java\(JSP\)$/, "java(jsp)", $2);
2095 sub(/^java\(JavaServerFaces\)$/, "java(javaserverfaces)", $2);
2096 sub(/^java\(Portlet\)$/, "java(portlet)", $2);
2097 sub(/^java\(Servlet\)$/, "java(servlet)", $2);
e441e70d 2098 sub(/^javamail$/, "java(javamail)", $2);
e210d877 2099 sub(/^jaxp$/, "java(jaxp)", $2);
2100 sub(/^jaxp_parser_impl$/, "java(jaxp_parser_impl)", $2);
981c8edf 2101 sub(/^jaxp_transform_impl$/, "java(jaxp_transform_impl)", $2);
e210d877 2102 sub(/^jce$/, "java(jce)", $2);
722d2feb 2103 sub(/^jcommon$/, "java-jcommon", $2);
e210d877 2104 sub(/^jdbc-stdext$/, "java(jdbc-stdext)", $2);
cda1ace5 2105 sub(/^jdepend$/, "java-jdepend", $2);
722d2feb 2106 sub(/^jfreechart$/, "java-jfreechart", $2);
e210d877 2107 sub(/^jmx$/, "java(jmx)", $2);
2108 sub(/^jndi$/, "java(jndi)", $2);
cda1ace5 2109 sub(/^jsch$/, "java-jsch", $2);
e210d877 2110 sub(/^jsse$/, "java(jsse)", $2);
981c8edf 2111 sub(/^jta$/, "java(jta)", $2);
cda1ace5 2112 sub(/^junit$/, "java-junit", $2);
5a157eb9 2113 sub(/^junit4$/, "java-junit", $2);
e441e70d 2114 sub(/^ldapjdk$/, "ldapsdk", $2);
5a157eb9
ER
2115 sub(/^libbase$/, "java-libbase", $2);
2116 sub(/^libfonts$/, "java-libfonts", $2);
2117 sub(/^libformula$/, "java-libformula", $2);
2118 sub(/^liblayout$/, "java-liblayout", $2);
2119 sub(/^libloader$/, "java-libloader", $2);
2120 sub(/^librepository$/, "java-librepository", $2);
2121 sub(/^libserializer$/, "java-libserializer", $2);
e441e70d 2122 sub(/^log4j$/, "java-log4j", $2);
2123 sub(/^logging-log4j$/, "java-log4j", $2);
2124 sub(/^oro$/, "java-oro", $2);
5a157eb9
ER
2125 sub(/^pdf-renderer$/, "java-pdf-renderer", $2);
2126 sub(/^pentaho-libxml$/, "java-libxml", $2);
e441e70d 2127 sub(/^rhino$/, "java-rhino", $2);
5a157eb9 2128 sub(/^sac$/, "java-sac", $2);
e441e70d 2129 sub(/^saxon-scripts$/, "saxon", $2);
981c8edf 2130 sub(/^servlet$/, "java(servlet)", $2);
e441e70d 2131 sub(/^uddi4j$/, "java-uddi4j", $2);
5a157eb9 2132 sub(/^ws-jaxme$/, "java-jaxme", $2);
e441e70d 2133 sub(/^wsdl4j$/, "java-wsdl4j", $2);
e441e70d 2134 sub(/^xalan-j$/, "java-xalan", $2);
8962c9c4 2135 sub(/^xalan-j2$/, "java-xalan", $2);
5d866dc6
ER
2136 sub(/^xerces-j$/, "java-xerces", $2);
2137 sub(/^xerces-j2$/, "java-xerces", $2);
5a157eb9 2138 sub(/^xml-commons-apis$/, "java-xml-commons", $2);
e441e70d 2139 sub(/^xml-commons-resolver$/, "java-xml-commons-resolver", $2);
5a157eb9
ER
2140 sub(/^xmldb-api$/, "java-xmldb", $2);
2141 sub(/^xmldb-api-sdk$/, "java-xmldb-sdk", $2);
485540f7 2142
8962c9c4 2143 # fedora / redhat
884d38da 2144 sub(/^Django$/, "python-django", $2);
41cf1970 2145 sub(/^GitPython$/, "python-git", $2);
1526cc0b
ER
2146 sub(/^PyQt4-devel$/, "python-PyQt4-devel", $2);
2147 sub(/^PyQwt-devel$/, "python-PyQwt-devel", $2);
01d2701e 2148 sub(/^ccid$/, "pcsc-driver-ccid", $2);
a73cc8a9 2149 sub(/^chkconfig$/, "/sbin/chkconfig", $2);
b2b85983 2150 sub(/^db4-devel$/, "db-devel", $2);
8962c9c4 2151 sub(/^dbus-python$/, "python-dbus", $2);
bd49d9cd 2152 sub(/^desktop-notification-daemon$/, "dbus(org.freedesktop.Notifications)", $2);
8962c9c4 2153 sub(/^file-devel$/, "libmagic-devel", $2);
283c3196 2154 sub(/^freetype2-devel$/, "freetype-devel", $2);
0393f419 2155 sub(/^fuse-devel$/, "libfuse-devel", $2);
8962c9c4
ER
2156 sub(/^gamin-python$/, "python-gamin", $2);
2157 sub(/^gcc-c\+\+$/, "libstdc++-devel", $2);
d742efc5 2158 sub(/^gnome-desktop3-devel$/, "gnome-desktop-devel", $2);
1a296ebe 2159 sub(/^gnome-python2-extras$/, "python-gnome-extras", $2);
75adc57d
ER
2160 sub(/^gnome-python2-gconf$/, "python-gnome-gconf", $2);
2161 sub(/^gnome-python2-gnomekeyring$/, "python-gnome-desktop-keyring", $2);
f6187a9d 2162 sub(/^gnome-python2-gtkspell$/, "python-gnome-extras-gtkspell", $2);
283c3196 2163 sub(/^gtk-sharp2-devel$/, "dotnet-gtk-sharp2-devel", $2);
1a296ebe 2164 sub(/^gtk2$/, "gtk+2", $2);
f731fd27 2165 sub(/^gtk2-devel$/, "gtk+2-devel", $2);
b7b03087 2166 sub(/^gtk3-devel$/, "gtk+3-devel", $2);
8962c9c4 2167 sub(/^initscripts$/, "rc-scripts", $2);
283c3196 2168 sub(/^iproute$/, "iproute2", $2);
8962c9c4 2169 sub(/^iscsi-initiator-utils$/, "open-iscsi", $2);
5a157eb9 2170 sub(/^keyutils-libs-devel$/, "keyutils-devel", $2);
d742efc5 2171 sub(/^libSM-devel$/, "xorg-lib-libSM-devel", $2);
5fb5a7f8
ER
2172 sub(/^libX11-devel$/, "xorg-lib-libX11-devel", $2);
2173 sub(/^libXScrnSaver-devel$/, "xorg-lib-libXScrnSaver-devel", $2);
5759a453 2174 sub(/^libXau-devel$/, "xorg-lib-libXau-devel", $2);
d742efc5
ER
2175 sub(/^libXcomposite-devel$/, "xorg-lib-libXcomposite-devel", $2);
2176 sub(/^libXcursor-devel$/, "xorg-lib-libXcursor-devel", $2);
2177 sub(/^libXdamage-devel$/, "xorg-lib-libXdamage-devel", $2);
5fb5a7f8 2178 sub(/^libXext-devel$/, "xorg-lib-libXext-devel", $2);
8962c9c4 2179 sub(/^libXft-devel$/, "xorg-lib-libXft-devel", $2);
5fb5a7f8 2180 sub(/^libXinerama-devel$/, "xorg-lib-libXinerama-devel", $2);
b2b85983 2181 sub(/^libXrandr-devel$/, "xorg-lib-libXrandr-devel", $2);
d742efc5 2182 sub(/^libXrender-devel$/, "xorg-lib-libXrender-devel", $2);
5fb5a7f8 2183 sub(/^libXxf86vm-devel$/, "xorg-lib-libXxf86vm-devel", $2);
b7b03087 2184 sub(/^libacl-devel$/, "acl-devel", $2);
283c3196 2185 sub(/^libcurl-devel$/, "curl-devel", $2);
75adc57d 2186 sub(/^libgudev1-devel$/, "udev-glib-devel", $2);
d742efc5 2187 sub(/^libmx-devel$/, "mx-devel", $2);
bd49d9cd 2188 sub(/^libselinux-python$/, "python-selinux", $2);
c6ddd554 2189 sub(/^libsrtp-devel$/, "srtp-devel", $2);
87c6ea72
ER
2190 sub(/^libtdb$/, "tdb", $2);
2191 sub(/^libtdb-devel$/, "tdb-devel", $2);
2192 sub(/^libtevent$/, "tevent", $2);
2193 sub(/^libtevent-devel$/, "tevent-devel", $2);
6a81dc9a 2194 sub(/^libusb1-devel$/, "libusb-devel", $2);
eb9c5afa 2195 sub(/^mod_wsgi$/, "apache-mod_wsgi", $2);
d742efc5 2196 sub(/^newt-python$/, "python-snack", $2);
8962c9c4 2197 sub(/^notify-python$/, "python-pynotify", $2);
01d2701e 2198 sub(/^pcsc-lite-ccid$/, "pcsc-driver-ccid", $2);
6547efbd 2199 sub(/^pulseaudio-libs-devel$/, "pulseaudio-devel", $2);
7b0e3e39 2200 sub(/^pyOpenSSL$/, "python-pyOpenSSL", $2);
bd49d9cd 2201 sub(/^pycairo$/, "python-pycairo", $2);
30f2ac22 2202 sub(/^pyflakes$/, "python-pyflakes", $2);
a3e413bc 2203 sub(/^pygobject2$/, "python-pygobject", $2);
d742efc5 2204 sub(/^pygobject3-devel$/, "python-pygobject3-common-devel", $2);
8962c9c4
ER
2205 sub(/^pygtk2$/, "python-pygtk", $2);
2206 sub(/^pygtk2-devel$/, "python-pygtk-devel", $2);
75adc57d 2207 sub(/^pygtk2-libglade$/, "python-pygtk-glade", $2);
30f2ac22 2208 sub(/^pysvn$/, "python-pysvn", $2);
87c6ea72
ER
2209 sub(/^pytalloc$/, "python-talloc", $2);
2210 sub(/^pytalloc-devel$/, "python-talloc-devel", $2);
bd49d9cd 2211 sub(/^python-cups$/, "python-pycups", $2);
eb9c5afa 2212 sub(/^python-enchant$/, "python-pyenchant", $2);
5005c892
ER
2213 sub(/^python-imaging$/, "python-PIL", $2);
2214 sub(/^python-imaging-tk$/, "python-PIL-tk", $2);
bd49d9cd 2215 sub(/^python-newt$/, "python-snack", $2);
f6187a9d 2216 sub(/^python-pygtk$/, "python-pygtk-gtk", $2);
30f2ac22
ER
2217 sub(/^python-recaptcha-client$/, "python-recaptcha", $2);
2218 sub(/^python-twisted-core$/, "python-TwistedCore", $2);
1526cc0b
ER
2219 sub(/^python-twisted-core$/, "python-TwistedCore", $2);
2220 sub(/^python-twisted-names$/, "python-TwistedNames", $2);
eb9c5afa 2221 sub(/^python2-devel$/, "python-devel", $2);
30f2ac22 2222 sub(/^pytz$/, "python-pytz", $2);
8962c9c4 2223 sub(/^qt4-devel$/, "qt4-build", $2);
1526cc0b 2224 sub(/^qt4-webkit-devel$/, "QtWebKit-devel", $2);
b2b85983 2225 sub(/^qtlockedfile-devel$/, "QtLockedFile-devel", $2);
c6ddd554 2226 sub(/^qtsingleapplication-devel$/, "QtSingleApplication-devel", $2);
c93842aa 2227 sub(/^rpm-python$/, "python-rpm", $2);
1526cc0b 2228 sub(/^sip-devel$/, "python-sip-devel", $2);
8962c9c4
ER
2229 sub(/^tftp-server$/, "tftpdaemon", $2);
2230 sub(/^tkinter$/, "python-tkinter", $2);
5a157eb9 2231 sub(/^urw-fonts$/, "fonts-Type1-urw", $2);
d742efc5 2232 sub(/^webkitgtk3-devel$/, "gtk-webkit3-devel", $2);
884d38da 2233 sub(/^xapian-bindings-python$/, "python-xapian", $2);
c6ddd554 2234 sub(/^xorg-x11-server-sdk$/, "xorg-xserver-server-devel", $2);
5a157eb9 2235
5919d837
ER
2236 # mandriva
2237 sub(/^python-gobject-devel$/, "python-pygobject-devel", $2);
2238 sub(/^python-pyrex$/, "python-Pyrex", $2);
2239 sub(/^webkitgtk-devel$/, "gtk-webkit-devel", $2);
2240 sub(/^python-curl$/, "python-pycurl", $2);
2241 sub(/^python-webkitgtk$/, "python-pywebkitgtk", $2);
2242 sub(/^pygtk2.0$/, "python-pygtk-gtk", $2);
2243 sub(/^gnome-python-gconf$/, "python-gnome-gconf", $2);
2244
2b4124b8 2245 # debian / ubuntu
8962c9c4
ER
2246 sub(/^blkid-dev$/, "libblkid-devel", $2);
2247 sub(/^ext2fs-dev$/, "e2fsprogs-devel", $2);
2248 sub(/^libao-dev$/, "libao-devel", $2);
eb4c7da2
ER
2249 sub(/^libboost-filesystem[0-9.]+-dev$/, "boost-devel", $2);
2250 sub(/^libboost-program-options[0-9.]+-dev$/, "boost-devel", $2);
2251 sub(/^libboost-regex[0-9.]+-dev$/, "boost-devel", $2);
2252 sub(/^libboost-thread[0-9.]+-dev$/, "boost-devel", $2);
eb4c7da2 2253 sub(/^libcurl4-openssl-dev$/, "curl-devel", $2);
75488183 2254 sub(/^libdnet-dev$/, "libdnet-devel", $2);
75488183 2255 sub(/^libesd0-dev$/, "esound-devel", $2);
75488183 2256 sub(/^libfishsound1-dev$/, "libfishsound-devel", $2);
8962c9c4
ER
2257 sub(/^libgconf2-dev$/, "GConf2-devel", $2);
2258 sub(/^libgl1-mesa-dev$/, "OpenGL-devel", $2);
2259 sub(/^libgl1-mesa-dri$/, "OpenGL", $2);
2260 sub(/^libglib2.0-dev$/, "glib2-devel", $2);
2261 sub(/^libglu1-mesa-dev$/, "OpenGL-GLU-devel", $2);
2262 sub(/^libgtk2.0-dev$/, "gtk+2-devel", $2);
2263 sub(/^libhunspell-dev$/, "hunspell-devel", $2);
2264 sub(/^libmcrypt-dev$/, "libmcrypt-devel", $2);
2265 sub(/^libmhash-dev$/, "mhash-devel", $2);
2266 sub(/^liboggz1-dev$/, "libggz-devel", $2);
2267 sub(/^libpango1.0-dev$/, "pango-devel", $2);
2268 sub(/^libqt4-dev$/, "qt4-build", $2);
2269 sub(/^libshout3-dev$/, "libshout-devel", $2);
75488183 2270 sub(/^libslp-dev$/, "openslp-devel", $2);
8962c9c4
ER
2271 sub(/^libsndfile1-dev$/, "libsndfile-devel", $2);
2272 sub(/^libspeex-dev$/, "speex-devel", $2);
2273 sub(/^libssl-dev$/, "openssl-devel", $2);
2274 sub(/^libvorbis-dev$/, "libvorbis-devel", $2);
2275 sub(/^libxslt1-dev$/, "libxslt-devel", $2);
2276 sub(/^libxss-dev$/, "xorg-lib-libXScrnSaver-devel", $2);
2277 sub(/^mesa-common-dev$/, "OpenGL-devel", $2);
5919d837
ER
2278 sub(/^libudev$/, "udev-libs", $2);
2279 sub(/^tcp_wrappers-devel$/, "libwrap-devel", $2);
2280 sub(/^vala-tools$/, "vala", $2);
2281 sub(/^vala-devel$/, "vala", $2);
f9aa4b77 2282
344db4b4 2283 # altlinux
68be04ba 2284 sub(/^libatk-devel$/, "atk-devel", $2);
9466625b 2285 sub(/^libgit-devel$/, "git-core-devel", $2);
68be04ba 2286 sub(/^libgtk\+2-devel$/, "gtk+2-devel", $2);
344db4b4
ER
2287 sub(/^libncurses-devel$/, "ncurses-devel", $2);
2288 sub(/^libncursesxx-devel$/, "ncurses-c++-devel", $2);
68be04ba 2289 sub(/^libpango-devel$/, "pango-devel", $2);
344db4b4 2290 sub(/^libpcre-devel$/, "pcre-devel", $2);
68be04ba 2291 sub(/^libpopt-devel$/, "popt-devel", $2);
9466625b 2292 sub(/^libssl-devel$/, "openssl-devel", $2);
344db4b4 2293
a6b4adc9 2294 # suse
a6b4adc9 2295 sub(/^alsa-devel$/, "alsa-lib-devel", $2);
a6b4adc9 2296 sub(/^gtk-sharp2$/, "dotnet-gtk-sharp2", $2);
c6ddd554 2297 sub(/^gtkmm2-devel$/, "gtkmm-devel", $2);
01d2701e
ER
2298 sub(/^libexpat-devel$/, "expat-devel", $2);
2299 sub(/^libffmpeg-devel$/, "ffmpeg-devel", $2);
c6ddd554 2300 sub(/^libopenssl-devel$/, "openssl-devel", $2);
01d2701e 2301 sub(/^libpulse-devel$/, "pulseaudio-devel", $2);
a6b4adc9 2302 sub(/^monodoc-core$/, "mono-monodoc", $2);
01d2701e 2303 sub(/^python-gtk$/, "python-pygtk-gtk", $2);
a6b4adc9 2304
485540f7
ER
2305 replace_php_virtual_deps()
2306}
2307
13dda4dc 2308# vim:ts=4:sw=4
This page took 0.638122 seconds and 4 git commands to generate.