X-Git-Url: http://git.pld-linux.org/?a=blobdiff_plain;ds=sidebyside;f=adapter.awk;h=626abf2be18a836ead13d60096ebf04876e8d18c;hb=e7daca0ab8b27950992c66d7d7e8985c8eb0a236;hp=478c71b44ebb03a50f91a3d6d7c4ea4b658b4be0;hpb=0731341f570afcae4b304fb50eb53fcff5647580;p=packages%2Frpm.git diff --git a/adapter.awk b/adapter.awk index 478c71b..626abf2 100644 --- a/adapter.awk +++ b/adapter.awk @@ -1,9 +1,9 @@ #!/usr/bin/gawk -f # -# This is adapter v0.28. Adapter adapts .spec files for PLD Linux. +# This is adapter v0.30-RELEASE. Adapter adapts .spec files for PLD Linux. # $Id$ # -# Copyright (C) 1999-2007 PLD-Team +# Copyright (C) 1999-2008 PLD-Team # Authors: # Michał Kuratczyk # Sebastian Zagrodzki @@ -18,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) @@ -31,6 +32,8 @@ BEGIN { 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 bod = 0 # Beginning of %description @@ -76,6 +79,7 @@ BEGIN { "rpm --eval %_kdedocdir" | getline kdedocdir "rpm --eval %_desktopdir" | getline desktopdir "rpm --eval %_pixmapsdir" | getline pixmapsdir + "rpm --eval %_javadir" | getline javadir "rpm --eval %perl_sitearch" | getline perl_sitearch "rpm --eval %perl_archlib" | getline perl_archlib @@ -95,6 +99,7 @@ BEGIN { "rpm --eval %ruby_sitelibdir" | getline ruby_sitelibdir "rpm --eval %php_pear_dir" | getline php_pear_dir + "rpm --eval %php_data_dir" | getline php_data_dir "rpm --eval %tmpdir" | getline tmpdir } @@ -168,7 +173,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 } @@ -244,6 +253,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$/) @@ -345,6 +356,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}( |$)/) { @@ -663,46 +677,7 @@ preamble == 1 { format_preamble() 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(/^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\/Internet\/Peer to Peer/, "Applications/Networking", group) - sub(/^Networking\/Deamons$/, "Networking/Daemons", 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\/Testing$/, "Development", group) - sub(/^Text Processing\/Markup\/HTML$/, "Applications/Text", group) - sub(/^Text Processing\/Markup\/XML$/, "Applications/Text", 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(/^Emulators$/, "Applications/Emulators", group) - sub(/^System\/Libraries$/, "Libraries", group) - + group = replace_groupnames(group); $0 = "Group:\t\t" group if (group ~ /^X11/ && x11 == 0) # Is it X11 application? @@ -760,24 +735,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(); } @@ -801,6 +763,24 @@ 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" + } + if (l == "GPLv2") { + l = "GPL v2" + } + if (l == "GPLv2+") { + l = "GPL v2+" + } $0 = "License:\t" l; } @@ -908,27 +888,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) - - sub("^ftp://ftp\.gnome\.org/", "http://ftp.gnome.org/", $2) - sub("^http://ftp\.gnome\.org/pub/gnome/", "http://ftp.gnome.org/pub/GNOME/", $2) + $2 = unify_url($2) } @@ -1133,8 +1100,10 @@ function use_macros() gsub("%{_datadir}/applications", "%{_desktopdir}") gsub("%{_datadir}/pixmaps", "%{_pixmapsdir}") + gsub("%{_datadir}/java", "%{_javadir}") gsub(libdir, "%{_libdir}") + gsub(javadir, "%{_javadir}") gsub(bindir, "%{_bindir}") gsub("%{prefix}/bin", "%{_bindir}") @@ -1173,7 +1142,9 @@ function use_macros() continue; if ($c ~ sysconfdir "/{?modprobe.(d|conf)") continue; - if ($c ~ sysconfdir "/{?udev/rules.d") + if ($c ~ sysconfdir "/{?udev") + continue; + if ($c ~ sysconfdir "/{?hotplug") continue; if ($c ~ sysconfdir "/{?logrotate.d") continue; @@ -1215,6 +1186,7 @@ function use_macros() gsub(kdedocdir, "%{_kdedocdir}") gsub(docdir, "%{_docdir}") gsub(php_pear_dir, "%{php_pear_dir}") + gsub(php_data_dir, "%{php_data_dir}") for (c = 1; c <= NF; c++) { if ($c ~ datadir "/automake") @@ -1305,6 +1277,7 @@ function use_macros() gsub("^make$", "%{__make}") gsub("^make ", "%{__make} ") gsub("^gcc ", "%{__cc} ") + gsub("^rm --interactive=never ", "%{__rm} ") # mandrake specs gsub("^%make$", "%{__make}") @@ -1314,7 +1287,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}") @@ -1347,12 +1319,15 @@ function use_macros() gsub("/usr/src/linux", "%{_kernelsrcdir}") gsub("%{_prefix}/src/linux", "%{_kernelsrcdir}") - if (/^ant /) { + if (/^ant / || /^%{ant}/) { sub(/^ant/, "%ant") + sub(/^%{ant}/, "%ant") add_br("BuildRequires: jpackage-utils"); add_br("BuildRequires: rpmbuild(macros) >= 1.300"); } + $0 = fixedsub("%(%{__cc} -dumpversion)", "%{cc_version}", $0); + $0 = fixedsub("%(%{__cxx} -dumpversion)", "%{cxx_version}", $0); } function format_configure(line, n, a, s) { @@ -1515,6 +1490,8 @@ function use_files_macros( i, n, t, a) gsub("%{_datadir}/applications", "%{_desktopdir}"); gsub("%{_datadir}/icons", "%{_iconsdir}"); gsub("%{_datadir}/pixmaps", "%{_pixmapsdir}"); + gsub("%{_datadir}/pear", "%{php_pear_dir}"); + gsub("%{_datadir}/php", "%{php_data_dir}"); } function use_script_macros() @@ -1574,6 +1551,37 @@ 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/", "http://ftp.gnu.org/", url) + sub("^http://ftp.gnu.org/pub/gnu/", "http://ftp.gnu.org/gnu/", url) + + return url +} + function demacroize(str) { if (mod_name) { @@ -1597,16 +1605,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); - # unify sourceforge url - sub("\.sf\.net/$", ".sourceforge.net/", $2); + } + if ($1 ~ /^URL:/) { + # NB! assigning $2 a value breaks tabbing + $2 = demacroize($2); + $2 = unify_url($2) } } @@ -1661,6 +1675,34 @@ 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); + + # fedora + sub(/^iscsi-initiator-utils$/, "open-iscsi", $2); + + replace_php_virtual_deps() +} + # php virtual deps as discussed in devel-en function replace_php_virtual_deps() { @@ -1691,4 +1733,56 @@ function replace_php_virtual_deps() } } +function replace_groupnames(group) +{ + sub(/^Amusements\/Games\/Strategy\/Real Time/, "X11/Applications/Games/Strategy", group) + sub(/^Application\/Multimedia$/, "Applications/Multimedia", 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(/^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(/^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(/^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) + sub(/^Development\/C$/, "Development/Libraries", group) + sub(/^Development\/Python$/, "Development/Languages/Python", group) + sub(/^System\/Kernel and hardware$/, "Base/Kernel", group) + sub(/^Application\/System$/, "Applications/System", group) + + return group; +} + # vim:ts=4:sw=4