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
22 preamble = 1 # Is it part of preamble? Default - yes
23 boc = 4 # Beggining of %changelog
24 bod = 0 # Beggining of %description
25 tw = 70 # Descriptions width
27 b_idx = 0 # index of BR/R arrays
29 # If variable removed, then 1 (for removing it from export)
30 removed["LDFLAGS"] = 0
32 removed["CXXFLAGS"] = 0
34 # get cvsaddress for changelog section
35 # using rpm macros as too lazy to add ~/.adapterrc parsing support.
36 "rpm --eval '%{?_cvsmaildomain}%{!?_cvsmaildomain:@pld-linux.org}'" | getline _cvsmaildomain
37 "rpm --eval '%{?_cvsmailfeedback}%{!?_cvsmailfeedback:PLD Team <feedback@pld-linux.org>}'" | getline _cvsmailfeedback
39 # If 1, we are inside of comment block (started with /^#%/)
42 # File with rpm groups
43 "rpm --eval %_sourcedir" | getline groups_file
44 groups_file = groups_file "/rpm.groups"
45 system("cd `rpm --eval %_sourcedir`; cvs up rpm.groups >/dev/null")
47 # Temporary file for changelog section
48 changelog_file = ENVIRON["HOME"] "/tmp/adapter.changelog"
51 "rpm --eval %_prefix" | getline prefix
52 "rpm --eval %_bindir" | getline bindir
53 "rpm --eval %_sbindir" | getline sbindir
54 "rpm --eval %_libdir" | getline libdir
55 "rpm --eval %_sysconfdir" | getline sysconfdir
56 "rpm --eval %_datadir" | getline datadir
57 "rpm --eval %_includedir" | getline includedir
58 "rpm --eval %_mandir" | getline mandir
59 "rpm --eval %_infodir" | getline infodir
60 "rpm --eval %_examplesdir" | getline examplesdir
62 "rpm --eval %perl_sitearch" | getline perl_sitearch
63 "rpm --eval %perl_archlib" | getline perl_archlib
64 "rpm --eval %perl_privlib" | getline perl_privlib
65 "rpm --eval %perl_vendorlib" | getline perl_vendorlib
66 "rpm --eval %perl_vendorarch" | getline perl_vendorarch
67 "rpm --eval %perl_sitelib" | getline perl_sitelib
69 "rpm --eval %py_sitescriptdir" | getline py_sitescriptdir
72 # There should be a comment with CVS keywords on the first line of file.
74 if (!/# \$Revision:/) # If this line is already OK?
75 print "# $" "Revision:$, " "$" "Date:$" # No
78 next # It is enough for first line
82 # If the latest line matched /%files/
84 if ($0 !~ /defattr/) # If no %defattr
85 print "%defattr(644,root,root,755)" # Add it
87 $0 = "%defattr(644,root,root,755)" # Correct mistakes (if any)
91 function b_makekey(a, b, s) {
94 gsub("%{\\?[_a-zA-Z0-9]+:", "", s);
101 # - mixing BR/R and anything else confuses this (all will be sorted together)
103 # - comments leading the BR/R can not be associated,
104 # so don't adapterize when the BR/R are mixed with comments
105 ENVIRON["SORTBR"] == 1 && preamble == 1 && /(Build)?Requires/, /(Build)?Requires/ { # && !/^%/) {
107 l = substr($0, index($0, $2));
108 b_ktmp = b_makekey($1, l);
109 b_key[b_idx] = b_ktmp;
124 for (i = 1; i <= b_idx; i++) {
125 print "" b_val[b_key[i]];
132 /^#/ && (description == 0) {
133 if (/This file does not like to be adapterized!/) {
134 print # print this message
135 while (getline) # print the rest of spec as it is
137 do_not_touch_anything = 1 # do not touch anything in END()
141 # Generally, comments are printed without touching
147 # Remove defining _applnkdir (this macro has been included in rpm-3.0.4)
149 if ($2 == "_applnkdir")
156 /^%include.*\/usr\/lib\/rpm\/macros\.python$/ {
163 /^%description/, (/^%[a-z]+/ && !/^%description/ && !/^%((end)?if|else)/) {
166 if (/^%description/) {
173 if (description == 1 && !/^%[a-z]+/ && !/^%description/) {
175 format_flush(format_line, format_indent)
179 } else if (/^[ \t]*[-\*][ \t]*/) {
180 format_flush(format_line, format_indent)
182 format_indent = RLENGTH
183 match($0, /^[ \t]*[-\*][ \t]/)
184 format_line = substr($0, RLENGTH)
186 format_line = format_line " " $0
190 if (/^%[a-z]+/ && (!/^%description/ || bod == 2)) {
191 if (NF > 3 && $2 == "-l") {
193 for (i = 4; i <= NF; i++)
197 format_flush(format_line, format_indent)
212 /^%prep/, (/^%[a-z]+$/ && !/^%prep/ && !/^%((end)?if|else)/) {
218 if (/^%setup/ && !/-q/) {
219 sub(/^%setup/, "%setup -q")
223 gsub(name, "%{name}");
224 gsub(version, "%{version}");
226 gsub(_beta, "%{_beta}");
232 gsub(_snap, "%{_snap}");
236 if (/^%setup/ && /-n %{name}-%{version}( |$)/) {
237 sub(/ -n %{name}-%{version}/, "")
241 sub("^rm -rf \$RPM_BUILD_ROOT.*", "");
247 /^%build/, (/^%[a-z]+$/ && !/^%build/ && !/^%((end)?if|else)/) {
256 if (/LDFLAGS="-s"/) {
257 removed["LDFLAGS"] = 1
260 split($0, tmp, "LDFLAGS=")
261 count = split(tmp[2], flags, "\"")
262 if (flags[1] != "" && flags[1] !~ "!?debug") {
263 sub(/-s[" ]?/, "%{rpmldflags} ", flags[1])
264 $0 = tmp[1] line[1] "LDFLAGS=" flags[1] "\""
265 for (i = 2; i < count; i++)
266 $0 = $0 flags[i] "\""
272 if (cflags("CFLAGS") == 0)
276 if (cflags("CXXFLAGS") == 0)
280 if (removed["LDFLAGS"])
282 if (removed["CFLAGS"])
284 if (removed["CXXFLAGS"])
286 # Is there still something?
292 $0 = fixedsub("glib-gettextize --copy --force","%{__glib_gettextize}", $0);
293 $0 = fixedsub("intltoolize --copy --force", "%{__intltoolize}", $0);
296 $0 = fixedsub("%perl_configure", "%{__perl} Makefile.PL \\\n\tINSTALLDIRS=vendor", $0);
297 $0 = fixedsub("%perl_makecheck", "%{?with_tests:%{__make} test}", $0);
303 /^%clean/, (/^%[a-z]+$/ && !/^%clean/ && !/^%((end)?if|else)/) {
311 /^%install/, (/^%[a-z]+$/ && !/^%install/ && !/^%((end)?if|else)/) {
315 if (/^[ \t]*rm([ \t]+-[rf]+)*[ \t]+\${?RPM_BUILD_ROOT}?/ && did_rmroot==0) {
317 print "rm -rf $RPM_BUILD_ROOT"
321 if (!/^(#?[ \t]*)$/ && !/^%install/ && did_rmroot==0) {
322 print "rm -rf $RPM_BUILD_ROOT"
328 # 'install -d' instead 'mkdir -p'
330 sub(/mkdir -p/, "install -d")
332 # 'install' instead 'cp -p'
334 sub(/cp -p/, "install")
336 # No '-u root' or '-g root' for 'install'
337 if (/^install/ && /-[ug][ \t]*root/)
338 gsub(/-[ug][ \t]*root /, "")
340 if (/^install/ && /-m[ \t]*[0-9]+/)
341 gsub(/-m[ \t]*[0-9]+ /, "")
343 # No lines contain 'chown' or 'chgrp' if owner/group is 'root'
344 if (($1 ~ /chown/ && $2 ~ /root\.root/) || ($1 ~ /chgrp/ && $2 ~ /root/))
347 # No lines contain 'chmod' if it sets the modes to '644'
348 if ($1 ~ /chmod/ && $2 ~ /644/)
352 $0 = fixedsub("%buildroot", "$RPM_BUILD_ROOT", $0)
353 $0 = fixedsub("%{buildroot}", "$RPM_BUILD_ROOT", $0)
356 $0 = fixedsub("%perl_makeinstall", "%{__make} pure_install \\\n\tDESTDIR=$RPM_BUILD_ROOT", $0);
362 /^%files/, (/^%[a-z \-]+$/ && !/^%files/ && !/^%((end)?if|else)/) {
375 /^%changelog/, (/^%[a-z]+$/ && !/^%changelog/) {
379 # There should be some CVS keywords on the first line of %changelog.
381 if ($0 !~ _cvsmailfeedback)
382 print "* %{date} " _cvsmailfeedback > changelog_file
387 if (boc == 2 && !skip) {
388 if (!/All persons listed below/) {
389 printf "All persons listed below can be reached at " > changelog_file
390 print "<cvs_login>" _cvsmaildomain "\n" > changelog_file
395 if (boc == 1 && !skip) {
398 print "$" "Log:$" > changelog_file
405 printf "%%define date\t%%(echo `LC_ALL=\"C\"" > changelog_file
406 print " date +\"%a %b %d %Y\"`)" > changelog_file
413 if (!/^%[a-z]+$/ || /changelog/)
414 print > changelog_file
423 /^%pre/, (/^%[a-z]+$/ && !/^%pre/) {
426 # %useradd and %groupadd may not be wrapped
427 if (/%(useradd|groupadd).*\\$/) {
430 $0 = substr(a, 1, length(a) - 1) $0;
434 /^%post/, (/^%[a-z]+$/ && !/^%post/) {
437 /^%preun/, (/^%[a-z]+$/ && !/^%preun/) {
440 /^%postun/, (/^%[a-z]+$/ && !/^%postun/) {
443 /^%triggerin/, (/^%[a-z]+$/ && !/^%triggerin/) {
446 /^%triggerun/, (/^%[a-z]+$/ && !/^%triggerun/) {
449 /^%triggerpostun/, (/^%[a-z]+$/ && !/^%triggerpostun/) {
452 /^%pretrans/, (/^%[a-z]+$/ && !/^%pretrans/) {
455 /^%posttrans/, (/^%[a-z]+$/ && !/^%posttrans/) {
463 # There should not be a space after the name of field
464 # and before the colon.
467 if (/^%perl_module_wo_prefix/) {
470 release = "0." fixedsub(".%{disttag}.at", "", $4)
475 if (field ~ /summary:/) {
478 if (field ~ /group(\([^)]+\)):/)
480 if (field ~ /group:/) {
482 sub(/^Utilities\//,"Applications/",$2)
483 sub(/^Games/,"Applications/Games",$2)
484 sub(/^X11\/Games/,"X11/Applications/Games",$2)
485 sub(/^X11\/GNOME\/Development\/Libraries/,"X11/Development/Libraries",$2)
486 sub(/^X11\/GNOME\/Applications/,"X11/Applications",$2)
487 sub(/^X11\/GNOME/,"X11/Applications",$2)
488 sub(/^X11\/Utilities/,"X11/Applications",$2)
489 sub(/^X11\/Games\/Strategy/,"X11/Applications/Games/Strategy",$2)
490 sub(/^Shells/,"Applications/Shells",$2)
492 sub(/^[^ \t]*[ \t]*/,"")
495 sub(/^System Environment\/Libraries/, "Libraries", Grupa)
497 print "Group:\t\t" Grupa
498 if (Grupa ~ /^X11/ && x11 == 0) # Is it X11 application?
501 byl_plik_z_grupami = 0
503 while ((getline linia_grup < groups_file) > 0) {
504 byl_plik_z_grupami = 1
505 if (linia_grup == Grupa) {
511 if (!byl_plik_z_grupami)
512 print "######\t\t" groups_file ": no such file"
513 else if (!byl_opis_grupy)
514 print "######\t\t" "Unknown group!"
520 if (field ~ /prereq:/) {
522 $(NF + 1) = " # FIXME add Requires(scriptlet) -adapter.awk"
525 # split (build)requires on commas
526 if (field ~ /requires:/ && $0 ~ /,/) {
527 l = substr($0, index($0, $2));
528 n = split(l, p, / *, */);
530 printf("%s\t%s\n", $1, p[i]);
535 if (field ~ /packager:|distribution:|docdir:|prefix:/)
538 if (field ~ /buildroot:/)
539 $0 = $1 "%{tmpdir}/%{name}-%{version}-root-%(id -u -n)"
541 # Use "License" instead of "Copyright" if it is (L)GPL or BSD
542 if (field ~ /copyright:/ && $2 ~ /GPL|BSD/)
545 if (field ~ /name:/) {
546 if ($2 == "%{name}" && name) {
553 if (field ~ /version:/) {
554 if ($2 == "%{version}" && version) {
561 if (field ~ /release:/) {
562 if ($2 == "%{release}" && release) {
569 if (field ~ /serial:/)
576 # Use %{name} and %{version} in the filenames in "Source:"
577 if (field ~ /^source/ || field ~ /patch/) {
578 n = split($2, url, /\//)
579 if (url[n] ~ /\.gz$/) {
580 url[n+1] = ".gz" url[n+1]
581 sub(/\.gz$/,"",url[n])
583 if (url[n] ~ /\.zip$/) {
584 url[n+1] = ".zip" url[n+1]
585 sub(/\.zip$/,"",url[n])
587 if (url[n] ~ /\.tar$/) {
588 url[n+1] = ".tar" url[n+1]
589 sub(/\.tar$/,"",url[n])
591 if (url[n] ~ /\.patch$/) {
592 url[n+1] = ".patch" url[n+1]
593 sub(/\.patch$/,"",url[n])
595 if (url[n] ~ /\.bz2$/) {
596 url[n+1] = ".bz2" url[n+1]
597 sub(/\.bz2$/,"",url[n])
599 if (url[n] ~ /\.logrotate$/) {
600 url[n+1] = ".logrotate" url[n+1]
601 sub(/\.logrotate$/,"",url[n])
603 if (url[n] ~ /\.pamd$/) {
604 url[n+1] = ".pamd" url[n+1]
605 sub(/\.pamd$/,"",url[n])
608 # allow %{name} just in last url component
610 for (i = 1; i <= n; i++) {
611 url[i] = fixedsub("%{name}", name, url[i])
622 url[n] = fixedsub(name, "%{name}", url[n])
624 if (field ~ /source/) {
626 url[n] = fixedsub(version, "%{version}", url[n])
629 url[n] = fixedsub(_beta, "%{_beta}", url[n])
632 url[n] = fixedsub(_rc, "%{_rc}", url[n])
635 url[n] = fixedsub(_snap, "%{_snap}", url[n])
638 $2 = fixedsub(filename, url[n], $2)
641 sub("[?]use_mirror=.*$", "", $2);
642 sub("[?]download$", "", $2);
643 sub("^http://prdownloads\.sourceforge\.net/", "http://dl.sourceforge.net/", $2)
645 sub("^http://.*\.dl\.sourceforge\.net/", "http://dl.sourceforge.net/", $2)
646 sub("^http://dl\.sourceforge\.net/sourceforge/", "http://dl.sourceforge.net/", $2)
647 sub("^http://dl\.sf\.net/", "http://dl.sourceforge.net/", $2)
651 if (field ~ /^source:/)
654 if (field ~ /patch:/)
659 if ($1 ~ /%define/) {
660 # Do not add %define of _prefix if it already is.
661 if ($2 ~ /^_prefix/) {
662 sub("^"prefix, $3, bindir)
663 sub("^"prefix, $3, sbindir)
664 sub("^"prefix, $3, libdir)
665 sub("^"prefix, $3, datadir)
666 sub("^"prefix, $3, includedir)
670 if ($2 ~ /_bindir/ && !/_sbindir/)
676 if ($2 ~ /_sysconfdir/ && $3 !~ /^%\(/)
680 if ($2 ~ /_includedir/)
696 if ($2 ~ /^version$/)
698 if ($2 ~ /^release$/)
702 if (field ~ /requires/) {
704 $0 = fixedsub("%{eversion}", "%{epoch}:%{version}-%{release}", $0);
715 if (name_seen == 0 && name) {
720 if (version_seen == 0 && version) {
721 print "Version:\t" version
725 if (release_seen == 0 && release) {
726 print "Release:\t" release
733 if (do_not_touch_anything)
736 close(changelog_file)
737 while ((getline < changelog_file) > 0)
739 system("rm -f " changelog_file)
743 if (did_clean == 0) {
746 print "rm -rf $RPM_BUILD_ROOT"
751 print "%define date\t%(echo `LC_ALL=\"C\" date +\"%a %b %d %Y\"`)"
754 if (has_changelog == 0)
758 print "* %{date} PLD Team <feedback@pld-linux.org>"
760 printf "All persons listed below can be reached at "
761 print "<cvs_login>@pld-linux.org\n"
767 function fixedsub(s1,s2,t, ind) {
768 # substitutes fixed strings (not regexps)
769 if (ind = index(t,s1))
770 t = substr(t, 1, ind-1) s2 substr(t, ind+length(s1))
774 # There should be one or two tabs after the colon.
775 function format_preamble()
778 if (match($0, /[A-Za-z0-9(),#_ \t]+[ \t]*:[ \t]*/) == 1) {
786 # Replace directly specified directories with macros
787 function use_macros()
789 gsub(perl_sitearch, "%{perl_sitearch}")
790 gsub(perl_archlib, "%{perl_archlib}")
791 gsub(perl_privlib, "%{perl_privlib}")
792 gsub(perl_vendorlib, "%{perl_vendorlib}")
793 gsub(perl_vendorarch, "%{perl_vendorarch}")
794 gsub(perl_sitelib, "%{perl_sitelib}")
796 gsub(py_sitescriptdir, "%{py_sitescriptdir}")
798 gsub(bindir, "%{_bindir}")
799 gsub("%{prefix}/bin", "%{_bindir}")
800 if(prefix"/bin" == bindir)
801 gsub("%{_prefix}/bin", "%{_bindir}")
803 for (c = 1; c <= NF; c++) {
804 if ($c ~ sbindir "/fix-info-dir")
806 gsub(sbindir, "%{_sbindir}", $c)
809 gsub("%{prefix}/sbin", "%{_sbindir}")
810 if (prefix"/sbin" == sbindir)
811 gsub("%{_prefix}/sbin", "%{_sbindir}")
813 for (c = 1; c <= NF; c++) {
814 if ($c ~ sysconfdir "/{?cron.")
816 if ($c ~ sysconfdir "/{?crontab.d")
818 if ($c ~ sysconfdir "/{?env.d")
820 if ($c ~ sysconfdir "/{?logrotate.d")
822 if ($c ~ sysconfdir "/{?pam.d")
824 if ($c ~ sysconfdir "/{?profile.d")
826 if ($c ~ sysconfdir "/{?rc.d")
828 if ($c ~ sysconfdir "/{?security")
830 if ($c ~ sysconfdir "/{?skel")
832 if ($c ~ sysconfdir "/{?sysconfig")
834 if ($c ~ sysconfdir "/{?certs")
836 gsub(sysconfdir, "%{_sysconfdir}", $c)
839 for (c = 1; c <= NF; c++) {
840 if ($c ~ datadir "/automake")
842 if ($c ~ datadir "/unsermake")
844 if ($c ~ datadir "/file/magic.mime")
846 gsub(datadir, "%{_datadir}", $c)
849 gsub("%_sbindir", "%{_sbindir}")
850 gsub("%_mandir", "%{_mandir}")
851 gsub("%name", "%{name}")
853 gsub("%{prefix}/share", "%{_datadir}")
854 if (prefix"/share" == datadir)
855 gsub("%{_prefix}/share", "%{_datadir}")
857 gsub(includedir, "%{_includedir}")
858 gsub("%{prefix}/include", "%{_includedir}")
859 if (prefix"/include" == includedir)
860 gsub("%{_prefix}/include", "%{_includedir}")
862 gsub(mandir, "%{_mandir}")
863 if ($0 !~ "%{_datadir}/manual")
864 gsub("%{_datadir}/man", "%{_mandir}")
865 gsub("%{_prefix}/share/man", "%{_mandir}")
866 gsub("%{prefix}/share/man", "%{_mandir}")
867 gsub("%{prefix}/man", "%{_mandir}")
868 gsub("%{_prefix}/man", "%{_mandir}")
870 gsub(infodir, "%{_infodir}")
871 gsub("%{prefix}/info", "%{_infodir}")
872 gsub("%{_prefix}/info", "%{_infodir}")
874 if (prefix !~ "/X11R6") {
875 gsub("%{_datadir}/aclocal", "%{_aclocaldir}")
878 gsub(examplesdir, "%{_examplesdir}")
881 # leave --with-foo=/usr alone
882 if ($0 !~ "--with.*=.*" prefix) {
883 for (c = 1; c <= NF; c++) {
884 if ($c ~ prefix "/sbin/fix-info-dir")
886 if ($c ~ prefix "/share/automake")
888 if ($c ~ prefix "/share/unsermake")
890 if ($c ~ prefix "/lib/sendmail")
892 if ($c ~ prefix "/lib/pkgconfig")
894 gsub(prefix, "%{_prefix}", $c)
897 gsub("%{prefix}", "%{_prefix}")
900 gsub("%{PACKAGE_VERSION}", "%{version}")
901 gsub("%{PACKAGE_NAME}", "%{name}")
903 gsub("^make$", "%{__make}")
904 gsub("^make ", "%{__make} ")
905 gsub("^gcc ", "%{__cc} ")
908 gsub("^%make$", "%{__make}")
909 gsub("^%make ", "%{__make} ")
910 gsub("^%makeinstall_std", "%{__make} install \\\n\tDESTDIR=$RPM_BUILD_ROOT")
911 gsub("^%{makeinstall}", "%{__make} install \\\n\tDESTDIR=$RPM_BUILD_ROOT")
912 gsub("^%makeinstall", "%{__make} install \\\n\tDESTDIR=$RPM_BUILD_ROOT")
913 gsub("^%{__rm} -rf %{buildroot}", "rm -rf $RPM_BUILD_ROOT")
914 gsub("^%{__install}", "install")
915 gsub("^%{__rm}", "rm")
916 gsub("%optflags", "%{rpmcflags}")
917 gsub("%{compat_perl_vendorarch}", "%{perl_vendorarch}")
919 gsub("^%{__make} install DESTDIR=\$RPM_BUILD_ROOT", "%{__make} install \\\n\tDESTDIR=$RPM_BUILD_ROOT")
920 gsub("^fix-info-dir$", "[ ! -x /usr/sbin/fix-info-dir ] || /usr/sbin/fix-info-dir -c %{_infodir} >/dev/null 2>\&1")
921 $0 = fixedsub("%buildroot", "$RPM_BUILD_ROOT", $0)
922 $0 = fixedsub("%{buildroot}", "$RPM_BUILD_ROOT", $0)
923 $0 = fixedsub("CXXFLAGS=%{rpmcflags} %configure", "CXXFLAGS=%{rpmcflags}\n%configure", $0);
925 gsub("%_bindir", "%{_bindir}")
926 gsub("%_datadir", "%{_datadir}")
927 gsub("%_iconsdir", "%{_iconsdir}")
929 gsub("/usr/src/linux", "%{_kernelsrcdir}")
930 gsub("%{_prefix}/src/linux", "%{_kernelsrcdir}")
934 # insertion sort of A[1..n]
935 # copied from mawk manual
936 function isort(A,n, i,j,hold) {
937 for (i = 2; i <= n; i++) {
939 while (A[j-1] > hold) {
944 # sentinel A[0] = "" will be created if needed
948 function use_files_macros( i, n, t, a)
950 gsub("^%{_sbindir}", "%attr(755,root,root) %{_sbindir}")
951 gsub("^%{_bindir}", "%attr(755,root,root) %{_bindir}")
953 # uid/gid nobody is not valid in %files
954 if (/%attr([^)]*nobody[^)]*)/ && !/FIXME/) {
955 $0 = $0 " # FIXME nobody user/group can't own files! -adapter.awk"
959 gsub("%{_sysconfdir}/cron\.d", "/etc/cron.d")
960 gsub("%{_sysconfdir}/crontab\.d", "/etc/crontab.d")
961 gsub("%{_sysconfdir}/logrotate\.d", "/etc/logrotate.d")
962 gsub("%{_sysconfdir}/pam\.d", "/etc/pam.d")
963 gsub("%{_sysconfdir}/profile\.d", "/etc/profile.d")
964 gsub("%{_sysconfdir}/rc\.d", "/etc/rc.d")
965 gsub("%{_sysconfdir}/security", "/etc/security")
966 gsub("%{_sysconfdir}/skel", "/etc/skel")
967 gsub("%{_sysconfdir}/sysconfig", "/etc/sysconfig")
968 gsub("%{_sysconfdir}/certs", "/etc/certs")
969 gsub("%{_sysconfdir}/init.d", "/etc/init.d")
971 # /etc/init.d -> /etc/rc.d/init.d
972 if (!/^\/etc\/init\.d$/) {
973 gsub("/etc/init.d", "/etc/rc.d/init.d")
976 if (/\/etc\/rc\.d\/init\.d\// && !/functions/) {
977 if (!/%attr.*\/etc\/rc\.d\/init\.d/) {
978 $0 = "%attr(754,root,root) " $0
980 if (/^%attr.*\/etc\/rc\.d\/init\.d/ && !/^%attr\(754 *,/) {
981 gsub("^%attr\\(... *,", "%attr(754,");
985 if (/lib.+\.so/ && !/^%attr.*/) {
986 $0 = "%attr(755,root,root) " $0
989 # /etc/sysconfig files
990 # %attr(640,root,root) %config(noreplace) %verify(not size mtime md5) /etc/sysconfig/*
991 # attr not required, allow default 644 attr
992 if (!/network-scripts/) {
993 if (/\/etc\/sysconfig\// && /%config/ && !/%config\(noreplace\)/) {
994 gsub("%config", "%config(noreplace)")
997 if (/\/etc\/sysconfig\// && !/%config\(noreplace\)/) {
998 $NF = "%config(noreplace) " $NF
1001 if (/\/etc\/sysconfig\// && /%attr\(755/) {
1002 gsub("^%attr\\(... *,", "%attr(640,");
1005 if (/\/etc\/sysconfig\// && !/%verify/) {
1006 gsub("/etc/sysconfig", "%verify(not size mtime md5) /etc/sysconfig");
1010 # kill leading zeros
1011 if (/%attr\(0[1-9]/) {
1012 gsub("%attr\\(0", "%attr(")
1015 # sort %verify attrs
1016 if (match($0, /%verify\(not([^)]+)\)/)) {
1017 t = substr($0, RSTART, RLENGTH)
1018 gsub(/^%verify\(not |\)$/, "", t)
1019 n = split(t, a, / /)
1023 for (i = 1 ; i <= n; i++) {
1028 gsub(/%verify\(not[^)]+\)/, s)
1036 $0 = fixedsub("%{perl_man1dir}", "%{_mandir}/man1", $0);
1037 $0 = fixedsub("%{perl_man3dir}", "%{_mandir}/man3", $0);
1038 $0 = fixedsub("%{perl_bin}", "%{_bindir}", $0);
1040 gsub(libdir "/pkgconfig", "%{_pkgconfigdir}");
1041 gsub("%{_libdir}/pkgconfig", "%{_pkgconfigdir}");
1042 gsub("%{_prefix}/lib/pkgconfig", "%{_pkgconfigdir}");
1045 function fill(ch, n, i) {
1046 for (i = 0; i < n; i++)
1050 function format_flush(line, indent, newline, word, first_word) {
1052 if (format_indent == -1)
1055 newline = fill(" ", format_indent) "- "
1057 while (match(line, /[^\t ]+/)) {
1058 word = substr(line, RSTART, RLENGTH)
1059 if (length(newline) + length(word) + 1 > tw) {
1062 if (format_indent == -1)
1065 newline = fill(" ", format_indent + 2)
1070 newline = newline word
1073 newline = newline " " word
1075 line = substr(line, RSTART + RLENGTH)
1077 if (newline ~ /[^\t ]/) {
1082 function cflags(var)
1084 if ($0 == var "=\"$RPM_OPT_FLAGS\"") {
1090 sub("\$RPM_OPT_FLAGS", "%{rpmcflags}")