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