#!/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 <feedback@pld-linux.org>
+# Copyright (C) 1999-2008 PLD-Team <feedback@pld-linux.org>
# Authors:
# MichaĆ Kuratczyk <kura@pld.org.pl>
# Sebastian Zagrodzki <s.zagrodzki@mimuw.edu.pl>
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# 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)
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
"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
"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
}
# 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
}
_pre = $3
if ($2 ~ /^_snap$/)
_snap = $3
+ if ($2 ~ /^subver$/)
+ subver = $3
# these are used usually when adapterizing external spec
if ($2 ~ /^name$/)
if (_snap) {
$0 = fixedsub(_snap, "%{_snap}", $0);
}
+ if (subver) {
+ $0 = fixedsub(subver, "%{subver}", $0);
+ }
}
if (/^%setup/ && /-n %{name}-%{version}( |$)/) {
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?
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();
}
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;
}
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)
}
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}")
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;
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")
gsub("^make$", "%{__make}")
gsub("^make ", "%{__make} ")
gsub("^gcc ", "%{__cc} ")
+ gsub("^rm --interactive=never ", "%{__rm} ")
# mandrake specs
gsub("^%make$", "%{__make}")
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}")
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) {
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()
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) {
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)
}
}
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()
{
}
}
+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