]> git.pld-linux.org Git - packages/rpm-build-tools.git/blobdiff - adapter.awk
- unify ftp.gnu.org url
[packages/rpm-build-tools.git] / adapter.awk
index 50371bfb290db0b832eb50a3f04f179809581258..f2133e3e51d1cd0469af61b2a24764958865858b 100644 (file)
@@ -1,15 +1,16 @@
 #!/usr/bin/gawk -f
 #
-# This is adapter v0.28. Adapter adapts .spec files for PLD Linux.
+# This is adapter v0.29. Adapter adapts .spec files for PLD Linux.
 # $Id$
 #
-# Copyright (C) 1999-2006 PLD-Team <feedback@pld-linux.org>
+# Copyright (C) 1999-2007 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-linux.org>
 #      Michal Kochanowicz <mkochano@pld.org.pl>
+#      Jakub Bogusz <qboosh@pld-linux.org>
 #      Elan Ruusamäe <glen@pld-linux.org>
 #
 # See cvs log adapter{,.awk} for list of contributors
@@ -17,6 +18,7 @@
 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
 
 # TODO
+# - really long sourceX make preamble sorting totally fcked up (try snake.spec r1.1)
 # - parse ../PLD-doc/BuildRequires.txt and setup proper BR epoches?
 # - add "-nc" option to skip CVS interaction
 # - sort Summary(XX)
@@ -28,7 +30,9 @@ BEGIN {
        RPM_SECTIONS = "package|build|changelog|clean|description|install|post|posttrans|postun|pre|prep|pretrans|preun|triggerin|triggerpostun|triggerun|verifyscript|check"
        SECTIONS = "^%(" RPM_SECTIONS ")"
 
-       PREAMBLE_TAGS = "(Summary|Name|Version|Release|Epoch|License|Group|URL|BuildArch|BuildRoot|Obsoletes|Conflicts|Provides|ExclusiveArch|ExcludeArch|Pre[Rr]eq|(Build)?Requires)"
+       PREAMBLE_TAGS = "(R|BR|Summary|Name|Version|Release|Epoch|License|Group|URL|BuildArch|BuildRoot|Obsoletes|Conflicts|Provides|ExclusiveArch|ExcludeArch|Pre[Rr]eq|(Build)?Requires|Suggests)"
+
+       usedigest = 0   # Enable to switch to rpm 4.4.6+ md5 digests
 
        preamble = 1    # Is it part of preamble? Default - yes
        boc = 4                 # Beginning of %changelog
@@ -140,10 +144,12 @@ function b_makekey(a, b,  s) {
 
        gsub(/^BuildRequires/, "B1BuildRequires", s);
        gsub(/^BuildConflicts/, "B2BuildConflicts", s);
-       gsub(/^Provides/, "X1Provides", s);
-       gsub(/^Obsoletes/, "X2Obsoletes", s);
-       gsub(/^Conflicts/, "X3Conflicts", s);
-       gsub(/^BuildArch/, "X4BuildArch", s);
+
+       gsub(/^Suggests/, "X1Suggests", s);
+       gsub(/^Provides/, "X2Provides", s);
+       gsub(/^Obsoletes/, "X3Obsoletes", s);
+       gsub(/^Conflicts/, "X4Conflicts", s);
+       gsub(/^BuildArch/, "X5BuildArch", s);
        gsub(/^ExclusiveArch/, "X6ExclusiveArch", s);
        gsub(/^ExcludeArch/, "X7ExcludeArch", s);
        gsub(/^BuildRoot/, "X9BuildRoot", s);
@@ -165,7 +171,11 @@ function b_makekey(a, b,   s) {
        # Generally, comments are printed without touching
        sub(/[ \t]+$/, "")
 
-       if (/Source.*md5/) {
+       if (/#[ \t]*Source.*md5/) {
+               if (usedigest == 1) {
+                       sub(/^#[ \t]*Source/, "BuildRequires:\tdigest(%SOURCE", $0)
+                       sub(/-md5[ \t]*:[ \t]*/, ") = ", $0)
+               }
                print $0
                next
        }
@@ -241,6 +251,8 @@ function b_makekey(a, b,    s) {
                _pre = $3
        if ($2 ~ /^_snap$/)
                _snap = $3
+       if ($2 ~ /^subver$/)
+               subver = $3
 
        # these are used usually when adapterizing external spec
        if ($2 ~ /^name$/)
@@ -342,6 +354,9 @@ function b_makekey(a, b,    s) {
                if (_snap) {
                        $0 = fixedsub(_snap, "%{_snap}", $0);
                }
+               if (subver) {
+                       $0 = fixedsub(subver, "%{subver}", $0);
+               }
        }
 
        if (/^%setup/ && /-n %{name}-%{version}( |$)/) {
@@ -661,42 +676,48 @@ preamble == 1 {
                group = $0;
                sub(/^[^ \t]*[ \t]*/, "", group);
 
-               sub(/^Utilities\//,"Applications/", group)
-               sub(/^Games/,"Applications/Games", group)
-               sub(/^X11\/Games/,"X11/Applications/Games", group)
-               sub(/^X11\/GNOME\/Development\/Libraries/,"X11/Development/Libraries", group)
-               sub(/^X11\/GNOME\/Applications/,"X11/Applications", group)
-               sub(/^X11\/GNOME/,"X11/Applications", group)
-               sub(/^X11\/Utilities/,"X11/Applications", group)
-               sub(/^X11\/Games\/Strategy/,"X11/Applications/Games/Strategy", group)
-               sub(/^X11\/Library/,"X11/Libraries", group)
-               sub(/^Shells/,"Applications/Shells", group)
-               sub(/^System Environment\/Libraries$/, "Libraries", group)
-               sub(/^Library\/Development$/, "Development/Libraries", group)
-               sub(/^System Environment\/Daemons$/, "Daemons", group)
-               sub(/^Applications\/Internet$/, "Applications/Networking", group)
-               sub(/^Applications\/Daemons$/, "Daemons", group)
+               sub(/^Amusements\/Games\/Strategy\/Real Time/, "X11/Applications/Games/Strategy", group)
                sub(/^Application\/Multimedia$/, "Applications/Multimedia", group)
-               sub(/^System\/Servers$/, "Daemons", group)
-               sub(/^X11\/Xserver$/, "X11/Servers", group)
-               sub(/^X11\/XFree86/, "X11", group)
                sub(/^Applications\/Compilers$/, "Development/Languages", group)
+               sub(/^Applications\/Daemons$/, "Daemons", group)
+               sub(/^Applications\/Internet$/, "Applications/Networking", group)
                sub(/^Applications\/Internet\/Peer to Peer/, "Applications/Networking", group)
-               sub(/^Networking\/Deamons$/, "Networking/Daemons", group)
+               sub(/^Applications\/Productivity$/, "X11/Applications", group)
+               sub(/^Database$/, "Applications/Databases", group)
+               sub(/^Development\/Code Generators$/, "Development", group)
                sub(/^Development\/Docs$/, "Documentation", group)
                sub(/^Development\/Documentation$/, "Documentation", group)
-               sub(/^System Environment\/Kernel$/, "Base/Kernel", group)
-               sub(/^Development\/Libraries\/Java$/, "Development/Languages/Java", group)
                sub(/^Development\/Java/, "Development/Languages/Java", group)
+               sub(/^Development\/Libraries\/C and C\+\+$/, "Development/Libraries", group)
+               sub(/^Development\/Libraries\/Java$/, "Development/Languages/Java", group)
+               sub(/^Development\/Other/,"Development", group)
                sub(/^Development\/Testing$/, "Development", group)
+               sub(/^Emulators$/, "Applications/Emulators", group)
+               sub(/^Games/,"Applications/Games", group)
+               sub(/^Library\/Development$/, "Development/Libraries", group)
+               sub(/^Networking\/Deamons$/, "Networking/Daemons", group)
+               sub(/^Shells/,"Applications/Shells", group)
+               sub(/^System Environment\/Base$/, "Base", group)
+               sub(/^System Environment\/Daemons$/, "Daemons", group)
+               sub(/^System Environment\/Kernel$/, "Base/Kernel", group)
+               sub(/^System Environment\/Libraries$/, "Libraries", group)
+               sub(/^System$/, "Base", group)
+               sub(/^System\/Base$/, "Base", group)
+               sub(/^System\/Libraries$/, "Libraries", group)
+               sub(/^System\/Servers$/, "Daemons", group)
                sub(/^Text Processing\/Markup\/HTML$/, "Applications/Text", group)
                sub(/^Text Processing\/Markup\/XML$/, "Applications/Text", group)
+               sub(/^Utilities\//,"Applications/", group)
                sub(/^Web\/Database$/, "Applications/WWW", group)
-               sub(/^System Environment\/Base$/, "Base", group)
-               sub(/^System$/, "Base", group)
-               sub(/^Applications\/Productivity$/, "X11/Applications", group)
-               sub(/^Database$/, "Applications/Databases", group)
-               sub(/^Development\/Code Generators$/, "Development", group)
+               sub(/^X11\/GNOME/,"X11/Applications", group)
+               sub(/^X11\/GNOME\/Applications/,"X11/Applications", group)
+               sub(/^X11\/GNOME\/Development\/Libraries/,"X11/Development/Libraries", group)
+               sub(/^X11\/Games/,"X11/Applications/Games", group)
+               sub(/^X11\/Games\/Strategy/,"X11/Applications/Games/Strategy", group)
+               sub(/^X11\/Library/,"X11/Libraries", group)
+               sub(/^X11\/Utilities/,"X11/Applications", group)
+               sub(/^X11\/XFree86/, "X11", group)
+               sub(/^X11\/Xserver$/, "X11/Servers", group)
 
                $0 = "Group:\t\t" group
 
@@ -755,24 +776,11 @@ preamble == 1 {
                        next
                }
 
-               # perhaps we have common known name?
-
-               # jpackages
-               sub(/^java-devel$/, "jdk", $2);
-               sub(/^log4j$/, "jakarta-log4j", $2);
-               sub(/^oro$/, "jakarta-oro", $2);
-               sub(/^jakarta-ant$/, "ant", $2);
-               sub(/^xerces-j2$/, "xerces-j", $2);
-               sub(/^ldapjdk$/, "ldapsdk", $2);
-               sub(/^saxon-scripts$/, "saxon", $2);
-               sub(/^xalan-j2$/, "xalan-j", $2);
-               sub(/^xerces-j2$/, "xerces-j", $2);
-
-               replace_php_virtual_deps();
+               replace_requires();
        }
 
        if (field ~ /^requires:/) {
-               replace_php_virtual_deps();
+               replace_requires();
        }
 
 
@@ -796,6 +804,18 @@ preamble == 1 {
                if (l == "Python Software Foundation License") {
                        l = "PSF"
                }
+               if (l == "Apache License 2.0" || l == "Apache 2.0" || l == "Apache License Version 2.0" || l == "Apache License, Version 2.0" || l == "Apache Software License v2") {
+                       l = "Apache v2.0"
+               }
+               if (l == "Apache Group License" || l == "Apache Software License" || l == "Apache License") {
+                       l = "Apache"
+               }
+               if (l == "Apache-style License" || l == "Apache-style Software License") {
+                       l = "Apache-like"
+               }
+               if (l == "Apache Software License 1.1" || l == "Apache 1.1") {
+                       l = "Apache v1.1"
+               }
                $0 = "License:\t" l;
        }
 
@@ -903,24 +923,14 @@ preamble == 1 {
                        if (_snap) {
                                url[n] = fixedsub(_snap, "%{_snap}", url[n])
                        }
+                       if (subver) {
+                               url[n] = fixedsub(subver, "%{subver}", url[n])
+                       }
                }
                # assigning to $2 kills preamble formatting
                $2 = fixedsub(filename, url[n], $2)
 
-               # sourceforge urls
-               sub("[?&]big_mirror=.*$", "", $2);
-               sub("[?&]modtime=.*$", "", $2);
-
-               sub("[?]use_mirror=.*$", "", $2);
-               sub("[?]download$", "", $2);
-
-               sub("^http://prdownloads\.sourceforge\.net/", "http://dl.sourceforge.net/", $2)
-               sub("^http://download\.sf\.net/", "http://dl.sourceforge.net/", $2)
-               sub("^http://downloads\.sourceforge\.net/", "http://dl.sourceforge.net/", $2)
-
-               sub("^http://.*\.dl\.sourceforge\.net/", "http://dl.sourceforge.net/", $2)
-               sub("^http://dl\.sourceforge\.net/sourceforge/", "http://dl.sourceforge.net/", $2)
-               sub("^http://dl\.sf\.net/", "http://dl.sourceforge.net/", $2)
+               $2 = unify_url($2)
        }
 
 
@@ -956,6 +966,12 @@ ENVIRON["SKIP_SORTBR"] != 1 && preamble == 1 && $0 ~ PREAMBLE_TAGS, $0 ~ PREAMBL
        if ($1 ~ /Pre[Rr]eq:/) {
                sub(/Pre[Rr]eq:/, "Requires:", $1);
        }
+       if ($1 == "BR:" ) {
+               $1 = "BuildRequires:"
+       }
+       if ($1 == "R:" ) {
+               $1 = "Requires:"
+       }
        format_preamble()
 #      kill_preamble_macros(); # breaks tabbing
 
@@ -1193,6 +1209,8 @@ function use_macros()
                        continue;
                if ($c ~ sysconfdir "/ppp")
                        continue;
+               if ($c ~ sysconfdir "/dbus-1")
+                       continue;
                gsub(sysconfdir, "%{_sysconfdir}", $c)
        }
 
@@ -1289,6 +1307,7 @@ function use_macros()
        gsub("^make$", "%{__make}")
        gsub("^make ", "%{__make} ")
        gsub("^gcc ", "%{__cc} ")
+       gsub("^rm --interactive=never ", "%{__rm} ")
 
        # mandrake specs
        gsub("^%make$", "%{__make}")
@@ -1298,7 +1317,6 @@ function use_macros()
        gsub("^%makeinstall", "%{__make} install \\\n\tDESTDIR=$RPM_BUILD_ROOT")
        gsub("^%{__rm} -rf %{buildroot}", "rm -rf $RPM_BUILD_ROOT")
        gsub("^%{__install}", "install")
-       gsub("^%{__rm}", "rm")
        gsub("%optflags", "%{rpmcflags}")
        gsub("%{compat_perl_vendorarch}", "%{perl_vendorarch}")
 
@@ -1307,6 +1325,7 @@ function use_macros()
        $0 = fixedsub("%buildroot", "$RPM_BUILD_ROOT", $0)
        $0 = fixedsub("%{buildroot}", "$RPM_BUILD_ROOT", $0)
        $0 = fixedsub("CXXFLAGS=%{rpmcflags} %configure", "CXXFLAGS=%{rpmcflags}\n%configure", $0);
+       $0 = fixedsub("%__install", "install", $0);
 
        # split configure line to multiple lines
        if (/%configure / && !/\\$/) {
@@ -1398,6 +1417,7 @@ function use_files_macros(        i, n, t, a)
        gsub("%{_sysconfdir}/sysconfig", "/etc/sysconfig")
        gsub("%{_sysconfdir}/certs", "/etc/certs")
        gsub("%{_sysconfdir}/init.d", "/etc/init.d")
+       gsub("%{_sysconfdir}/dbus-1", "/etc/dbus-1")
 
        # /etc/init.d -> /etc/rc.d/init.d
        if (!/^\/etc\/init\.d$/) {
@@ -1556,6 +1576,36 @@ function cflags(var)
        return 1
 }
 
+function unify_url(url)
+{
+
+       # sourceforge urls
+       sub("[?&]big_mirror=.*$", "", url);
+       sub("[?&]modtime=.*$", "", url);
+       sub("[?]use_mirror=.*$", "", url);
+       sub("[?]download$", "", url);
+
+       sub("^http://prdownloads\.sourceforge\.net/", "http://dl.sourceforge.net/", url)
+       sub("^http://download\.sf\.net/", "http://dl.sourceforge.net/", url)
+       sub("^http://download\.sourceforge\.net/", "http://dl.sourceforge.net/", url)
+       sub("^http://downloads\.sourceforge\.net/", "http://dl.sourceforge.net/", url)
+
+       sub("^http://.*\.dl\.sourceforge\.net/", "http://dl.sourceforge.net/", url)
+       sub("^http://dl\.sourceforge\.net/sourceforge/", "http://dl.sourceforge.net/", url)
+       sub("^http://dl\.sf\.net/", "http://dl.sourceforge.net/", url)
+
+       sub("^ftp://ftp\.gnome\.org/", "http://ftp.gnome.org/", url)
+       sub("^http://ftp\.gnome\.org/pub/gnome/", "http://ftp.gnome.org/pub/GNOME/", url)
+
+       # apache urls
+       sub("^http://apache.zone-h.org/", "http://www.apache.org/dist/", url)
+
+       # gnu.org
+       sub("^ftp://ftp.gnu.org/gnu/", "http://ftp.gnu.org/gnu/", url)
+
+       return url
+}
+
 function demacroize(str)
 {
        if (mod_name) {
@@ -1579,16 +1629,22 @@ function demacroize(str)
        if (_snap) {
                sub("%{_snap}", _snap, str);
        }
+       if (subver) {
+               sub("%{subver}", subver, str);
+       }
        return str;
 }
 
 function kill_preamble_macros()
 {
-       if ($1 ~ /^URL:/ || $1 ~ /^Obsoletes:/) {
+       if ($1 ~ /^Obsoletes:/) {
+               # NB! assigning $2 a value breaks tabbing
+               $2 = demacroize($2);
+       }
+       if ($1 ~ /^URL:/) {
                # NB! assigning $2 a value breaks tabbing
                $2 = demacroize($2);
-               # unify sourceforge url
-               sub("\.sf\.net/$", ".sourceforge.net/", $2);
+               $2 = unify_url($2)
        }
 }
 
@@ -1643,6 +1699,31 @@ function add_br(br)
        BR[BR_count++] = br
 }
 
+function replace_requires()
+{
+
+       # jpackages
+       sub(/^java-devel$/, "jdk", $2);
+       sub(/^log4j$/, "logging-log4j", $2);
+       sub(/^jakarta-log4j$/, "logging-log4j", $2);
+       sub(/^oro$/, "jakarta-oro", $2);
+       sub(/^jakarta-ant$/, "ant", $2);
+       sub(/^xerces-j2$/, "xerces-j", $2);
+       sub(/^ldapjdk$/, "ldapsdk", $2);
+       sub(/^saxon-scripts$/, "saxon", $2);
+       sub(/^xalan-j2$/, "xalan-j", $2);
+       sub(/^xerces-j2$/, "xerces-j", $2);
+       sub(/^gnu-regexp$/, "gnu.regexp", $2);
+
+       # redhat virtual
+       sub(/^tftp-server$/, "tftpdaemon", $2);
+
+       sub(/^gcc-c\+\+$/, "libstdc++-devel", $2);
+       sub(/^chkconfig$/, "/sbin/chkconfig", $2);
+
+       replace_php_virtual_deps()
+}
+
 # php virtual deps as discussed in devel-en
 function replace_php_virtual_deps()
 {
@@ -1652,11 +1733,11 @@ function replace_php_virtual_deps()
 #              return
 #      }
 
-       if (pkg ~ /^php-[a-z]/ && pkg !~ /^php-(pear|common|cli|devel|fcgi|cgi|dirs|program|pecl-)/) {
-               sub(/^php-/, "php(", pkg);
-               sub(/$/, ")", pkg);
-               $2 = pkg
-       }
+#      if (pkg ~ /^php-[a-z]/ && pkg !~ /^php-(pear|common|cli|devel|fcgi|cgi|dirs|program|pecl-)/) {
+#              sub(/^php-/, "php(", pkg);
+#              sub(/$/, ") # verify this correctness -- it may be wanted to use specific not virtual dep", pkg);
+#              $2 = pkg
+#      }
 
        if (pkg ~/^php$/) {
                $2 = "webserver(php)";
This page took 0.038962 seconds and 4 git commands to generate.