3 # This is adapter v0.4. Adapter adapts .spec files for PLD.
4 # Copyright (C) 1999 Micha³ Kuratczyk <kura@pld.org.pl>
8 bof = 1; # Beggining of file
9 boc = 2; # Beggining of %changelog
12 # There should be a comment with CVS keywords on the first line of file.
15 print "# $" "Revision:$, " "$" "Date:$";
20 /%description/, (/^%[a-z]+/ && !/%description/) {
23 # Define _prefix and _mandir if it is X11 application
24 if (/^%description$/ && x11 == 1) {
25 print "%define\t\t_prefix\t\t/usr/X11R6";
26 print "%define\t\t_mandir\t\t%{_prefix}/man\n";
32 /%prep/, (/^%[a-z]+$/ && !/%prep/) {
36 if (/%setup/ && !/-q/)
37 sub(/%setup/, "%setup -q");
41 /%build/, (/^%[a-z]+$/ && !/%build/) {
48 /%install/, (/^[a-z]+$/ && !/%install/) {
51 # 'install -d' instead 'mkdir -p'
53 sub(/mkdir -p/, "install -d");
55 # no '-u root' or '-g root' for 'install'
56 if (/^install/ && /-[ug][ \t]*root/)
57 gsub(/-[ug][ \t]*root/, "\b");
59 if (/^install/ && /-m[ \t]*644/)
60 gsub(/-m[ \t]*644/, "\b");
62 # no lines contain 'chown' or 'chgrp', which changes
63 # owner/group to 'root'
64 if ($1 ~ /chown|chgrp/ && $2 ~ /root|root.root/)
67 # no lines contain 'chmod' if it sets the modes to '644'
68 if ($1 ~ /chmod/ && $2 ~ /644/)
71 # 'gzip -9nf' for compressing
72 if ($1 ~ /gzip|bzip2/) {
80 /%files/, (/^%[a-z]+$/ && !/%files/) {
84 $0 = "%defattr(644,root,root,755)";
89 /%changelog/, (/^%[a-z]+$/ && !/%changelog/) {
92 # There should be some CVS keywords on the first line of %changelog.
95 print "* %{date} PLD Team <pld-list@pld.org.pl>";
96 printf "All below listed persons can be reached on ";
97 print "<cvs_login>@pld.org.pl\n\n";
104 if (boc == 2 && date == 0) {
105 printf "%%define date\t%%(echo `LC_ALL=\"C\"";
106 print " date +\"%a %b %d %Y\"`)"
113 # There should not be a space after the name of field
114 # and before the colon.
117 if (tolower($1) ~ /buildroot:/)
118 $2 = "/tmp/%{name}-%{version}-root";
120 # Is it X11 application?
121 if (tolower($1) ~ /group/ && $2 ~ /^X11/ && x11 == 0)
124 # Do not add %define of _prefix if it already is.
125 if ($1 ~ /%define/ && $2 ~ /_prefix/)
128 # Use "License" instead of "Copyright" if it is (L)GPL or BSD
129 if (tolower($1) ~ /copyright:/ && $2 ~ /GPL|BSD/)
132 if (tolower($1) ~ /name:/)
135 if (tolower($1) ~ /version:/)
138 # Use %{name} and %{version} in the filenames in "Source:"
139 if (tolower($1) ~ /source/ && $2 ~ /^ftp:|^http:/) {
140 n = split($2, url, /\//);
142 sub(name, "%{name}", url[n]);
143 sub(version, "%{version}", url[n]);
144 sub(filename, url[n], $2);
147 # There should be one or two tabs after the colon.
149 if (match($0, /[A-Za-z0-9()# \t]+[ \t]*:[ \t]*/) == 1) {
158 # If redundant_line is zero, print this line, otherwise do not print,
159 # but set the redundant_line to 0.
163 # Macro 'date' already defined.