3 # This is adapter v0.27. Adapter adapts .spec files for PLD.
5 # Copyright (C) 1999-2003 PLD-Team <feedback@pld-linux.org>
7 # Micha³ Kuratczyk <kura@pld.org.pl>
8 # Sebastian Zagrodzki <s.zagrodzki@mimuw.edu.pl>
9 # Tomasz K³oczko <kloczek@rudy.mif.pg.gda.pl>
10 # Artur Frysiak <wiget@pld-linux.org>
11 # Michal Kochanowicz <mkochano@pld.org.pl>
12 # Elan Ruusamäe <glen@pld-linux.org>
13 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
16 # - parse ../PLD-doc/BuildRequires.txt and setup proper BR epoches?
17 # - add "-nc" option to skip CVS interaction
19 # - sort Requires, BuildRequires
20 # - check if %description (lang=C) contains 8bit
21 # - desc wrapping is totally fucked up on global.spec,1.25, dosemu.spec,1.115-
24 preamble = 1 # Is it part of preamble? Default - yes
25 boc = 4 # Beginning of %changelog
26 bod = 0 # Beginning of %description
27 tw = 70 # Descriptions width
29 b_idx = 0 # index of BR/R arrays
31 # If variable removed, then 1 (for removing it from export)
32 removed["LDFLAGS"] = 0
34 removed["CXXFLAGS"] = 0
36 # get cvsaddress for changelog section
37 # using rpm macros as too lazy to add ~/.adapterrc parsing support.
38 "rpm --eval '%{?_cvsmaildomain}%{!?_cvsmaildomain:@pld-linux.org}'" | getline _cvsmaildomain
39 "rpm --eval '%{?_cvsmailfeedback}%{!?_cvsmailfeedback:PLD Team <feedback@pld-linux.org>}'" | getline _cvsmailfeedback
41 # If 1, we are inside of comment block (started with /^#%/)
44 # File with rpm groups
45 "rpm --eval %_sourcedir" | getline groups_file
46 groups_file = groups_file "/rpm.groups"
47 system("cd `rpm --eval %_sourcedir`; [ -f rpm.groups ] || cvs up rpm.groups >/dev/null")
49 # Temporary file for changelog section
50 changelog_file = ENVIRON["HOME"] "/tmp/adapter.changelog"
53 "rpm --eval %_prefix" | getline prefix
54 "rpm --eval %_bindir" | getline bindir
55 "rpm --eval %_sbindir" | getline sbindir
56 "rpm --eval %_libdir" | getline libdir
57 "rpm --eval %_sysconfdir" | getline sysconfdir
58 "rpm --eval %_datadir" | getline datadir
59 "rpm --eval %_includedir" | getline includedir
60 "rpm --eval %_mandir" | getline mandir
61 "rpm --eval %_infodir" | getline infodir
62 "rpm --eval %_examplesdir" | getline examplesdir
64 "rpm --eval %perl_sitearch" | getline perl_sitearch
65 "rpm --eval %perl_archlib" | getline perl_archlib
66 "rpm --eval %perl_privlib" | getline perl_privlib
67 "rpm --eval %perl_vendorlib" | getline perl_vendorlib
68 "rpm --eval %perl_vendorarch" | getline perl_vendorarch
69 "rpm --eval %perl_sitelib" | getline perl_sitelib
71 "rpm --eval %py_sitescriptdir" | getline py_sitescriptdir
74 # There should be a comment with CVS keywords on the first line of file.
76 if (!/# \$Revision:/) # If this line is already OK?
77 print "# $" "Revision:$, " "$" "Date:$" # No
80 next # It is enough for first line
84 # If the latest line matched /%files/
86 if (ENVIRON["SKIP_DEFATTR"] != 1) {
87 if ($0 !~ /defattr/) { # If no %defattr
88 print "%defattr(644,root,root,755)" # Add it
90 $0 = "%defattr(644,root,root,755)" # Correct mistakes (if any)
96 function b_makekey(a, b, s) {
99 gsub(/[#%]+{[!?]+[_a-zA-Z0-9]+:/, "", s);
100 # kill commented out items
101 gsub(/[# \t]*/, "", s);
108 # - mixing BR/R and anything else confuses this (all will be sorted together)
110 # - comments leading the BR/R can not be associated,
111 # so don't adapterize when the BR/R are mixed with comments
112 ENVIRON["SKIP_SORTBR"] != 1 && preamble == 1 && /(PreReq|(Build)?Requires)/, /(PreReq|(Build)?Requires)/ {
113 if ($1 ~ /PreReq:/) {
114 sub(/PreReq:/, "Requires:", $1);
119 l = substr($0, index($0, $2));
120 b_ktmp = b_makekey($1, l);
121 b_key[b_idx] = b_ktmp;
136 for (i = 1; i <= b_idx; i++) {
137 print "" b_val[b_key[i]];
144 /^#/ && (description == 0) {
145 if (/This file does not like to be adapterized!/) {
146 print # print this message
147 while (getline) # print the rest of spec as it is
149 do_not_touch_anything = 1 # do not touch anything in END()
153 # Generally, comments are printed without touching
159 # Remove defining _applnkdir (this macro has been included in rpm-3.0.4)
161 if ($2 == "_applnkdir") {
168 # Do not add %define of _prefix if it already is.
169 if ($2 ~ /^_prefix/) {
170 sub("^"prefix, $3, bindir)
171 sub("^"prefix, $3, sbindir)
172 sub("^"prefix, $3, libdir)
173 sub("^"prefix, $3, datadir)
174 sub("^"prefix, $3, includedir)
178 if ($2 ~ /_bindir/ && !/_sbindir/)
184 if ($2 ~ /_sysconfdir/ && $3 !~ /^%\(/)
188 if ($2 ~ /_includedir/)
195 # version related macros
203 # these are used usually when adapterizing external spec
206 if ($2 ~ /^version$/)
208 if ($2 ~ /^release$/)
211 # do nothing further, otherwise adapter thinks we're at preamble
217 /^%include.*\/usr\/lib\/rpm\/macros\.python$/ {
224 /^%description/, (/^%[a-z]+/ && !/^%description/ && !/^%((end)?if|else)/) {
227 if (/^%description/) {
234 if (ENVIRON["SKIP_DESC"] != 1 && description == 1 && !/^%[a-z]+/ && !/^%description/) {
236 format_flush(format_line, format_indent)
240 } else if (/^[ \t]*[-\*][ \t]*/) {
241 format_flush(format_line, format_indent)
243 format_indent = RLENGTH
244 match($0, /^[ \t]*[-\*][ \t]/)
245 format_line = substr($0, RLENGTH)
247 format_line = format_line " " $0
251 if (/^%[a-z]+/ && (!/^%description/ || bod == 2)) {
252 if (NF > 3 && $2 == "-l") {
254 for (i = 4; i <= NF; i++)
258 format_flush(format_line, format_indent)
273 /^%prep/, (/^%[a-z]+$/ && !/^%prep/ && !/^%((end)?if|else)/) {
279 if (/^%setup/ && !/-q/) {
280 sub(/^%setup/, "%setup -q")
284 $0 = fixedsub(name, "%{name}", $0);
285 $0 = fixedsub(version, "%{version}", $0);
287 $0 = fixedsub(_beta, "%{_beta}", $0);
290 $0 = fixedsub(_rc, "%{_rc}", $0);
293 $0 = fixedsub(_snap, "%{_snap}", $0);
297 if (/^%setup/ && /-n %{name}-%{version}( |$)/) {
298 $0 = fixedsub(" -n %{name}-%{version}", "", $0)
302 sub("^rm -rf \$RPM_BUILD_ROOT.*", "");
308 /^%build/, (/^%[a-z]+$/ && !/^%build/ && !/^%((end)?if|else)/) {
317 if (/LDFLAGS="-s"/) {
318 removed["LDFLAGS"] = 1
321 split($0, tmp, "LDFLAGS=")
322 count = split(tmp[2], flags, "\"")
323 if (flags[1] != "" && flags[1] !~ "!?debug") {
324 sub(/-s[" ]?/, "%{rpmldflags} ", flags[1])
325 $0 = tmp[1] line[1] "LDFLAGS=" flags[1] "\""
326 for (i = 2; i < count; i++)
327 $0 = $0 flags[i] "\""
333 if (cflags("CFLAGS") == 0)
337 if (cflags("CXXFLAGS") == 0)
341 if (removed["LDFLAGS"])
343 if (removed["CFLAGS"])
345 if (removed["CXXFLAGS"])
347 # Is there still something?
354 sub("CC=%{__cc}", "CC=\"%{__cc}\"")
357 # use PLD Linux macros
358 $0 = fixedsub("glib-gettextize --copy --force","%{__glib_gettextize}", $0);
359 $0 = fixedsub("intltoolize --copy --force", "%{__intltoolize}", $0);
360 $0 = fixedsub("automake --add-missing --copy", "%{__automake}", $0);
362 sub(/^aclocal$/, "%{__aclocal}");
363 sub(/^autoheader$/, "%{__autoheader}");
364 sub(/^autoconf$/, "%{__autoconf}");
365 sub(/^automake$/, "%{__automake}");
368 $0 = fixedsub("%perl_configure", "%{__perl} Makefile.PL \\\n\tINSTALLDIRS=vendor", $0);
369 $0 = fixedsub("%perl_makecheck", "%{?with_tests:%{__make} test}", $0);
375 /^%clean/, (/^%[a-z]+$/ && !/^%clean/ && !/^%((end)?if|else)/) {
378 # prevent next section header like "%post -p /sbin/ldconfig" being adapterized
387 /^%install/, (/^%[a-z]+$/ && !/^%install/ && !/^%((end)?if|else)/) {
391 if (/^[ \t]*rm([ \t]+-[rf]+)*[ \t]+\${?RPM_BUILD_ROOT}?/ && did_rmroot==0) {
393 print "rm -rf $RPM_BUILD_ROOT"
397 if (!/^(#?[ \t]*)$/ && !/^%install/ && did_rmroot==0) {
398 print "rm -rf $RPM_BUILD_ROOT"
404 # 'install -d' instead 'mkdir -p'
406 sub(/mkdir -p/, "install -d")
408 # 'install' instead 'cp -p'
410 sub(/cp -p/, "install")
412 # No '-u root' or '-g root' for 'install'
413 if (/^install/ && /-[ug][ \t]*root/)
414 gsub(/-[ug][ \t]*root /, "")
416 if (/^install/ && /-m[ \t]*[0-9]+/)
417 gsub(/-m[ \t]*[0-9]+ /, "")
419 # No lines contain 'chown' or 'chgrp' if owner/group is 'root'
420 if (($1 ~ /chown/ && $2 ~ /root\.root/) || ($1 ~ /chgrp/ && $2 ~ /root/))
423 # No lines contain 'chmod' if it sets the modes to '644'
424 if ($1 ~ /chmod/ && $2 ~ /644/)
428 $0 = fixedsub("%buildroot", "$RPM_BUILD_ROOT", $0)
429 $0 = fixedsub("%{buildroot}", "$RPM_BUILD_ROOT", $0)
432 $0 = fixedsub("%perl_makeinstall", "%{__make} pure_install \\\n\tDESTDIR=$RPM_BUILD_ROOT", $0);
438 /^%files/, (/^%[a-z \-]+$/ && !/^%files/ && !/^%((end)?if|else)/) {
450 /^%changelog/, (/^%[a-z]+$/ && !/^%changelog/) {
454 # There should be some CVS keywords on the first line of %changelog.
456 if ($0 !~ _cvsmailfeedback)
457 print "* %{date} " _cvsmailfeedback > changelog_file
462 if (boc == 2 && !skip) {
463 if (!/All persons listed below/) {
464 printf "All persons listed below can be reached at " > changelog_file
465 print "<cvs_login>" _cvsmaildomain "\n" > changelog_file
470 if (boc == 1 && !skip) {
473 print "$" "Log:$" > changelog_file
480 printf "%%define date\t%%(echo `LC_ALL=\"C\"" > changelog_file
481 print " date +\"%a %b %d %Y\"`)" > changelog_file
488 if (!/^%[a-z]+$/ || /changelog/)
489 print > changelog_file
498 /^%pre/, (/^%[a-z]+$/ && !/^%pre/) {
501 # %useradd and %groupadd may not be wrapped
502 if (/%(useradd|groupadd).*\\$/) {
505 $0 = substr(a, 1, length(a) - 1) $0;
509 /^%post/, (/^%[a-z]+$/ && !/^%post/) {
512 /^%preun/, (/^%[a-z]+$/ && !/^%preun/) {
515 /^%postun/, (/^%[a-z]+$/ && !/^%postun/) {
518 /^%triggerin/, (/^%[a-z]+$/ && !/^%triggerin/) {
521 /^%triggerun/, (/^%[a-z]+$/ && !/^%triggerun/) {
524 /^%triggerpostun/, (/^%[a-z]+$/ && !/^%triggerpostun/) {
527 /^%pretrans/, (/^%[a-z]+$/ && !/^%pretrans/) {
530 /^%posttrans/, (/^%[a-z]+$/ && !/^%posttrans/) {
538 # There should not be a space after the name of field
539 # and before the colon.
542 if (/^%perl_module_wo_prefix/) {
545 release = "0." fixedsub(".%{disttag}.at", "", $4)
550 if (field ~ /summary:/) {
553 if (field ~ /group(\([^)]+\)):/)
555 if (field ~ /group:/) {
557 sub(/^Utilities\//,"Applications/",$2)
558 sub(/^Games/,"Applications/Games",$2)
559 sub(/^X11\/Games/,"X11/Applications/Games",$2)
560 sub(/^X11\/GNOME\/Development\/Libraries/,"X11/Development/Libraries",$2)
561 sub(/^X11\/GNOME\/Applications/,"X11/Applications",$2)
562 sub(/^X11\/GNOME/,"X11/Applications",$2)
563 sub(/^X11\/Utilities/,"X11/Applications",$2)
564 sub(/^X11\/Games\/Strategy/,"X11/Applications/Games/Strategy",$2)
565 sub(/^Shells/,"Applications/Shells",$2)
567 sub(/^[^ \t]*[ \t]*/,"")
570 sub(/^System Environment\/Libraries$/, "Libraries", Grupa)
571 sub(/^System Environment\/Daemons$/, "Daemons", Grupa)
572 sub(/^Applications\/Internet$/, "Applications/Networking", Grupa)
573 sub(/^Applications\/Daemons$/, "Daemons", Grupa)
574 sub(/^Application\/Multimedia$/, "Applications/Multimedia", Grupa)
575 sub(/^System\/Servers$/, "Daemons", Grupa)
576 sub(/^X11\/Xserver$/, "X11/Servers", Grupa)
577 sub(/^X11\/XFree86/, "X11", Grupa)
578 sub(/^Applications\/Compilers$/, "Development/Languages", Grupa)
579 sub(/^Applications\/Internet\/Peer to Peer/, "Applications/Networking", Grupa)
580 sub(/^Networking\/Deamons$/, "Networking/Daemons", Grupa)
581 sub(/^Development\/Docs$/, "Documentation", Grupa)
583 print "Group:\t\t" Grupa
584 if (Grupa ~ /^X11/ && x11 == 0) # Is it X11 application?
587 byl_plik_z_grupami = 0
589 while ((getline linia_grup < groups_file) > 0) {
590 byl_plik_z_grupami = 1
591 if (linia_grup == Grupa) {
597 if (!byl_plik_z_grupami)
598 print "######\t\t" groups_file ": no such file"
599 else if (!byl_opis_grupy)
600 print "######\t\t" "Unknown group!"
606 if (field ~ /prereq:/) {
607 sub(/PreReq:/, "Requires:", $1);
610 # split (build)requires, obsoletes on commas
611 if (field ~ /(obsoletes|requires):/ && $0 ~ /,/) {
612 l = substr($0, index($0, $2));
613 n = split(l, p, / *, */);
615 printf("%s\t%s\n", $1, p[i]);
620 if (field ~ /packager:|distribution:|docdir:|prefix:/)
623 if (field ~ /buildroot:/)
624 $0 = $1 "%{tmpdir}/%{name}-%{version}-root-%(id -u -n)"
626 # Use "License" instead of "Copyright" if it is (L)GPL or BSD
627 if (field ~ /copyright:/ && $2 ~ /GPL|BSD/)
630 if (field ~ /name:/) {
631 if ($2 == "%{name}" && name) {
638 if (field ~ /version:/) {
639 if ($2 == "%{version}" && version) {
646 if (field ~ /release:/) {
647 if ($2 == "%{release}" && release) {
654 if (field ~ /serial:/)
658 if (field ~ /^url:$/)
661 # Use %{name} and %{version} in the filenames in "Source:"
662 if (field ~ /^source/ || field ~ /patch/) {
663 n = split($2, url, /\//)
664 if (url[n] ~ /\.gz$/) {
665 url[n+1] = ".gz" url[n+1]
666 sub(/\.gz$/,"",url[n])
668 if (url[n] ~ /\.zip$/) {
669 url[n+1] = ".zip" url[n+1]
670 sub(/\.zip$/,"",url[n])
672 if (url[n] ~ /\.tar$/) {
673 url[n+1] = ".tar" url[n+1]
674 sub(/\.tar$/,"",url[n])
676 if (url[n] ~ /\.patch$/) {
677 url[n+1] = ".patch" url[n+1]
678 sub(/\.patch$/,"",url[n])
680 if (url[n] ~ /\.bz2$/) {
681 url[n+1] = ".bz2" url[n+1]
682 sub(/\.bz2$/,"",url[n])
684 if (url[n] ~ /\.logrotate$/) {
685 url[n+1] = ".logrotate" url[n+1]
686 sub(/\.logrotate$/,"",url[n])
688 if (url[n] ~ /\.pamd$/) {
689 url[n+1] = ".pamd" url[n+1]
690 sub(/\.pamd$/,"",url[n])
693 # allow %{name} just in last url component
695 for (i = 1; i <= n; i++) {
696 url[i] = fixedsub("%{name}", name, url[i])
707 url[n] = fixedsub(name, "%{name}", url[n])
709 if (field ~ /source/) {
711 url[n] = fixedsub(version, "%{version}", url[n])
714 url[n] = fixedsub(_beta, "%{_beta}", url[n])
717 url[n] = fixedsub(_rc, "%{_rc}", url[n])
720 url[n] = fixedsub(_snap, "%{_snap}", url[n])
723 $2 = fixedsub(filename, url[n], $2)
726 sub("[?]use_mirror=.*$", "", $2);
727 sub("[?]download$", "", $2);
728 sub("^http://prdownloads\.sourceforge\.net/", "http://dl.sourceforge.net/", $2)
730 sub("^http://.*\.dl\.sourceforge\.net/", "http://dl.sourceforge.net/", $2)
731 sub("^http://dl\.sourceforge\.net/sourceforge/", "http://dl.sourceforge.net/", $2)
732 sub("^http://dl\.sf\.net/", "http://dl.sourceforge.net/", $2)
736 if (field ~ /^source:/)
739 if (field ~ /^patch:/)
744 if (field ~ /requires/) {
746 $0 = fixedsub("%{eversion}", "%{epoch}:%{version}-%{release}", $0);
757 if (name_seen == 0 && name) {
762 if (version_seen == 0 && version) {
763 print "Version:\t" version
767 if (release_seen == 0 && release) {
768 print "Release:\t" release
775 if (do_not_touch_anything)
778 close(changelog_file)
779 while ((getline < changelog_file) > 0)
781 system("rm -f " changelog_file)
783 if (did_clean == 0) {
786 print "rm -rf $RPM_BUILD_ROOT"
791 print "%define date\t%(echo `LC_ALL=\"C\" date +\"%a %b %d %Y\"`)"
794 if (has_changelog == 0)
798 print "* %{date} PLD Team <feedback@pld-linux.org>"
800 printf "All persons listed below can be reached at "
801 print "<cvs_login>@pld-linux.org\n"
807 function fixedsub(s1,s2,t, ind) {
808 # substitutes fixed strings (not regexps)
809 if (ind = index(t,s1))
810 t = substr(t, 1, ind-1) s2 substr(t, ind+length(s1))
814 # There should be one or two tabs after the colon.
815 function format_preamble()
818 if (match($0, /[A-Za-z0-9(),#_ \t]+[ \t]*:[ \t]*/) == 1) {
826 # Replace directly specified directories with macros
827 function use_macros()
829 # -m, --skip-macros, --no-macros -- skip macros subst
830 if (ENVIRON["SKIP_MACROS"]) {
834 gsub(perl_sitearch, "%{perl_sitearch}")
835 gsub(perl_archlib, "%{perl_archlib}")
836 gsub(perl_privlib, "%{perl_privlib}")
837 gsub(perl_vendorlib, "%{perl_vendorlib}")
838 gsub(perl_vendorarch, "%{perl_vendorarch}")
839 gsub(perl_sitelib, "%{perl_sitelib}")
841 gsub(py_sitescriptdir, "%{py_sitescriptdir}")
843 gsub(bindir, "%{_bindir}")
844 gsub("%{prefix}/bin", "%{_bindir}")
845 if(prefix"/bin" == bindir)
846 gsub("%{_prefix}/bin", "%{_bindir}")
848 for (c = 1; c <= NF; c++) {
849 if ($c ~ sbindir "/fix-info-dir")
851 if ($c ~ sbindir "/webapp")
853 if ($c ~ sbindir "/chsh")
855 if ($c ~ sbindir "/usermod")
857 gsub(sbindir, "%{_sbindir}", $c)
860 gsub("%{prefix}/sbin", "%{_sbindir}")
861 if (prefix"/sbin" == sbindir)
862 gsub("%{_prefix}/sbin", "%{_sbindir}")
864 for (c = 1; c <= NF; c++) {
865 if ($c ~ sysconfdir "/{?cron.")
867 if ($c ~ sysconfdir "/{?crontab.d")
869 if ($c ~ sysconfdir "/{?env.d")
871 if ($c ~ sysconfdir "/{?logrotate.d")
873 if ($c ~ sysconfdir "/{?pam.d")
875 if ($c ~ sysconfdir "/{?profile.d")
877 if ($c ~ sysconfdir "/{?rc.d")
879 if ($c ~ sysconfdir "/{?security")
881 if ($c ~ sysconfdir "/{?skel")
883 if ($c ~ sysconfdir "/{?sysconfig")
885 if ($c ~ sysconfdir "/{?shrc.d")
887 if ($c ~ sysconfdir "/{?certs")
889 if ($c ~ sysconfdir "/{?X11")
891 if ($c ~ sysconfdir "/{?ld.so.conf.d")
893 if ($c ~ sysconfdir "/{?httpd") # temp
895 gsub(sysconfdir, "%{_sysconfdir}", $c)
898 for (c = 1; c <= NF; c++) {
899 if ($c ~ datadir "/automake")
901 if ($c ~ datadir "/unsermake")
903 if ($c ~ datadir "/file/magic.mime")
905 gsub(datadir, "%{_datadir}", $c)
908 gsub("%_sbindir", "%{_sbindir}")
909 gsub("%_mandir", "%{_mandir}")
910 gsub("%name", "%{name}")
912 gsub("%{prefix}/share", "%{_datadir}")
913 if (prefix"/share" == datadir)
914 gsub("%{_prefix}/share", "%{_datadir}")
916 # CFLAGS="-I/usr/include/ncurses is usually correct.
917 if (!/-I\/usr\/include/) {
918 gsub(includedir, "%{_includedir}")
921 gsub("%{prefix}/include", "%{_includedir}")
922 if (prefix"/include" == includedir) {
923 gsub("%{_prefix}/include", "%{_includedir}")
926 gsub(mandir, "%{_mandir}")
927 if ($0 !~ "%{_datadir}/manual") {
928 gsub("%{_datadir}/man", "%{_mandir}")
930 gsub("%{_prefix}/share/man", "%{_mandir}")
931 gsub("%{prefix}/share/man", "%{_mandir}")
932 gsub("%{prefix}/man", "%{_mandir}")
933 gsub("%{_prefix}/man", "%{_mandir}")
935 gsub(infodir, "%{_infodir}")
936 gsub("%{prefix}/info", "%{_infodir}")
937 gsub("%{_prefix}/info", "%{_infodir}")
939 if (prefix !~ "/X11R6") {
940 gsub("%{_datadir}/aclocal", "%{_aclocaldir}")
943 gsub(examplesdir, "%{_examplesdir}")
946 # leave --with-foo=/usr alone
947 if ($0 !~ "--with.*=.*" prefix) {
948 for (c = 1; c <= NF; c++) {
949 if ($c ~ prefix "/sbin/fix-info-dir")
951 if ($c ~ prefix "/sbin/webapp")
953 if ($c ~ prefix "/sbin/chsh")
955 if ($c ~ prefix "/sbin/usermod")
957 if ($c ~ prefix "/share/automake")
959 if ($c ~ prefix "/share/unsermake")
961 if ($c ~ prefix "/lib/sendmail")
963 if ($c ~ prefix "/lib/pkgconfig")
966 # CFLAGS="-I/usr..." is usually correct.
969 # same for LDFLAGS="-L/usr..."
973 gsub(prefix, "%{_prefix}", $c)
976 gsub("%{prefix}", "%{_prefix}")
979 gsub("%{PACKAGE_VERSION}", "%{version}")
980 gsub("%{PACKAGE_NAME}", "%{name}")
982 gsub("^make$", "%{__make}")
983 gsub("^make ", "%{__make} ")
984 gsub("^gcc ", "%{__cc} ")
987 gsub("^%make$", "%{__make}")
988 gsub("^%make ", "%{__make} ")
989 gsub("^%makeinstall_std", "%{__make} install \\\n\tDESTDIR=$RPM_BUILD_ROOT")
990 gsub("^%{makeinstall}", "%{__make} install \\\n\tDESTDIR=$RPM_BUILD_ROOT")
991 gsub("^%makeinstall", "%{__make} install \\\n\tDESTDIR=$RPM_BUILD_ROOT")
992 gsub("^%{__rm} -rf %{buildroot}", "rm -rf $RPM_BUILD_ROOT")
993 gsub("^%{__install}", "install")
994 gsub("^%{__rm}", "rm")
995 gsub("%optflags", "%{rpmcflags}")
996 gsub("%{compat_perl_vendorarch}", "%{perl_vendorarch}")
998 gsub("^%{__make} install DESTDIR=\$RPM_BUILD_ROOT", "%{__make} install \\\n\tDESTDIR=$RPM_BUILD_ROOT")
999 gsub("^fix-info-dir$", "[ ! -x /usr/sbin/fix-info-dir ] || /usr/sbin/fix-info-dir -c %{_infodir} >/dev/null 2>\&1")
1000 $0 = fixedsub("%buildroot", "$RPM_BUILD_ROOT", $0)
1001 $0 = fixedsub("%{buildroot}", "$RPM_BUILD_ROOT", $0)
1002 $0 = fixedsub("CXXFLAGS=%{rpmcflags} %configure", "CXXFLAGS=%{rpmcflags}\n%configure", $0);
1004 gsub("%_bindir", "%{_bindir}")
1005 gsub("%_datadir", "%{_datadir}")
1006 gsub("%_iconsdir", "%{_iconsdir}")
1008 gsub("/usr/src/linux", "%{_kernelsrcdir}")
1009 gsub("%{_prefix}/src/linux", "%{_kernelsrcdir}")
1013 # insertion sort of A[1..n]
1014 # copied from mawk manual
1015 function isort(A,n, i,j,hold) {
1016 for (i = 2; i <= n; i++) {
1018 while (A[j-1] > hold) {
1023 # sentinel A[0] = "" will be created if needed
1027 function use_files_macros( i, n, t, a)
1031 gsub("^%{_sbindir}", "%attr(755,root,root) %{_sbindir}")
1032 gsub("^%{_bindir}", "%attr(755,root,root) %{_bindir}")
1034 # uid/gid nobody is not valid in %files
1035 if (/%attr([^)]*nobody[^)]*)/ && !/FIXME/) {
1036 $0 = $0 " # FIXME nobody user/group can't own files! -adapter.awk"
1040 gsub("%{_sysconfdir}/cron\.d", "/etc/cron.d")
1041 gsub("%{_sysconfdir}/crontab\.d", "/etc/crontab.d")
1042 gsub("%{_sysconfdir}/logrotate\.d", "/etc/logrotate.d")
1043 gsub("%{_sysconfdir}/pam\.d", "/etc/pam.d")
1044 gsub("%{_sysconfdir}/profile\.d", "/etc/profile.d")
1045 gsub("%{_sysconfdir}/rc\.d", "/etc/rc.d")
1046 gsub("%{_sysconfdir}/security", "/etc/security")
1047 gsub("%{_sysconfdir}/skel", "/etc/skel")
1048 gsub("%{_sysconfdir}/sysconfig", "/etc/sysconfig")
1049 gsub("%{_sysconfdir}/certs", "/etc/certs")
1050 gsub("%{_sysconfdir}/init.d", "/etc/init.d")
1052 # /etc/init.d -> /etc/rc.d/init.d
1053 if (!/^\/etc\/init\.d$/) {
1054 gsub("/etc/init.d", "/etc/rc.d/init.d")
1057 if (/\/etc\/rc\.d\/init\.d\// && !/functions/) {
1058 if (!/%attr.*\/etc\/rc\.d\/init\.d/) {
1059 $0 = "%attr(754,root,root) " $0
1061 if (/^%attr.*\/etc\/rc\.d\/init\.d/ && !/^%attr\(754 *,/) {
1062 gsub("^%attr\\(... *,", "%attr(754,");
1066 if (/lib.+\.so/ && !/\.so$/ && !/^%attr.*/ && !/%exclude/) {
1067 $0 = "%attr(755,root,root) " $0
1070 # /etc/sysconfig files
1071 # %attr(640,root,root) %config(noreplace) %verify(not size mtime md5) /etc/sysconfig/*
1072 # attr not required, allow default 644 attr
1073 if (!/network-scripts/ && !/%dir/ && !/\.d$/ && !/functions/ && !/\/etc\/sysconfig\/wmstyle/) {
1074 if (/\/etc\/sysconfig\// && /%config/ && !/%config\(noreplace\)/) {
1075 gsub("%config", "%config(noreplace)")
1078 if (/\/etc\/sysconfig\// && !/%config\(noreplace\)/) {
1079 $NF = "%config(noreplace) " $NF
1082 if (/\/etc\/sysconfig\// && /%attr\(755/) {
1083 gsub("^%attr\\(... *,", "%attr(640,");
1086 if (/\/etc\/sysconfig\// && !/%verify/) {
1087 gsub("/etc/sysconfig", "%verify(not size mtime md5) /etc/sysconfig");
1091 # kill leading zeros
1092 if (/%attr\(0[1-9]/) {
1093 gsub("%attr\\(0", "%attr(")
1096 # sort %verify attrs
1097 if (match($0, /%verify\(not([^)]+)\)/)) {
1098 t = substr($0, RSTART, RLENGTH)
1099 # kill commas: %verify(not,md5,size,mtime)
1102 gsub(/^%verify\(not |\)$/, "", t)
1103 n = split(t, a, / /)
1107 for (i = 1 ; i <= n; i++) {
1112 gsub(/%verify\(not[^)]+\)/, s)
1119 # locale dir and no %lang -> bad
1120 if (/%{_datadir}\/locale\/.*\// && !/%(dir|lang)/) {
1121 $(NF + 1) = "# FIXME consider using %find_lang"
1125 $0 = fixedsub("%{perl_man1dir}", "%{_mandir}/man1", $0);
1126 $0 = fixedsub("%{perl_man3dir}", "%{_mandir}/man3", $0);
1127 $0 = fixedsub("%{perl_bin}", "%{_bindir}", $0);
1129 gsub(libdir "/pkgconfig", "%{_pkgconfigdir}");
1130 gsub("%{_libdir}/pkgconfig", "%{_pkgconfigdir}");
1131 gsub("%{_prefix}/lib/pkgconfig", "%{_pkgconfigdir}");
1133 gsub("%{_datadir}/applications", "%{_desktopdir}");
1134 gsub("%{_datadir}/icons", "%{_iconsdir}");
1135 gsub("%{_datadir}/pixmaps", "%{_pixmapsdir}");
1138 function fill(ch, n, i) {
1139 for (i = 0; i < n; i++)
1143 function format_flush(line, indent, newline, word, first_word) {
1145 if (format_indent == -1)
1148 newline = fill(" ", format_indent) "- "
1150 while (match(line, /[^\t ]+/)) {
1151 word = substr(line, RSTART, RLENGTH)
1152 if (length(newline) + length(word) + 1 > tw) {
1155 if (format_indent == -1)
1158 newline = fill(" ", format_indent + 2)
1163 newline = newline word
1166 newline = newline " " word
1168 line = substr(line, RSTART + RLENGTH)
1170 if (newline ~ /[^\t ]/) {
1175 function cflags(var)
1177 if ($0 == var "=\"$RPM_OPT_FLAGS\"") {
1183 sub("\$RPM_OPT_FLAGS", "%{rpmcflags}")