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
23 preamble = 1 # Is it part of preamble? Default - yes
24 boc = 4 # Beggining of %changelog
25 bod = 0 # Beggining of %description
26 tw = 70 # Descriptions width
28 b_idx = 0 # index of BR/R arrays
30 # If variable removed, then 1 (for removing it from export)
31 removed["LDFLAGS"] = 0
33 removed["CXXFLAGS"] = 0
35 # get cvsaddress for changelog section
36 # using rpm macros as too lazy to add ~/.adapterrc parsing support.
37 "rpm --eval '%{?_cvsmaildomain}%{!?_cvsmaildomain:@pld-linux.org}'" | getline _cvsmaildomain
38 "rpm --eval '%{?_cvsmailfeedback}%{!?_cvsmailfeedback:PLD Team <feedback@pld-linux.org>}'" | getline _cvsmailfeedback
40 # If 1, we are inside of comment block (started with /^#%/)
43 # File with rpm groups
44 "rpm --eval %_sourcedir" | getline groups_file
45 groups_file = groups_file "/rpm.groups"
46 system("cd `rpm --eval %_sourcedir`; cvs up rpm.groups >/dev/null")
48 # Temporary file for changelog section
49 changelog_file = ENVIRON["HOME"] "/tmp/adapter.changelog"
52 "rpm --eval %_prefix" | getline prefix
53 "rpm --eval %_bindir" | getline bindir
54 "rpm --eval %_sbindir" | getline sbindir
55 "rpm --eval %_libdir" | getline libdir
56 "rpm --eval %_sysconfdir" | getline sysconfdir
57 "rpm --eval %_datadir" | getline datadir
58 "rpm --eval %_includedir" | getline includedir
59 "rpm --eval %_mandir" | getline mandir
60 "rpm --eval %_infodir" | getline infodir
61 "rpm --eval %_examplesdir" | getline examplesdir
63 "rpm --eval %perl_sitearch" | getline perl_sitearch
64 "rpm --eval %perl_archlib" | getline perl_archlib
65 "rpm --eval %perl_privlib" | getline perl_privlib
66 "rpm --eval %perl_vendorlib" | getline perl_vendorlib
67 "rpm --eval %perl_vendorarch" | getline perl_vendorarch
68 "rpm --eval %perl_sitelib" | getline perl_sitelib
70 "rpm --eval %py_sitescriptdir" | getline py_sitescriptdir
73 # There should be a comment with CVS keywords on the first line of file.
75 if (!/# \$Revision:/) # If this line is already OK?
76 print "# $" "Revision:$, " "$" "Date:$" # No
79 next # It is enough for first line
83 # If the latest line matched /%files/
85 if ($0 !~ /defattr/) # If no %defattr
86 print "%defattr(644,root,root,755)" # Add it
88 $0 = "%defattr(644,root,root,755)" # Correct mistakes (if any)
92 function b_makekey(a, b, s) {
95 gsub("%{\\?[_a-zA-Z0-9]+:", "", s);
102 # - mixing BR/R and anything else confuses this (all will be sorted together)
104 # - comments leading the BR/R can not be associated,
105 # so don't adapterize when the BR/R are mixed with comments
106 ENVIRON["SORTBR"] == 1 && preamble == 1 && /(Build)?Requires/, /(Build)?Requires/ { # && !/^%/) {
108 l = substr($0, index($0, $2));
109 b_ktmp = b_makekey($1, l);
110 b_key[b_idx] = b_ktmp;
125 for (i = 1; i <= b_idx; i++) {
126 print "" b_val[b_key[i]];
133 /^#/ && (description == 0) {
134 if (/This file does not like to be adapterized!/) {
135 print # print this message
136 while (getline) # print the rest of spec as it is
138 do_not_touch_anything = 1 # do not touch anything in END()
142 # Generally, comments are printed without touching
148 # Remove defining _applnkdir (this macro has been included in rpm-3.0.4)
150 if ($2 == "_applnkdir")
157 /^%include.*\/usr\/lib\/rpm\/macros\.python$/ {
164 /^%description/, (/^%[a-z]+/ && !/^%description/ && !/^%((end)?if|else)/) {
167 if (/^%description/) {
174 if (description == 1 && !/^%[a-z]+/ && !/^%description/) {
176 format_flush(format_line, format_indent)
180 } else if (/^[ \t]*[-\*][ \t]*/) {
181 format_flush(format_line, format_indent)
183 format_indent = RLENGTH
184 match($0, /^[ \t]*[-\*][ \t]/)
185 format_line = substr($0, RLENGTH)
187 format_line = format_line " " $0
191 if (/^%[a-z]+/ && (!/^%description/ || bod == 2)) {
192 if (NF > 3 && $2 == "-l") {
194 for (i = 4; i <= NF; i++)
198 format_flush(format_line, format_indent)
213 /^%prep/, (/^%[a-z]+$/ && !/^%prep/ && !/^%((end)?if|else)/) {
219 if (/^%setup/ && !/-q/) {
220 sub(/^%setup/, "%setup -q")
224 gsub(name, "%{name}");
225 gsub(version, "%{version}");
227 gsub(_beta, "%{_beta}");
233 gsub(_snap, "%{_snap}");
237 if (/^%setup/ && /-n %{name}-%{version}( |$)/) {
238 sub(/ -n %{name}-%{version}/, "")
242 sub("^rm -rf \$RPM_BUILD_ROOT.*", "");
248 /^%build/, (/^%[a-z]+$/ && !/^%build/ && !/^%((end)?if|else)/) {
257 if (/LDFLAGS="-s"/) {
258 removed["LDFLAGS"] = 1
261 split($0, tmp, "LDFLAGS=")
262 count = split(tmp[2], flags, "\"")
263 if (flags[1] != "" && flags[1] !~ "!?debug") {
264 sub(/-s[" ]?/, "%{rpmldflags} ", flags[1])
265 $0 = tmp[1] line[1] "LDFLAGS=" flags[1] "\""
266 for (i = 2; i < count; i++)
267 $0 = $0 flags[i] "\""
273 if (cflags("CFLAGS") == 0)
277 if (cflags("CXXFLAGS") == 0)
281 if (removed["LDFLAGS"])
283 if (removed["CFLAGS"])
285 if (removed["CXXFLAGS"])
287 # Is there still something?
293 $0 = fixedsub("glib-gettextize --copy --force","%{__glib_gettextize}", $0);
294 $0 = fixedsub("intltoolize --copy --force", "%{__intltoolize}", $0);
297 $0 = fixedsub("%perl_configure", "%{__perl} Makefile.PL \\\n\tINSTALLDIRS=vendor", $0);
298 $0 = fixedsub("%perl_makecheck", "%{?with_tests:%{__make} test}", $0);
304 /^%clean/, (/^%[a-z]+$/ && !/^%clean/ && !/^%((end)?if|else)/) {
312 /^%install/, (/^%[a-z]+$/ && !/^%install/ && !/^%((end)?if|else)/) {
316 if (/^[ \t]*rm([ \t]+-[rf]+)*[ \t]+\${?RPM_BUILD_ROOT}?/ && did_rmroot==0) {
318 print "rm -rf $RPM_BUILD_ROOT"
322 if (!/^(#?[ \t]*)$/ && !/^%install/ && did_rmroot==0) {
323 print "rm -rf $RPM_BUILD_ROOT"
329 # 'install -d' instead 'mkdir -p'
331 sub(/mkdir -p/, "install -d")
333 # 'install' instead 'cp -p'
335 sub(/cp -p/, "install")
337 # No '-u root' or '-g root' for 'install'
338 if (/^install/ && /-[ug][ \t]*root/)
339 gsub(/-[ug][ \t]*root /, "")
341 if (/^install/ && /-m[ \t]*[0-9]+/)
342 gsub(/-m[ \t]*[0-9]+ /, "")
344 # No lines contain 'chown' or 'chgrp' if owner/group is 'root'
345 if (($1 ~ /chown/ && $2 ~ /root\.root/) || ($1 ~ /chgrp/ && $2 ~ /root/))
348 # No lines contain 'chmod' if it sets the modes to '644'
349 if ($1 ~ /chmod/ && $2 ~ /644/)
353 $0 = fixedsub("%buildroot", "$RPM_BUILD_ROOT", $0)
354 $0 = fixedsub("%{buildroot}", "$RPM_BUILD_ROOT", $0)
357 $0 = fixedsub("%perl_makeinstall", "%{__make} pure_install \\\n\tDESTDIR=$RPM_BUILD_ROOT", $0);
363 /^%files/, (/^%[a-z \-]+$/ && !/^%files/ && !/^%((end)?if|else)/) {
376 /^%changelog/, (/^%[a-z]+$/ && !/^%changelog/) {
380 # There should be some CVS keywords on the first line of %changelog.
382 if ($0 !~ _cvsmailfeedback)
383 print "* %{date} " _cvsmailfeedback > changelog_file
388 if (boc == 2 && !skip) {
389 if (!/All persons listed below/) {
390 printf "All persons listed below can be reached at " > changelog_file
391 print "<cvs_login>" _cvsmaildomain "\n" > changelog_file
396 if (boc == 1 && !skip) {
399 print "$" "Log:$" > changelog_file
406 printf "%%define date\t%%(echo `LC_ALL=\"C\"" > changelog_file
407 print " date +\"%a %b %d %Y\"`)" > changelog_file
414 if (!/^%[a-z]+$/ || /changelog/)
415 print > changelog_file
424 /^%pre/, (/^%[a-z]+$/ && !/^%pre/) {
427 # %useradd and %groupadd may not be wrapped
428 if (/%(useradd|groupadd).*\\$/) {
431 $0 = substr(a, 1, length(a) - 1) $0;
435 /^%post/, (/^%[a-z]+$/ && !/^%post/) {
438 /^%preun/, (/^%[a-z]+$/ && !/^%preun/) {
441 /^%postun/, (/^%[a-z]+$/ && !/^%postun/) {
444 /^%triggerin/, (/^%[a-z]+$/ && !/^%triggerin/) {
447 /^%triggerun/, (/^%[a-z]+$/ && !/^%triggerun/) {
450 /^%triggerpostun/, (/^%[a-z]+$/ && !/^%triggerpostun/) {
453 /^%pretrans/, (/^%[a-z]+$/ && !/^%pretrans/) {
456 /^%posttrans/, (/^%[a-z]+$/ && !/^%posttrans/) {
464 # There should not be a space after the name of field
465 # and before the colon.
468 if (/^%perl_module_wo_prefix/) {
471 release = "0." fixedsub(".%{disttag}.at", "", $4)
476 if (field ~ /summary:/) {
479 if (field ~ /group(\([^)]+\)):/)
481 if (field ~ /group:/) {
483 sub(/^Utilities\//,"Applications/",$2)
484 sub(/^Games/,"Applications/Games",$2)
485 sub(/^X11\/Games/,"X11/Applications/Games",$2)
486 sub(/^X11\/GNOME\/Development\/Libraries/,"X11/Development/Libraries",$2)
487 sub(/^X11\/GNOME\/Applications/,"X11/Applications",$2)
488 sub(/^X11\/GNOME/,"X11/Applications",$2)
489 sub(/^X11\/Utilities/,"X11/Applications",$2)
490 sub(/^X11\/Games\/Strategy/,"X11/Applications/Games/Strategy",$2)
491 sub(/^Shells/,"Applications/Shells",$2)
493 sub(/^[^ \t]*[ \t]*/,"")
496 sub(/^System Environment\/Libraries/, "Libraries", Grupa)
498 print "Group:\t\t" Grupa
499 if (Grupa ~ /^X11/ && x11 == 0) # Is it X11 application?
502 byl_plik_z_grupami = 0
504 while ((getline linia_grup < groups_file) > 0) {
505 byl_plik_z_grupami = 1
506 if (linia_grup == Grupa) {
512 if (!byl_plik_z_grupami)
513 print "######\t\t" groups_file ": no such file"
514 else if (!byl_opis_grupy)
515 print "######\t\t" "Unknown group!"
521 if (field ~ /prereq:/) {
523 $(NF + 1) = " # FIXME add Requires(scriptlet) -adapter.awk"
526 # split (build)requires on commas
527 if (field ~ /requires:/ && $0 ~ /,/) {
528 l = substr($0, index($0, $2));
529 n = split(l, p, / *, */);
531 printf("%s\t%s\n", $1, p[i]);
536 if (field ~ /packager:|distribution:|docdir:|prefix:/)
539 if (field ~ /buildroot:/)
540 $0 = $1 "%{tmpdir}/%{name}-%{version}-root-%(id -u -n)"
542 # Use "License" instead of "Copyright" if it is (L)GPL or BSD
543 if (field ~ /copyright:/ && $2 ~ /GPL|BSD/)
546 if (field ~ /name:/) {
547 if ($2 == "%{name}" && name) {
554 if (field ~ /version:/) {
555 if ($2 == "%{version}" && version) {
562 if (field ~ /release:/) {
563 if ($2 == "%{release}" && release) {
570 if (field ~ /serial:/)
577 # Use %{name} and %{version} in the filenames in "Source:"
578 if (field ~ /^source/ || field ~ /patch/) {
579 n = split($2, url, /\//)
580 if (url[n] ~ /\.gz$/) {
581 url[n+1] = ".gz" url[n+1]
582 sub(/\.gz$/,"",url[n])
584 if (url[n] ~ /\.zip$/) {
585 url[n+1] = ".zip" url[n+1]
586 sub(/\.zip$/,"",url[n])
588 if (url[n] ~ /\.tar$/) {
589 url[n+1] = ".tar" url[n+1]
590 sub(/\.tar$/,"",url[n])
592 if (url[n] ~ /\.patch$/) {
593 url[n+1] = ".patch" url[n+1]
594 sub(/\.patch$/,"",url[n])
596 if (url[n] ~ /\.bz2$/) {
597 url[n+1] = ".bz2" url[n+1]
598 sub(/\.bz2$/,"",url[n])
600 if (url[n] ~ /\.logrotate$/) {
601 url[n+1] = ".logrotate" url[n+1]
602 sub(/\.logrotate$/,"",url[n])
604 if (url[n] ~ /\.pamd$/) {
605 url[n+1] = ".pamd" url[n+1]
606 sub(/\.pamd$/,"",url[n])
609 # allow %{name} just in last url component
611 for (i = 1; i <= n; i++) {
612 url[i] = fixedsub("%{name}", name, url[i])
623 url[n] = fixedsub(name, "%{name}", url[n])
625 if (field ~ /source/) {
627 url[n] = fixedsub(version, "%{version}", url[n])
630 url[n] = fixedsub(_beta, "%{_beta}", url[n])
633 url[n] = fixedsub(_rc, "%{_rc}", url[n])
636 url[n] = fixedsub(_snap, "%{_snap}", url[n])
639 $2 = fixedsub(filename, url[n], $2)
642 sub("[?]use_mirror=.*$", "", $2);
643 sub("[?]download$", "", $2);
644 sub("^http://prdownloads\.sourceforge\.net/", "http://dl.sourceforge.net/", $2)
646 sub("^http://.*\.dl\.sourceforge\.net/", "http://dl.sourceforge.net/", $2)
647 sub("^http://dl\.sourceforge\.net/sourceforge/", "http://dl.sourceforge.net/", $2)
648 sub("^http://dl\.sf\.net/", "http://dl.sourceforge.net/", $2)
652 if (field ~ /^source:/)
655 if (field ~ /patch:/)
660 if ($1 ~ /%define/) {
661 # Do not add %define of _prefix if it already is.
662 if ($2 ~ /^_prefix/) {
663 sub("^"prefix, $3, bindir)
664 sub("^"prefix, $3, sbindir)
665 sub("^"prefix, $3, libdir)
666 sub("^"prefix, $3, datadir)
667 sub("^"prefix, $3, includedir)
671 if ($2 ~ /_bindir/ && !/_sbindir/)
677 if ($2 ~ /_sysconfdir/ && $3 !~ /^%\(/)
681 if ($2 ~ /_includedir/)
697 if ($2 ~ /^version$/)
699 if ($2 ~ /^release$/)
703 if (field ~ /requires/) {
705 $0 = fixedsub("%{eversion}", "%{epoch}:%{version}-%{release}", $0);
716 if (name_seen == 0 && name) {
721 if (version_seen == 0 && version) {
722 print "Version:\t" version
726 if (release_seen == 0 && release) {
727 print "Release:\t" release
734 if (do_not_touch_anything)
737 close(changelog_file)
738 while ((getline < changelog_file) > 0)
740 system("rm -f " changelog_file)
744 if (did_clean == 0) {
747 print "rm -rf $RPM_BUILD_ROOT"
752 print "%define date\t%(echo `LC_ALL=\"C\" date +\"%a %b %d %Y\"`)"
755 if (has_changelog == 0)
759 print "* %{date} PLD Team <feedback@pld-linux.org>"
761 printf "All persons listed below can be reached at "
762 print "<cvs_login>@pld-linux.org\n"
768 function fixedsub(s1,s2,t, ind) {
769 # substitutes fixed strings (not regexps)
770 if (ind = index(t,s1))
771 t = substr(t, 1, ind-1) s2 substr(t, ind+length(s1))
775 # There should be one or two tabs after the colon.
776 function format_preamble()
779 if (match($0, /[A-Za-z0-9(),#_ \t]+[ \t]*:[ \t]*/) == 1) {
787 # Replace directly specified directories with macros
788 function use_macros()
790 gsub(perl_sitearch, "%{perl_sitearch}")
791 gsub(perl_archlib, "%{perl_archlib}")
792 gsub(perl_privlib, "%{perl_privlib}")
793 gsub(perl_vendorlib, "%{perl_vendorlib}")
794 gsub(perl_vendorarch, "%{perl_vendorarch}")
795 gsub(perl_sitelib, "%{perl_sitelib}")
797 gsub(py_sitescriptdir, "%{py_sitescriptdir}")
799 gsub(bindir, "%{_bindir}")
800 gsub("%{prefix}/bin", "%{_bindir}")
801 if(prefix"/bin" == bindir)
802 gsub("%{_prefix}/bin", "%{_bindir}")
804 for (c = 1; c <= NF; c++) {
805 if ($c ~ sbindir "/fix-info-dir")
807 gsub(sbindir, "%{_sbindir}", $c)
810 gsub("%{prefix}/sbin", "%{_sbindir}")
811 if (prefix"/sbin" == sbindir)
812 gsub("%{_prefix}/sbin", "%{_sbindir}")
814 for (c = 1; c <= NF; c++) {
815 if ($c ~ sysconfdir "/{?cron.")
817 if ($c ~ sysconfdir "/{?crontab.d")
819 if ($c ~ sysconfdir "/{?env.d")
821 if ($c ~ sysconfdir "/{?logrotate.d")
823 if ($c ~ sysconfdir "/{?pam.d")
825 if ($c ~ sysconfdir "/{?profile.d")
827 if ($c ~ sysconfdir "/{?rc.d")
829 if ($c ~ sysconfdir "/{?security")
831 if ($c ~ sysconfdir "/{?skel")
833 if ($c ~ sysconfdir "/{?sysconfig")
835 if ($c ~ sysconfdir "/{?certs")
837 gsub(sysconfdir, "%{_sysconfdir}", $c)
840 for (c = 1; c <= NF; c++) {
841 if ($c ~ datadir "/automake")
843 if ($c ~ datadir "/unsermake")
845 if ($c ~ datadir "/file/magic.mime")
847 gsub(datadir, "%{_datadir}", $c)
850 gsub("%_sbindir", "%{_sbindir}")
851 gsub("%_mandir", "%{_mandir}")
852 gsub("%name", "%{name}")
854 gsub("%{prefix}/share", "%{_datadir}")
855 if (prefix"/share" == datadir)
856 gsub("%{_prefix}/share", "%{_datadir}")
858 gsub(includedir, "%{_includedir}")
859 gsub("%{prefix}/include", "%{_includedir}")
860 if (prefix"/include" == includedir)
861 gsub("%{_prefix}/include", "%{_includedir}")
863 gsub(mandir, "%{_mandir}")
864 if ($0 !~ "%{_datadir}/manual")
865 gsub("%{_datadir}/man", "%{_mandir}")
866 gsub("%{_prefix}/share/man", "%{_mandir}")
867 gsub("%{prefix}/share/man", "%{_mandir}")
868 gsub("%{prefix}/man", "%{_mandir}")
869 gsub("%{_prefix}/man", "%{_mandir}")
871 gsub(infodir, "%{_infodir}")
872 gsub("%{prefix}/info", "%{_infodir}")
873 gsub("%{_prefix}/info", "%{_infodir}")
875 if (prefix !~ "/X11R6") {
876 gsub("%{_datadir}/aclocal", "%{_aclocaldir}")
879 gsub(examplesdir, "%{_examplesdir}")
882 # leave --with-foo=/usr alone
883 if ($0 !~ "--with.*=.*" prefix) {
884 for (c = 1; c <= NF; c++) {
885 if ($c ~ prefix "/sbin/fix-info-dir")
887 if ($c ~ prefix "/share/automake")
889 if ($c ~ prefix "/share/unsermake")
891 if ($c ~ prefix "/lib/sendmail")
893 if ($c ~ prefix "/lib/pkgconfig")
895 gsub(prefix, "%{_prefix}", $c)
898 gsub("%{prefix}", "%{_prefix}")
901 gsub("%{PACKAGE_VERSION}", "%{version}")
902 gsub("%{PACKAGE_NAME}", "%{name}")
904 gsub("^make$", "%{__make}")
905 gsub("^make ", "%{__make} ")
906 gsub("^gcc ", "%{__cc} ")
909 gsub("^%make$", "%{__make}")
910 gsub("^%make ", "%{__make} ")
911 gsub("^%makeinstall_std", "%{__make} install \\\n\tDESTDIR=$RPM_BUILD_ROOT")
912 gsub("^%{makeinstall}", "%{__make} install \\\n\tDESTDIR=$RPM_BUILD_ROOT")
913 gsub("^%makeinstall", "%{__make} install \\\n\tDESTDIR=$RPM_BUILD_ROOT")
914 gsub("^%{__rm} -rf %{buildroot}", "rm -rf $RPM_BUILD_ROOT")
915 gsub("^%{__install}", "install")
916 gsub("^%{__rm}", "rm")
917 gsub("%optflags", "%{rpmcflags}")
918 gsub("%{compat_perl_vendorarch}", "%{perl_vendorarch}")
920 gsub("^%{__make} install DESTDIR=\$RPM_BUILD_ROOT", "%{__make} install \\\n\tDESTDIR=$RPM_BUILD_ROOT")
921 gsub("^fix-info-dir$", "[ ! -x /usr/sbin/fix-info-dir ] || /usr/sbin/fix-info-dir -c %{_infodir} >/dev/null 2>\&1")
922 $0 = fixedsub("%buildroot", "$RPM_BUILD_ROOT", $0)
923 $0 = fixedsub("%{buildroot}", "$RPM_BUILD_ROOT", $0)
924 $0 = fixedsub("CXXFLAGS=%{rpmcflags} %configure", "CXXFLAGS=%{rpmcflags}\n%configure", $0);
926 gsub("%_bindir", "%{_bindir}")
927 gsub("%_datadir", "%{_datadir}")
928 gsub("%_iconsdir", "%{_iconsdir}")
930 gsub("/usr/src/linux", "%{_kernelsrcdir}")
931 gsub("%{_prefix}/src/linux", "%{_kernelsrcdir}")
935 # insertion sort of A[1..n]
936 # copied from mawk manual
937 function isort(A,n, i,j,hold) {
938 for (i = 2; i <= n; i++) {
940 while (A[j-1] > hold) {
945 # sentinel A[0] = "" will be created if needed
949 function use_files_macros( i, n, t, a)
951 gsub("^%{_sbindir}", "%attr(755,root,root) %{_sbindir}")
952 gsub("^%{_bindir}", "%attr(755,root,root) %{_bindir}")
954 # uid/gid nobody is not valid in %files
955 if (/%attr([^)]*nobody[^)]*)/ && !/FIXME/) {
956 $0 = $0 " # FIXME nobody user/group can't own files! -adapter.awk"
960 gsub("%{_sysconfdir}/cron\.d", "/etc/cron.d")
961 gsub("%{_sysconfdir}/crontab\.d", "/etc/crontab.d")
962 gsub("%{_sysconfdir}/logrotate\.d", "/etc/logrotate.d")
963 gsub("%{_sysconfdir}/pam\.d", "/etc/pam.d")
964 gsub("%{_sysconfdir}/profile\.d", "/etc/profile.d")
965 gsub("%{_sysconfdir}/rc\.d", "/etc/rc.d")
966 gsub("%{_sysconfdir}/security", "/etc/security")
967 gsub("%{_sysconfdir}/skel", "/etc/skel")
968 gsub("%{_sysconfdir}/sysconfig", "/etc/sysconfig")
969 gsub("%{_sysconfdir}/certs", "/etc/certs")
970 gsub("%{_sysconfdir}/init.d", "/etc/init.d")
972 # /etc/init.d -> /etc/rc.d/init.d
973 if (!/^\/etc\/init\.d$/) {
974 gsub("/etc/init.d", "/etc/rc.d/init.d")
977 if (/\/etc\/rc\.d\/init\.d\// && !/functions/) {
978 if (!/%attr.*\/etc\/rc\.d\/init\.d/) {
979 $0 = "%attr(754,root,root) " $0
981 if (/^%attr.*\/etc\/rc\.d\/init\.d/ && !/^%attr\(754 *,/) {
982 gsub("^%attr\\(... *,", "%attr(754,");
986 if (/lib.+\.so/ && !/^%attr.*/) {
987 $0 = "%attr(755,root,root) " $0
990 # /etc/sysconfig files
991 # %attr(640,root,root) %config(noreplace) %verify(not size mtime md5) /etc/sysconfig/*
992 # attr not required, allow default 644 attr
993 if (!/network-scripts/) {
994 if (/\/etc\/sysconfig\// && /%config/ && !/%config\(noreplace\)/) {
995 gsub("%config", "%config(noreplace)")
998 if (/\/etc\/sysconfig\// && !/%config\(noreplace\)/) {
999 $NF = "%config(noreplace) " $NF
1002 if (/\/etc\/sysconfig\// && /%attr\(755/) {
1003 gsub("^%attr\\(... *,", "%attr(640,");
1006 if (/\/etc\/sysconfig\// && !/%verify/) {
1007 gsub("/etc/sysconfig", "%verify(not size mtime md5) /etc/sysconfig");
1011 # kill leading zeros
1012 if (/%attr\(0[1-9]/) {
1013 gsub("%attr\\(0", "%attr(")
1016 # sort %verify attrs
1017 if (match($0, /%verify\(not([^)]+)\)/)) {
1018 t = substr($0, RSTART, RLENGTH)
1019 gsub(/^%verify\(not |\)$/, "", t)
1020 n = split(t, a, / /)
1024 for (i = 1 ; i <= n; i++) {
1029 gsub(/%verify\(not[^)]+\)/, s)
1037 $0 = fixedsub("%{perl_man1dir}", "%{_mandir}/man1", $0);
1038 $0 = fixedsub("%{perl_man3dir}", "%{_mandir}/man3", $0);
1039 $0 = fixedsub("%{perl_bin}", "%{_bindir}", $0);
1041 gsub(libdir "/pkgconfig", "%{_pkgconfigdir}");
1042 gsub("%{_libdir}/pkgconfig", "%{_pkgconfigdir}");
1043 gsub("%{_prefix}/lib/pkgconfig", "%{_pkgconfigdir}");
1046 function fill(ch, n, i) {
1047 for (i = 0; i < n; i++)
1051 function format_flush(line, indent, newline, word, first_word) {
1053 if (format_indent == -1)
1056 newline = fill(" ", format_indent) "- "
1058 while (match(line, /[^\t ]+/)) {
1059 word = substr(line, RSTART, RLENGTH)
1060 if (length(newline) + length(word) + 1 > tw) {
1063 if (format_indent == -1)
1066 newline = fill(" ", format_indent + 2)
1071 newline = newline word
1074 newline = newline " " word
1076 line = substr(line, RSTART + RLENGTH)
1078 if (newline ~ /[^\t ]/) {
1083 function cflags(var)
1085 if ($0 == var "=\"$RPM_OPT_FLAGS\"") {
1091 sub("\$RPM_OPT_FLAGS", "%{rpmcflags}")