]> git.pld-linux.org Git - packages/adapter.git/blame - adapter.awk
- remove cvs leftover: $id in at line 1
[packages/adapter.git] / adapter.awk
CommitLineData
37fceb07 1#!/usr/bin/gawk -f
bf0a58ea 2#
18f95017 3# Adapter adapts .spec files for PLD Linux.
236b87ac 4#
08226650 5# Copyright (C) 1999-2012 PLD-Team <feedback@pld-linux.org>
236b87ac 6# Authors:
b4e337d9 7# Michał Kuratczyk <kura@pld.org.pl>
dda3eaa5 8# Sebastian Zagrodzki <s.zagrodzki@mimuw.edu.pl>
b4e337d9 9# Tomasz Kłoczko <kloczek@rudy.mif.pg.gda.pl>
d8313167 10# Artur Frysiak <wiget@pld-linux.org>
f37c1259 11# Michal Kochanowicz <mkochano@pld.org.pl>
fccce8b5 12# Jakub Bogusz <qboosh@pld-linux.org>
b4e337d9 13# Elan Ruusamäe <glen@pld-linux.org>
115a3045
ER
14#
15# See cvs log adapter{,.awk} for list of contributors
16#
236b87ac 17# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
3a14bf9d 18
8ebb1c08 19# TODO
03180d14 20# - really long sourceX make preamble sorting totally fcked up (try snake.spec r1.1)
8ebb1c08
ER
21# - parse ../PLD-doc/BuildRequires.txt and setup proper BR epoches?
22# - add "-nc" option to skip CVS interaction
6c67f9b1
ER
23# - sort Summary(XX)
24# - sort Requires, BuildRequires
fd5553c9 25# - check if %description (lang=C) contains 8bit
6e985933 26# - desc wrapping is totally fucked up on global.spec,1.25, dosemu.spec,1.115-
da226e35
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
ba533641
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 ]
8ebb1c08 31
bf0a58ea 32BEGIN {
0ae11f54 33 RPM_SECTIONS = "package|build|changelog|clean|description|install|post|posttrans|postun|pre|prep|pretrans|preun|triggerin|triggerpostun|triggerun|verifyscript|check"
2b47df45 34 SECTIONS = "^%(" RPM_SECTIONS ")"
93e2a87a 35
8aa5d2f8
ER
36 rev = "1.514"
37 VERSION = "0.36/" rev
18f95017 38
8492c30a 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))"
c58d1357 40
50037ea2
PZ
41 usedigest = 0 # Enable to switch to rpm 4.4.6+ md5 digests
42
1c955424 43 preamble = 1 # Is it part of preamble? Default - yes
6e985933
ER
44 boc = 4 # Beginning of %changelog
45 bod = 0 # Beginning of %description
7a72f436 46 tw = 70 # Descriptions width
f171fd40 47
89c604c7 48 b_idx = 0 # index of BR/R arrays
b6875e34 49 BR_count = 0 # number of additional BuildRequires
89c604c7 50
85e708f2 51 # If variable removed, then 1 (for removing it from export)
52 removed["LDFLAGS"] = 0
53 removed["CFLAGS"] = 0
54 removed["CXXFLAGS"] = 0
5c18171e 55
246ad57e 56 # If 1, we are inside of comment block (started with /^#%/)
57 comment_block = 0
f171fd40 58
683ce9e3
ER
59 import_rpm_macros()
60
c5cb79f5 61 packages_dir = topdir
a877f3a5 62 groups_file = packages_dir "/rpm.groups"
683ce9e3 63
a877f3a5 64 system("cd "packages_dir"; [ -f rpm.groups ] || cvs up rpm.groups > /dev/null")
c2814373 65 system("[ -d ../PLD-doc ] && cd ../PLD-doc && ([ -f BuildRequires.txt ] || cvs up BuildRequires.txt >/dev/null)");
f1991554 66
5c18171e 67 # Temporary file for changelog section
bbc531d9 68 changelog_file = mktemp("adapter.changelogXXXXXX")
bf0a58ea 69}
70
43c05c3c 71# If the latest line matched /%files/
72defattr == 1 {
13b24a87
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 }
aec1bddb 80 defattr = 0
43c05c3c 81}
82
bbc531d9
ER
83# call mktemp(1) and return the value
84function mktemp(template, tmp) {
85 "mktemp " template | getline tmp
86 return tmp
87}
88
89c604c7
ER
89function b_makekey(a, b, s) {
90 s = a "" b;
91 # kill bcond
b6875e34 92 gsub(/[#%]+{[!?]+[_a-zA-Z0-9]+:/, "", s);
3b0074cc 93
8409a9b2 94 # kill commented out items
b6875e34 95 gsub(/^#[ \t]*/, "", s);
3b0074cc 96
c58d1357 97 # force order
8492c30a 98 gsub(/^Summary\(/, "11Summary(", s);
2ce787c9 99 gsub(/^Summary/, "10Summary", s);
8492c30a 100
985d9bc7
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);
43f8581a 111
43f8581a 112 gsub(/^Suggests/, "X1Suggests", s);
2eef43e9
JB
113 gsub(/^Provides/, "X2Provides", s);
114 gsub(/^Obsoletes/, "X3Obsoletes", s);
115 gsub(/^Conflicts/, "X4Conflicts", s);
116 gsub(/^BuildArch/, "X5BuildArch", s);
985d9bc7
ER
117 gsub(/^ExclusiveArch/, "X6ExclusiveArch", s);
118 gsub(/^ExcludeArch/, "X7ExcludeArch", s);
119 gsub(/^BuildRoot/, "X9BuildRoot", s);
d9e2bd9b 120
8492c30a
ER
121 gsub(/^AutoProv/, "Xx1AutoProv", s);
122 gsub(/^AutoReq/, "Xx2AutoReq", s);
123
d9e2bd9b 124# printf("%s -> %s\n", a""b, s);
89c604c7
ER
125 return s;
126}
127
eee34ffb 128# Comments
22622171 129/^#/ && (description == 0) {
eee34ffb 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()
a4de4386 135 exit(rc = 0)
eee34ffb 136 }
246ad57e 137
eee34ffb 138 # Generally, comments are printed without touching
70a1dc9e 139 sub(/[ \t]+$/, "")
4414eb86 140
50037ea2
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 }
4414eb86
ER
146 print $0
147 next
148 }
246ad57e 149}
150
1da27823 151/^%define/ {
93e2a87a 152 # Remove defining _applnkdir (this macro has been included in rpm-3.0.4)
71a4728c 153 if ($2 == "_applnkdir") {
ba4b52a7 154 next
71a4728c
ER
155 }
156 if ($2 == "date") {
ba4b52a7 157 date = 1
4ab1678b
ER
158 if (did_files == 0) {
159 print "%files"
160 print ""
161 did_files = 1
162 }
71a4728c
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
a27fac4d
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 }
93e2a87a
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 }
a27fac4d
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 }
71a4728c
ER
203 if ($2 ~ /_includedir/)
204 includedir = $3
205 if ($2 ~ /_mandir/)
206 mandir = $3
207 if ($2 ~ /_infodir/)
208 infodir = $3
c2b069de
ER
209 if ($2 ~ /_docdir/)
210 docdir = $3
71a4728c
ER
211
212 # version related macros
213 if ($2 ~ /^_beta$/)
214 _beta = $3
215 if ($2 ~ /^_rc$/)
216 _rc = $3
59de1799
ER
217 if ($2 ~ /^_pre$/)
218 _pre = $3
71a4728c
ER
219 if ($2 ~ /^_snap$/)
220 _snap = $3
3c5e6e5f
ER
221 if ($2 ~ /^subver$/)
222 subver = $3
71a4728c
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
a39ddef5 231
0ea7c3cd
ER
232 if ($2 ~ /^mod_name$/)
233 mod_name = $3
f5f6280a
ER
234 if ($2 ~ /^_?pearname$/)
235 pearname = $3
d6e33af7
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 }
0ea7c3cd 250
78d96561 251 sub(/[ \t]+$/, "");
a39ddef5
ER
252 # do nothing further, otherwise adapter thinks we're at preamble
253 print
254 next
1da27823
SZ
255}
256
6c67f9b1
ER
257# Obsolete
258/^%include.*\/usr\/lib\/rpm\/macros\.python$/ {
259 next
260}
261
246ad57e 262################
263# %description #
264################
93e2a87a 265/^%description/, (!/^%description/ && $0 ~ SECTIONS) {
aec1bddb 266 preamble = 0
efe53381 267
3a14bf9d 268 if (/^%description/) {
aec1bddb 269 bod++
236b87ac 270 format_line = ""
271 format_indent = -1
3a14bf9d
SZ
272 }
273
236b87ac 274 # Format description
7b868d98 275 if (ENVIRON["SKIP_DESC"] != 1 && description == 1 && !/^%[a-z]+/ && !/^%description/) {
3a14bf9d 276 if (/^[ \t]*$/) {
236b87ac 277 format_flush(format_line, format_indent)
3a14bf9d 278 print ""
236b87ac 279 format_line = ""
280 format_indent = -1
3a14bf9d 281 } else if (/^[ \t]*[-\*][ \t]*/) {
236b87ac 282 format_flush(format_line, format_indent)
f171fd40 283 match($0, /^[ \t]*/)
236b87ac 284 format_indent = RLENGTH
285 match($0, /^[ \t]*[-\*][ \t]/)
286 format_line = substr($0, RLENGTH)
f171fd40 287 } else
236b87ac 288 format_line = format_line " " $0
aec1bddb 289 next
efe53381 290 }
f171fd40 291
1da27823 292 if (/^%[a-z]+/ && (!/^%description/ || bod == 2)) {
ddb18dd4 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 }
236b87ac 299 format_flush(format_line, format_indent)
efe53381 300 if (bod == 2) {
aec1bddb
SZ
301 bod = 1
302 description = 1
efe53381 303 } else {
aec1bddb
SZ
304 bod = 0
305 description = 0
efe53381 306 }
307 } else
aec1bddb 308 description = 1
bf0a58ea 309}
310
246ad57e 311#########
312# %prep #
313#########
93e2a87a 314/^%prep/, (!/^%prep/ && $0 ~ SECTIONS) {
aec1bddb 315 preamble = 0
4ab1678b 316 did_prep = 1
f171fd40 317
ac779c71
ER
318 use_macros()
319
43c05c3c 320 # Add '-q' to %setup
e780ff0a 321 if (/^%setup/ && !/-q/) {
1da27823 322 sub(/^%setup/, "%setup -q")
e780ff0a
ER
323 }
324
af38fe16 325 if (/^%setup/ && name != "setup") {
e9097b46
ER
326 $0 = fixedsub(name, "%{name}", $0);
327 $0 = fixedsub(version, "%{version}", $0);
4a8d9a70 328 if (_beta) {
e9097b46 329 $0 = fixedsub(_beta, "%{_beta}", $0);
4a8d9a70
ER
330 }
331 if (_rc) {
e9097b46 332 $0 = fixedsub(_rc, "%{_rc}", $0);
4a8d9a70 333 }
59de1799
ER
334 if (_pre) {
335 $0 = fixedsub(_pre, "%{_pre}", $0);
336 }
4a8d9a70 337 if (_snap) {
e9097b46 338 $0 = fixedsub(_snap, "%{_snap}", $0);
4a8d9a70 339 }
3c5e6e5f
ER
340 if (subver) {
341 $0 = fixedsub(subver, "%{subver}", $0);
342 }
4f822e22
ER
343 }
344
10690436 345 if (/^%setup/ && /-n %{name}-%{version}( |$)/) {
e9097b46 346 $0 = fixedsub(" -n %{name}-%{version}", "", $0)
e780ff0a 347 }
b6875e34 348 sub("^%patch ", "%patch0 ");
ac779c71 349
e31553a7
ER
350 # fedora extras
351 if (/^%apply/) {
352 sub("^%apply -n", "%patch");
353 }
354
ac779c71
ER
355 # invalid in %prep
356 sub("^rm -rf \$RPM_BUILD_ROOT.*", "");
bf0a58ea 357}
358
246ad57e 359##########
360# %build #
361##########
93e2a87a 362/^%build/, (!/^%build/ && $0 ~ SECTIONS) {
aec1bddb 363 preamble = 0
bf0a58ea 364
4ab1678b
ER
365 if (did_prep == 0) {
366 print "%prep"
367 print ""
368 did_prep = 1
369 }
370
aec1bddb 371 use_macros()
6ebff802 372 use_tabs()
f171fd40 373
9cb72c72 374 if (/^automake$/)
375 sub(/$/, " -a -c")
376
eb4bf70e 377 if (/LDFLAGS/) {
85e708f2 378 if (/LDFLAGS="-s"/) {
379 removed["LDFLAGS"] = 1
380 next
381 } else {
382 split($0, tmp, "LDFLAGS=")
eb4bf70e 383 count = split(tmp[2], flags, "\"")
85e708f2 384 if (flags[1] != "" && flags[1] !~ "!?debug") {
fde8f52a 385 sub(/-s[" ]?/, "%{rpmldflags} ", flags[1])
85e708f2 386 $0 = tmp[1] line[1] "LDFLAGS=" flags[1] "\""
387 for (i = 2; i < count; i++)
388 $0 = $0 flags[i] "\""
389 }
eb4bf70e 390 }
391 }
392
393 if (/CFLAGS=/)
394 if (cflags("CFLAGS") == 0)
395 next
396
397 if (/CXXFLAGS=/)
398 if (cflags("CXXFLAGS") == 0)
399 next
f171fd40 400
85e708f2 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 }
2d74be7e 412
db9b1bf2 413 # quote CC
2d74be7e
ER
414 if (/CC=%{__cc} /) {
415 sub("CC=%{__cc}", "CC=\"%{__cc}\"")
416 }
b34b8660 417
e6f1551d 418 # use PLD Linux macros
b34b8660
ER
419 $0 = fixedsub("glib-gettextize --copy --force","%{__glib_gettextize}", $0);
420 $0 = fixedsub("intltoolize --copy --force", "%{__intltoolize}", $0);
db9b1bf2 421 $0 = fixedsub("automake --add-missing --copy", "%{__automake}", $0);
56699a32 422 $0 = fixedsub("automake -a --foreign --copy", "%{__automake}", $0);
4e26c5f2 423 $0 = fixedsub("automake -a -c --foreign", "%{__automake}", $0);
ebeed758 424 $0 = fixedsub("automake -a -c", "%{__automake}", $0);
56699a32
ER
425 $0 = fixedsub("libtoolize --force --automake --copy", "%{__libtoolize}", $0);
426 $0 = fixedsub("libtoolize -c -f --automake", "%{__libtoolize}", $0);
db9b1bf2
ER
427
428 sub(/^aclocal$/, "%{__aclocal}");
429 sub(/^autoheader$/, "%{__autoheader}");
430 sub(/^autoconf$/, "%{__autoconf}");
431 sub(/^automake$/, "%{__automake}");
ebeed758 432 sub(/^libtoolize$/, "%{__libtoolize}");
f171fd40 433
5e15e952
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);
377e5b9e
ER
437
438 # alt linux
439 $0 = fixedsub("%make_build", "%{__make}", $0);
bf0a58ea 440}
441
246ad57e 442##########
443# %clean #
444##########
93e2a87a 445/^%clean/, (!/^%clean/ && $0 ~ SECTIONS) {
1c52b18e 446 did_clean = 1
e6f1551d 447
b6875e34 448 use_macros()
1c52b18e
SZ
449}
450
246ad57e 451############
452# %install #
453############
93e2a87a 454/^%install/, (!/^%install/ && $0 ~ SECTIONS) {
f171fd40 455
aec1bddb 456 preamble = 0
f171fd40 457
ec0082cc 458 # foreign rpms
624df313 459 sub("^%{__rm} -rf %{buildroot}", "rm -rf $RPM_BUILD_ROOT")
b6875e34
ER
460 sub("%buildroot", "$RPM_BUILD_ROOT");
461 sub("%{buildroot}", "$RPM_BUILD_ROOT");
ec0082cc 462
624df313 463 if (/^[ \t]*rm([ \t]+-[rf]+)*[ \t]+(\${?RPM_BUILD_ROOT}?|%{?buildroot}?)/ && did_rmroot==0) {
1c52b18e 464 did_rmroot=1
dda3eaa5
SZ
465 print "rm -rf $RPM_BUILD_ROOT"
466 next
467 }
43c05c3c 468
1c52b18e 469 if (!/^(#?[ \t]*)$/ && !/^%install/ && did_rmroot==0) {
dda3eaa5 470 print "rm -rf $RPM_BUILD_ROOT"
1c52b18e 471 did_rmroot=1
dda3eaa5 472 }
f171fd40 473
b6875e34
ER
474 if (tmpdir) {
475 buildroot = tmpdir "/" name "-" version "-root-" ENVIRON["USER"]
3d8be7c3 476 gsub(buildroot, "$RPM_BUILD_ROOT")
b6875e34 477 }
3d8be7c3 478
b6875e34
ER
479 if (!/%{_lib}/) {
480 sub("\$RPM_BUILD_ROOT/%", "$RPM_BUILD_ROOT%")
481 }
259883bf 482
dda3eaa5 483 use_macros()
f171fd40 484
bf0a58ea 485 # 'install -d' instead 'mkdir -p'
486 if (/mkdir -p/)
aec1bddb 487 sub(/mkdir -p/, "install -d")
fde90d94 488
48409aee 489 # cp -a already implies cp -r
b6875e34 490 sub(/^cp -ar/, "cp -a")
f171fd40 491
43c05c3c 492 # No '-u root' or '-g root' for 'install'
681a4871 493 if (/^install/ && /-[ug][ \t]*root/)
aec1bddb 494 gsub(/-[ug][ \t]*root /, "")
f171fd40 495
2016aa83
ER
496 if (/^install/ && /-m[ \t]*[0-9]+/)
497 gsub(/-m[ \t]*[0-9]+ /, "")
f171fd40 498
f1991554 499 # No lines contain 'chown' or 'chgrp' if owner/group is 'root'
43c05c3c 500 if (($1 ~ /chown/ && $2 ~ /root\.root/) || ($1 ~ /chgrp/ && $2 ~ /root/))
aec1bddb 501 next
f171fd40 502
43c05c3c 503 # No lines contain 'chmod' if it sets the modes to '644'
681a4871 504 if ($1 ~ /chmod/ && $2 ~ /644/)
aec1bddb 505 next
5e15e952 506
5e15e952
ER
507 # atrpms
508 $0 = fixedsub("%perl_makeinstall", "%{__make} pure_install \\\n\tDESTDIR=$RPM_BUILD_ROOT", $0);
377e5b9e
ER
509
510 # alt linux
511 $0 = fixedsub("%make_install DESTDIR=$RPM_BUILD_ROOT install", "%{__make} install \\\n\tDESTDIR=$RPM_BUILD_ROOT", $0);
bf0a58ea 512}
513
246ad57e 514##########
515# %files #
516##########
93e2a87a 517/^%files/, (!/^%files/ && $0 ~ SECTIONS) {
aec1bddb 518 preamble = 0
4ab1678b 519 did_files = 1
f171fd40 520
1da27823 521 if ($0 ~ /^%files/)
aec1bddb 522 defattr = 1
f171fd40 523
484bbf6d
ER
524 if (!use_files_macros()) {
525 next
526 }
bf0a58ea 527}
528
246ad57e 529##############
530# %changelog #
531##############
93e2a87a 532/^%changelog/, (!/^%changelog/ && $0 ~ SECTIONS) {
aec1bddb 533 preamble = 0
dda3eaa5 534 has_changelog = 1
97e21521 535 skip = 0
bf0a58ea 536 # There should be some CVS keywords on the first line of %changelog.
97e21521 537 if (boc == 3) {
4b7a9b6b 538 if ($0 !~ _cvsmailfeedback) {
f6f0c932 539 print "* %{date} " _cvsmailfeedback > changelog_file
4b7a9b6b 540 } else {
97e21521 541 skip = 1
4b7a9b6b 542 }
97e21521 543 boc = 2
d31b8a48 544 }
97e21521 545 if (boc == 2 && !skip) {
d31b8a48 546 if (!/All persons listed below/) {
fd5e70be 547 printf "All persons listed below can be reached at " > changelog_file
f6f0c932 548 print "<cvs_login>" _cvsmaildomain "\n" > changelog_file
4b7a9b6b 549 } else {
97e21521 550 skip = 1
4b7a9b6b 551 }
44379e57 552 boc = 1
bf0a58ea 553 }
97e21521
JB
554 if (boc == 1 && !skip) {
555 if (!/^$/) {
4b7a9b6b 556 if (!/\$.*Log:.*\$/) {
97e21521 557 print "$" "Log:$" > changelog_file
4b7a9b6b 558 }
97e21521
JB
559 boc = 0
560 }
d31b8a48 561 }
3fdddc43 562 # Define date macro.
d31b8a48 563 if (boc == 4) {
a1aa4976 564 if (date == 0) {
5c18171e 565 printf "%%define date\t%%(echo `LC_ALL=\"C\"" > changelog_file
566 print " date +\"%a %b %d %Y\"`)" > changelog_file
1395ea1c 567 date = 1
a1aa4976 568 }
d31b8a48 569 boc = 3
3fdddc43 570 }
5c18171e 571
4b7a9b6b
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 }
5c18171e 581 print > changelog_file
4b7a9b6b 582 } else {
5c18171e 583 print
4b7a9b6b 584 }
5c18171e 585 next
bf0a58ea 586}
587
246ad57e 588###########
589# SCRIPTS #
590###########
93e2a87a 591/^%pre/, (!/^%pre/ && $0 ~ SECTIONS) {
246ad57e 592 preamble = 0
e9176470 593
723ce732
ER
594 if (gsub("/usr/sbin/useradd", "%useradd")) {
595 sub(" 2> /dev/null \|\| :", "");
596 sub(" >/dev/null 2>&1 \|\|:", "");
597 }
598
e31553a7
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
e9176470
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 }
723ce732 618 use_script_macros()
246ad57e 619}
e9176470 620
93e2a87a 621/^%post/, (!/^%post/ && $0 ~ SECTIONS) {
246ad57e 622 preamble = 0
e31553a7
ER
623
624 # fedora extras macros
625 sub("%__chkconfig", "/sbin/chkconfig");
626
a6490001
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 ")
24873dc2 634 sub("> /dev/null", "");
a6490001
ER
635 }
636
c2b069de 637 use_macros()
246ad57e 638}
93e2a87a 639/^%preun/, (!/^%preun/ && $0 ~ SECTIONS) {
246ad57e 640 preamble = 0
d11acde9 641 use_macros()
246ad57e 642}
93e2a87a 643/^%postun/, (!/^%postun/ && $0 ~ SECTIONS) {
246ad57e 644 preamble = 0
e31553a7
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
723ce732 653 use_script_macros()
246ad57e 654}
93e2a87a 655/^%triggerin/, (!/^%triggerin/ && $0 ~ SECTIONS) {
bdba3986 656 preamble = 0
723ce732 657 use_script_macros()
bdba3986 658}
93e2a87a 659/^%triggerun/, (!/^%triggerun/ && $0 ~ SECTIONS) {
bdba3986 660 preamble = 0
723ce732 661 use_script_macros()
bdba3986 662}
93e2a87a 663/^%triggerpostun/, (!/^%triggerpostun/ && $0 ~ SECTIONS) {
bdba3986 664 preamble = 0
723ce732 665 use_script_macros()
bdba3986 666}
93e2a87a 667/^%pretrans/, (!/^%pretrans/ && $0 ~ SECTIONS) {
bdba3986 668 preamble = 0
723ce732 669 use_script_macros()
bdba3986 670}
93e2a87a 671/^%posttrans/, (!/^%posttrans/ && $0 ~ SECTIONS) {
bdba3986 672 preamble = 0
723ce732 673 use_script_macros()
bdba3986 674}
0ae11f54
ER
675/^%verifyscript/, (!/^%verifyscript/ && $0 ~ SECTIONS) {
676 preamble = 0
723ce732 677 use_script_macros()
0ae11f54
ER
678}
679/^%check/, (!/^%check/ && $0 ~ SECTIONS) {
680 preamble = 0
723ce732 681 use_script_macros()
0ae11f54 682}
246ad57e 683
684#############
685# PREAMBLES #
686#############
bf0a58ea 687preamble == 1 {
681a4871 688 # There should not be a space after the name of field
689 # and before the colon.
aec1bddb 690 sub(/[ \t]*:/, ":")
f171fd40 691
1462d6a3
ER
692 if (/^%perl_module_wo_prefix/) {
693 name = $2
694 version = $3
695 release = "0." fixedsub(".%{disttag}.at", "", $4)
696 }
697
aec1bddb 698 field = tolower($1)
38cb34ef 699 if (field ~ /summary:/ && !/etc\.$/ && !/Inc\.$/) {
024709c6
ER
700 sub(/\.$/, "", $0);
701 }
f37c1259 702 if (field ~ /group(\([^)]+\)):/)
1a5b27d5 703 next
f37c1259 704 if (field ~ /group:/) {
705 format_preamble()
d9e2bd9b
ER
706 group = $0;
707 sub(/^[^ \t]*[ \t]*/, "", group);
ad9ea417 708 group = replace_groupnames(group);
d9e2bd9b
ER
709 $0 = "Group:\t\t" group
710
711 if (group ~ /^X11/ && x11 == 0) # Is it X11 application?
7a72f436 712 x11 = 1
8e5358f8 713
d9e2bd9b 714 byl_plik_z_groupmi = 0
8e5358f8
SZ
715 byl_opis_grupy = 0
716 while ((getline linia_grup < groups_file) > 0) {
d9e2bd9b
ER
717 byl_plik_z_groupmi = 1
718 if (linia_grup == group) {
8e5358f8
SZ
719 byl_opis_grupy = 1
720 break
721 }
722 }
69501a12 723
d9e2bd9b 724 if (!byl_plik_z_groupmi)
8e5358f8
SZ
725 print "######\t\t" groups_file ": no such file"
726 else if (!byl_opis_grupy)
727 print "######\t\t" "Unknown group!"
f171fd40 728
8e5358f8 729 close(groups_file)
4ab1678b 730 did_groups = 1
8e5358f8 731 }
f171fd40 732
307f5229 733 if (field ~ /prereq:/) {
a68f7b3b 734 sub(/Pre[Rr]eq:/, "Requires:", $1);
307f5229
ER
735 }
736
4aa6db15 737 # split (build)requires, obsoletes on commas
21a50087 738 if (field ~ /(obsoletes|requires|provides|conflicts|suggests):/ && NF > 2) {
ba377afe
ER
739 value = substr($0, index($0, $2));
740 $0 = format_requires($1, value);
f12ab15d 741 }
b6875e34 742
8e734165
ER
743 # BR: tar (and others) is to common (rpm-build requires it)
744 if (field ~ /^buildrequires:/) {
eb028bca
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") {
8e734165
ER
763 next
764 }
d0297fb3 765
92fa789e 766 replace_requires();
8e734165
ER
767 }
768
e27788d1 769 if (field ~ /^requires:/ || field ~ /^requires\(/) {
92fa789e 770 replace_requires();
b6875e34 771 }
30cd4686
ER
772
773
ff21ed9e 774 # obsolete/unwanted tags
32908bc5 775 if (field ~ /vendor:|packager:|distribution:|docdir:|prefix:|icon:|author:|author-email:|metadata-version:/) {
aec1bddb 776 next
ba377afe 777 }
f171fd40 778
4ab1678b 779 if (field ~ /buildroot:/) {
376e6bc4 780 $0 = $1 "%{tmpdir}/%{name}-%{version}-root-%(id -u -n)"
4ab1678b
ER
781 did_build_root = 1
782 }
681a4871 783
681a4871 784 # Use "License" instead of "Copyright" if it is (L)GPL or BSD
4932d2c6 785 if (field ~ /copyright:/ && $2 ~ /GPL|BSD/) {
aec1bddb 786 $1 = "License:"
4932d2c6 787 }
f171fd40 788
ad2932df
ER
789 # ease updating from debian .dsc
790 if (field ~ /homepage:/) {
791 $1 = "URL:"
792 }
793
517313c5
ER
794 # suse
795 if (field ~ /recommends:/) {
796 $1 = "Suggests:"
797 }
798
4defab2b 799 if ($3 == "==" && $1 !~ /%/) {
517313c5
ER
800 $3 = "="
801 }
802
3b07e07f
ER
803 if (field ~ /license:/) {
804 l = substr($0, index($0, $2));
805 if (l == "Python Software Foundation License") {
806 l = "PSF"
807 }
6112ae02
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 }
ee9487af
ER
820 if (l == "GPLv2") {
821 l = "GPL v2"
822 }
823 if (l == "GPLv2+") {
824 l = "GPL v2+"
825 }
407e19de
ER
826 if (l == "GPL v2 or later") {
827 l = "GPL v2+"
828 }
517313c5
ER
829 if (l == "LGPL v2.0 only") {
830 l = "LGPL v2"
831 }
af8efb29
ER
832 if (l == "LGPLv2+") {
833 l = "LGPL v2+"
834 }
471a5464
ER
835 if (l == "GPLv3") {
836 l = "GPL v3"
837 }
838 if (l == "GPLv3+") {
839 l = "GPL v3+"
840 }
e02ad475
ER
841 if (l == "MPLv1.1") {
842 l = "MPL v1.1"
843 }
3b07e07f
ER
844 $0 = "License:\t" l;
845 }
846
847
1462d6a3 848 if (field ~ /name:/) {
6426afb8 849 if ($2 == "%{name}" && name) {
63d47bae
ER
850 $2 = name
851 }
aec1bddb 852 name = $2
1462d6a3
ER
853 name_seen = 1;
854 }
681a4871 855
1462d6a3 856 if (field ~ /version:/) {
63d47bae
ER
857 if ($2 == "%{version}" && version) {
858 $2 = version
859 }
aec1bddb 860 version = $2
1462d6a3
ER
861 version_seen = 1;
862 }
863
864 if (field ~ /release:/) {
63d47bae
ER
865 if ($2 == "%{release}" && release) {
866 $2 = release
867 }
4ab1678b 868 sub(/%atrelease /, "0.", $0)
1462d6a3
ER
869 release = $2
870 release_seen = 1;
871 }
681a4871 872
32908bc5 873
c4dde22b
SZ
874 if (field ~ /serial:/)
875 $1 = "Epoch:"
b6853342 876
32908bc5
ER
877 if (field ~ /home-page:/)
878 $1 = "URL:"
879
89b1cd55 880 # proper caps
cf038723 881 if (field ~ /^url:$/)
89b1cd55
ER
882 $1 = "URL:"
883
471a5464
ER
884 if (field ~ /^patch/)
885 $1 = "Patch" substr(field, 6);
886
32908bc5
ER
887 if (field ~ /^description:$/)
888 $1 = "\n%description\n"
889
681a4871 890 # Use %{name} and %{version} in the filenames in "Source:"
f4cb1924 891 if (field ~ /^source/ || field ~ /patch/) {
aec1bddb 892 n = split($2, url, /\//)
fd8718a5
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 }
dac4e142
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
a3fcc309 922 # allow %{name} only in last url component
ced0372e
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
aec1bddb 934 filename = url[n]
5e028343
ER
935 if (name) {
936 url[n] = fixedsub(name, "%{name}", url[n])
937 }
755ab9c0 938 if (field ~ /source/) {
5e028343
ER
939 if (version) {
940 url[n] = fixedsub(version, "%{version}", url[n])
941 }
755ab9c0
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 }
59de1799
ER
948 if (_pre) {
949 url[n] = fixedsub(_pre, "%{_pre}", url[n])
950 }
755ab9c0
ER
951 if (_snap) {
952 url[n] = fixedsub(_snap, "%{_snap}", url[n])
953 }
3c5e6e5f
ER
954 if (subver) {
955 url[n] = fixedsub(subver, "%{subver}", url[n])
956 }
755ab9c0 957 }
57caba32 958 # assigning to $2 kills preamble formatting
fd8718a5 959 $2 = fixedsub(filename, url[n], $2)
f171fd40 960
8ea8f0ae 961 $2 = unify_url($2)
681a4871 962 }
8b1938ea 963
f171fd40 964
f4cb1924 965 if (field ~ /^source:/)
f171fd40 966 $1 = "Source0:"
aec1bddb 967
13b24a87 968 if (field ~ /^patch:/)
aec1bddb 969 $1 = "Patch0:"
f171fd40 970
0ea7c3cd 971 kill_preamble_macros();
aec1bddb 972 format_preamble()
f171fd40 973
c26ee7ef
ER
974 if (field ~ /requires/) {
975 # atrpms
976 $0 = fixedsub("%{eversion}", "%{epoch}:%{version}-%{release}", $0);
977 }
bf0a58ea 978}
979
4c1b7426
ER
980/^%bcond_/ {
981 # do nothing
982 print
983 next
984}
c58d1357
ER
985
986# sort BR/R!
987#
988# NOTES:
989# - mixing BR/R and anything else confuses this (all will be sorted together)
b6875e34 990# so don't do that.
c58d1357 991# - comments leading the BR/R can not be associated,
b6875e34 992# so don't adapterize when the BR/R are mixed with comments
a6b7c72d 993ENVIRON["SKIP_SORTBR"] != 1 && preamble == 1 && $0 ~ PREAMBLE_TAGS ":", $0 ~ PREAMBLE_TAGS ":"{
57caba32 994 if ($1 ~ /Pre[Rr]eq:/) {
a68f7b3b 995 sub(/Pre[Rr]eq:/, "Requires:", $1);
c58d1357 996 }
23ddcab1
ER
997 if ($1 == "BR:" ) {
998 $1 = "BuildRequires:"
999 }
1000 if ($1 == "R:" ) {
1001 $1 = "Requires:"
1002 }
c58d1357 1003 format_preamble()
8f7c516b 1004# kill_preamble_macros(); # breaks tabbing
c58d1357
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
c58d1357
ER
1015preamble == 1 {
1016 if (b_idx > 0) {
1017 isort(b_key, b_idx);
1018 for (i = 1; i <= b_idx; i++) {
4932d2c6
ER
1019 v = b_val[b_key[i]];
1020 sub(/[ \t]+$/, "", v);
1021 print "" v;
c58d1357
ER
1022 }
1023 b_idx = 0
1024 }
1025}
1026
7a72f436 1027# main() ;-)
bf0a58ea 1028{
aec1bddb 1029 preamble = 1
f171fd40 1030
70a1dc9e 1031 sub(/[ \t]+$/, "")
aec1bddb 1032 print
1462d6a3
ER
1033
1034 if (name_seen == 0 && name) {
31702e1e 1035 print "Name:\t\t" name
1462d6a3
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 }
32908bc5
ER
1048
1049 if (did_build_root == 0) {
4ab1678b 1050# print "BuildRoot:\t%{tmpdir}/%{name}-%{version}-root-%(id -u -n)"
32908bc5
ER
1051 did_build_root = 1
1052 }
4ab1678b
ER
1053 if (did_groups == 0) {
1054# print "Group:\t\tunknown"
1055 did_groups = 1
1056 }
a1aa4976 1057}
1058
f1991554 1059
a1aa4976 1060END {
a4de4386
ER
1061 if (do_not_touch_anything) {
1062 exit(rc)
1063 }
f171fd40 1064
b6875e34
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 }
1c955424 1071
f1991554 1072 close(changelog_file)
1073 while ((getline < changelog_file) > 0)
1074 print
1075 system("rm -f " changelog_file)
48c6019c 1076
1c52b18e
SZ
1077 if (did_clean == 0) {
1078 print ""
1079 print "%clean"
1080 print "rm -rf $RPM_BUILD_ROOT"
1081 }
1082
dda3eaa5
SZ
1083 if (date == 0) {
1084 print ""
1085 print "%define date\t%(echo `LC_ALL=\"C\" date +\"%a %b %d %Y\"`)"
1086 }
f171fd40 1087
1c955424 1088 if (has_changelog == 0) {
1395ea1c 1089 print "%changelog"
b6875e34 1090 }
dda3eaa5 1091
1c955424 1092 if (boc > 2) {
5bdbef27 1093 print "* %{date} PLD Team <feedback@pld-linux.org>"
b6875e34 1094 }
d31b8a48 1095 if (boc > 1) {
f818cd64 1096 printf "All persons listed below can be reached at "
5bdbef27 1097 print "<cvs_login>@pld-linux.org\n"
a1aa4976 1098 }
1c955424 1099 if (boc > 0) {
d31b8a48 1100 print "$" "Log:$"
b6875e34 1101 }
bf0a58ea 1102}
1103
fd8718a5 1104# substitutes fixed strings (not regexps)
98e37f1f 1105function fixedsub(s1,s2,t, ind) {
7a72f436 1106 if (ind = index(t,s1))
1107 t = substr(t, 1, ind-1) s2 substr(t, ind+length(s1))
1108 return t
fd8718a5
SZ
1109}
1110
98e37f1f
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
8b1938ea 1120# There should be one or two tabs after the colon.
1121function format_preamble()
1122{
57caba32 1123 if (/^#/ || /^%bcond_with/) {
08f60a73
ER
1124 return;
1125 }
aec1bddb 1126 sub(/:[ \t]*/, ":")
2b94cfb4
ER
1127 if (match($0, /[A-Za-z0-9(),#_ \t.-]+[ \t]*:[ \t]*/) == 1) {
1128 if (RLENGTH < 8) {
aec1bddb 1129 sub(/:/, ":\t\t")
b6875e34 1130 } else {
aec1bddb 1131 sub(/:/, ":\t")
b6875e34 1132 }
8b1938ea 1133 }
1134}
1135
43c05c3c 1136# Replace directly specified directories with macros
1137function use_macros()
1138{
13b24a87
ER
1139 # -m, --skip-macros, --no-macros -- skip macros subst
1140 if (ENVIRON["SKIP_MACROS"]) {
1141 return
1142 }
1143
b05d5275
ER
1144 # leave inline sed lines alone
1145 if (/(%{__sed}|sed) -i -e/) {
1146 return;
1147 }
1148
b6875e34
ER
1149 sub("%{_defaultdocdir}", "%{_docdir}");
1150 sub("%{_bindir}/perl", "%{__perl}");
1151 sub("%{_bindir}/python", "%{__python}");
36d9a33d 1152
a372a159
ER
1153 gsub(infodir, "%{_infodir}")
1154
336c1a4f
ER
1155 gsub(perl_sitearch, "%{perl_sitearch}")
1156 gsub(perl_archlib, "%{perl_archlib}")
1157 gsub(perl_privlib, "%{perl_privlib}")
336c1a4f
ER
1158 gsub(perl_vendorlib, "%{perl_vendorlib}")
1159 gsub(perl_vendorarch, "%{perl_vendorarch}")
1160 gsub(perl_sitelib, "%{perl_sitelib}")
9732cb3d
ER
1161
1162 gsub(py_sitescriptdir, "%{py_sitescriptdir}")
4ab1678b 1163 gsub(py_sitedir, "%{py_sitedir}")
1bdf7824 1164 gsub(py_scriptdir, "%{py_scriptdir}")
ae4d1624
ER
1165
1166 gsub(py3_sitescriptdir, "%{py3_sitescriptdir}")
1167 gsub(py3_sitedir, "%{py3_sitedir}")
1168 gsub(py3_scriptdir, "%{py3_scriptdir}")
6f2c1099
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}")
51847161 1175 gsub(ruby_rdocdir, "%{ruby_rdocdir}")
6f2c1099 1176
85084f0d
ER
1177 gsub(systemdunitdir, "%{systemdunitdir}")
1178 gsub(systemdtmpfilesdir, "%{systemdtmpfilesdir}")
1179
4a62fb54
ER
1180 gsub("%{_datadir}/applications", "%{_desktopdir}")
1181 gsub("%{_datadir}/pixmaps", "%{_pixmapsdir}")
ee9487af 1182 gsub("%{_datadir}/java", "%{_javadir}")
336c1a4f 1183
a4de4386
ER
1184 gsub("%{_libdir}/pkgconfig", "%{_pkgconfigdir}")
1185 gsub(pkgconfigdir, "%{_pkgconfigdir}")
1186
1c298a13
ER
1187 gsub("%{_datadir}/pkgconfig", "%{_npkgconfigdir}")
1188 gsub(npkgconfigdir, "%{_npkgconfigdir}")
1189
4efeac87
ER
1190 gsub("%{_datadir}/locale", "%{_localedir}")
1191 gsub(localedir, "%{_localedir}")
1192
e00f41b5 1193 gsub(libdir, "%{_libdir}")
ee9487af 1194 gsub(javadir, "%{_javadir}")
e00f41b5 1195
aec1bddb 1196 gsub(bindir, "%{_bindir}")
74edc57e 1197 gsub("%{prefix}/bin", "%{_bindir}")
b05d5275 1198 if (prefix"/bin" == bindir)
0080f34c 1199 gsub("%{_prefix}/bin", "%{_bindir}")
74edc57e 1200
de69503c 1201 for (c = 1; c <= NF; c++) {
1202 if ($c ~ sbindir "/fix-info-dir")
1203 continue;
3457b4f7
ER
1204 if ($c ~ sbindir "/webapp")
1205 continue;
a372a159
ER
1206 if ($c ~ sbindir "/ldconfig")
1207 continue;
4837c1e3
ER
1208 if ($c ~ sbindir "/chsh")
1209 continue;
1210 if ($c ~ sbindir "/usermod")
1211 continue;
f06959ff
ER
1212 if ($c ~ sbindir "/chkconfig")
1213 continue;
836e411f
ER
1214 if ($c ~ sbindir "/installzope(product|3package)")
1215 continue;
de69503c 1216 gsub(sbindir, "%{_sbindir}", $c)
1217 }
1218
74edc57e 1219 gsub("%{prefix}/sbin", "%{_sbindir}")
836e411f 1220 if (prefix"/sbin" == sbindir) {
5e1d0492 1221 gsub("%{_prefix}/sbin", "%{_sbindir}")
836e411f 1222 }
74edc57e 1223
353f5eea 1224 for (c = 1; c <= NF; c++) {
0965a1a0 1225 if ($c ~ sysconfdir "/{?cron.")
de69503c 1226 continue;
0080f34c 1227 if ($c ~ sysconfdir "/{?crontab.d")
807a0f6b 1228 continue;
6c178315
ER
1229 if ($c ~ sysconfdir "/{?env.d")
1230 continue;
90a421f5 1231 if ($c ~ sysconfdir "/{?modprobe.(d|conf)")
554d6b98 1232 continue;
5d7c48a4
ER
1233 if ($c ~ sysconfdir "/{?udev")
1234 continue;
1235 if ($c ~ sysconfdir "/{?hotplug")
e61b5989 1236 continue;
0080f34c 1237 if ($c ~ sysconfdir "/{?logrotate.d")
353f5eea 1238 continue;
0080f34c 1239 if ($c ~ sysconfdir "/{?pam.d")
a9b2c8c7 1240 continue;
0080f34c 1241 if ($c ~ sysconfdir "/{?profile.d")
66ef7810 1242 continue;
0080f34c 1243 if ($c ~ sysconfdir "/{?rc.d")
9ad7f20b 1244 continue;
0080f34c 1245 if ($c ~ sysconfdir "/{?security")
a9b2c8c7 1246 continue;
0080f34c 1247 if ($c ~ sysconfdir "/{?skel")
c21d1979 1248 continue;
0080f34c 1249 if ($c ~ sysconfdir "/{?sysconfig")
66ef7810 1250 continue;
6e985933
ER
1251 if ($c ~ sysconfdir "/{?shrc.d")
1252 continue;
7c73bc0f
ER
1253 if ($c ~ sysconfdir "/{?certs")
1254 continue;
de5d18d8
ER
1255 if ($c ~ sysconfdir "/{?X11")
1256 continue;
5debd9f6
ER
1257 if ($c ~ sysconfdir "/{?ld.so.conf.d")
1258 continue;
ff21ed9e
ER
1259 if ($c ~ sysconfdir "/{?rpm")
1260 continue;
57caba32 1261 if ($c ~ sysconfdir "/{?bash_completion.d")
6e985933 1262 continue;
57caba32 1263 if ($c ~ sysconfdir "/{?samba")
9292b547 1264 continue;
b371c36f
ER
1265 if ($c ~ sysconfdir "/{?xdg")
1266 continue;
52a943cf
ER
1267 if ($c ~ sysconfdir "/shells")
1268 continue;
b371c36f
ER
1269 if ($c ~ sysconfdir "/inittab")
1270 continue;
98e9501e
ER
1271 if ($c ~ sysconfdir "/init")
1272 continue;
5dc7f5e4
ER
1273 if ($c ~ sysconfdir "/ppp")
1274 continue;
9395915a
ER
1275 if ($c ~ sysconfdir "/dbus-1")
1276 continue;
be827f42
ER
1277 if ($c ~ sysconfdir "/tmpwatch")
1278 continue;
471a5464
ER
1279 if ($c ~ sysconfdir "/acpi")
1280 continue;
1281 if ($c ~ sysconfdir "/apm")
1282 continue;
353f5eea 1283 gsub(sysconfdir, "%{_sysconfdir}", $c)
1284 }
74edc57e 1285
c2b069de 1286 gsub(docdir, "%{_docdir}")
7cb79e98
ER
1287
1288 gsub(kdedocdir, "%{_kdedocdir}")
1289
1290 gsub(gtkdocdir, "%{_gtkdocdir}")
1291 gsub("%{_docdir}/gtk-doc/html", "%{_gtkdocdir}")
1292
57caba32 1293 gsub(php_pear_dir, "%{php_pear_dir}")
4b1d6e6d 1294 gsub(php_data_dir, "%{php_data_dir}")
c2b069de 1295
c4adc376
ER
1296 for (c = 1; c <= NF; c++) {
1297 if ($c ~ datadir "/automake")
1298 continue;
13670287
ER
1299 if ($c ~ datadir "/unsermake")
1300 continue;
a9fb2db8
ER
1301 if ($c ~ datadir "/file/magic.mime")
1302 continue;
c4adc376
ER
1303 gsub(datadir, "%{_datadir}", $c)
1304 }
1305
74edc57e 1306 gsub("%{prefix}/share", "%{_datadir}")
c4adc376 1307 if (prefix"/share" == datadir)
0080f34c 1308 gsub("%{_prefix}/share", "%{_datadir}")
74edc57e 1309
826b40ea
ER
1310 # CFLAGS="-I/usr/include/ncurses is usually correct.
1311 if (!/-I\/usr\/include/) {
1312 gsub(includedir, "%{_includedir}")
1313 }
1314
74edc57e 1315 gsub("%{prefix}/include", "%{_includedir}")
826b40ea 1316 if (prefix"/include" == includedir) {
0080f34c 1317 gsub("%{_prefix}/include", "%{_includedir}")
826b40ea 1318 }
74edc57e 1319
aec1bddb 1320 gsub(mandir, "%{_mandir}")
826b40ea 1321 if ($0 !~ "%{_datadir}/manual") {
5e1d0492 1322 gsub("%{_datadir}/man", "%{_mandir}")
826b40ea 1323 }
9ce0df66 1324 gsub("%{_prefix}/share/man", "%{_mandir}")
1325 gsub("%{prefix}/share/man", "%{_mandir}")
74edc57e 1326 gsub("%{prefix}/man", "%{_mandir}")
1327 gsub("%{_prefix}/man", "%{_mandir}")
1328
aec1bddb 1329 gsub(infodir, "%{_infodir}")
74edc57e 1330 gsub("%{prefix}/info", "%{_infodir}")
1331 gsub("%{_prefix}/info", "%{_infodir}")
1332
0965a1a0 1333 if (prefix !~ "/X11R6") {
1334 gsub("%{_datadir}/aclocal", "%{_aclocaldir}")
1335 }
cfbf94ec 1336
2a638fcb 1337 gsub(examplesdir, "%{_examplesdir}")
7c6b85c4 1338
efd2d668 1339 if (prefix != "/") {
a9fb2db8
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;
3457b4f7
ER
1345 if ($c ~ prefix "/sbin/webapp")
1346 continue;
4837c1e3
ER
1347 if ($c ~ prefix "/sbin/chsh")
1348 continue;
1349 if ($c ~ prefix "/sbin/usermod")
1350 continue;
836e411f
ER
1351 if ($c ~ prefix "/sbin/installzope(product|3package)")
1352 continue;
a9fb2db8
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;
97dae8dc
ER
1359 if ($c ~ prefix "/lib/pkgconfig")
1360 continue;
826b40ea 1361
b5fc4b79
ER
1362 # CFLAGS="-I/usr..." is usually correct.
1363 if (/-I\/usr/)
826b40ea 1364 continue;
474f0944
ER
1365 # same for LDFLAGS="-L/usr..."
1366 if (/-L\/usr/)
1367 continue;
826b40ea 1368
a9fb2db8
ER
1369 gsub(prefix, "%{_prefix}", $c)
1370 }
de69503c 1371 }
efd2d668 1372 gsub("%{prefix}", "%{_prefix}")
1373 }
3bcd1fab 1374
53d16b95
ER
1375 # replace back
1376 gsub("%{_includedir}/ncurses", "/usr/include/ncurses")
1377 gsub("%{_includedir}/freetype", "/usr/include/freetype")
1378
3bcd1fab 1379 gsub("%{PACKAGE_VERSION}", "%{version}")
1380 gsub("%{PACKAGE_NAME}", "%{name}")
b35c10f1 1381
59e208d5 1382 gsub("^make$", "%{__make}")
1383 gsub("^make ", "%{__make} ")
61b753c5 1384 gsub("^gcc ", "%{__cc} ")
67fe737e 1385 gsub("^rm --interactive=never ", "%{__rm} ")
9aece8c8 1386
471a5464
ER
1387 # fedora
1388 gsub("%{ruby_sitearch}", "%{ruby_sitearchdir}")
1389 gsub("%{python_sitearch}", "%{py_sitedir}")
e02ad475
ER
1390 gsub("%{python_sitelib}", "%{py_sitescriptdir}")
1391
1392 # alt linux
1393 gsub("%_man1dir", "%{_mandir}/man1")
471a5464 1394
cab706de
ER
1395 # mandrake specs
1396 gsub("^%make$", "%{__make}")
1397 gsub("^%make ", "%{__make} ")
1398 gsub("^%makeinstall_std", "%{__make} install \\\n\tDESTDIR=$RPM_BUILD_ROOT")
b7ca53a5 1399 gsub("^%{makeinstall}", "%{__make} install \\\n\tDESTDIR=$RPM_BUILD_ROOT")
63d47bae 1400 gsub("^%makeinstall", "%{__make} install \\\n\tDESTDIR=$RPM_BUILD_ROOT")
cab706de 1401 gsub("^%{__rm} -rf %{buildroot}", "rm -rf $RPM_BUILD_ROOT")
b7ca53a5 1402 gsub("^%{__install}", "install")
cab706de
ER
1403 gsub("%optflags", "%{rpmcflags}")
1404 gsub("%{compat_perl_vendorarch}", "%{perl_vendorarch}")
1405
a6ed8b03 1406 gsub("^%{__make} install DESTDIR=\$RPM_BUILD_ROOT", "%{__make} install \\\n\tDESTDIR=$RPM_BUILD_ROOT")
d11acde9 1407 gsub("^fix-info-dir$", "[ ! -x /usr/sbin/fix-info-dir ] || /usr/sbin/fix-info-dir -c %{_infodir} >/dev/null 2>\\&1")
5e15e952
ER
1408 $0 = fixedsub("%buildroot", "$RPM_BUILD_ROOT", $0)
1409 $0 = fixedsub("%{buildroot}", "$RPM_BUILD_ROOT", $0)
63d47bae 1410 $0 = fixedsub("CXXFLAGS=%{rpmcflags} %configure", "CXXFLAGS=%{rpmcflags}\n%configure", $0);
43f8581a 1411 $0 = fixedsub("%__install", "install", $0);
63d47bae 1412
740e3cd8 1413 # split configure line to multiple lines
6c8a2863 1414 if (/%configure +$/) {
1415 sub( / +$/, "" );
1416 } else if (/%configure / && !/\\$/) {
740e3cd8
ER
1417 $0 = format_configure($0);
1418 }
1419
ac779c71
ER
1420 gsub("%_bindir", "%{_bindir}")
1421 gsub("%_datadir", "%{_datadir}")
1422 gsub("%_iconsdir", "%{_iconsdir}")
c2b069de
ER
1423 gsub("%_sbindir", "%{_sbindir}")
1424 gsub("%_mandir", "%{_mandir}")
1425 gsub("%name", "%{name}")
b6875e34
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");
a6ed8b03 1433
9aece8c8 1434 gsub("/usr/src/linux", "%{_kernelsrcdir}")
1435 gsub("%{_prefix}/src/linux", "%{_kernelsrcdir}")
1c955424 1436
ecaaa784 1437 if (/^ant / || /^%{ant}/) {
1c955424 1438 sub(/^ant/, "%ant")
ecaaa784 1439 sub(/^%{ant}/, "%ant")
b6875e34
ER
1440 add_br("BuildRequires: jpackage-utils");
1441 add_br("BuildRequires: rpmbuild(macros) >= 1.300");
1442 }
1c955424 1443
2dc1a8cd
ER
1444 $0 = fixedsub("%(%{__cc} -dumpversion)", "%{cc_version}", $0);
1445 $0 = fixedsub("%(%{__cxx} -dumpversion)", "%{cxx_version}", $0);
d6e33af7
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 }
9ae21f47 1454}
f171fd40 1455
740e3cd8
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
7c23055b
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) {
54caef3d 1472 j-- ; A[j+1] = A[j]
1473 }
7c23055b
ER
1474 A[j] = hold
1475 }
1476 # sentinel A[0] = "" will be created if needed
1477}
1478
1479
23e0529e 1480function use_files_macros( i, n, t, a, l)
eee34ffb 1481{
e6f1551d
ER
1482 use_macros()
1483
da6457aa
ER
1484 # skip comments
1485 if (/^#/) {
484bbf6d 1486 return 1;
da6457aa
ER
1487 }
1488
f158eddc
ER
1489 sub("^%doc %{_mandir}", "%{_mandir}")
1490
eee34ffb 1491 gsub("^%{_sbindir}", "%attr(755,root,root) %{_sbindir}")
1492 gsub("^%{_bindir}", "%attr(755,root,root) %{_bindir}")
7c23055b 1493
61cb9711
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
16bb0647
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"
85bed066
ER
1502 }
1503
5dc673eb 1504 # replace back
8f6ddcd9 1505 gsub("%{_sysconfdir}/cron\.d", "/etc/cron.d")
3feaeac8 1506 gsub("%{_sysconfdir}/crontab\.d", "/etc/crontab.d")
8f6ddcd9
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")
5dc673eb 1515 gsub("%{_sysconfdir}/init.d", "/etc/init.d")
9395915a 1516 gsub("%{_sysconfdir}/dbus-1", "/etc/dbus-1")
be827f42
ER
1517 gsub("%{_sysconfdir}/pki", "/etc/pki")
1518 gsub("%{_sysconfdir}/tmpwatch", "/etc/tmpwatch")
2fc0e274 1519
5dc673eb
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/) {
2fc0e274
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 *,/) {
89c604c7 1530 gsub("^%attr\\(... *,", "%attr(754,");
2fc0e274 1531 }
9a7a5776
ER
1532 }
1533
1c298a13 1534 if (/lib.+\.so\b/ && !/\.so$/ && !/^%attr.*/ && !/%exclude/) {
55356feb
ER
1535 $0 = "%attr(755,root,root) " $0
1536 }
1537
ab9b09e2
ER
1538 if (/%{perl_vendorarch}.*\.so$/ && !/^%attr.*/) {
1539 $0 = "%attr(755,root,root) " $0
1540 }
1541
af8efb29
ER
1542 # remove attrs from man pages
1543 if (/%{_mandir}/ && /^%attr/) {
1544 sub("^%attr\\(.*\\) *", "");
1545 }
1546
f56d5519
ER
1547 # /etc/sysconfig files
1548 # %attr(640,root,root) %config(noreplace) %verify(not size mtime md5) /etc/sysconfig/*
a825b76b 1549 # attr not required, allow default 644 attr
6ea64b8d 1550 if (!/network-scripts/ && !/%dir/ && !/\.d$/ && !/functions/ && !/\/etc\/sysconfig\/wmstyle/) {
6ea0907e 1551 if (/\/etc\/sysconfig\// && /%config/ && !/%config\(noreplace/) {
5dc673eb
ER
1552 gsub("%config", "%config(noreplace)")
1553 }
f56d5519 1554
6ea0907e 1555 if (/\/etc\/sysconfig\// && !/%config\(noreplace/) {
5dc673eb
ER
1556 $NF = "%config(noreplace) " $NF
1557 }
f56d5519 1558
5dc673eb 1559 if (/\/etc\/sysconfig\// && /%attr\(755/) {
89c604c7 1560 gsub("^%attr\\(... *,", "%attr(640,");
5dc673eb 1561 }
f56d5519 1562
5dc673eb
ER
1563 if (/\/etc\/sysconfig\// && !/%verify/) {
1564 gsub("/etc/sysconfig", "%verify(not size mtime md5) /etc/sysconfig");
1565 }
a825b76b
ER
1566 }
1567
f56d5519 1568 # kill leading zeros
7dfb4dea
ER
1569 if (/%attr\(0[1-9]/) {
1570 gsub("%attr\\(0", "%attr(")
1571 }
f9d5d512 1572
95ae7268 1573 # kill leading whitespace
b8085249 1574 gsub(/^ +/, "");
95ae7268 1575
b6875e34
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 }
46292535 1582
7c23055b 1583 # sort %verify attrs
12bfc5c8 1584 if (match($0, /%verify\(not([^)]+)\)/)) {
7c23055b 1585 t = substr($0, RSTART, RLENGTH)
8409a9b2
ER
1586 # kill commas: %verify(not,md5,size,mtime)
1587 gsub(/,/, " ", t);
1588
7c23055b
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
12bfc5c8 1599 gsub(/%verify\(not[^)]+\)/, s)
7c23055b 1600 }
13defa79
ER
1601
1602 if (/%{_mandir}/) {
d64e2ec0 1603 gsub("\.gz$", "*")
1080e5b7 1604 gsub("%ext_man$", "*")
13defa79 1605 }
5e15e952 1606
ef6d2b7a 1607 # locale dir and no %lang -> bad
b9080a1b 1608 if (/%{_datadir}\/locale\/.*\// && !/%(dir|lang)/) {
ef6d2b7a
ER
1609 $(NF + 1) = "# FIXME consider using %find_lang"
1610 }
1611
23e0529e 1612 # python egg-infos
860a6f52 1613 if (match($0, "^%{py_site(script)?dir}/.+-py"py_ver".egg-info$")) {
484bbf6d
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
860a6f52 1620 l = index($0, "/");
484bbf6d 1621 t = substr($0, 0, l);
23e0529e 1622 s = substr($0, l + 1, RLENGTH - l - length("-py"py_ver".egg-info"));
860a6f52 1623 if (match(s, "[^-]+$")) {
484bbf6d
ER
1624 if (RSTART > 1) {
1625 s = substr(s, 0, RSTART - 1);
5384172a 1626 }
23e0529e 1627 print "%if \"%{py_ver}\" > \"2.4\""
860a6f52 1628 gsub(t "/.+.egg-info", t "/" s "-*.egg-info");
23e0529e
ER
1629 print
1630 print "%endif"
484bbf6d 1631 return 0;
23e0529e
ER
1632 }
1633 }
1634
5e15e952
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);
97dae8dc
ER
1639
1640 gsub(libdir "/pkgconfig", "%{_pkgconfigdir}");
1641 gsub("%{_libdir}/pkgconfig", "%{_pkgconfigdir}");
1642 gsub("%{_prefix}/lib/pkgconfig", "%{_pkgconfigdir}");
eee20d8d
ER
1643
1644 gsub("%{_datadir}/applications", "%{_desktopdir}");
9730a549 1645 gsub("%{_datadir}/icons", "%{_iconsdir}");
0904210e 1646 gsub("%{_datadir}/pixmaps", "%{_pixmapsdir}");
4b1d6e6d
ER
1647 gsub("%{_datadir}/pear", "%{php_pear_dir}");
1648 gsub("%{_datadir}/php", "%{php_data_dir}");
484bbf6d
ER
1649
1650 return 1
eee34ffb 1651}
236b87ac 1652
723ce732
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
236b87ac 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
f171fd40 1668 if (format_indent == -1)
236b87ac 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
f171fd40 1677
236b87ac 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
f171fd40 1690
236b87ac 1691 line = substr(line, RSTART + RLENGTH)
1692 }
1693 if (newline ~ /[^\t ]/) {
1694 print newline
1695 }
1696}
1697
eb4bf70e 1698function cflags(var)
1699{
85e708f2 1700 if ($0 == var "=\"$RPM_OPT_FLAGS\"") {
1701 removed[var] = 1
eb4bf70e 1702 return 0
85e708f2 1703 }
f171fd40 1704
246ad57e 1705 if (!/!\?debug/)
fde8f52a 1706 sub("\$RPM_OPT_FLAGS", "%{rpmcflags}")
eb4bf70e 1707 return 1
1708}
0ea7c3cd 1709
9b781beb
ER
1710# return whole matched pattern
1711function matchstr(str, pat)
1712{
1713 match(str, "[^/]+$");
1714 return substr(str, RSTART, RLENGTH);
1715}
1716
8ea8f0ae
ER
1717function unify_url(url)
1718{
1719
1720 # sourceforge urls
3f8ea9bd 1721 # Docs about sourceforge mirror system: http://sourceforge.net/apps/trac/sourceforge/wiki/Mirrors
f6403de9
ER
1722
1723 # 1. unify domains
3f8ea9bd
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)
f6403de9 1731
f6403de9 1732 # 3. unify urls
2bee6485
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 }
8ea8f0ae 1740
9b781beb
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
8ea8f0ae
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
11401cd0 1759 # gnu.org
a4799779
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)
11401cd0 1767
8ea8f0ae
ER
1768 return url
1769}
1770
4e26c5f2
ER
1771function demacroize(str)
1772{
8f7c516b
ER
1773 if (mod_name) {
1774 sub("%{mod_name}", mod_name, str);
1775 }
f5f6280a
ER
1776 if (pearname) {
1777 sub("%{_pearname}", pearname, str);
1778 }
1779 if (pearname) {
1780 sub("%{pearname}", pearname, str);
1781 }
8f7c516b
ER
1782 if (name) {
1783 sub("%{name}", name, str);
1784 }
4e26c5f2
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 }
59de1799
ER
1794 if (_pre) {
1795 sub("%{_pre}", _pre, str);
1796 }
4e26c5f2
ER
1797 if (_snap) {
1798 sub("%{_snap}", _snap, str);
1799 }
3c5e6e5f
ER
1800 if (subver) {
1801 sub("%{subver}", subver, str);
1802 }
4e26c5f2
ER
1803 return str;
1804}
1805
0ea7c3cd
ER
1806function kill_preamble_macros()
1807{
a64d362e
ER
1808 if ($1 ~ /^Obsoletes:/) {
1809 # NB! assigning $2 a value breaks tabbing
1810 $2 = demacroize($2);
1811 }
1812 if ($1 ~ /^URL:/) {
8f7c516b 1813 # NB! assigning $2 a value breaks tabbing
4e26c5f2 1814 $2 = demacroize($2);
ec30d23e 1815 $2 = unify_url($2)
0ea7c3cd 1816 }
e31553a7
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 }
0ea7c3cd 1827}
ba377afe 1828
9815f9b2
ER
1829function get_epoch(pkg, ver, epoch)
1830{
cccfa553
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
9815f9b2
ER
1836 shell = "grep -o '^" pkg ":[^:]\+' ../PLD-doc/BuildRequires.txt | awk '{print $NF}'";
1837 shell | getline epoch;
1838 return epoch;
1839}
1840
ba377afe 1841function format_requires(tag, value, n, p, i, deps, ndeps) {
87b130e2
ER
1842 # skip any formatting for commented out items or some weird macros
1843 if (/^#/ || /%\(/) {
3f81d059
ER
1844 return tag "\t" value
1845 }
ba377afe
ER
1846 n = split(value, p, / *,? */);
1847 for (i = 1; i <= n; i++) {
1848 if (p[i+1] ~ /[<=>]/) {
9815f9b2
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 }
ba377afe
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}
6ebff802
ER
1868
1869function use_tabs()
1870{
1871 # reverse vim: ts=4 sw=4 et
1872 gsub(/ /, "\t");
1873}
1c955424
ER
1874
1875function add_br(br)
1876{
b6875e34 1877 BR[BR_count++] = br
1c955424
ER
1878}
1879
76c7e23c
ER
1880# Load rpm macros
1881# you should update the list also in adapter when making changes here
8d9ad434 1882function import_rpm_macros( v) {
76c7e23c
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
a4de4386
ER
1889 exit(rc = 1);
1890 }
1891
8fc7c329 1892 # update this version dep each time some new macro export is added
8d9ad434
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"
a4de4386
ER
1896 do_not_touch_anything = 1
1897 exit(rc = 1);
76c7e23c
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"]
a4de4386 1921 pkgconfigdir = ENVIRON["_pkgconfigdir"]
1c298a13 1922 npkgconfigdir = ENVIRON["_npkgconfigdir"]
4efeac87 1923 localedir = ENVIRON["_localedir"]
76c7e23c
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
8fc7c329
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
76c7e23c
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"]
df79d912
JR
1952
1953 systemdunitdir = ENVIRON["systemdunitdir"]
1954 systemdtmpfilesdir = ENVIRON["systemdtmpfilesdir"]
76c7e23c
ER
1955}
1956
76c7e23c
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
b2cb3007
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");
3df50196 2040 group = replace(group, "User Interface/X", "X11/Applications");
b2cb3007
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
e27788d1 2056function replace_requires() {
92fa789e 2057
517313c5 2058 sub(/^python-setuptools-devel$/, "python-distribute", $2);
1e1d065d 2059 sub(/^gcc-g77/, "gcc-fortran", $2);
532cbdf9
ER
2060
2061 # use virtual, not package name
2062 sub(/^rpm-build-macros$/, "rpmbuild(macros)", $2);
2063
6ca05bf8
ER
2064 # bad package.xml, see http://pear.php.net/bugs/bug.php?id=17779
2065 sub(/^php-php-gtk/, "php-gtk2", $2);
2066
40ee9b70 2067 # jpackages / fedora java packages
de0b52ae 2068 sub(/^antlr3$/, "java-antlr3", $2);
08226650 2069 sub(/^aqute-bnd$/, "java-bnd", $2);
83ed1722 2070 sub(/^avalon-framework$/, "java-avalon-framework", $2);
2071 sub(/^avalon-logkit$/, "java-avalon-logkit", $2);
6b5f846d 2072 sub(/^axis$/, "java-axis", $2);
40ee9b70
ER
2073 sub(/^bouncycastle$/, "java-bcprov", $2);
2074 sub(/^bouncycastle-mail$/, "java-bcmail", $2);
08226650 2075 sub(/^bouncycastle-pg$/, "java-bcpg", $2);
40ee9b70 2076 sub(/^bouncycastle-tsp$/, "java-bctsp", $2);
de0b52ae 2077 sub(/^bsf$/, "java-bsf", $2);
40ee9b70
ER
2078 sub(/^dom4j$/, "java-dom4j", $2);
2079 sub(/^flute$/, "java-flute", $2);
d95a12d3
ER
2080 sub(/^gnu-regexp$/, "java-gnu-regexp", $2);
2081 sub(/^gnu.regexp$/, "java-gnu-regexp", $2);
22e27c40 2082 sub(/^hamcrest$/, "java-hamcrest", $2);
40ee9b70 2083 sub(/^itext$/, "java-itext", $2);
ed0e2c9b 2084 sub(/^jaas$/, "java(jaas)", $2);
2085 sub(/^jaf$/, "java(jaf)", $2);
6b5f846d 2086 sub(/^jakarta-ant$/, "ant", $2);
40ee9b70 2087 sub(/^jakarta-commons-codec$/, "java-commons-codec", $2);
6b5f846d 2088 sub(/^jakarta-commons-httpclient$/, "java-commons-httpclient", $2);
40ee9b70 2089 sub(/^jakarta-commons-logging$/, "java-commons-logging", $2);
6b5f846d 2090 sub(/^jakarta-log4j$/, "java-log4j", $2);
2091 sub(/^jakarta-oro$/, "java-oro", $2);
83ed1722 2092 sub(/^jakarta-servletapi$/, "java(servlet)", $2);
3c606e9e
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);
6b5f846d 2098 sub(/^javamail$/, "java(javamail)", $2);
ed0e2c9b 2099 sub(/^jaxp$/, "java(jaxp)", $2);
2100 sub(/^jaxp_parser_impl$/, "java(jaxp_parser_impl)", $2);
9d9c44b3 2101 sub(/^jaxp_transform_impl$/, "java(jaxp_transform_impl)", $2);
ed0e2c9b 2102 sub(/^jce$/, "java(jce)", $2);
dda2335f 2103 sub(/^jcommon$/, "java-jcommon", $2);
ed0e2c9b 2104 sub(/^jdbc-stdext$/, "java(jdbc-stdext)", $2);
de0b52ae 2105 sub(/^jdepend$/, "java-jdepend", $2);
dda2335f 2106 sub(/^jfreechart$/, "java-jfreechart", $2);
ed0e2c9b 2107 sub(/^jmx$/, "java(jmx)", $2);
2108 sub(/^jndi$/, "java(jndi)", $2);
de0b52ae 2109 sub(/^jsch$/, "java-jsch", $2);
ed0e2c9b 2110 sub(/^jsse$/, "java(jsse)", $2);
9d9c44b3 2111 sub(/^jta$/, "java(jta)", $2);
de0b52ae 2112 sub(/^junit$/, "java-junit", $2);
40ee9b70 2113 sub(/^junit4$/, "java-junit", $2);
6b5f846d 2114 sub(/^ldapjdk$/, "ldapsdk", $2);
40ee9b70
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);
6b5f846d 2122 sub(/^log4j$/, "java-log4j", $2);
2123 sub(/^logging-log4j$/, "java-log4j", $2);
2124 sub(/^oro$/, "java-oro", $2);
40ee9b70
ER
2125 sub(/^pdf-renderer$/, "java-pdf-renderer", $2);
2126 sub(/^pentaho-libxml$/, "java-libxml", $2);
6b5f846d 2127 sub(/^rhino$/, "java-rhino", $2);
40ee9b70 2128 sub(/^sac$/, "java-sac", $2);
6b5f846d 2129 sub(/^saxon-scripts$/, "saxon", $2);
9d9c44b3 2130 sub(/^servlet$/, "java(servlet)", $2);
6b5f846d 2131 sub(/^uddi4j$/, "java-uddi4j", $2);
40ee9b70 2132 sub(/^ws-jaxme$/, "java-jaxme", $2);
6b5f846d 2133 sub(/^wsdl4j$/, "java-wsdl4j", $2);
6b5f846d 2134 sub(/^xalan-j$/, "java-xalan", $2);
3c606e9e 2135 sub(/^xalan-j2$/, "java-xalan", $2);
f75c7006
ER
2136 sub(/^xerces-j$/, "java-xerces", $2);
2137 sub(/^xerces-j2$/, "java-xerces", $2);
40ee9b70 2138 sub(/^xml-commons-apis$/, "java-xml-commons", $2);
6b5f846d 2139 sub(/^xml-commons-resolver$/, "java-xml-commons-resolver", $2);
40ee9b70
ER
2140 sub(/^xmldb-api$/, "java-xmldb", $2);
2141 sub(/^xmldb-api-sdk$/, "java-xmldb-sdk", $2);
92fa789e 2142
3c606e9e 2143 # fedora / redhat
435d1309 2144 sub(/^Django$/, "python-django", $2);
09f3f638 2145 sub(/^GitPython$/, "python-git", $2);
f6403de9
ER
2146 sub(/^PyQt4-devel$/, "python-PyQt4-devel", $2);
2147 sub(/^PyQwt-devel$/, "python-PyQwt-devel", $2);
87ffb46f 2148 sub(/^ccid$/, "pcsc-driver-ccid", $2);
03180d14 2149 sub(/^chkconfig$/, "/sbin/chkconfig", $2);
da9ff7a7 2150 sub(/^db4-devel$/, "db-devel", $2);
3c606e9e 2151 sub(/^dbus-python$/, "python-dbus", $2);
3df50196 2152 sub(/^desktop-notification-daemon$/, "dbus(org.freedesktop.Notifications)", $2);
3c606e9e 2153 sub(/^file-devel$/, "libmagic-devel", $2);
0e53c084 2154 sub(/^freetype2-devel$/, "freetype-devel", $2);
154cb95a 2155 sub(/^fuse-devel$/, "libfuse-devel", $2);
3c606e9e
ER
2156 sub(/^gamin-python$/, "python-gamin", $2);
2157 sub(/^gcc-c\+\+$/, "libstdc++-devel", $2);
08226650 2158 sub(/^gnome-desktop3-devel$/, "gnome-desktop-devel", $2);
af8efb29 2159 sub(/^gnome-python2-extras$/, "python-gnome-extras", $2);
24873dc2
ER
2160 sub(/^gnome-python2-gconf$/, "python-gnome-gconf", $2);
2161 sub(/^gnome-python2-gnomekeyring$/, "python-gnome-desktop-keyring", $2);
471a5464 2162 sub(/^gnome-python2-gtkspell$/, "python-gnome-extras-gtkspell", $2);
0e53c084 2163 sub(/^gtk-sharp2-devel$/, "dotnet-gtk-sharp2-devel", $2);
af8efb29 2164 sub(/^gtk2$/, "gtk+2", $2);
8aede7e3 2165 sub(/^gtk2-devel$/, "gtk+2-devel", $2);
e31553a7 2166 sub(/^gtk3-devel$/, "gtk+3-devel", $2);
3c606e9e 2167 sub(/^initscripts$/, "rc-scripts", $2);
0e53c084 2168 sub(/^iproute$/, "iproute2", $2);
3c606e9e 2169 sub(/^iscsi-initiator-utils$/, "open-iscsi", $2);
40ee9b70 2170 sub(/^keyutils-libs-devel$/, "keyutils-devel", $2);
08226650 2171 sub(/^libSM-devel$/, "xorg-lib-libSM-devel", $2);
5f76b6c6
ER
2172 sub(/^libX11-devel$/, "xorg-lib-libX11-devel", $2);
2173 sub(/^libXScrnSaver-devel$/, "xorg-lib-libXScrnSaver-devel", $2);
d2bfc4ba 2174 sub(/^libXau-devel$/, "xorg-lib-libXau-devel", $2);
08226650
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);
5f76b6c6 2178 sub(/^libXext-devel$/, "xorg-lib-libXext-devel", $2);
3c606e9e 2179 sub(/^libXft-devel$/, "xorg-lib-libXft-devel", $2);
5f76b6c6 2180 sub(/^libXinerama-devel$/, "xorg-lib-libXinerama-devel", $2);
da9ff7a7 2181 sub(/^libXrandr-devel$/, "xorg-lib-libXrandr-devel", $2);
08226650 2182 sub(/^libXrender-devel$/, "xorg-lib-libXrender-devel", $2);
5f76b6c6 2183 sub(/^libXxf86vm-devel$/, "xorg-lib-libXxf86vm-devel", $2);
e31553a7 2184 sub(/^libacl-devel$/, "acl-devel", $2);
0e53c084 2185 sub(/^libcurl-devel$/, "curl-devel", $2);
24873dc2 2186 sub(/^libgudev1-devel$/, "udev-glib-devel", $2);
08226650 2187 sub(/^libmx-devel$/, "mx-devel", $2);
3df50196 2188 sub(/^libselinux-python$/, "python-selinux", $2);
484bf2b0 2189 sub(/^libsrtp-devel$/, "srtp-devel", $2);
689721b0
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);
842b198d 2194 sub(/^libusb1-devel$/, "libusb-devel", $2);
e02ad475 2195 sub(/^mod_wsgi$/, "apache-mod_wsgi", $2);
08226650 2196 sub(/^newt-python$/, "python-snack", $2);
3c606e9e 2197 sub(/^notify-python$/, "python-pynotify", $2);
87ffb46f 2198 sub(/^pcsc-lite-ccid$/, "pcsc-driver-ccid", $2);
039d8103 2199 sub(/^pulseaudio-libs-devel$/, "pulseaudio-devel", $2);
2bbf619a 2200 sub(/^pyOpenSSL$/, "python-pyOpenSSL", $2);
3df50196 2201 sub(/^pycairo$/, "python-pycairo", $2);
dd1ce547 2202 sub(/^pyflakes$/, "python-pyflakes", $2);
4a7554aa 2203 sub(/^pygobject2$/, "python-pygobject", $2);
08226650 2204 sub(/^pygobject3-devel$/, "python-pygobject3-common-devel", $2);
3c606e9e
ER
2205 sub(/^pygtk2$/, "python-pygtk", $2);
2206 sub(/^pygtk2-devel$/, "python-pygtk-devel", $2);
24873dc2 2207 sub(/^pygtk2-libglade$/, "python-pygtk-glade", $2);
dd1ce547 2208 sub(/^pysvn$/, "python-pysvn", $2);
689721b0
ER
2209 sub(/^pytalloc$/, "python-talloc", $2);
2210 sub(/^pytalloc-devel$/, "python-talloc-devel", $2);
3df50196 2211 sub(/^python-cups$/, "python-pycups", $2);
e02ad475 2212 sub(/^python-enchant$/, "python-pyenchant", $2);
e27788d1
ER
2213 sub(/^python-imaging$/, "python-PIL", $2);
2214 sub(/^python-imaging-tk$/, "python-PIL-tk", $2);
3df50196 2215 sub(/^python-newt$/, "python-snack", $2);
471a5464 2216 sub(/^python-pygtk$/, "python-pygtk-gtk", $2);
dd1ce547
ER
2217 sub(/^python-recaptcha-client$/, "python-recaptcha", $2);
2218 sub(/^python-twisted-core$/, "python-TwistedCore", $2);
f6403de9
ER
2219 sub(/^python-twisted-core$/, "python-TwistedCore", $2);
2220 sub(/^python-twisted-names$/, "python-TwistedNames", $2);
e02ad475 2221 sub(/^python2-devel$/, "python-devel", $2);
dd1ce547 2222 sub(/^pytz$/, "python-pytz", $2);
3c606e9e 2223 sub(/^qt4-devel$/, "qt4-build", $2);
f6403de9 2224 sub(/^qt4-webkit-devel$/, "QtWebKit-devel", $2);
da9ff7a7 2225 sub(/^qtlockedfile-devel$/, "QtLockedFile-devel", $2);
484bf2b0 2226 sub(/^qtsingleapplication-devel$/, "QtSingleApplication-devel", $2);
b86601da 2227 sub(/^rpm-python$/, "python-rpm", $2);
f6403de9 2228 sub(/^sip-devel$/, "python-sip-devel", $2);
3c606e9e
ER
2229 sub(/^tftp-server$/, "tftpdaemon", $2);
2230 sub(/^tkinter$/, "python-tkinter", $2);
40ee9b70 2231 sub(/^urw-fonts$/, "fonts-Type1-urw", $2);
08226650 2232 sub(/^webkitgtk3-devel$/, "gtk-webkit3-devel", $2);
435d1309 2233 sub(/^xapian-bindings-python$/, "python-xapian", $2);
484bf2b0 2234 sub(/^xorg-x11-server-sdk$/, "xorg-xserver-server-devel", $2);
40ee9b70 2235
b371c36f
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
b1fc2b39 2245 # debian / ubuntu
3c606e9e
ER
2246 sub(/^blkid-dev$/, "libblkid-devel", $2);
2247 sub(/^ext2fs-dev$/, "e2fsprogs-devel", $2);
2248 sub(/^libao-dev$/, "libao-devel", $2);
aead9fa9
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);
aead9fa9 2253 sub(/^libcurl4-openssl-dev$/, "curl-devel", $2);
30a90064 2254 sub(/^libdnet-dev$/, "libdnet-devel", $2);
30a90064 2255 sub(/^libesd0-dev$/, "esound-devel", $2);
30a90064 2256 sub(/^libfishsound1-dev$/, "libfishsound-devel", $2);
3c606e9e
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);
30a90064 2270 sub(/^libslp-dev$/, "openslp-devel", $2);
3c606e9e
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);
b371c36f
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);
c7f91339 2282
00697b90 2283 # altlinux
436f0f9e 2284 sub(/^libatk-devel$/, "atk-devel", $2);
7b8dbdb3 2285 sub(/^libgit-devel$/, "git-core-devel", $2);
436f0f9e 2286 sub(/^libgtk\+2-devel$/, "gtk+2-devel", $2);
00697b90
ER
2287 sub(/^libncurses-devel$/, "ncurses-devel", $2);
2288 sub(/^libncursesxx-devel$/, "ncurses-c++-devel", $2);
436f0f9e 2289 sub(/^libpango-devel$/, "pango-devel", $2);
00697b90 2290 sub(/^libpcre-devel$/, "pcre-devel", $2);
436f0f9e 2291 sub(/^libpopt-devel$/, "popt-devel", $2);
7b8dbdb3 2292 sub(/^libssl-devel$/, "openssl-devel", $2);
00697b90 2293
517313c5 2294 # suse
517313c5 2295 sub(/^alsa-devel$/, "alsa-lib-devel", $2);
517313c5 2296 sub(/^gtk-sharp2$/, "dotnet-gtk-sharp2", $2);
484bf2b0 2297 sub(/^gtkmm2-devel$/, "gtkmm-devel", $2);
87ffb46f
ER
2298 sub(/^libexpat-devel$/, "expat-devel", $2);
2299 sub(/^libffmpeg-devel$/, "ffmpeg-devel", $2);
484bf2b0 2300 sub(/^libopenssl-devel$/, "openssl-devel", $2);
87ffb46f 2301 sub(/^libpulse-devel$/, "pulseaudio-devel", $2);
517313c5 2302 sub(/^monodoc-core$/, "mono-monodoc", $2);
87ffb46f 2303 sub(/^python-gtk$/, "python-pygtk-gtk", $2);
517313c5 2304
92fa789e
ER
2305 replace_php_virtual_deps()
2306}
2307
2b94cfb4 2308# vim:ts=4:sw=4
This page took 0.801705 seconds and 4 git commands to generate.