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