]> git.pld-linux.org Git - packages/adapter.git/blame - adapter.awk
- remove cvs leftover: changelog formatting
[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 44 bod = 0 # Beginning of %description
7a72f436 45 tw = 70 # Descriptions width
f171fd40 46
89c604c7 47 b_idx = 0 # index of BR/R arrays
b6875e34 48 BR_count = 0 # number of additional BuildRequires
89c604c7 49
85e708f2 50 # If variable removed, then 1 (for removing it from export)
51 removed["LDFLAGS"] = 0
52 removed["CFLAGS"] = 0
53 removed["CXXFLAGS"] = 0
5c18171e 54
246ad57e 55 # If 1, we are inside of comment block (started with /^#%/)
56 comment_block = 0
f171fd40 57
683ce9e3
ER
58 import_rpm_macros()
59
c5cb79f5 60 packages_dir = topdir
a877f3a5 61 groups_file = packages_dir "/rpm.groups"
683ce9e3 62
a877f3a5 63 system("cd "packages_dir"; [ -f rpm.groups ] || cvs up rpm.groups > /dev/null")
c2814373 64 system("[ -d ../PLD-doc ] && cd ../PLD-doc && ([ -f BuildRequires.txt ] || cvs up BuildRequires.txt >/dev/null)");
bf0a58ea 65}
66
43c05c3c 67# If the latest line matched /%files/
68defattr == 1 {
13b24a87
ER
69 if (ENVIRON["SKIP_DEFATTR"] != 1) {
70 if ($0 !~ /defattr/) { # If no %defattr
71 print "%defattr(644,root,root,755)" # Add it
72 } else {
73 $0 = "%defattr(644,root,root,755)" # Correct mistakes (if any)
74 }
75 }
aec1bddb 76 defattr = 0
43c05c3c 77}
78
bbc531d9
ER
79# call mktemp(1) and return the value
80function mktemp(template, tmp) {
81 "mktemp " template | getline tmp
82 return tmp
83}
84
89c604c7
ER
85function b_makekey(a, b, s) {
86 s = a "" b;
87 # kill bcond
b6875e34 88 gsub(/[#%]+{[!?]+[_a-zA-Z0-9]+:/, "", s);
3b0074cc 89
8409a9b2 90 # kill commented out items
b6875e34 91 gsub(/^#[ \t]*/, "", s);
3b0074cc 92
c58d1357 93 # force order
8492c30a 94 gsub(/^Summary\(/, "11Summary(", s);
2ce787c9 95 gsub(/^Summary/, "10Summary", s);
8492c30a 96
985d9bc7
ER
97 gsub(/^Name/, "2Name", s);
98 gsub(/^Version/, "3Version", s);
99 gsub(/^Release/, "4Release", s);
100 gsub(/^Epoch/, "5Epoch", s);
101 gsub(/^License/, "5License", s);
102 gsub(/^Group/, "6Group", s);
103 gsub(/^URL/, "7URL", s);
104
105 gsub(/^BuildRequires/, "B1BuildRequires", s);
106 gsub(/^BuildConflicts/, "B2BuildConflicts", s);
43f8581a 107
43f8581a 108 gsub(/^Suggests/, "X1Suggests", s);
2eef43e9
JB
109 gsub(/^Provides/, "X2Provides", s);
110 gsub(/^Obsoletes/, "X3Obsoletes", s);
111 gsub(/^Conflicts/, "X4Conflicts", s);
112 gsub(/^BuildArch/, "X5BuildArch", s);
985d9bc7
ER
113 gsub(/^ExclusiveArch/, "X6ExclusiveArch", s);
114 gsub(/^ExcludeArch/, "X7ExcludeArch", s);
115 gsub(/^BuildRoot/, "X9BuildRoot", s);
d9e2bd9b 116
8492c30a
ER
117 gsub(/^AutoProv/, "Xx1AutoProv", s);
118 gsub(/^AutoReq/, "Xx2AutoReq", s);
119
d9e2bd9b 120# printf("%s -> %s\n", a""b, s);
89c604c7
ER
121 return s;
122}
123
eee34ffb 124# Comments
22622171 125/^#/ && (description == 0) {
eee34ffb 126 if (/This file does not like to be adapterized!/) {
127 print # print this message
128 while (getline) # print the rest of spec as it is
129 print
130 do_not_touch_anything = 1 # do not touch anything in END()
a4de4386 131 exit(rc = 0)
eee34ffb 132 }
246ad57e 133
eee34ffb 134 # Generally, comments are printed without touching
70a1dc9e 135 sub(/[ \t]+$/, "")
4414eb86 136
50037ea2
PZ
137 if (/#[ \t]*Source.*md5/) {
138 if (usedigest == 1) {
139 sub(/^#[ \t]*Source/, "BuildRequires:\tdigest(%SOURCE", $0)
140 sub(/-md5[ \t]*:[ \t]*/, ") = ", $0)
141 }
4414eb86
ER
142 print $0
143 next
144 }
246ad57e 145}
146
1da27823 147/^%define/ {
93e2a87a 148 # Remove defining _applnkdir (this macro has been included in rpm-3.0.4)
71a4728c 149 if ($2 == "_applnkdir") {
ba4b52a7 150 next
71a4728c 151 }
95b34f9d
ER
152
153 # FIXME: this section will likely never match after cvs->git migration
71a4728c 154 if ($2 == "date") {
4ab1678b
ER
155 if (did_files == 0) {
156 print "%files"
157 print ""
158 did_files = 1
159 }
71a4728c
ER
160 }
161
162 # Do not add %define of _prefix if it already is.
163 if ($2 ~ /^_prefix/) {
164 sub("^"prefix, $3, bindir)
165 sub("^"prefix, $3, sbindir)
166 sub("^"prefix, $3, libdir)
167 sub("^"prefix, $3, datadir)
168 sub("^"prefix, $3, includedir)
169 prefix = $3
170 }
171
172 if ($2 ~ /_bindir/ && !/_sbindir/)
173 bindir = $3
174 if ($2 ~ /_sbindir/)
175 sbindir = $3
a27fac4d
ER
176 if ($2 ~ /_libdir/) {
177 if ($3 ~ /^%\(/) {
178 # TODO: should escape for latter checks like: ($c ~ sysconfdir "/{?cron.")
179 libdir = "%%%%%%%%%%%%%%"
180 } else {
181 libdir = $3
182 }
183 }
93e2a87a
ER
184 if ($2 ~ /_sysconfdir/) {
185 if ($3 ~ /^%\(/) {
186 # TODO: should escape for latter checks like: ($c ~ sysconfdir "/{?cron.")
187 sysconfdir = "%%%%%%%%%%%%%%"
188 } else {
189 sysconfdir = $3
190 }
191 }
a27fac4d
ER
192 if ($2 ~ /_datadir/) {
193 if ($3 ~ /^%\(/) {
194 # TODO: should escape for latter checks like: ($c ~ sysconfdir "/{?cron.")
195 datadir = "%%%%%%%%%%%%%%"
196 } else {
197 datadir = $3
198 }
199 }
71a4728c
ER
200 if ($2 ~ /_includedir/)
201 includedir = $3
202 if ($2 ~ /_mandir/)
203 mandir = $3
204 if ($2 ~ /_infodir/)
205 infodir = $3
c2b069de
ER
206 if ($2 ~ /_docdir/)
207 docdir = $3
71a4728c
ER
208
209 # version related macros
210 if ($2 ~ /^_beta$/)
211 _beta = $3
212 if ($2 ~ /^_rc$/)
213 _rc = $3
59de1799
ER
214 if ($2 ~ /^_pre$/)
215 _pre = $3
71a4728c
ER
216 if ($2 ~ /^_snap$/)
217 _snap = $3
3c5e6e5f
ER
218 if ($2 ~ /^subver$/)
219 subver = $3
71a4728c
ER
220
221 # these are used usually when adapterizing external spec
222 if ($2 ~ /^name$/)
223 name = $3
224 if ($2 ~ /^version$/)
225 version = $3
226 if ($2 ~ /^release$/)
227 release = $3
a39ddef5 228
0ea7c3cd
ER
229 if ($2 ~ /^mod_name$/)
230 mod_name = $3
f5f6280a
ER
231 if ($2 ~ /^_?pearname$/)
232 pearname = $3
d6e33af7
ER
233 if ($2 ~ /^_class$/)
234 pear_class = $3
235 if ($2 ~ /^_subclass$/)
236 pear_subclass = $3
237
238 # kill the _class and _subclass pear macros
239 if ($2 == "_pearname" || $2 == "pearname") {
240 if (pear_class) {
241 gsub("%{_class}", pear_class, $3);
242 }
243 if (pear_subclass) {
244 gsub("%{_subclass}", pear_subclass, $3);
245 }
246 }
0ea7c3cd 247
78d96561 248 sub(/[ \t]+$/, "");
a39ddef5
ER
249 # do nothing further, otherwise adapter thinks we're at preamble
250 print
251 next
1da27823
SZ
252}
253
6c67f9b1
ER
254# Obsolete
255/^%include.*\/usr\/lib\/rpm\/macros\.python$/ {
256 next
257}
258
246ad57e 259################
260# %description #
261################
93e2a87a 262/^%description/, (!/^%description/ && $0 ~ SECTIONS) {
aec1bddb 263 preamble = 0
efe53381 264
3a14bf9d 265 if (/^%description/) {
aec1bddb 266 bod++
236b87ac 267 format_line = ""
268 format_indent = -1
3a14bf9d
SZ
269 }
270
236b87ac 271 # Format description
7b868d98 272 if (ENVIRON["SKIP_DESC"] != 1 && description == 1 && !/^%[a-z]+/ && !/^%description/) {
3a14bf9d 273 if (/^[ \t]*$/) {
236b87ac 274 format_flush(format_line, format_indent)
3a14bf9d 275 print ""
236b87ac 276 format_line = ""
277 format_indent = -1
3a14bf9d 278 } else if (/^[ \t]*[-\*][ \t]*/) {
236b87ac 279 format_flush(format_line, format_indent)
f171fd40 280 match($0, /^[ \t]*/)
236b87ac 281 format_indent = RLENGTH
282 match($0, /^[ \t]*[-\*][ \t]/)
283 format_line = substr($0, RLENGTH)
f171fd40 284 } else
236b87ac 285 format_line = format_line " " $0
aec1bddb 286 next
efe53381 287 }
f171fd40 288
1da27823 289 if (/^%[a-z]+/ && (!/^%description/ || bod == 2)) {
ddb18dd4 290 if (NF > 3 && $2 == "-l") {
291 ll = $1
292 for (i = 4; i <= NF; i++)
293 ll = ll " " $i
294 $0 = ll " -l " $3
295 }
236b87ac 296 format_flush(format_line, format_indent)
efe53381 297 if (bod == 2) {
aec1bddb
SZ
298 bod = 1
299 description = 1
efe53381 300 } else {
aec1bddb
SZ
301 bod = 0
302 description = 0
efe53381 303 }
304 } else
aec1bddb 305 description = 1
bf0a58ea 306}
307
246ad57e 308#########
309# %prep #
310#########
93e2a87a 311/^%prep/, (!/^%prep/ && $0 ~ SECTIONS) {
aec1bddb 312 preamble = 0
4ab1678b 313 did_prep = 1
f171fd40 314
ac779c71
ER
315 use_macros()
316
43c05c3c 317 # Add '-q' to %setup
e780ff0a 318 if (/^%setup/ && !/-q/) {
1da27823 319 sub(/^%setup/, "%setup -q")
e780ff0a
ER
320 }
321
af38fe16 322 if (/^%setup/ && name != "setup") {
e9097b46
ER
323 $0 = fixedsub(name, "%{name}", $0);
324 $0 = fixedsub(version, "%{version}", $0);
4a8d9a70 325 if (_beta) {
e9097b46 326 $0 = fixedsub(_beta, "%{_beta}", $0);
4a8d9a70
ER
327 }
328 if (_rc) {
e9097b46 329 $0 = fixedsub(_rc, "%{_rc}", $0);
4a8d9a70 330 }
59de1799
ER
331 if (_pre) {
332 $0 = fixedsub(_pre, "%{_pre}", $0);
333 }
4a8d9a70 334 if (_snap) {
e9097b46 335 $0 = fixedsub(_snap, "%{_snap}", $0);
4a8d9a70 336 }
3c5e6e5f
ER
337 if (subver) {
338 $0 = fixedsub(subver, "%{subver}", $0);
339 }
4f822e22
ER
340 }
341
10690436 342 if (/^%setup/ && /-n %{name}-%{version}( |$)/) {
e9097b46 343 $0 = fixedsub(" -n %{name}-%{version}", "", $0)
e780ff0a 344 }
b6875e34 345 sub("^%patch ", "%patch0 ");
ac779c71 346
e31553a7
ER
347 # fedora extras
348 if (/^%apply/) {
349 sub("^%apply -n", "%patch");
350 }
351
ac779c71
ER
352 # invalid in %prep
353 sub("^rm -rf \$RPM_BUILD_ROOT.*", "");
bf0a58ea 354}
355
246ad57e 356##########
357# %build #
358##########
93e2a87a 359/^%build/, (!/^%build/ && $0 ~ SECTIONS) {
aec1bddb 360 preamble = 0
bf0a58ea 361
4ab1678b
ER
362 if (did_prep == 0) {
363 print "%prep"
364 print ""
365 did_prep = 1
366 }
367
aec1bddb 368 use_macros()
6ebff802 369 use_tabs()
f171fd40 370
9cb72c72 371 if (/^automake$/)
372 sub(/$/, " -a -c")
373
eb4bf70e 374 if (/LDFLAGS/) {
85e708f2 375 if (/LDFLAGS="-s"/) {
376 removed["LDFLAGS"] = 1
377 next
378 } else {
379 split($0, tmp, "LDFLAGS=")
eb4bf70e 380 count = split(tmp[2], flags, "\"")
85e708f2 381 if (flags[1] != "" && flags[1] !~ "!?debug") {
fde8f52a 382 sub(/-s[" ]?/, "%{rpmldflags} ", flags[1])
85e708f2 383 $0 = tmp[1] line[1] "LDFLAGS=" flags[1] "\""
384 for (i = 2; i < count; i++)
385 $0 = $0 flags[i] "\""
386 }
eb4bf70e 387 }
388 }
389
390 if (/CFLAGS=/)
391 if (cflags("CFLAGS") == 0)
392 next
393
394 if (/CXXFLAGS=/)
395 if (cflags("CXXFLAGS") == 0)
396 next
f171fd40 397
85e708f2 398 if (/^export /) {
399 if (removed["LDFLAGS"])
400 sub(" LDFLAGS", "")
401 if (removed["CFLAGS"])
402 sub(" CFLAGS", "")
403 if (removed["CXXFLAGS"])
404 sub(" CXXFLAGS", "")
405 # Is there still something?
406 if (/^export[ ]*$/)
407 next
408 }
2d74be7e 409
db9b1bf2 410 # quote CC
2d74be7e
ER
411 if (/CC=%{__cc} /) {
412 sub("CC=%{__cc}", "CC=\"%{__cc}\"")
413 }
b34b8660 414
e6f1551d 415 # use PLD Linux macros
b34b8660
ER
416 $0 = fixedsub("glib-gettextize --copy --force","%{__glib_gettextize}", $0);
417 $0 = fixedsub("intltoolize --copy --force", "%{__intltoolize}", $0);
db9b1bf2 418 $0 = fixedsub("automake --add-missing --copy", "%{__automake}", $0);
56699a32 419 $0 = fixedsub("automake -a --foreign --copy", "%{__automake}", $0);
4e26c5f2 420 $0 = fixedsub("automake -a -c --foreign", "%{__automake}", $0);
ebeed758 421 $0 = fixedsub("automake -a -c", "%{__automake}", $0);
56699a32
ER
422 $0 = fixedsub("libtoolize --force --automake --copy", "%{__libtoolize}", $0);
423 $0 = fixedsub("libtoolize -c -f --automake", "%{__libtoolize}", $0);
db9b1bf2
ER
424
425 sub(/^aclocal$/, "%{__aclocal}");
426 sub(/^autoheader$/, "%{__autoheader}");
427 sub(/^autoconf$/, "%{__autoconf}");
428 sub(/^automake$/, "%{__automake}");
ebeed758 429 sub(/^libtoolize$/, "%{__libtoolize}");
f171fd40 430
5e15e952
ER
431 # atrpms
432 $0 = fixedsub("%perl_configure", "%{__perl} Makefile.PL \\\n\tINSTALLDIRS=vendor", $0);
433 $0 = fixedsub("%perl_makecheck", "%{?with_tests:%{__make} test}", $0);
377e5b9e
ER
434
435 # alt linux
436 $0 = fixedsub("%make_build", "%{__make}", $0);
bf0a58ea 437}
438
246ad57e 439##########
440# %clean #
441##########
93e2a87a 442/^%clean/, (!/^%clean/ && $0 ~ SECTIONS) {
1c52b18e 443 did_clean = 1
e6f1551d 444
b6875e34 445 use_macros()
1c52b18e
SZ
446}
447
246ad57e 448############
449# %install #
450############
93e2a87a 451/^%install/, (!/^%install/ && $0 ~ SECTIONS) {
f171fd40 452
aec1bddb 453 preamble = 0
f171fd40 454
ec0082cc 455 # foreign rpms
624df313 456 sub("^%{__rm} -rf %{buildroot}", "rm -rf $RPM_BUILD_ROOT")
b6875e34
ER
457 sub("%buildroot", "$RPM_BUILD_ROOT");
458 sub("%{buildroot}", "$RPM_BUILD_ROOT");
ec0082cc 459
624df313 460 if (/^[ \t]*rm([ \t]+-[rf]+)*[ \t]+(\${?RPM_BUILD_ROOT}?|%{?buildroot}?)/ && did_rmroot==0) {
1c52b18e 461 did_rmroot=1
dda3eaa5
SZ
462 print "rm -rf $RPM_BUILD_ROOT"
463 next
464 }
43c05c3c 465
1c52b18e 466 if (!/^(#?[ \t]*)$/ && !/^%install/ && did_rmroot==0) {
dda3eaa5 467 print "rm -rf $RPM_BUILD_ROOT"
1c52b18e 468 did_rmroot=1
dda3eaa5 469 }
f171fd40 470
b6875e34
ER
471 if (tmpdir) {
472 buildroot = tmpdir "/" name "-" version "-root-" ENVIRON["USER"]
3d8be7c3 473 gsub(buildroot, "$RPM_BUILD_ROOT")
b6875e34 474 }
3d8be7c3 475
b6875e34
ER
476 if (!/%{_lib}/) {
477 sub("\$RPM_BUILD_ROOT/%", "$RPM_BUILD_ROOT%")
478 }
259883bf 479
dda3eaa5 480 use_macros()
f171fd40 481
bf0a58ea 482 # 'install -d' instead 'mkdir -p'
483 if (/mkdir -p/)
aec1bddb 484 sub(/mkdir -p/, "install -d")
fde90d94 485
48409aee 486 # cp -a already implies cp -r
b6875e34 487 sub(/^cp -ar/, "cp -a")
f171fd40 488
43c05c3c 489 # No '-u root' or '-g root' for 'install'
681a4871 490 if (/^install/ && /-[ug][ \t]*root/)
aec1bddb 491 gsub(/-[ug][ \t]*root /, "")
f171fd40 492
2016aa83
ER
493 if (/^install/ && /-m[ \t]*[0-9]+/)
494 gsub(/-m[ \t]*[0-9]+ /, "")
f171fd40 495
f1991554 496 # No lines contain 'chown' or 'chgrp' if owner/group is 'root'
43c05c3c 497 if (($1 ~ /chown/ && $2 ~ /root\.root/) || ($1 ~ /chgrp/ && $2 ~ /root/))
aec1bddb 498 next
f171fd40 499
43c05c3c 500 # No lines contain 'chmod' if it sets the modes to '644'
681a4871 501 if ($1 ~ /chmod/ && $2 ~ /644/)
aec1bddb 502 next
5e15e952 503
5e15e952
ER
504 # atrpms
505 $0 = fixedsub("%perl_makeinstall", "%{__make} pure_install \\\n\tDESTDIR=$RPM_BUILD_ROOT", $0);
377e5b9e
ER
506
507 # alt linux
508 $0 = fixedsub("%make_install DESTDIR=$RPM_BUILD_ROOT install", "%{__make} install \\\n\tDESTDIR=$RPM_BUILD_ROOT", $0);
bf0a58ea 509}
510
246ad57e 511##########
512# %files #
513##########
93e2a87a 514/^%files/, (!/^%files/ && $0 ~ SECTIONS) {
aec1bddb 515 preamble = 0
4ab1678b 516 did_files = 1
f171fd40 517
1da27823 518 if ($0 ~ /^%files/)
aec1bddb 519 defattr = 1
f171fd40 520
484bbf6d
ER
521 if (!use_files_macros()) {
522 next
523 }
bf0a58ea 524}
525
246ad57e 526###########
527# SCRIPTS #
528###########
93e2a87a 529/^%pre/, (!/^%pre/ && $0 ~ SECTIONS) {
246ad57e 530 preamble = 0
e9176470 531
723ce732
ER
532 if (gsub("/usr/sbin/useradd", "%useradd")) {
533 sub(" 2> /dev/null \|\| :", "");
534 sub(" >/dev/null 2>&1 \|\|:", "");
535 }
536
e31553a7
ER
537 # fedora extras macros
538 if (/%__fe_useradd/) {
539 sub("%__fe_useradd", "%useradd -u ");
540 sub(" 2> /dev/null \|\| :", "");
541 sub(" >/dev/null 2>&1 \|\|:", "");
542 sub(" &>/dev/null \\|\\| :", "");
543 }
544
545 if (/%__fe_groupadd/) {
546 sub("%__fe_groupadd", "%groupadd -g ");
547 sub(" &>/dev/null \\|\\| :", "");
548 }
549
e9176470
ER
550 # %useradd and %groupadd may not be wrapped
551 if (/%(useradd|groupadd).*\\$/) {
552 a = $0; getline;
553 sub(/^[\s\t]*/, "");
554 $0 = substr(a, 1, length(a) - 1) $0;
555 }
723ce732 556 use_script_macros()
246ad57e 557}
e9176470 558
93e2a87a 559/^%post/, (!/^%post/ && $0 ~ SECTIONS) {
246ad57e 560 preamble = 0
e31553a7
ER
561
562 # fedora extras macros
563 sub("%__chkconfig", "/sbin/chkconfig");
564
a6490001
ER
565 sub("update-desktop-database &> /dev/null \\|\\| :", "%update_desktop_database");
566 sub("touch --no-create %{_datadir}/icons/hicolor", "%update_icon_cache_post hicolor");
567 sub("if \\[ -x %{_bindir}/gtk-update-icon-cache \\]; then\n\t%{_bindir}/gtk-update-icon-cache -q %{_datadir}/icons/hicolor \|\| :\nfi", "");
568
569 sub("export GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source`", "")
570 if (/gconftool-2 --makefile-install-rule/) {
571 sub("gconftool-2 --makefile-install-rule %{_sysconfdir}/gconf/schemas/", "%gconf_schema_install ")
24873dc2 572 sub("> /dev/null", "");
a6490001
ER
573 }
574
c2b069de 575 use_macros()
246ad57e 576}
93e2a87a 577/^%preun/, (!/^%preun/ && $0 ~ SECTIONS) {
246ad57e 578 preamble = 0
d11acde9 579 use_macros()
246ad57e 580}
93e2a87a 581/^%postun/, (!/^%postun/ && $0 ~ SECTIONS) {
246ad57e 582 preamble = 0
e31553a7
ER
583
584 # fedora extras macros
585 if (/%__fe_userdel|%__fe_groupdel/) {
586 sub("%__fe_groupdel", "%groupremove");
587 sub("%__fe_userdel", "%userremove");
588 sub(" &>/dev/null \\|\\| :", "");
589 }
590
723ce732 591 use_script_macros()
246ad57e 592}
93e2a87a 593/^%triggerin/, (!/^%triggerin/ && $0 ~ SECTIONS) {
bdba3986 594 preamble = 0
723ce732 595 use_script_macros()
bdba3986 596}
93e2a87a 597/^%triggerun/, (!/^%triggerun/ && $0 ~ SECTIONS) {
bdba3986 598 preamble = 0
723ce732 599 use_script_macros()
bdba3986 600}
93e2a87a 601/^%triggerpostun/, (!/^%triggerpostun/ && $0 ~ SECTIONS) {
bdba3986 602 preamble = 0
723ce732 603 use_script_macros()
bdba3986 604}
93e2a87a 605/^%pretrans/, (!/^%pretrans/ && $0 ~ SECTIONS) {
bdba3986 606 preamble = 0
723ce732 607 use_script_macros()
bdba3986 608}
93e2a87a 609/^%posttrans/, (!/^%posttrans/ && $0 ~ SECTIONS) {
bdba3986 610 preamble = 0
723ce732 611 use_script_macros()
bdba3986 612}
0ae11f54
ER
613/^%verifyscript/, (!/^%verifyscript/ && $0 ~ SECTIONS) {
614 preamble = 0
723ce732 615 use_script_macros()
0ae11f54
ER
616}
617/^%check/, (!/^%check/ && $0 ~ SECTIONS) {
618 preamble = 0
723ce732 619 use_script_macros()
0ae11f54 620}
246ad57e 621
622#############
623# PREAMBLES #
624#############
bf0a58ea 625preamble == 1 {
681a4871 626 # There should not be a space after the name of field
627 # and before the colon.
aec1bddb 628 sub(/[ \t]*:/, ":")
f171fd40 629
1462d6a3
ER
630 if (/^%perl_module_wo_prefix/) {
631 name = $2
632 version = $3
633 release = "0." fixedsub(".%{disttag}.at", "", $4)
634 }
635
aec1bddb 636 field = tolower($1)
38cb34ef 637 if (field ~ /summary:/ && !/etc\.$/ && !/Inc\.$/) {
024709c6
ER
638 sub(/\.$/, "", $0);
639 }
f37c1259 640 if (field ~ /group(\([^)]+\)):/)
1a5b27d5 641 next
f37c1259 642 if (field ~ /group:/) {
643 format_preamble()
d9e2bd9b
ER
644 group = $0;
645 sub(/^[^ \t]*[ \t]*/, "", group);
ad9ea417 646 group = replace_groupnames(group);
d9e2bd9b
ER
647 $0 = "Group:\t\t" group
648
649 if (group ~ /^X11/ && x11 == 0) # Is it X11 application?
7a72f436 650 x11 = 1
8e5358f8 651
d9e2bd9b 652 byl_plik_z_groupmi = 0
8e5358f8
SZ
653 byl_opis_grupy = 0
654 while ((getline linia_grup < groups_file) > 0) {
d9e2bd9b
ER
655 byl_plik_z_groupmi = 1
656 if (linia_grup == group) {
8e5358f8
SZ
657 byl_opis_grupy = 1
658 break
659 }
660 }
69501a12 661
d9e2bd9b 662 if (!byl_plik_z_groupmi)
8e5358f8
SZ
663 print "######\t\t" groups_file ": no such file"
664 else if (!byl_opis_grupy)
665 print "######\t\t" "Unknown group!"
f171fd40 666
8e5358f8 667 close(groups_file)
4ab1678b 668 did_groups = 1
8e5358f8 669 }
f171fd40 670
307f5229 671 if (field ~ /prereq:/) {
a68f7b3b 672 sub(/Pre[Rr]eq:/, "Requires:", $1);
307f5229
ER
673 }
674
4aa6db15 675 # split (build)requires, obsoletes on commas
21a50087 676 if (field ~ /(obsoletes|requires|provides|conflicts|suggests):/ && NF > 2) {
ba377afe
ER
677 value = substr($0, index($0, $2));
678 $0 = format_requires($1, value);
f12ab15d 679 }
b6875e34 680
8e734165
ER
681 # BR: tar (and others) is to common (rpm-build requires it)
682 if (field ~ /^buildrequires:/) {
eb028bca
ER
683 l = substr($0, index($0, $2));
684 if (l == "awk" ||
685 l == "binutils" ||
686 l == "bzip2" ||
687 l == "cpio" ||
688 l == "diffutils" ||
689 l == "elfutils" ||
690 l == "fileutils" ||
691 l == "findutils" ||
692 l == "glibc-devel" ||
693 l == "grep" ||
694 l == "gzip" ||
695 l == "make" ||
696 l == "patch" ||
697 l == "sed" ||
698 l == "sh-utils" ||
699 l == "tar" ||
700 l == "textutils") {
8e734165
ER
701 next
702 }
d0297fb3 703
92fa789e 704 replace_requires();
8e734165
ER
705 }
706
e27788d1 707 if (field ~ /^requires:/ || field ~ /^requires\(/) {
92fa789e 708 replace_requires();
b6875e34 709 }
30cd4686
ER
710
711
ff21ed9e 712 # obsolete/unwanted tags
32908bc5 713 if (field ~ /vendor:|packager:|distribution:|docdir:|prefix:|icon:|author:|author-email:|metadata-version:/) {
aec1bddb 714 next
ba377afe 715 }
f171fd40 716
4ab1678b 717 if (field ~ /buildroot:/) {
376e6bc4 718 $0 = $1 "%{tmpdir}/%{name}-%{version}-root-%(id -u -n)"
4ab1678b
ER
719 did_build_root = 1
720 }
681a4871 721
681a4871 722 # Use "License" instead of "Copyright" if it is (L)GPL or BSD
4932d2c6 723 if (field ~ /copyright:/ && $2 ~ /GPL|BSD/) {
aec1bddb 724 $1 = "License:"
4932d2c6 725 }
f171fd40 726
ad2932df
ER
727 # ease updating from debian .dsc
728 if (field ~ /homepage:/) {
729 $1 = "URL:"
730 }
731
517313c5
ER
732 # suse
733 if (field ~ /recommends:/) {
734 $1 = "Suggests:"
735 }
736
4defab2b 737 if ($3 == "==" && $1 !~ /%/) {
517313c5
ER
738 $3 = "="
739 }
740
3b07e07f
ER
741 if (field ~ /license:/) {
742 l = substr($0, index($0, $2));
743 if (l == "Python Software Foundation License") {
744 l = "PSF"
745 }
6112ae02
ER
746 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") {
747 l = "Apache v2.0"
748 }
749 if (l == "Apache Group License" || l == "Apache Software License" || l == "Apache License") {
750 l = "Apache"
751 }
752 if (l == "Apache-style License" || l == "Apache-style Software License") {
753 l = "Apache-like"
754 }
755 if (l == "Apache Software License 1.1" || l == "Apache 1.1") {
756 l = "Apache v1.1"
757 }
ee9487af
ER
758 if (l == "GPLv2") {
759 l = "GPL v2"
760 }
761 if (l == "GPLv2+") {
762 l = "GPL v2+"
763 }
407e19de
ER
764 if (l == "GPL v2 or later") {
765 l = "GPL v2+"
766 }
517313c5
ER
767 if (l == "LGPL v2.0 only") {
768 l = "LGPL v2"
769 }
af8efb29
ER
770 if (l == "LGPLv2+") {
771 l = "LGPL v2+"
772 }
471a5464
ER
773 if (l == "GPLv3") {
774 l = "GPL v3"
775 }
776 if (l == "GPLv3+") {
777 l = "GPL v3+"
778 }
e02ad475
ER
779 if (l == "MPLv1.1") {
780 l = "MPL v1.1"
781 }
3b07e07f
ER
782 $0 = "License:\t" l;
783 }
784
785
1462d6a3 786 if (field ~ /name:/) {
6426afb8 787 if ($2 == "%{name}" && name) {
63d47bae
ER
788 $2 = name
789 }
aec1bddb 790 name = $2
1462d6a3
ER
791 name_seen = 1;
792 }
681a4871 793
1462d6a3 794 if (field ~ /version:/) {
63d47bae
ER
795 if ($2 == "%{version}" && version) {
796 $2 = version
797 }
aec1bddb 798 version = $2
1462d6a3
ER
799 version_seen = 1;
800 }
801
802 if (field ~ /release:/) {
63d47bae
ER
803 if ($2 == "%{release}" && release) {
804 $2 = release
805 }
4ab1678b 806 sub(/%atrelease /, "0.", $0)
1462d6a3
ER
807 release = $2
808 release_seen = 1;
809 }
681a4871 810
32908bc5 811
c4dde22b
SZ
812 if (field ~ /serial:/)
813 $1 = "Epoch:"
b6853342 814
32908bc5
ER
815 if (field ~ /home-page:/)
816 $1 = "URL:"
817
89b1cd55 818 # proper caps
cf038723 819 if (field ~ /^url:$/)
89b1cd55
ER
820 $1 = "URL:"
821
471a5464
ER
822 if (field ~ /^patch/)
823 $1 = "Patch" substr(field, 6);
824
32908bc5
ER
825 if (field ~ /^description:$/)
826 $1 = "\n%description\n"
827
681a4871 828 # Use %{name} and %{version} in the filenames in "Source:"
f4cb1924 829 if (field ~ /^source/ || field ~ /patch/) {
aec1bddb 830 n = split($2, url, /\//)
fd8718a5
SZ
831 if (url[n] ~ /\.gz$/) {
832 url[n+1] = ".gz" url[n+1]
833 sub(/\.gz$/,"",url[n])
834 }
835 if (url[n] ~ /\.zip$/) {
836 url[n+1] = ".zip" url[n+1]
837 sub(/\.zip$/,"",url[n])
838 }
839 if (url[n] ~ /\.tar$/) {
840 url[n+1] = ".tar" url[n+1]
841 sub(/\.tar$/,"",url[n])
842 }
843 if (url[n] ~ /\.patch$/) {
844 url[n+1] = ".patch" url[n+1]
845 sub(/\.patch$/,"",url[n])
846 }
847 if (url[n] ~ /\.bz2$/) {
848 url[n+1] = ".bz2" url[n+1]
849 sub(/\.bz2$/,"",url[n])
850 }
dac4e142
SZ
851 if (url[n] ~ /\.logrotate$/) {
852 url[n+1] = ".logrotate" url[n+1]
853 sub(/\.logrotate$/,"",url[n])
854 }
855 if (url[n] ~ /\.pamd$/) {
856 url[n+1] = ".pamd" url[n+1]
857 sub(/\.pamd$/,"",url[n])
858 }
859
a3fcc309 860 # allow %{name} only in last url component
ced0372e
ER
861 s = ""
862 for (i = 1; i <= n; i++) {
863 url[i] = fixedsub("%{name}", name, url[i])
864 if (s) {
865 s = s "/" url[i]
866 } else {
867 s = url[i]
868 }
869 }
870 $2 = s url[n+1]
871
aec1bddb 872 filename = url[n]
5e028343
ER
873 if (name) {
874 url[n] = fixedsub(name, "%{name}", url[n])
875 }
755ab9c0 876 if (field ~ /source/) {
5e028343
ER
877 if (version) {
878 url[n] = fixedsub(version, "%{version}", url[n])
879 }
755ab9c0
ER
880 if (_beta) {
881 url[n] = fixedsub(_beta, "%{_beta}", url[n])
882 }
883 if (_rc) {
884 url[n] = fixedsub(_rc, "%{_rc}", url[n])
885 }
59de1799
ER
886 if (_pre) {
887 url[n] = fixedsub(_pre, "%{_pre}", url[n])
888 }
755ab9c0
ER
889 if (_snap) {
890 url[n] = fixedsub(_snap, "%{_snap}", url[n])
891 }
3c5e6e5f
ER
892 if (subver) {
893 url[n] = fixedsub(subver, "%{subver}", url[n])
894 }
755ab9c0 895 }
57caba32 896 # assigning to $2 kills preamble formatting
fd8718a5 897 $2 = fixedsub(filename, url[n], $2)
f171fd40 898
8ea8f0ae 899 $2 = unify_url($2)
681a4871 900 }
8b1938ea 901
f171fd40 902
f4cb1924 903 if (field ~ /^source:/)
f171fd40 904 $1 = "Source0:"
aec1bddb 905
13b24a87 906 if (field ~ /^patch:/)
aec1bddb 907 $1 = "Patch0:"
f171fd40 908
0ea7c3cd 909 kill_preamble_macros();
aec1bddb 910 format_preamble()
f171fd40 911
c26ee7ef
ER
912 if (field ~ /requires/) {
913 # atrpms
914 $0 = fixedsub("%{eversion}", "%{epoch}:%{version}-%{release}", $0);
915 }
bf0a58ea 916}
917
4c1b7426
ER
918/^%bcond_/ {
919 # do nothing
920 print
921 next
922}
c58d1357
ER
923
924# sort BR/R!
925#
926# NOTES:
927# - mixing BR/R and anything else confuses this (all will be sorted together)
b6875e34 928# so don't do that.
c58d1357 929# - comments leading the BR/R can not be associated,
b6875e34 930# so don't adapterize when the BR/R are mixed with comments
a6b7c72d 931ENVIRON["SKIP_SORTBR"] != 1 && preamble == 1 && $0 ~ PREAMBLE_TAGS ":", $0 ~ PREAMBLE_TAGS ":"{
57caba32 932 if ($1 ~ /Pre[Rr]eq:/) {
a68f7b3b 933 sub(/Pre[Rr]eq:/, "Requires:", $1);
c58d1357 934 }
23ddcab1
ER
935 if ($1 == "BR:" ) {
936 $1 = "BuildRequires:"
937 }
938 if ($1 == "R:" ) {
939 $1 = "Requires:"
940 }
c58d1357 941 format_preamble()
8f7c516b 942# kill_preamble_macros(); # breaks tabbing
c58d1357
ER
943
944 b_idx++;
945 l = substr($0, index($0, $2));
946 b_ktmp = b_makekey($1, l);
947 b_key[b_idx] = b_ktmp;
948 b_val[b_ktmp] = $0;
949
950 next;
951}
952
c58d1357
ER
953preamble == 1 {
954 if (b_idx > 0) {
955 isort(b_key, b_idx);
956 for (i = 1; i <= b_idx; i++) {
4932d2c6
ER
957 v = b_val[b_key[i]];
958 sub(/[ \t]+$/, "", v);
959 print "" v;
c58d1357
ER
960 }
961 b_idx = 0
962 }
963}
964
7a72f436 965# main() ;-)
bf0a58ea 966{
aec1bddb 967 preamble = 1
f171fd40 968
70a1dc9e 969 sub(/[ \t]+$/, "")
aec1bddb 970 print
1462d6a3
ER
971
972 if (name_seen == 0 && name) {
31702e1e 973 print "Name:\t\t" name
1462d6a3
ER
974 name_seen = 1
975 }
976
977 if (version_seen == 0 && version) {
978 print "Version:\t" version
979 version_seen = 1
980 }
981
982 if (release_seen == 0 && release) {
983 print "Release:\t" release
984 release_seen = 1
985 }
32908bc5
ER
986
987 if (did_build_root == 0) {
4ab1678b 988# print "BuildRoot:\t%{tmpdir}/%{name}-%{version}-root-%(id -u -n)"
32908bc5
ER
989 did_build_root = 1
990 }
4ab1678b
ER
991 if (did_groups == 0) {
992# print "Group:\t\tunknown"
993 did_groups = 1
994 }
a1aa4976 995}
996
f1991554 997
a1aa4976 998END {
a4de4386
ER
999 if (do_not_touch_anything) {
1000 exit(rc)
1001 }
f171fd40 1002
b6875e34
ER
1003 # TODO: need to output these in proper place
1004 if (BR_count > 0) {
1005 for (i = 0; i <= BR_count; i++) {
1006 print BR[i];
1007 }
1008 }
1c955424 1009
1c52b18e
SZ
1010 if (did_clean == 0) {
1011 print ""
1012 print "%clean"
1013 print "rm -rf $RPM_BUILD_ROOT"
1014 }
bf0a58ea 1015}
1016
fd8718a5 1017# substitutes fixed strings (not regexps)
98e37f1f 1018function fixedsub(s1,s2,t, ind) {
7a72f436 1019 if (ind = index(t,s1))
1020 t = substr(t, 1, ind-1) s2 substr(t, ind+length(s1))
1021 return t
fd8718a5
SZ
1022}
1023
98e37f1f
ER
1024# replace s with s2 if it equals to s1
1025function replace(s, s1, s2) {
1026 if (s == s1) {
1027 return s2;
1028 } else {
1029 return s;
1030 }
1031}
1032
8b1938ea 1033# There should be one or two tabs after the colon.
1034function format_preamble()
1035{
57caba32 1036 if (/^#/ || /^%bcond_with/) {
08f60a73
ER
1037 return;
1038 }
aec1bddb 1039 sub(/:[ \t]*/, ":")
2b94cfb4
ER
1040 if (match($0, /[A-Za-z0-9(),#_ \t.-]+[ \t]*:[ \t]*/) == 1) {
1041 if (RLENGTH < 8) {
aec1bddb 1042 sub(/:/, ":\t\t")
b6875e34 1043 } else {
aec1bddb 1044 sub(/:/, ":\t")
b6875e34 1045 }
8b1938ea 1046 }
1047}
1048
43c05c3c 1049# Replace directly specified directories with macros
1050function use_macros()
1051{
13b24a87
ER
1052 # -m, --skip-macros, --no-macros -- skip macros subst
1053 if (ENVIRON["SKIP_MACROS"]) {
1054 return
1055 }
1056
b05d5275
ER
1057 # leave inline sed lines alone
1058 if (/(%{__sed}|sed) -i -e/) {
1059 return;
1060 }
1061
b6875e34
ER
1062 sub("%{_defaultdocdir}", "%{_docdir}");
1063 sub("%{_bindir}/perl", "%{__perl}");
1064 sub("%{_bindir}/python", "%{__python}");
36d9a33d 1065
a372a159
ER
1066 gsub(infodir, "%{_infodir}")
1067
336c1a4f
ER
1068 gsub(perl_sitearch, "%{perl_sitearch}")
1069 gsub(perl_archlib, "%{perl_archlib}")
1070 gsub(perl_privlib, "%{perl_privlib}")
336c1a4f
ER
1071 gsub(perl_vendorlib, "%{perl_vendorlib}")
1072 gsub(perl_vendorarch, "%{perl_vendorarch}")
1073 gsub(perl_sitelib, "%{perl_sitelib}")
9732cb3d
ER
1074
1075 gsub(py_sitescriptdir, "%{py_sitescriptdir}")
4ab1678b 1076 gsub(py_sitedir, "%{py_sitedir}")
1bdf7824 1077 gsub(py_scriptdir, "%{py_scriptdir}")
ae4d1624
ER
1078
1079 gsub(py3_sitescriptdir, "%{py3_sitescriptdir}")
1080 gsub(py3_sitedir, "%{py3_sitedir}")
1081 gsub(py3_scriptdir, "%{py3_scriptdir}")
6f2c1099
ER
1082
1083 gsub(ruby_archdir, "%{ruby_archdir}")
1084 gsub(ruby_ridir, "%{ruby_ridir}")
1085 gsub(ruby_rubylibdir, "%{ruby_rubylibdir}")
1086 gsub(ruby_sitearchdir, "%{ruby_sitearchdir}")
1087 gsub(ruby_sitelibdir, "%{ruby_sitelibdir}")
51847161 1088 gsub(ruby_rdocdir, "%{ruby_rdocdir}")
6f2c1099 1089
85084f0d
ER
1090 gsub(systemdunitdir, "%{systemdunitdir}")
1091 gsub(systemdtmpfilesdir, "%{systemdtmpfilesdir}")
1092
4a62fb54
ER
1093 gsub("%{_datadir}/applications", "%{_desktopdir}")
1094 gsub("%{_datadir}/pixmaps", "%{_pixmapsdir}")
ee9487af 1095 gsub("%{_datadir}/java", "%{_javadir}")
336c1a4f 1096
a4de4386
ER
1097 gsub("%{_libdir}/pkgconfig", "%{_pkgconfigdir}")
1098 gsub(pkgconfigdir, "%{_pkgconfigdir}")
1099
1c298a13
ER
1100 gsub("%{_datadir}/pkgconfig", "%{_npkgconfigdir}")
1101 gsub(npkgconfigdir, "%{_npkgconfigdir}")
1102
4efeac87
ER
1103 gsub("%{_datadir}/locale", "%{_localedir}")
1104 gsub(localedir, "%{_localedir}")
1105
e00f41b5 1106 gsub(libdir, "%{_libdir}")
ee9487af 1107 gsub(javadir, "%{_javadir}")
e00f41b5 1108
aec1bddb 1109 gsub(bindir, "%{_bindir}")
74edc57e 1110 gsub("%{prefix}/bin", "%{_bindir}")
b05d5275 1111 if (prefix"/bin" == bindir)
0080f34c 1112 gsub("%{_prefix}/bin", "%{_bindir}")
74edc57e 1113
de69503c 1114 for (c = 1; c <= NF; c++) {
1115 if ($c ~ sbindir "/fix-info-dir")
1116 continue;
3457b4f7
ER
1117 if ($c ~ sbindir "/webapp")
1118 continue;
a372a159
ER
1119 if ($c ~ sbindir "/ldconfig")
1120 continue;
4837c1e3
ER
1121 if ($c ~ sbindir "/chsh")
1122 continue;
1123 if ($c ~ sbindir "/usermod")
1124 continue;
f06959ff
ER
1125 if ($c ~ sbindir "/chkconfig")
1126 continue;
836e411f
ER
1127 if ($c ~ sbindir "/installzope(product|3package)")
1128 continue;
de69503c 1129 gsub(sbindir, "%{_sbindir}", $c)
1130 }
1131
74edc57e 1132 gsub("%{prefix}/sbin", "%{_sbindir}")
836e411f 1133 if (prefix"/sbin" == sbindir) {
5e1d0492 1134 gsub("%{_prefix}/sbin", "%{_sbindir}")
836e411f 1135 }
74edc57e 1136
353f5eea 1137 for (c = 1; c <= NF; c++) {
0965a1a0 1138 if ($c ~ sysconfdir "/{?cron.")
de69503c 1139 continue;
0080f34c 1140 if ($c ~ sysconfdir "/{?crontab.d")
807a0f6b 1141 continue;
6c178315
ER
1142 if ($c ~ sysconfdir "/{?env.d")
1143 continue;
90a421f5 1144 if ($c ~ sysconfdir "/{?modprobe.(d|conf)")
554d6b98 1145 continue;
5d7c48a4
ER
1146 if ($c ~ sysconfdir "/{?udev")
1147 continue;
1148 if ($c ~ sysconfdir "/{?hotplug")
e61b5989 1149 continue;
0080f34c 1150 if ($c ~ sysconfdir "/{?logrotate.d")
353f5eea 1151 continue;
0080f34c 1152 if ($c ~ sysconfdir "/{?pam.d")
a9b2c8c7 1153 continue;
0080f34c 1154 if ($c ~ sysconfdir "/{?profile.d")
66ef7810 1155 continue;
0080f34c 1156 if ($c ~ sysconfdir "/{?rc.d")
9ad7f20b 1157 continue;
0080f34c 1158 if ($c ~ sysconfdir "/{?security")
a9b2c8c7 1159 continue;
0080f34c 1160 if ($c ~ sysconfdir "/{?skel")
c21d1979 1161 continue;
0080f34c 1162 if ($c ~ sysconfdir "/{?sysconfig")
66ef7810 1163 continue;
6e985933
ER
1164 if ($c ~ sysconfdir "/{?shrc.d")
1165 continue;
7c73bc0f
ER
1166 if ($c ~ sysconfdir "/{?certs")
1167 continue;
de5d18d8
ER
1168 if ($c ~ sysconfdir "/{?X11")
1169 continue;
5debd9f6
ER
1170 if ($c ~ sysconfdir "/{?ld.so.conf.d")
1171 continue;
ff21ed9e
ER
1172 if ($c ~ sysconfdir "/{?rpm")
1173 continue;
57caba32 1174 if ($c ~ sysconfdir "/{?bash_completion.d")
6e985933 1175 continue;
57caba32 1176 if ($c ~ sysconfdir "/{?samba")
9292b547 1177 continue;
b371c36f
ER
1178 if ($c ~ sysconfdir "/{?xdg")
1179 continue;
52a943cf
ER
1180 if ($c ~ sysconfdir "/shells")
1181 continue;
b371c36f
ER
1182 if ($c ~ sysconfdir "/inittab")
1183 continue;
98e9501e
ER
1184 if ($c ~ sysconfdir "/init")
1185 continue;
5dc7f5e4
ER
1186 if ($c ~ sysconfdir "/ppp")
1187 continue;
9395915a
ER
1188 if ($c ~ sysconfdir "/dbus-1")
1189 continue;
be827f42
ER
1190 if ($c ~ sysconfdir "/tmpwatch")
1191 continue;
471a5464
ER
1192 if ($c ~ sysconfdir "/acpi")
1193 continue;
1194 if ($c ~ sysconfdir "/apm")
1195 continue;
353f5eea 1196 gsub(sysconfdir, "%{_sysconfdir}", $c)
1197 }
74edc57e 1198
c2b069de 1199 gsub(docdir, "%{_docdir}")
7cb79e98
ER
1200
1201 gsub(kdedocdir, "%{_kdedocdir}")
1202
1203 gsub(gtkdocdir, "%{_gtkdocdir}")
1204 gsub("%{_docdir}/gtk-doc/html", "%{_gtkdocdir}")
1205
57caba32 1206 gsub(php_pear_dir, "%{php_pear_dir}")
4b1d6e6d 1207 gsub(php_data_dir, "%{php_data_dir}")
c2b069de 1208
c4adc376
ER
1209 for (c = 1; c <= NF; c++) {
1210 if ($c ~ datadir "/automake")
1211 continue;
13670287
ER
1212 if ($c ~ datadir "/unsermake")
1213 continue;
a9fb2db8
ER
1214 if ($c ~ datadir "/file/magic.mime")
1215 continue;
c4adc376
ER
1216 gsub(datadir, "%{_datadir}", $c)
1217 }
1218
74edc57e 1219 gsub("%{prefix}/share", "%{_datadir}")
c4adc376 1220 if (prefix"/share" == datadir)
0080f34c 1221 gsub("%{_prefix}/share", "%{_datadir}")
74edc57e 1222
826b40ea
ER
1223 # CFLAGS="-I/usr/include/ncurses is usually correct.
1224 if (!/-I\/usr\/include/) {
1225 gsub(includedir, "%{_includedir}")
1226 }
1227
74edc57e 1228 gsub("%{prefix}/include", "%{_includedir}")
826b40ea 1229 if (prefix"/include" == includedir) {
0080f34c 1230 gsub("%{_prefix}/include", "%{_includedir}")
826b40ea 1231 }
74edc57e 1232
aec1bddb 1233 gsub(mandir, "%{_mandir}")
826b40ea 1234 if ($0 !~ "%{_datadir}/manual") {
5e1d0492 1235 gsub("%{_datadir}/man", "%{_mandir}")
826b40ea 1236 }
9ce0df66 1237 gsub("%{_prefix}/share/man", "%{_mandir}")
1238 gsub("%{prefix}/share/man", "%{_mandir}")
74edc57e 1239 gsub("%{prefix}/man", "%{_mandir}")
1240 gsub("%{_prefix}/man", "%{_mandir}")
1241
aec1bddb 1242 gsub(infodir, "%{_infodir}")
74edc57e 1243 gsub("%{prefix}/info", "%{_infodir}")
1244 gsub("%{_prefix}/info", "%{_infodir}")
1245
0965a1a0 1246 if (prefix !~ "/X11R6") {
1247 gsub("%{_datadir}/aclocal", "%{_aclocaldir}")
1248 }
cfbf94ec 1249
2a638fcb 1250 gsub(examplesdir, "%{_examplesdir}")
7c6b85c4 1251
efd2d668 1252 if (prefix != "/") {
a9fb2db8
ER
1253 # leave --with-foo=/usr alone
1254 if ($0 !~ "--with.*=.*" prefix) {
1255 for (c = 1; c <= NF; c++) {
1256 if ($c ~ prefix "/sbin/fix-info-dir")
1257 continue;
3457b4f7
ER
1258 if ($c ~ prefix "/sbin/webapp")
1259 continue;
4837c1e3
ER
1260 if ($c ~ prefix "/sbin/chsh")
1261 continue;
1262 if ($c ~ prefix "/sbin/usermod")
1263 continue;
836e411f
ER
1264 if ($c ~ prefix "/sbin/installzope(product|3package)")
1265 continue;
a9fb2db8
ER
1266 if ($c ~ prefix "/share/automake")
1267 continue;
1268 if ($c ~ prefix "/share/unsermake")
1269 continue;
1270 if ($c ~ prefix "/lib/sendmail")
1271 continue;
97dae8dc
ER
1272 if ($c ~ prefix "/lib/pkgconfig")
1273 continue;
826b40ea 1274
b5fc4b79
ER
1275 # CFLAGS="-I/usr..." is usually correct.
1276 if (/-I\/usr/)
826b40ea 1277 continue;
474f0944
ER
1278 # same for LDFLAGS="-L/usr..."
1279 if (/-L\/usr/)
1280 continue;
826b40ea 1281
a9fb2db8
ER
1282 gsub(prefix, "%{_prefix}", $c)
1283 }
de69503c 1284 }
efd2d668 1285 gsub("%{prefix}", "%{_prefix}")
1286 }
3bcd1fab 1287
53d16b95
ER
1288 # replace back
1289 gsub("%{_includedir}/ncurses", "/usr/include/ncurses")
1290 gsub("%{_includedir}/freetype", "/usr/include/freetype")
1291
3bcd1fab 1292 gsub("%{PACKAGE_VERSION}", "%{version}")
1293 gsub("%{PACKAGE_NAME}", "%{name}")
b35c10f1 1294
59e208d5 1295 gsub("^make$", "%{__make}")
1296 gsub("^make ", "%{__make} ")
61b753c5 1297 gsub("^gcc ", "%{__cc} ")
67fe737e 1298 gsub("^rm --interactive=never ", "%{__rm} ")
9aece8c8 1299
471a5464
ER
1300 # fedora
1301 gsub("%{ruby_sitearch}", "%{ruby_sitearchdir}")
1302 gsub("%{python_sitearch}", "%{py_sitedir}")
e02ad475
ER
1303 gsub("%{python_sitelib}", "%{py_sitescriptdir}")
1304
1305 # alt linux
1306 gsub("%_man1dir", "%{_mandir}/man1")
471a5464 1307
cab706de
ER
1308 # mandrake specs
1309 gsub("^%make$", "%{__make}")
1310 gsub("^%make ", "%{__make} ")
1311 gsub("^%makeinstall_std", "%{__make} install \\\n\tDESTDIR=$RPM_BUILD_ROOT")
b7ca53a5 1312 gsub("^%{makeinstall}", "%{__make} install \\\n\tDESTDIR=$RPM_BUILD_ROOT")
63d47bae 1313 gsub("^%makeinstall", "%{__make} install \\\n\tDESTDIR=$RPM_BUILD_ROOT")
cab706de 1314 gsub("^%{__rm} -rf %{buildroot}", "rm -rf $RPM_BUILD_ROOT")
b7ca53a5 1315 gsub("^%{__install}", "install")
cab706de
ER
1316 gsub("%optflags", "%{rpmcflags}")
1317 gsub("%{compat_perl_vendorarch}", "%{perl_vendorarch}")
1318
a6ed8b03 1319 gsub("^%{__make} install DESTDIR=\$RPM_BUILD_ROOT", "%{__make} install \\\n\tDESTDIR=$RPM_BUILD_ROOT")
d11acde9 1320 gsub("^fix-info-dir$", "[ ! -x /usr/sbin/fix-info-dir ] || /usr/sbin/fix-info-dir -c %{_infodir} >/dev/null 2>\\&1")
5e15e952
ER
1321 $0 = fixedsub("%buildroot", "$RPM_BUILD_ROOT", $0)
1322 $0 = fixedsub("%{buildroot}", "$RPM_BUILD_ROOT", $0)
63d47bae 1323 $0 = fixedsub("CXXFLAGS=%{rpmcflags} %configure", "CXXFLAGS=%{rpmcflags}\n%configure", $0);
43f8581a 1324 $0 = fixedsub("%__install", "install", $0);
63d47bae 1325
740e3cd8 1326 # split configure line to multiple lines
6c8a2863 1327 if (/%configure +$/) {
1328 sub( / +$/, "" );
1329 } else if (/%configure / && !/\\$/) {
740e3cd8
ER
1330 $0 = format_configure($0);
1331 }
1332
ac779c71
ER
1333 gsub("%_bindir", "%{_bindir}")
1334 gsub("%_datadir", "%{_datadir}")
1335 gsub("%_iconsdir", "%{_iconsdir}")
c2b069de
ER
1336 gsub("%_sbindir", "%{_sbindir}")
1337 gsub("%_mandir", "%{_mandir}")
1338 gsub("%name", "%{name}")
b6875e34
ER
1339 gsub(/%__rm/, "rm");
1340 gsub(/%__mkdir_p/, "install -d");
1341 gsub(/%__cp/, "cp");
1342 gsub(/%__ln_s/, "ln -s");
1343 gsub(/%__sed/, "%{__sed}");
1344 gsub(/%__cat/, "cat");
1345 gsub(/%__chmod/, "chmod");
a6ed8b03 1346
9aece8c8 1347 gsub("/usr/src/linux", "%{_kernelsrcdir}")
1348 gsub("%{_prefix}/src/linux", "%{_kernelsrcdir}")
1c955424 1349
ecaaa784 1350 if (/^ant / || /^%{ant}/) {
1c955424 1351 sub(/^ant/, "%ant")
ecaaa784 1352 sub(/^%{ant}/, "%ant")
b6875e34
ER
1353 add_br("BuildRequires: jpackage-utils");
1354 add_br("BuildRequires: rpmbuild(macros) >= 1.300");
1355 }
1c955424 1356
2dc1a8cd
ER
1357 $0 = fixedsub("%(%{__cc} -dumpversion)", "%{cc_version}", $0);
1358 $0 = fixedsub("%(%{__cxx} -dumpversion)", "%{cxx_version}", $0);
d6e33af7
ER
1359
1360 # kill the _class and _subclass pear macros
1361 if (pear_class) {
1362 gsub("%{_class}", pear_class);
1363 }
1364 if (pear_subclass) {
1365 gsub("%{_subclass}", pear_subclass);
1366 }
9ae21f47 1367}
f171fd40 1368
740e3cd8
ER
1369function format_configure(line, n, a, s) {
1370 n = split(line, a, / /);
1371 s = a[1] " \\\n";
1372 for (i = 2; i <= n; i++) {
1373 s = s "\t" a[i] " \\\n"
1374 }
1375 return s
1376}
1377
7c23055b
ER
1378
1379# insertion sort of A[1..n]
1380# copied from mawk manual
1381function isort(A,n, i,j,hold) {
1382 for (i = 2; i <= n; i++) {
1383 hold = A[j = i]
1384 while (A[j-1] > hold) {
54caef3d 1385 j-- ; A[j+1] = A[j]
1386 }
7c23055b
ER
1387 A[j] = hold
1388 }
1389 # sentinel A[0] = "" will be created if needed
1390}
1391
1392
23e0529e 1393function use_files_macros( i, n, t, a, l)
eee34ffb 1394{
e6f1551d
ER
1395 use_macros()
1396
da6457aa
ER
1397 # skip comments
1398 if (/^#/) {
484bbf6d 1399 return 1;
da6457aa
ER
1400 }
1401
f158eddc
ER
1402 sub("^%doc %{_mandir}", "%{_mandir}")
1403
eee34ffb 1404 gsub("^%{_sbindir}", "%attr(755,root,root) %{_sbindir}")
1405 gsub("^%{_bindir}", "%attr(755,root,root) %{_bindir}")
7c23055b 1406
61cb9711
ER
1407 # uid/gid nobody is not valid in %files
1408 if (/%attr([^)]*nobody[^)]*)/ && !/FIXME/) {
1409 $0 = $0 " # FIXME nobody user/group can't own files! -adapter.awk"
1410 }
1411
16bb0647
JB
1412 # s[gu]id programs with globs are evil
1413 if (/%attr\([246]...,.*\*/ && !/FIXME/) {
1414 $0 = $0 " # FIXME no globs for suid/sgid files"
85bed066
ER
1415 }
1416
5dc673eb 1417 # replace back
8f6ddcd9 1418 gsub("%{_sysconfdir}/cron\.d", "/etc/cron.d")
3feaeac8 1419 gsub("%{_sysconfdir}/crontab\.d", "/etc/crontab.d")
8f6ddcd9
ER
1420 gsub("%{_sysconfdir}/logrotate\.d", "/etc/logrotate.d")
1421 gsub("%{_sysconfdir}/pam\.d", "/etc/pam.d")
1422 gsub("%{_sysconfdir}/profile\.d", "/etc/profile.d")
1423 gsub("%{_sysconfdir}/rc\.d", "/etc/rc.d")
1424 gsub("%{_sysconfdir}/security", "/etc/security")
1425 gsub("%{_sysconfdir}/skel", "/etc/skel")
1426 gsub("%{_sysconfdir}/sysconfig", "/etc/sysconfig")
1427 gsub("%{_sysconfdir}/certs", "/etc/certs")
5dc673eb 1428 gsub("%{_sysconfdir}/init.d", "/etc/init.d")
9395915a 1429 gsub("%{_sysconfdir}/dbus-1", "/etc/dbus-1")
be827f42
ER
1430 gsub("%{_sysconfdir}/pki", "/etc/pki")
1431 gsub("%{_sysconfdir}/tmpwatch", "/etc/tmpwatch")
2fc0e274 1432
5dc673eb
ER
1433 # /etc/init.d -> /etc/rc.d/init.d
1434 if (!/^\/etc\/init\.d$/) {
1435 gsub("/etc/init.d", "/etc/rc.d/init.d")
1436 }
1437
1438 if (/\/etc\/rc\.d\/init\.d\// && !/functions/) {
2fc0e274
ER
1439 if (!/%attr.*\/etc\/rc\.d\/init\.d/) {
1440 $0 = "%attr(754,root,root) " $0
1441 }
1442 if (/^%attr.*\/etc\/rc\.d\/init\.d/ && !/^%attr\(754 *,/) {
89c604c7 1443 gsub("^%attr\\(... *,", "%attr(754,");
2fc0e274 1444 }
9a7a5776
ER
1445 }
1446
1c298a13 1447 if (/lib.+\.so\b/ && !/\.so$/ && !/^%attr.*/ && !/%exclude/) {
55356feb
ER
1448 $0 = "%attr(755,root,root) " $0
1449 }
1450
ab9b09e2
ER
1451 if (/%{perl_vendorarch}.*\.so$/ && !/^%attr.*/) {
1452 $0 = "%attr(755,root,root) " $0
1453 }
1454
af8efb29
ER
1455 # remove attrs from man pages
1456 if (/%{_mandir}/ && /^%attr/) {
1457 sub("^%attr\\(.*\\) *", "");
1458 }
1459
f56d5519
ER
1460 # /etc/sysconfig files
1461 # %attr(640,root,root) %config(noreplace) %verify(not size mtime md5) /etc/sysconfig/*
a825b76b 1462 # attr not required, allow default 644 attr
6ea64b8d 1463 if (!/network-scripts/ && !/%dir/ && !/\.d$/ && !/functions/ && !/\/etc\/sysconfig\/wmstyle/) {
6ea0907e 1464 if (/\/etc\/sysconfig\// && /%config/ && !/%config\(noreplace/) {
5dc673eb
ER
1465 gsub("%config", "%config(noreplace)")
1466 }
f56d5519 1467
6ea0907e 1468 if (/\/etc\/sysconfig\// && !/%config\(noreplace/) {
5dc673eb
ER
1469 $NF = "%config(noreplace) " $NF
1470 }
f56d5519 1471
5dc673eb 1472 if (/\/etc\/sysconfig\// && /%attr\(755/) {
89c604c7 1473 gsub("^%attr\\(... *,", "%attr(640,");
5dc673eb 1474 }
f56d5519 1475
5dc673eb
ER
1476 if (/\/etc\/sysconfig\// && !/%verify/) {
1477 gsub("/etc/sysconfig", "%verify(not size mtime md5) /etc/sysconfig");
1478 }
a825b76b
ER
1479 }
1480
f56d5519 1481 # kill leading zeros
7dfb4dea
ER
1482 if (/%attr\(0[1-9]/) {
1483 gsub("%attr\\(0", "%attr(")
1484 }
f9d5d512 1485
95ae7268 1486 # kill leading whitespace
b8085249 1487 gsub(/^ +/, "");
95ae7268 1488
b6875e34
ER
1489 # kill default attrs
1490 gsub(/%dir %attr\(755,root,root\)/, "%dir");
1491 gsub(/%attr\(755,root,root\) %dir/, "%dir");
1492 if (!/%dir/) {
1493 gsub(/%attr\(644,root,root\) /, "");
1494 }
46292535 1495
7c23055b 1496 # sort %verify attrs
12bfc5c8 1497 if (match($0, /%verify\(not([^)]+)\)/)) {
7c23055b 1498 t = substr($0, RSTART, RLENGTH)
8409a9b2
ER
1499 # kill commas: %verify(not,md5,size,mtime)
1500 gsub(/,/, " ", t);
1501
7c23055b
ER
1502 gsub(/^%verify\(not |\)$/, "", t)
1503 n = split(t, a, / /)
1504 isort(a, n)
1505
1506 s = "%verify(not"
1507 for (i = 1 ; i <= n; i++) {
1508 s = s " " a[i]
1509 }
1510 s = s ")"
1511
12bfc5c8 1512 gsub(/%verify\(not[^)]+\)/, s)
7c23055b 1513 }
13defa79
ER
1514
1515 if (/%{_mandir}/) {
d64e2ec0 1516 gsub("\.gz$", "*")
1080e5b7 1517 gsub("%ext_man$", "*")
13defa79 1518 }
5e15e952 1519
ef6d2b7a 1520 # locale dir and no %lang -> bad
b9080a1b 1521 if (/%{_datadir}\/locale\/.*\// && !/%(dir|lang)/) {
ef6d2b7a
ER
1522 $(NF + 1) = "# FIXME consider using %find_lang"
1523 }
1524
23e0529e 1525 # python egg-infos
860a6f52 1526 if (match($0, "^%{py_site(script)?dir}/.+-py"py_ver".egg-info$")) {
484bbf6d
ER
1527 # tests:
1528 #%{py_sitedir}/*-py2.4.egg-info
1529 #%{py_sitescriptdir}/GnuPGInterface-%{version}-py2.4.egg-info
1530 #%{py_sitescriptdir}/python_mpd-%{version}-py2.4.egg-info
1531 #%{py_sitescriptdir}/mechanize-0.1.6b-py2.4.egg-info
1532
860a6f52 1533 l = index($0, "/");
484bbf6d 1534 t = substr($0, 0, l);
23e0529e 1535 s = substr($0, l + 1, RLENGTH - l - length("-py"py_ver".egg-info"));
860a6f52 1536 if (match(s, "[^-]+$")) {
484bbf6d
ER
1537 if (RSTART > 1) {
1538 s = substr(s, 0, RSTART - 1);
5384172a 1539 }
23e0529e 1540 print "%if \"%{py_ver}\" > \"2.4\""
860a6f52 1541 gsub(t "/.+.egg-info", t "/" s "-*.egg-info");
23e0529e
ER
1542 print
1543 print "%endif"
484bbf6d 1544 return 0;
23e0529e
ER
1545 }
1546 }
1547
5e15e952
ER
1548 # atrpms
1549 $0 = fixedsub("%{perl_man1dir}", "%{_mandir}/man1", $0);
1550 $0 = fixedsub("%{perl_man3dir}", "%{_mandir}/man3", $0);
1551 $0 = fixedsub("%{perl_bin}", "%{_bindir}", $0);
97dae8dc
ER
1552
1553 gsub(libdir "/pkgconfig", "%{_pkgconfigdir}");
1554 gsub("%{_libdir}/pkgconfig", "%{_pkgconfigdir}");
1555 gsub("%{_prefix}/lib/pkgconfig", "%{_pkgconfigdir}");
eee20d8d
ER
1556
1557 gsub("%{_datadir}/applications", "%{_desktopdir}");
9730a549 1558 gsub("%{_datadir}/icons", "%{_iconsdir}");
0904210e 1559 gsub("%{_datadir}/pixmaps", "%{_pixmapsdir}");
4b1d6e6d
ER
1560 gsub("%{_datadir}/pear", "%{php_pear_dir}");
1561 gsub("%{_datadir}/php", "%{php_data_dir}");
484bbf6d
ER
1562
1563 return 1
eee34ffb 1564}
236b87ac 1565
723ce732
ER
1566function use_script_macros()
1567{
1568 if (gsub("/sbin/service", "%service")) {
1569 sub(" >/dev/null 2>&1 \|\|:", "");
1570 sub(" 2> /dev/null \|\| :", "");
1571 }
1572}
1573
236b87ac 1574function fill(ch, n, i) {
1575 for (i = 0; i < n; i++)
1576 printf("%c", ch)
1577}
1578
1579function format_flush(line, indent, newline, word, first_word) {
1580 first_word = 1
f171fd40 1581 if (format_indent == -1)
236b87ac 1582 newline = ""
1583 else
1584 newline = fill(" ", format_indent) "- "
1585
1586 while (match(line, /[^\t ]+/)) {
1587 word = substr(line, RSTART, RLENGTH)
1588 if (length(newline) + length(word) + 1 > tw) {
1589 print newline
f171fd40 1590
236b87ac 1591 if (format_indent == -1)
1592 newline = ""
1593 else
1594 newline = fill(" ", format_indent + 2)
1595 first_word = 1
1596 }
1597
1598 if (first_word) {
1599 newline = newline word
1600 first_word = 0
1601 } else
1602 newline = newline " " word
f171fd40 1603
236b87ac 1604 line = substr(line, RSTART + RLENGTH)
1605 }
1606 if (newline ~ /[^\t ]/) {
1607 print newline
1608 }
1609}
1610
eb4bf70e 1611function cflags(var)
1612{
85e708f2 1613 if ($0 == var "=\"$RPM_OPT_FLAGS\"") {
1614 removed[var] = 1
eb4bf70e 1615 return 0
85e708f2 1616 }
f171fd40 1617
246ad57e 1618 if (!/!\?debug/)
fde8f52a 1619 sub("\$RPM_OPT_FLAGS", "%{rpmcflags}")
eb4bf70e 1620 return 1
1621}
0ea7c3cd 1622
9b781beb
ER
1623# return whole matched pattern
1624function matchstr(str, pat)
1625{
1626 match(str, "[^/]+$");
1627 return substr(str, RSTART, RLENGTH);
1628}
1629
8ea8f0ae
ER
1630function unify_url(url)
1631{
1632
1633 # sourceforge urls
3f8ea9bd 1634 # Docs about sourceforge mirror system: http://sourceforge.net/apps/trac/sourceforge/wiki/Mirrors
f6403de9
ER
1635
1636 # 1. unify domains
3f8ea9bd
JB
1637 sub("^http://prdownloads\.sourceforge\.net/", "http://downloads.sourceforge.net/", url)
1638 sub("^http://download\.sf\.net/", "http://downloads.sourceforge.net/", url)
1639 sub("^http://download\.sourceforge\.net/", "http://downloads.sourceforge.net/", url)
1640 sub("^http://dl\.sourceforge\.net/", "http://downloads.sourceforge.net/", url)
1641 sub("^http://.*\.dl\.sourceforge\.net/", "http://downloads.sourceforge.net/", url)
1642 sub("^http://dl\.sf\.net/", "http://downloads.sourceforge.net/", url)
1643 sub("^http://downloads\.sourceforge\.net/sourceforge/", "http://downloads.sourceforge.net/", url)
f6403de9 1644
f6403de9 1645 # 3. unify urls
2bee6485
ER
1646 if (url ~ /sourceforge.net/) {
1647 sub("[?&]big_mirror=.*$", "", url);
1648 sub("[?&]modtime=.*$", "", url);
1649 sub("[?]use_mirror=.*$", "", url);
1650 sub("[?]download$", "", url);
1651 sub("/download$", "", url);
1652 }
8ea8f0ae 1653
9b781beb
ER
1654 # SF: new style urls, strip "files/" between and prepend dl.
1655 if (match(url, "^http://sourceforge.net/projects/[^/]+/files/")) {
1656 url = substr(url, 1, RLENGTH - length("files/")) substr(url, RSTART + RLENGTH);
1657 sub("^http://sourceforge.net/projects/", "http://downloads.sourceforge.net/project/", url);
1658 }
1659
1660 # SF unify: http://downloads.sourceforge.net/PROJECT/TARBALL
1661 # http://downloads.sourceforge.net/project/PROJECT/FILE/VERSION/%{name}-%{version}.zip
1662 if (match(url, "^http://downloads.sourceforge.net/project/[^/]+")) {
1663 url = sprintf("http://downloads.sourceforge.net/%s/%s", substr(url, 42, RLENGTH - 41), matchstr(url, "[^/]+$"));
1664 }
1665
8ea8f0ae
ER
1666 sub("^ftp://ftp\.gnome\.org/", "http://ftp.gnome.org/", url)
1667 sub("^http://ftp\.gnome\.org/pub/gnome/", "http://ftp.gnome.org/pub/GNOME/", url)
1668
1669 # apache urls
1670 sub("^http://apache.zone-h.org/", "http://www.apache.org/dist/", url)
1671
11401cd0 1672 # gnu.org
a4799779
ER
1673 sub("^ftp://ftp\.gnu\.org/", "http://ftp.gnu.org/", url)
1674 sub("^http://ftp\.gnu\.org/pub/gnu/", "http://ftp.gnu.org/gnu/", url)
1675
1676 # debian.org
1677 sub("^ftp://ftp\.[^.]+\.debian\.org/", "ftp://ftp.debian.org/", url)
1678 sub("^http://ftp\.[^.]+\.debian\.org/", "ftp://ftp.debian.org/", url)
1679 sub("^ftp://ftp\.debian\.org/pub/debian/", "ftp://ftp.debian.org/debian/", url)
11401cd0 1680
8ea8f0ae
ER
1681 return url
1682}
1683
4e26c5f2
ER
1684function demacroize(str)
1685{
8f7c516b
ER
1686 if (mod_name) {
1687 sub("%{mod_name}", mod_name, str);
1688 }
f5f6280a
ER
1689 if (pearname) {
1690 sub("%{_pearname}", pearname, str);
1691 }
1692 if (pearname) {
1693 sub("%{pearname}", pearname, str);
1694 }
8f7c516b
ER
1695 if (name) {
1696 sub("%{name}", name, str);
1697 }
4e26c5f2
ER
1698 if (version) {
1699 sub("%{version}", version, str);
1700 }
1701 if (_beta) {
1702 sub("%{_beta}", _beta, str);
1703 }
1704 if (_rc) {
1705 sub("%{_rc}", _rc, str);
1706 }
59de1799
ER
1707 if (_pre) {
1708 sub("%{_pre}", _pre, str);
1709 }
4e26c5f2
ER
1710 if (_snap) {
1711 sub("%{_snap}", _snap, str);
1712 }
3c5e6e5f
ER
1713 if (subver) {
1714 sub("%{subver}", subver, str);
1715 }
4e26c5f2
ER
1716 return str;
1717}
1718
0ea7c3cd
ER
1719function kill_preamble_macros()
1720{
a64d362e
ER
1721 if ($1 ~ /^Obsoletes:/) {
1722 # NB! assigning $2 a value breaks tabbing
1723 $2 = demacroize($2);
1724 }
1725 if ($1 ~ /^URL:/) {
8f7c516b 1726 # NB! assigning $2 a value breaks tabbing
4e26c5f2 1727 $2 = demacroize($2);
ec30d23e 1728 $2 = unify_url($2)
0ea7c3cd 1729 }
e31553a7
ER
1730
1731 # fedora extras
1732 if (/%{\?FE_USERADD_REQ}/) {
1733 $0 = "";
1734 print "BuildRequires: rpmbuild(macros) >= 1.202"
1735 print "Provides: user(xxx)"
1736 print "Requires(postun): /usr/sbin/userdel"
1737 print "Requires(pre): /bin/id"
1738 print "Requires(pre): /usr/sbin/useradd"
1739 }
0ea7c3cd 1740}
ba377afe 1741
9815f9b2
ER
1742function get_epoch(pkg, ver, epoch)
1743{
cccfa553
ER
1744 return
1745# should parse the BR lines more adequately:
1746# freetype = 2.0.0 -> correct
1747# freetype = 2.1.9 -> with epoch 1, as epoch 1 was added in 2.1.7
1748
9815f9b2
ER
1749 shell = "grep -o '^" pkg ":[^:]\+' ../PLD-doc/BuildRequires.txt | awk '{print $NF}'";
1750 shell | getline epoch;
1751 return epoch;
1752}
1753
ba377afe 1754function format_requires(tag, value, n, p, i, deps, ndeps) {
87b130e2
ER
1755 # skip any formatting for commented out items or some weird macros
1756 if (/^#/ || /%\(/) {
3f81d059
ER
1757 return tag "\t" value
1758 }
ba377afe
ER
1759 n = split(value, p, / *,? */);
1760 for (i = 1; i <= n; i++) {
1761 if (p[i+1] ~ /[<=>]/) {
9815f9b2
ER
1762 # add epoch if the version doesn't have it but BuildRequires.txt has
1763 if (p[i] ~ /^[a-z]/ && p[i+2] !~ /^[0-9]+:/) {
1764 epoch = get_epoch(p[i], p[i+2])
1765 if (epoch) {
1766 p[i+2] = epoch ":" p[i+2];
1767 }
1768 }
ba377afe
ER
1769 deps[ndeps++] = p[i] " " p[i+1] " " p[i+2];
1770 i += 2;
1771 } else {
1772 deps[ndeps++] = p[i];
1773 }
1774 }
1775 s = ""
1776 for (i in deps) {
1777 s = s sprintf("%s\t%s\n", tag, deps[i]);
1778 }
1779 return substr(s, 1, length(s)-1);
1780}
6ebff802
ER
1781
1782function use_tabs()
1783{
1784 # reverse vim: ts=4 sw=4 et
1785 gsub(/ /, "\t");
1786}
1c955424
ER
1787
1788function add_br(br)
1789{
b6875e34 1790 BR[BR_count++] = br
1c955424
ER
1791}
1792
76c7e23c
ER
1793# Load rpm macros
1794# you should update the list also in adapter when making changes here
8d9ad434 1795function import_rpm_macros( v) {
76c7e23c
ER
1796 # File with rpm groups
1797 topdir = ENVIRON["_topdir"]
1798
1799 if (!topdir) {
1800 print "adapter.awk should not not be invoked directly, but via adapter script" > "/dev/stderr"
1801 do_not_touch_anything = 1
a4de4386
ER
1802 exit(rc = 1);
1803 }
1804
8fc7c329 1805 # update this version dep each time some new macro export is added
8d9ad434
ER
1806 v = 1.49
1807 if (!ENVIRON["ADAPTER_REVISION"] || ENVIRON["ADAPTER_REVISION"] < v) {
1808 printf("adapter shell script is outdated: Need %s, got %s. Please update it.\n", v, ENVIRON["ADAPTER_REVISION"]) > "/dev/stderr"
a4de4386
ER
1809 do_not_touch_anything = 1
1810 exit(rc = 1);
76c7e23c
ER
1811 }
1812
76c7e23c
ER
1813 prefix = ENVIRON["_prefix"]
1814 bindir = ENVIRON["_bindir"]
1815 sbindir = ENVIRON["_sbindir"]
1816 libdir = ENVIRON["_libdir"]
1817 sysconfdir = ENVIRON["_sysconfdir"]
1818 datadir = ENVIRON["_datadir"]
1819 includedir = ENVIRON["_includedir"]
1820 mandir = ENVIRON["_mandir"]
1821 infodir = ENVIRON["_infodir"]
1822 examplesdir = ENVIRON["_examplesdir"]
1823 docdir = ENVIRON["_defaultdocdir"]
1824 kdedocdir = ENVIRON["_kdedocdir"]
1825 gtkdocdir = ENVIRON["_gtkdocdir"]
1826 desktopdir = ENVIRON["_desktopdir"]
1827 pixmapsdir = ENVIRON["_pixmapsdir"]
1828 javadir = ENVIRON["_javadir"]
a4de4386 1829 pkgconfigdir = ENVIRON["_pkgconfigdir"]
1c298a13 1830 npkgconfigdir = ENVIRON["_npkgconfigdir"]
4efeac87 1831 localedir = ENVIRON["_localedir"]
76c7e23c
ER
1832
1833 perl_sitearch = ENVIRON["perl_sitearch"]
1834 perl_archlib = ENVIRON["perl_archlib"]
1835 perl_privlib = ENVIRON["perl_privlib"]
1836 perl_vendorlib = ENVIRON["perl_vendorlib"]
1837 perl_vendorarch = ENVIRON["perl_vendorarch"]
1838 perl_sitelib = ENVIRON["perl_sitelib"]
1839
1840 py_sitescriptdir = ENVIRON["py_sitescriptdir"]
1841 py_sitedir = ENVIRON["py_sitedir"]
1842 py_scriptdir = ENVIRON["py_scriptdir"]
1843 py_ver = ENVIRON["py_ver"]
1844
8fc7c329
ER
1845 py3_sitescriptdir = ENVIRON["py3_sitescriptdir"]
1846 py3_sitedir = ENVIRON["py3_sitedir"]
1847 py3_scriptdir = ENVIRON["py3_scriptdir"]
1848 py3_ver = ENVIRON["py3_ver"]
1849
76c7e23c
ER
1850 ruby_archdir = ENVIRON["ruby_archdir"]
1851 ruby_ridir = ENVIRON["ruby_ridir"]
1852 ruby_rubylibdir = ENVIRON["ruby_rubylibdir"]
1853 ruby_sitearchdir = ENVIRON["ruby_sitearchdir"]
1854 ruby_sitelibdir = ENVIRON["ruby_sitelibdir"]
1855 ruby_rdocdir = ENVIRON["ruby_rdocdir"]
1856
1857 php_pear_dir = ENVIRON["php_pear_dir"]
1858 php_data_dir = ENVIRON["php_data_dir"]
1859 tmpdir = ENVIRON["tmpdir"]
df79d912
JR
1860
1861 systemdunitdir = ENVIRON["systemdunitdir"]
1862 systemdtmpfilesdir = ENVIRON["systemdtmpfilesdir"]
76c7e23c
ER
1863}
1864
76c7e23c
ER
1865# php virtual deps as discussed in devel-en
1866function replace_php_virtual_deps() {
1867 pkg = $2
1868# if (pkg == "php-program") {
1869# $0 = $1 "\t/usr/bin/php"
1870# return
1871# }
1872
1873# if (pkg ~ /^php-[a-z]/ && pkg !~ /^php-(pear|common|cli|devel|fcgi|cgi|dirs|program|pecl-)/) {
1874# sub(/^php-/, "php(", pkg);
1875# sub(/$/, ") # verify this correctness -- it may be wanted to use specific not virtual dep", pkg);
1876# $2 = pkg
1877# }
1878
1879 if (pkg ~/^php$/) {
1880 $2 = "webserver(php)";
1881 if ($4 ~ /^[0-9]:/) {
1882 $4 = substr($4, 3);
1883 }
1884 }
1885
1886 if (pkg ~/^php4$/) {
1887 $2 = "webserver(php)";
1888 if ($4 ~ /^[0-9]:/) {
1889 $4 = substr($4, 3);
1890 }
1891 }
1892}
1893
b2cb3007
ER
1894function replace_groupnames(group) {
1895 group = replace(group, "Amusements/Games", "Applications/Games");
1896 group = replace(group, "Amusements/Games/Strategy/Real Time", "X11/Applications/Games/Strategy");
1897 group = replace(group, "Application/Multimedia", "Applications/Multimedia");
1898 group = replace(group, "Application/System", "Applications/System");
1899 group = replace(group, "Applications/Compilers", "Development/Languages");
1900 group = replace(group, "Applications/Daemons", "Daemons");
1901 group = replace(group, "Applications/Internet", "Applications/Networking");
1902 group = replace(group, "Applications/Internet/Peer to Peer", "Applications/Networking");
1903 group = replace(group, "Applications/Productivity", "X11/Applications");
1904 group = replace(group, "Applications/Security", "Applications/System");
1905 group = replace(group, "Applications/Web", "Applications/WWW");
1906 group = replace(group, "Database", "Applications/Databases");
1907 group = replace(group, "Development/C", "Development/Libraries");
1908 group = replace(group, "Development/Code Generators", "Development");
1909 group = replace(group, "Development/Docs", "Documentation");
1910 group = replace(group, "Development/Documentation", "Documentation");
1911 group = replace(group, "Development/Java", "Development/Languages/Java");
1912 group = replace(group, "Development/Languages/C and C++", "Libraries");
1913 group = replace(group, "Development/Languages/Other", "Development/Languages");;
1914 group = replace(group, "Development/Languages/Ruby", "Development/Languages");
1915 group = replace(group, "Development/Libraries/C and C++", "Development/Libraries");
1916 group = replace(group, "Development/Libraries/Java", "Development/Languages/Java");
1917 group = replace(group, "Development/Libraries/Python", "Development/Languages/Python");
1918 group = replace(group, "Development/Libraries/TCL", "Development/Languages/Tcl");;
1919 group = replace(group, "Development/Other", "Development");
1920 group = replace(group, "Development/Python", "Development/Languages/Python");
1921 group = replace(group, "Development/Testing", "Development");
1922 group = replace(group, "Editors", "Applications/Text");
1923 group = replace(group, "Emulators", "Applications/Emulators");
1924 group = replace(group, "File tools", "Applications/File");
1925 group = replace(group, "Games", "Applications/Games");
1926 group = replace(group, "Library/Development", "Development/Libraries");
1927 group = replace(group, "Networking/Deamons", "Networking/Daemons");
1928 group = replace(group, "Networking/Mail", "Applications/Mail");
1929 group = replace(group, "Networking/Other", "Networking");
1930 group = replace(group, "Productivity/Databases/Servers", "Applications/Databases");
1931 group = replace(group, "Productivity/Multimedia/Other", "X11/Applications/Multimedia");
1932 group = replace(group, "Productivity/Networking/Web/Servers", "Networking/Daemons/HTTP");;
1933 group = replace(group, "Shells", "Applications/Shells");
1934 group = replace(group, "System Environment/Base", "Base");
1935 group = replace(group, "System Environment/Daemons", "Daemons");
1936 group = replace(group, "System Environment/Kernel", "Base/Kernel");
1937 group = replace(group, "System Environment/Libraries", "Libraries");
1938 group = replace(group, "System Tools", "Applications/System");
1939 group = replace(group, "System", "Base");
1940 group = replace(group, "System/Base", "Base");
1941 group = replace(group, "System/Kernel and hardware", "Base/Kernel");
1942 group = replace(group, "System/Libraries", "Libraries");
1943 group = replace(group, "System/Servers", "Daemons");
1944 group = replace(group, "Text Processing/Markup/HTML", "Applications/Text");
1945 group = replace(group, "Text Processing/Markup/XML", "Applications/Text");
1946 group = replace(group, "Text tools", "Applications/Text");
1947 group = replace(group, "User Interface/Desktops", "X11/Applications");
3df50196 1948 group = replace(group, "User Interface/X", "X11/Applications");
b2cb3007
ER
1949 group = replace(group, "Utilities/System", "Applications/System");
1950 group = replace(group, "Web/Database", "Applications/WWW");
1951 group = replace(group, "X11/GNOME", "X11/Applications");
1952 group = replace(group, "X11/GNOME/Applications", "X11/Applications");
1953 group = replace(group, "X11/GNOME/Development/Libraries", "X11/Development/Libraries");
1954 group = replace(group, "X11/Games", "X11/Applications/Games");
1955 group = replace(group, "X11/Games/Strategy", "X11/Applications/Games/Strategy");
1956 group = replace(group, "X11/Library", "X11/Libraries");
1957 group = replace(group, "X11/Utilities", "X11/Applications");
1958 group = replace(group, "X11/XFree86", "X11");
1959 group = replace(group, "X11/Xserver", "X11/Servers");
1960
1961 return group;
1962}
1963
e27788d1 1964function replace_requires() {
92fa789e 1965
517313c5 1966 sub(/^python-setuptools-devel$/, "python-distribute", $2);
1e1d065d 1967 sub(/^gcc-g77/, "gcc-fortran", $2);
532cbdf9
ER
1968
1969 # use virtual, not package name
1970 sub(/^rpm-build-macros$/, "rpmbuild(macros)", $2);
1971
6ca05bf8
ER
1972 # bad package.xml, see http://pear.php.net/bugs/bug.php?id=17779
1973 sub(/^php-php-gtk/, "php-gtk2", $2);
1974
40ee9b70 1975 # jpackages / fedora java packages
de0b52ae 1976 sub(/^antlr3$/, "java-antlr3", $2);
08226650 1977 sub(/^aqute-bnd$/, "java-bnd", $2);
83ed1722 1978 sub(/^avalon-framework$/, "java-avalon-framework", $2);
1979 sub(/^avalon-logkit$/, "java-avalon-logkit", $2);
6b5f846d 1980 sub(/^axis$/, "java-axis", $2);
40ee9b70
ER
1981 sub(/^bouncycastle$/, "java-bcprov", $2);
1982 sub(/^bouncycastle-mail$/, "java-bcmail", $2);
08226650 1983 sub(/^bouncycastle-pg$/, "java-bcpg", $2);
40ee9b70 1984 sub(/^bouncycastle-tsp$/, "java-bctsp", $2);
de0b52ae 1985 sub(/^bsf$/, "java-bsf", $2);
40ee9b70
ER
1986 sub(/^dom4j$/, "java-dom4j", $2);
1987 sub(/^flute$/, "java-flute", $2);
d95a12d3
ER
1988 sub(/^gnu-regexp$/, "java-gnu-regexp", $2);
1989 sub(/^gnu.regexp$/, "java-gnu-regexp", $2);
22e27c40 1990 sub(/^hamcrest$/, "java-hamcrest", $2);
40ee9b70 1991 sub(/^itext$/, "java-itext", $2);
ed0e2c9b 1992 sub(/^jaas$/, "java(jaas)", $2);
1993 sub(/^jaf$/, "java(jaf)", $2);
6b5f846d 1994 sub(/^jakarta-ant$/, "ant", $2);
40ee9b70 1995 sub(/^jakarta-commons-codec$/, "java-commons-codec", $2);
6b5f846d 1996 sub(/^jakarta-commons-httpclient$/, "java-commons-httpclient", $2);
40ee9b70 1997 sub(/^jakarta-commons-logging$/, "java-commons-logging", $2);
6b5f846d 1998 sub(/^jakarta-log4j$/, "java-log4j", $2);
1999 sub(/^jakarta-oro$/, "java-oro", $2);
83ed1722 2000 sub(/^jakarta-servletapi$/, "java(servlet)", $2);
3c606e9e
ER
2001 sub(/^java-devel$/, "jdk", $2);
2002 sub(/^java\(JSP\)$/, "java(jsp)", $2);
2003 sub(/^java\(JavaServerFaces\)$/, "java(javaserverfaces)", $2);
2004 sub(/^java\(Portlet\)$/, "java(portlet)", $2);
2005 sub(/^java\(Servlet\)$/, "java(servlet)", $2);
6b5f846d 2006 sub(/^javamail$/, "java(javamail)", $2);
ed0e2c9b 2007 sub(/^jaxp$/, "java(jaxp)", $2);
2008 sub(/^jaxp_parser_impl$/, "java(jaxp_parser_impl)", $2);
9d9c44b3 2009 sub(/^jaxp_transform_impl$/, "java(jaxp_transform_impl)", $2);
ed0e2c9b 2010 sub(/^jce$/, "java(jce)", $2);
dda2335f 2011 sub(/^jcommon$/, "java-jcommon", $2);
ed0e2c9b 2012 sub(/^jdbc-stdext$/, "java(jdbc-stdext)", $2);
de0b52ae 2013 sub(/^jdepend$/, "java-jdepend", $2);
dda2335f 2014 sub(/^jfreechart$/, "java-jfreechart", $2);
ed0e2c9b 2015 sub(/^jmx$/, "java(jmx)", $2);
2016 sub(/^jndi$/, "java(jndi)", $2);
de0b52ae 2017 sub(/^jsch$/, "java-jsch", $2);
ed0e2c9b 2018 sub(/^jsse$/, "java(jsse)", $2);
9d9c44b3 2019 sub(/^jta$/, "java(jta)", $2);
de0b52ae 2020 sub(/^junit$/, "java-junit", $2);
40ee9b70 2021 sub(/^junit4$/, "java-junit", $2);
6b5f846d 2022 sub(/^ldapjdk$/, "ldapsdk", $2);
40ee9b70
ER
2023 sub(/^libbase$/, "java-libbase", $2);
2024 sub(/^libfonts$/, "java-libfonts", $2);
2025 sub(/^libformula$/, "java-libformula", $2);
2026 sub(/^liblayout$/, "java-liblayout", $2);
2027 sub(/^libloader$/, "java-libloader", $2);
2028 sub(/^librepository$/, "java-librepository", $2);
2029 sub(/^libserializer$/, "java-libserializer", $2);
6b5f846d 2030 sub(/^log4j$/, "java-log4j", $2);
2031 sub(/^logging-log4j$/, "java-log4j", $2);
2032 sub(/^oro$/, "java-oro", $2);
40ee9b70
ER
2033 sub(/^pdf-renderer$/, "java-pdf-renderer", $2);
2034 sub(/^pentaho-libxml$/, "java-libxml", $2);
6b5f846d 2035 sub(/^rhino$/, "java-rhino", $2);
40ee9b70 2036 sub(/^sac$/, "java-sac", $2);
6b5f846d 2037 sub(/^saxon-scripts$/, "saxon", $2);
9d9c44b3 2038 sub(/^servlet$/, "java(servlet)", $2);
6b5f846d 2039 sub(/^uddi4j$/, "java-uddi4j", $2);
40ee9b70 2040 sub(/^ws-jaxme$/, "java-jaxme", $2);
6b5f846d 2041 sub(/^wsdl4j$/, "java-wsdl4j", $2);
6b5f846d 2042 sub(/^xalan-j$/, "java-xalan", $2);
3c606e9e 2043 sub(/^xalan-j2$/, "java-xalan", $2);
f75c7006
ER
2044 sub(/^xerces-j$/, "java-xerces", $2);
2045 sub(/^xerces-j2$/, "java-xerces", $2);
40ee9b70 2046 sub(/^xml-commons-apis$/, "java-xml-commons", $2);
6b5f846d 2047 sub(/^xml-commons-resolver$/, "java-xml-commons-resolver", $2);
40ee9b70
ER
2048 sub(/^xmldb-api$/, "java-xmldb", $2);
2049 sub(/^xmldb-api-sdk$/, "java-xmldb-sdk", $2);
92fa789e 2050
3c606e9e 2051 # fedora / redhat
435d1309 2052 sub(/^Django$/, "python-django", $2);
09f3f638 2053 sub(/^GitPython$/, "python-git", $2);
f6403de9
ER
2054 sub(/^PyQt4-devel$/, "python-PyQt4-devel", $2);
2055 sub(/^PyQwt-devel$/, "python-PyQwt-devel", $2);
87ffb46f 2056 sub(/^ccid$/, "pcsc-driver-ccid", $2);
03180d14 2057 sub(/^chkconfig$/, "/sbin/chkconfig", $2);
da9ff7a7 2058 sub(/^db4-devel$/, "db-devel", $2);
3c606e9e 2059 sub(/^dbus-python$/, "python-dbus", $2);
3df50196 2060 sub(/^desktop-notification-daemon$/, "dbus(org.freedesktop.Notifications)", $2);
3c606e9e 2061 sub(/^file-devel$/, "libmagic-devel", $2);
0e53c084 2062 sub(/^freetype2-devel$/, "freetype-devel", $2);
154cb95a 2063 sub(/^fuse-devel$/, "libfuse-devel", $2);
3c606e9e
ER
2064 sub(/^gamin-python$/, "python-gamin", $2);
2065 sub(/^gcc-c\+\+$/, "libstdc++-devel", $2);
08226650 2066 sub(/^gnome-desktop3-devel$/, "gnome-desktop-devel", $2);
af8efb29 2067 sub(/^gnome-python2-extras$/, "python-gnome-extras", $2);
24873dc2
ER
2068 sub(/^gnome-python2-gconf$/, "python-gnome-gconf", $2);
2069 sub(/^gnome-python2-gnomekeyring$/, "python-gnome-desktop-keyring", $2);
471a5464 2070 sub(/^gnome-python2-gtkspell$/, "python-gnome-extras-gtkspell", $2);
0e53c084 2071 sub(/^gtk-sharp2-devel$/, "dotnet-gtk-sharp2-devel", $2);
af8efb29 2072 sub(/^gtk2$/, "gtk+2", $2);
8aede7e3 2073 sub(/^gtk2-devel$/, "gtk+2-devel", $2);
e31553a7 2074 sub(/^gtk3-devel$/, "gtk+3-devel", $2);
3c606e9e 2075 sub(/^initscripts$/, "rc-scripts", $2);
0e53c084 2076 sub(/^iproute$/, "iproute2", $2);
3c606e9e 2077 sub(/^iscsi-initiator-utils$/, "open-iscsi", $2);
40ee9b70 2078 sub(/^keyutils-libs-devel$/, "keyutils-devel", $2);
08226650 2079 sub(/^libSM-devel$/, "xorg-lib-libSM-devel", $2);
5f76b6c6
ER
2080 sub(/^libX11-devel$/, "xorg-lib-libX11-devel", $2);
2081 sub(/^libXScrnSaver-devel$/, "xorg-lib-libXScrnSaver-devel", $2);
d2bfc4ba 2082 sub(/^libXau-devel$/, "xorg-lib-libXau-devel", $2);
08226650
ER
2083 sub(/^libXcomposite-devel$/, "xorg-lib-libXcomposite-devel", $2);
2084 sub(/^libXcursor-devel$/, "xorg-lib-libXcursor-devel", $2);
2085 sub(/^libXdamage-devel$/, "xorg-lib-libXdamage-devel", $2);
5f76b6c6 2086 sub(/^libXext-devel$/, "xorg-lib-libXext-devel", $2);
3c606e9e 2087 sub(/^libXft-devel$/, "xorg-lib-libXft-devel", $2);
5f76b6c6 2088 sub(/^libXinerama-devel$/, "xorg-lib-libXinerama-devel", $2);
da9ff7a7 2089 sub(/^libXrandr-devel$/, "xorg-lib-libXrandr-devel", $2);
08226650 2090 sub(/^libXrender-devel$/, "xorg-lib-libXrender-devel", $2);
5f76b6c6 2091 sub(/^libXxf86vm-devel$/, "xorg-lib-libXxf86vm-devel", $2);
e31553a7 2092 sub(/^libacl-devel$/, "acl-devel", $2);
0e53c084 2093 sub(/^libcurl-devel$/, "curl-devel", $2);
24873dc2 2094 sub(/^libgudev1-devel$/, "udev-glib-devel", $2);
08226650 2095 sub(/^libmx-devel$/, "mx-devel", $2);
3df50196 2096 sub(/^libselinux-python$/, "python-selinux", $2);
484bf2b0 2097 sub(/^libsrtp-devel$/, "srtp-devel", $2);
689721b0
ER
2098 sub(/^libtdb$/, "tdb", $2);
2099 sub(/^libtdb-devel$/, "tdb-devel", $2);
2100 sub(/^libtevent$/, "tevent", $2);
2101 sub(/^libtevent-devel$/, "tevent-devel", $2);
842b198d 2102 sub(/^libusb1-devel$/, "libusb-devel", $2);
e02ad475 2103 sub(/^mod_wsgi$/, "apache-mod_wsgi", $2);
08226650 2104 sub(/^newt-python$/, "python-snack", $2);
3c606e9e 2105 sub(/^notify-python$/, "python-pynotify", $2);
87ffb46f 2106 sub(/^pcsc-lite-ccid$/, "pcsc-driver-ccid", $2);
039d8103 2107 sub(/^pulseaudio-libs-devel$/, "pulseaudio-devel", $2);
2bbf619a 2108 sub(/^pyOpenSSL$/, "python-pyOpenSSL", $2);
3df50196 2109 sub(/^pycairo$/, "python-pycairo", $2);
dd1ce547 2110 sub(/^pyflakes$/, "python-pyflakes", $2);
4a7554aa 2111 sub(/^pygobject2$/, "python-pygobject", $2);
08226650 2112 sub(/^pygobject3-devel$/, "python-pygobject3-common-devel", $2);
3c606e9e
ER
2113 sub(/^pygtk2$/, "python-pygtk", $2);
2114 sub(/^pygtk2-devel$/, "python-pygtk-devel", $2);
24873dc2 2115 sub(/^pygtk2-libglade$/, "python-pygtk-glade", $2);
dd1ce547 2116 sub(/^pysvn$/, "python-pysvn", $2);
689721b0
ER
2117 sub(/^pytalloc$/, "python-talloc", $2);
2118 sub(/^pytalloc-devel$/, "python-talloc-devel", $2);
3df50196 2119 sub(/^python-cups$/, "python-pycups", $2);
e02ad475 2120 sub(/^python-enchant$/, "python-pyenchant", $2);
e27788d1
ER
2121 sub(/^python-imaging$/, "python-PIL", $2);
2122 sub(/^python-imaging-tk$/, "python-PIL-tk", $2);
3df50196 2123 sub(/^python-newt$/, "python-snack", $2);
471a5464 2124 sub(/^python-pygtk$/, "python-pygtk-gtk", $2);
dd1ce547
ER
2125 sub(/^python-recaptcha-client$/, "python-recaptcha", $2);
2126 sub(/^python-twisted-core$/, "python-TwistedCore", $2);
f6403de9
ER
2127 sub(/^python-twisted-core$/, "python-TwistedCore", $2);
2128 sub(/^python-twisted-names$/, "python-TwistedNames", $2);
e02ad475 2129 sub(/^python2-devel$/, "python-devel", $2);
dd1ce547 2130 sub(/^pytz$/, "python-pytz", $2);
3c606e9e 2131 sub(/^qt4-devel$/, "qt4-build", $2);
f6403de9 2132 sub(/^qt4-webkit-devel$/, "QtWebKit-devel", $2);
da9ff7a7 2133 sub(/^qtlockedfile-devel$/, "QtLockedFile-devel", $2);
484bf2b0 2134 sub(/^qtsingleapplication-devel$/, "QtSingleApplication-devel", $2);
b86601da 2135 sub(/^rpm-python$/, "python-rpm", $2);
f6403de9 2136 sub(/^sip-devel$/, "python-sip-devel", $2);
3c606e9e
ER
2137 sub(/^tftp-server$/, "tftpdaemon", $2);
2138 sub(/^tkinter$/, "python-tkinter", $2);
40ee9b70 2139 sub(/^urw-fonts$/, "fonts-Type1-urw", $2);
08226650 2140 sub(/^webkitgtk3-devel$/, "gtk-webkit3-devel", $2);
435d1309 2141 sub(/^xapian-bindings-python$/, "python-xapian", $2);
484bf2b0 2142 sub(/^xorg-x11-server-sdk$/, "xorg-xserver-server-devel", $2);
40ee9b70 2143
b371c36f
ER
2144 # mandriva
2145 sub(/^python-gobject-devel$/, "python-pygobject-devel", $2);
2146 sub(/^python-pyrex$/, "python-Pyrex", $2);
2147 sub(/^webkitgtk-devel$/, "gtk-webkit-devel", $2);
2148 sub(/^python-curl$/, "python-pycurl", $2);
2149 sub(/^python-webkitgtk$/, "python-pywebkitgtk", $2);
2150 sub(/^pygtk2.0$/, "python-pygtk-gtk", $2);
2151 sub(/^gnome-python-gconf$/, "python-gnome-gconf", $2);
2152
b1fc2b39 2153 # debian / ubuntu
3c606e9e
ER
2154 sub(/^blkid-dev$/, "libblkid-devel", $2);
2155 sub(/^ext2fs-dev$/, "e2fsprogs-devel", $2);
2156 sub(/^libao-dev$/, "libao-devel", $2);
aead9fa9
ER
2157 sub(/^libboost-filesystem[0-9.]+-dev$/, "boost-devel", $2);
2158 sub(/^libboost-program-options[0-9.]+-dev$/, "boost-devel", $2);
2159 sub(/^libboost-regex[0-9.]+-dev$/, "boost-devel", $2);
2160 sub(/^libboost-thread[0-9.]+-dev$/, "boost-devel", $2);
aead9fa9 2161 sub(/^libcurl4-openssl-dev$/, "curl-devel", $2);
30a90064 2162 sub(/^libdnet-dev$/, "libdnet-devel", $2);
30a90064 2163 sub(/^libesd0-dev$/, "esound-devel", $2);
30a90064 2164 sub(/^libfishsound1-dev$/, "libfishsound-devel", $2);
3c606e9e
ER
2165 sub(/^libgconf2-dev$/, "GConf2-devel", $2);
2166 sub(/^libgl1-mesa-dev$/, "OpenGL-devel", $2);
2167 sub(/^libgl1-mesa-dri$/, "OpenGL", $2);
2168 sub(/^libglib2.0-dev$/, "glib2-devel", $2);
2169 sub(/^libglu1-mesa-dev$/, "OpenGL-GLU-devel", $2);
2170 sub(/^libgtk2.0-dev$/, "gtk+2-devel", $2);
2171 sub(/^libhunspell-dev$/, "hunspell-devel", $2);
2172 sub(/^libmcrypt-dev$/, "libmcrypt-devel", $2);
2173 sub(/^libmhash-dev$/, "mhash-devel", $2);
2174 sub(/^liboggz1-dev$/, "libggz-devel", $2);
2175 sub(/^libpango1.0-dev$/, "pango-devel", $2);
2176 sub(/^libqt4-dev$/, "qt4-build", $2);
2177 sub(/^libshout3-dev$/, "libshout-devel", $2);
30a90064 2178 sub(/^libslp-dev$/, "openslp-devel", $2);
3c606e9e
ER
2179 sub(/^libsndfile1-dev$/, "libsndfile-devel", $2);
2180 sub(/^libspeex-dev$/, "speex-devel", $2);
2181 sub(/^libssl-dev$/, "openssl-devel", $2);
2182 sub(/^libvorbis-dev$/, "libvorbis-devel", $2);
2183 sub(/^libxslt1-dev$/, "libxslt-devel", $2);
2184 sub(/^libxss-dev$/, "xorg-lib-libXScrnSaver-devel", $2);
2185 sub(/^mesa-common-dev$/, "OpenGL-devel", $2);
b371c36f
ER
2186 sub(/^libudev$/, "udev-libs", $2);
2187 sub(/^tcp_wrappers-devel$/, "libwrap-devel", $2);
2188 sub(/^vala-tools$/, "vala", $2);
2189 sub(/^vala-devel$/, "vala", $2);
c7f91339 2190
00697b90 2191 # altlinux
436f0f9e 2192 sub(/^libatk-devel$/, "atk-devel", $2);
7b8dbdb3 2193 sub(/^libgit-devel$/, "git-core-devel", $2);
436f0f9e 2194 sub(/^libgtk\+2-devel$/, "gtk+2-devel", $2);
00697b90
ER
2195 sub(/^libncurses-devel$/, "ncurses-devel", $2);
2196 sub(/^libncursesxx-devel$/, "ncurses-c++-devel", $2);
436f0f9e 2197 sub(/^libpango-devel$/, "pango-devel", $2);
00697b90 2198 sub(/^libpcre-devel$/, "pcre-devel", $2);
436f0f9e 2199 sub(/^libpopt-devel$/, "popt-devel", $2);
7b8dbdb3 2200 sub(/^libssl-devel$/, "openssl-devel", $2);
00697b90 2201
517313c5 2202 # suse
517313c5 2203 sub(/^alsa-devel$/, "alsa-lib-devel", $2);
517313c5 2204 sub(/^gtk-sharp2$/, "dotnet-gtk-sharp2", $2);
484bf2b0 2205 sub(/^gtkmm2-devel$/, "gtkmm-devel", $2);
87ffb46f
ER
2206 sub(/^libexpat-devel$/, "expat-devel", $2);
2207 sub(/^libffmpeg-devel$/, "ffmpeg-devel", $2);
484bf2b0 2208 sub(/^libopenssl-devel$/, "openssl-devel", $2);
87ffb46f 2209 sub(/^libpulse-devel$/, "pulseaudio-devel", $2);
517313c5 2210 sub(/^monodoc-core$/, "mono-monodoc", $2);
87ffb46f 2211 sub(/^python-gtk$/, "python-pygtk-gtk", $2);
517313c5 2212
92fa789e
ER
2213 replace_php_virtual_deps()
2214}
2215
2b94cfb4 2216# vim:ts=4:sw=4
This page took 0.596621 seconds and 4 git commands to generate.