#!/bin/awk -f
#
-# This is adapter v0.24. Adapter adapts .spec files for PLD.
+# This is adapter v0.27. Adapter adapts .spec files for PLD.
#
-# Copyright (C) 1999-2001 PLD-Team <pld-list@pld.org.pl>
+# Copyright (C) 1999-2003 PLD-Team <feedback@pld-linux.org>
# Authors:
# Micha³ Kuratczyk <kura@pld.org.pl>
# Sebastian Zagrodzki <s.zagrodzki@mimuw.edu.pl>
# Tomasz K³oczko <kloczek@rudy.mif.pg.gda.pl>
# Artur Frysiak <wiget@pld.org.pl>
-# Michal Kochanowicz <mkochano@ee.pw.edu.pl>
+# Michal Kochanowicz <mkochano@pld.org.pl>
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
BEGIN {
preamble = 1 # Is it part of preamble? Default - yes
- boc = 2 # Beggining of %changelog
+ boc = 4 # Beggining of %changelog
bod = 0 # Beggining of %description
tw = 70 # Descriptions width
removed["CFLAGS"] = 0
removed["CXXFLAGS"] = 0
+ # If 1, we are inside of comment block (started with /^#%/)
+ comment_block = 0
+
# File with rpm groups
"rpm --eval %_sourcedir" | getline groups_file
groups_file = groups_file "/rpm.groups"
- system("cd `rpm --eval %_sourcedir`; cvs up rpm.groups 1>&2")
+ system("cd `rpm --eval %_sourcedir`; cvs up rpm.groups >/dev/null")
# Temporary file for changelog section
changelog_file = ENVIRON["HOME"] "/tmp/adapter.changelog"
defattr = 0
}
+# Comments
+/^#/ && (description == 0) {
+ if (/This file does not like to be adapterized!/) {
+ print # print this message
+ while (getline) # print the rest of spec as it is
+ print
+ do_not_touch_anything = 1 # do not touch anything in END()
+ exit 0
+ }
+
+ # Generally, comments are printed without touching
+ sub(/[ \t]+$/, "")
+ print $0
+ next
+}
+
# Remove defining _applnkdir (this macro has been included in rpm-3.0.4)
/^%define/ {
if ($2 == "_applnkdir")
date = 1
}
-# descriptions:
+################
+# %description #
+################
/^%description/, (/^%[a-z]+/ && !/^%description/) {
preamble = 0
format_indent = -1
}
- # Define _prefix and _mandir if it is X11 application
- if (/^%description$/ && x11 == 1) {
- print "%define\t\t_prefix\t\t/usr/X11R6"
- print "%define\t\t_mandir\t\t%{_prefix}/man\n"
- prefix = "/usr/X11R6"
- x11 = 2
- }
-
# Format description
if (description == 1 && !/^%[a-z]+/ && !/^%description/) {
if (/^[ \t]*$/) {
}
if (/^%[a-z]+/ && (!/^%description/ || bod == 2)) {
+ if (NF > 3 && $2 == "-l") {
+ ll = $1
+ for (i = 4; i <= NF; i++)
+ ll = ll " " $i
+ $0 = ll " -l " $3
+ }
format_flush(format_line, format_indent)
if (bod == 2) {
bod = 1
description = 1
}
-# %prep section:
+#########
+# %prep #
+#########
/^%prep/, (/^%[a-z]+$/ && !/^%prep/) {
preamble = 0
sub(/^%setup/, "%setup -q")
}
-# %build section:
+##########
+# %build #
+##########
/^%build/, (/^%[a-z]+$/ && !/^%build/) {
preamble = 0
split($0, tmp, "LDFLAGS=")
count = split(tmp[2], flags, "\"")
if (flags[1] != "" && flags[1] !~ "!?debug") {
- sub(/-s[" ]?/, "%{!?debug:-s} ", flags[1])
+ sub(/-s[" ]?/, "%{rpmldflags} ", flags[1])
$0 = tmp[1] line[1] "LDFLAGS=" flags[1] "\""
for (i = 2; i < count; i++)
$0 = $0 flags[i] "\""
}
-# %clean section:
+##########
+# %clean #
+##########
/^%clean/, (/^%[a-z]+$/ && !/^%clean/) {
did_clean = 1
}
-# %install section:
+############
+# %install #
+############
/^%install/, (/^%[a-z]+$/ && !/^%install/) {
preamble = 0
next
}
-
-# %files section:
+##########
+# %files #
+##########
/^%files/, (/^%[a-z \-]+$/ && !/^%files/) {
preamble = 0
defattr = 1
use_macros()
+ use_files_macros()
}
-# %changelog section:
+##############
+# %changelog #
+##############
/^%changelog/, (/^%[a-z]+$/ && !/^%changelog/) {
preamble = 0
has_changelog = 1
+ skip = 0
# There should be some CVS keywords on the first line of %changelog.
- if (boc == 1) {
- if (!/PLD Team/) {
- print "* %{date} PLD Team <pld-list@pld.org.pl>" > changelog_file
+ if (boc == 3) {
+ if (!/PLD Team/)
+ print "* %{date} PLD Team <feedback@pld-linux.org>" > changelog_file
+ else
+ skip = 1
+ boc = 2
+ }
+ if (boc == 2 && !skip) {
+ if (!/All persons listed below/) {
printf "All persons listed below can be reached at " > changelog_file
- print "<cvs_login>@pld.org.pl\n" > changelog_file
- print "$" "Log:$" > changelog_file
+ print "<cvs_login>@pld-linux.org\n" > changelog_file
+ } else
+ skip = 1
+ boc = 1
+ }
+ if (boc == 1 && !skip) {
+ if (!/^$/) {
+ if (!/\$.*Log:.*\$/)
+ print "$" "Log:$" > changelog_file
+ boc = 0
}
- boc = 0
}
-
# Define date macro.
- if (boc == 2) {
+ if (boc == 4) {
if (date == 0) {
printf "%%define date\t%%(echo `LC_ALL=\"C\"" > changelog_file
print " date +\"%a %b %d %Y\"`)" > changelog_file
date = 1
}
- boc = 1
+ boc = 3
}
+ sub(/[ \t]+$/, "")
if (!/^%[a-z]+$/ || /changelog/)
print > changelog_file
else
next
}
-# preambles:
+###########
+# SCRIPTS #
+###########
+/^%pre/, (/^%[a-z]+$/ && !/^%pre/) {
+ preamble = 0
+}
+/^%post/, (/^%[a-z]+$/ && !/^%post/) {
+ preamble = 0
+}
+/^%preun/, (/^%[a-z]+$/ && !/^%preun/) {
+ preamble = 0
+}
+/^%postun/, (/^%[a-z]+$/ && !/^%postun/) {
+ preamble = 0
+}
+
+#############
+# PREAMBLES #
+#############
preamble == 1 {
# There should not be a space after the name of field
# and before the colon.
sub(/[ \t]*:/, ":")
field = tolower($1)
- if (Byla_grupa == 1 && field ~ /^#/)
+ fieldnlower = $1
+ if (field ~ /group(\([^)]+\)):/)
next
- if (Byla_grupa == 1 && field !~ /group(\(..\))?:/) {
- Byla_grupa = 0
- print "Group:\t\t" Grupa["en"]
- if (Grupa["en"] ~ /^X11/ && x11 == 0) # Is it X11 application?
+ if (field ~ /group:/) {
+ format_preamble()
+ sub(/^Utilities\//,"Applications/",$2)
+ sub(/^Games/,"Applications/Games",$2)
+ sub(/^X11\/Games/,"X11/Applications/Games",$2)
+ sub(/^X11\/GNOME\/Development\/Libraries/,"X11/Development/Libraries",$2)
+ sub(/^X11\/GNOME\/Applications/,"X11/Applications",$2)
+ sub(/^X11\/GNOME/,"X11/Applications",$2)
+ sub(/^X11\/Utilities/,"X11/Applications",$2)
+ sub(/^X11\/Games\/Strategy/,"X11/Applications/Games/Strategy",$2)
+ sub(/^Shells/,"Applications/Shells",$2)
+
+ sub(/^[^ \t]*[ \t]*/,"")
+ Grupa = $0
+
+ print "Group:\t\t" Grupa
+ if (Grupa ~ /^X11/ && x11 == 0) # Is it X11 application?
x11 = 1
byl_plik_z_grupami = 0
byl_opis_grupy = 0
while ((getline linia_grup < groups_file) > 0) {
byl_plik_z_grupami = 1
- if (linia_grup == Grupa["en"]) {
+ if (linia_grup == Grupa) {
byl_opis_grupy = 1
break
}
print "######\t\t" groups_file ": no such file"
else if (!byl_opis_grupy)
print "######\t\t" "Unknown group!"
- else
- while (getline linia_grup < groups_file) {
- if (linia_grup == "")
- break
- split(linia_grup, g, /[\[\]:]/)
- sub(/^[ \t]*/,"",g[4])
- Grupa[g[2]]=g[4]
- }
close(groups_file)
-
- delete Grupa["en"]
- for (jezyk in Grupa) {
- print "Group(" jezyk "):\t" Grupa[jezyk] | "sort"
- delete Grupa[jezyk]
- }
- close ("sort")
+ next
}
if (field ~ /packager:|distribution:|docdir:|prefix:/)
if (field ~ /buildroot:/)
$0 = $1 "%{tmpdir}/%{name}-%{version}-root-%(id -u -n)"
- if (field ~ /group(\(..\))?:/) {
- format_preamble()
- sub(/^Utilities\//,"Applications/",$2)
- sub(/^Games/,"Applications/Games",$2)
- sub(/^X11\/Games/,"Applications\/Games",$2)
- sub(/^X11\/GNOME\/Development\/Libraries/,"X11/Development/Libraries",$2)
- sub(/^X11\/GNOME\/Applications/,"X11/Applications",$2)
- sub(/^X11\/GNOME/,"X11/Applications",$2)
- sub(/^X11\/Utilities/,"X11\/Applications",$2)
- sub(/^X11\/Games\/Strategy/,"X11/Applications/Games/Strategy",$2)
- sub(/^Shells/,"Applications/Shells",$2)
-
- if (!match(field,/\(..\):/))
- glang="en"
- else
- glang=substr(field,RSTART+1,2)
- sub(/^[^ \t]*[ \t]*/,"")
- Grupa[glang] = $0
- Byla_grupa = 1
-
- next # Line is already formatted and printed
- }
-
# Use "License" instead of "Copyright" if it is (L)GPL or BSD
if (field ~ /copyright:/ && $2 ~ /GPL|BSD/)
$1 = "License:"
$1 = "Epoch:"
# Use %{name} and %{version} in the filenames in "Source:"
- if (field ~ /source/ || field ~ /patch/) {
+ if (field ~ /^source/ || field ~ /patch/) {
n = split($2, url, /\//)
if (url[n] ~ /\.gz$/) {
url[n+1] = ".gz" url[n+1]
$2 = fixedsub(filename, url[n], $2)
}
- if (field ~ /source:/)
+ if (field ~ /^source:/)
$1 = "Source0:"
if (field ~ /patch:/)
if ($1 ~ /%define/) {
# Do not add %define of _prefix if it already is.
- if ($2 ~ /_prefix/) {
+ if ($2 ~ /^_prefix/) {
sub("^"prefix, $3, bindir)
sub("^"prefix, $3, sbindir)
sub("^"prefix, $3, libdir)
sub("^"prefix, $3, datadir)
sub("^"prefix, $3, includedir)
prefix = $3
- x11 = 2
}
if ($2 ~ /_bindir/ && !/_sbindir/)
bindir = $3
{
preamble = 1
+ sub(/[ \t]+$/, "")
print
}
END {
+ if (do_not_touch_anything)
+ exit 0
+
close(changelog_file)
while ((getline < changelog_file) > 0)
print
if (has_changelog == 0)
print "%changelog"
- if (boc > 0) {
- print "* %{date} PLD Team <pld-list@pld.org.pl>"
+ if (boc > 2)
+ print "* %{date} PLD Team <feedback@pld-linux.org>"
+ if (boc > 1) {
printf "All persons listed below can be reached at "
- print "<cvs_login>@pld.org.pl\n"
- print "$" "Log:$"
+ print "<cvs_login>@pld-linux.org\n"
}
+ if (boc > 0)
+ print "$" "Log:$"
}
function fixedsub(s1,s2,t, ind) {
function format_preamble()
{
sub(/:[ \t]*/, ":")
- if (match($0, /[A-Za-z0-9()# \t]+[ \t]*:[ \t]*/) == 1) {
+ if (match($0, /[A-Za-z0-9(),#_ \t]+[ \t]*:[ \t]*/) == 1) {
if (RLENGTH < 8)
sub(/:/, ":\t\t")
else
function use_macros()
{
gsub(bindir, "%{_bindir}")
- gsub("%{_prefix}/bin", "%{_bindir}")
gsub("%{prefix}/bin", "%{_bindir}")
+ if(prefix"/bin" == bindir)
+ gsub("%{_prefix}/bin", "%{_bindir}")
for (c = 1; c <= NF; c++) {
if ($c ~ sbindir "/fix-info-dir")
}
gsub("%{prefix}/sbin", "%{_sbindir}")
- gsub("%{_prefix}/sbib", "%{_sbindir}")
-
- gsub(libdir, "%{_libdir}")
- gsub("%{prefix}/lib", "%{_libdir}")
- gsub("%{_prefix}/lib", "%{_libdir}")
+ if(prefix"/sbin" == sbindir)
+ gsub("%{_prefix}/sbin", "%{_sbindir}")
for (c = 1; c <= NF; c++) {
- if ($c ~ sysconfdir "/cron.d")
+ if ($c ~ sysconfdir "/{?cron.")
continue;
- if ($c ~ sysconfdir "/crontab.d")
+ if ($c ~ sysconfdir "/{?crontab.d")
continue;
- if ($c ~ sysconfdir "/logrotate.d")
+ if ($c ~ sysconfdir "/{?logrotate.d")
continue;
- if ($c ~ sysconfdir "/pam.d")
+ if ($c ~ sysconfdir "/{?pam.d")
continue;
- if ($c ~ sysconfdir "/profile.d")
+ if ($c ~ sysconfdir "/{?profile.d")
continue;
- if ($c ~ sysconfdir "/rc.d")
+ if ($c ~ sysconfdir "/{?rc.d")
continue;
- if ($c ~ sysconfdir "/security")
+ if ($c ~ sysconfdir "/{?security")
continue;
- if ($c ~ sysconfdir "/skel")
+ if ($c ~ sysconfdir "/{?skel")
continue;
- if ($c ~ sysconfdir "/sysconfig")
+ if ($c ~ sysconfdir "/{?sysconfig")
continue;
gsub(sysconfdir, "%{_sysconfdir}", $c)
}
gsub(datadir, "%{_datadir}")
gsub("%{prefix}/share", "%{_datadir}")
- gsub("%{_prefix}/share", "%{_datadir}")
+ if(prefix"/share" == datadir)
+ gsub("%{_prefix}/share", "%{_datadir}")
gsub(includedir, "%{_includedir}")
gsub("%{prefix}/include", "%{_includedir}")
- gsub("%{_prefix}/include", "%{_includedir}")
+ if(prefix"/include" == includedir)
+ gsub("%{_prefix}/include", "%{_includedir}")
gsub(mandir, "%{_mandir}")
- gsub("%{_datadir}/man", "%{_mandir}")
+ if ($0 !~ "%{_datadir}/manual")
+ gsub("%{_datadir}/man", "%{_mandir}")
gsub("%{_prefix}/share/man", "%{_mandir}")
gsub("%{prefix}/share/man", "%{_mandir}")
gsub("%{prefix}/man", "%{_mandir}")
gsub("%{prefix}/info", "%{_infodir}")
gsub("%{_prefix}/info", "%{_infodir}")
- gsub("%{_datadir}/aclocal", "%{_aclocaldir}")
+ if (prefix !~ "/X11R6") {
+ gsub("%{_datadir}/aclocal", "%{_aclocaldir}")
+ }
if (prefix != "/") {
for (c = 1; c <= NF; c++) {
gsub("%{PACKAGE_VERSION}", "%{version}")
gsub("%{PACKAGE_NAME}", "%{name}")
- gsub("^%{_sbindir}", "%attr(755,root,root) %{_sbindir}")
- gsub("^%{_bindir}", "%attr(755,root,root) %{_bindir}")
-
- gsub("%{_datadir}/gnome/apps", "%{_applnkdir}")
- gsub("%{_datadir}/applnk", "%{_applnkdir}")
+ # we can move files between the dirs below
+ if ($0 !~ "%{_applnkdir}") {
+ gsub("%{_datadir}/gnome/apps", "%{_applnkdir}")
+ }
gsub("^make$", "%{__make}")
gsub("^make ", "%{__make} ")
+
+ gsub("/usr/src/linux", "%{_kernelsrcdir}")
+ gsub("%{_prefix}/src/linux", "%{_kernelsrcdir}")
+}
+
+function use_files_macros()
+{
+ gsub("^%{_sbindir}", "%attr(755,root,root) %{_sbindir}")
+ gsub("^%{_bindir}", "%attr(755,root,root) %{_bindir}")
}
function fill(ch, n, i) {
return 0
}
- sub("\$RPM_OPT_FLAGS", "%{!?debug:$RPM_OPT_FLAGS}%{?debug:-O0 -g}")
+ if (!/!\?debug/)
+ sub("\$RPM_OPT_FLAGS", "%{rpmcflags}")
return 1
}