]> git.pld-linux.org Git - packages/adapter.git/blobdiff - adapter.awk
Replace Requires(triggerpostun) with Requires(post)
[packages/adapter.git] / adapter.awk
index 7e26f90774e1198dfec2cf459c1edece9c6443c1..e84d29ec6df1010f9597af5cf30499c770ee18a3 100644 (file)
@@ -2,7 +2,7 @@
 #
 # Adapter adapts .spec files for PLD Linux.
 #
-# Copyright (C) 1999-2016 PLD-Team <feedback@pld-linux.org>
+# Copyright (C) 1999-2021 PLD-Team <feedback@pld-linux.org>
 # Authors:
 #      Michał Kuratczyk <kura@pld.org.pl>
 #      Sebastian Zagrodzki <s.zagrodzki@mimuw.edu.pl>
@@ -33,7 +33,7 @@ BEGIN {
        RPM_SECTIONS = "package|build|changelog|clean|description|install|post|posttrans|postun|pre|prep|pretrans|preun|triggerin|triggerpostun|triggerun|verifyscript|check"
        SECTIONS = "^%(" RPM_SECTIONS ")"
 
-       VERSION="1.514"
+       VERSION="1.515"
 
        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|Auto(Req|Prov))"
 
@@ -46,6 +46,9 @@ BEGIN {
        b_idx = 0               # index of BR/R arrays
        BR_count = 0    # number of additional BuildRequires
 
+       # %global defines
+       globals["nil"] = ""
+
        # If variable removed, then 1 (for removing it from export)
        removed["LDFLAGS"] = 0
        removed["CFLAGS"] = 0
@@ -142,6 +145,11 @@ function b_makekey(a, b,   s) {
        }
 }
 
+# load globals
+/^%global/ {
+       globals[$2] = $3;
+}
+
 /^%define/ {
        # FIXME: this section will likely never match after cvs->git migration
        if ($2 == "date") {
@@ -270,6 +278,8 @@ function b_makekey(a, b,    s) {
 /^%package/, (!/^%package/ && $0 ~ SECTIONS) {
        # FIXME: this breaks \t indenting in preamble?
        gsub(/\t/, " ")
+
+       sub(/%{python3_pkgversion}/, "3", $2)
 }
 
 ################
@@ -284,6 +294,10 @@ function b_makekey(a, b,   s) {
                format_indent = -1
        }
 
+       # try ASCII quotes and apostrophes
+       gsub(/’/, "'")
+       gsub(/—/, " - ")
+
        # Format description
        if (ENVIRON["SKIP_DESC"] != 1 && description == 1 && !/^%[a-z]+/ && !/^%description/) {
                if (/^[ \t]*$/) {
@@ -366,7 +380,7 @@ function b_makekey(a, b,    s) {
        }
 
        # invalid in %prep
-       sub("^rm -rf \$RPM_BUILD_ROOT.*", "")
+       sub("^rm -rf \\$RPM_BUILD_ROOT.*", "")
 }
 
 ##########
@@ -440,11 +454,11 @@ function b_makekey(a, b,  s) {
        $0 = fixedsub("libtoolize --force --copy", "%{__libtoolize}", $0)
        $0 = fixedsub("libtoolize -c -f --automake", "%{__libtoolize}", $0)
 
-       sub(/^aclocal$/, "%{__aclocal}")
-       sub(/^autoheader$/, "%{__autoheader}")
-       sub(/^autoconf$/, "%{__autoconf}")
+       sub(/^aclocal( --force)?$/, "%{__aclocal}")
+       sub(/^(%{_bindir}\/)?autoheader( --force)?$/, "%{__autoheader}")
+       sub(/^(%{_bindir}\/)?autoconf( --force)?$/, "%{__autoconf}")
        sub(/^automake$/, "%{__automake}")
-       sub(/^libtoolize$/, "%{__libtoolize}")
+       sub(/^libtoolize( --copy --force)?$/, "%{__libtoolize}")
 
        # atrpms
        $0 = fixedsub("%perl_configure", "%{__perl} Makefile.PL \\\n\tINSTALLDIRS=vendor", $0)
@@ -474,7 +488,7 @@ function b_makekey(a, b,    s) {
        sub("^%{__rm} -rf %{buildroot}", "rm -rf $RPM_BUILD_ROOT")
        sub("%buildroot", "$RPM_BUILD_ROOT")
        sub("%{buildroot}", "$RPM_BUILD_ROOT")
-       sub("%{\?buildroot}", "$RPM_BUILD_ROOT")
+       sub("%{\\?buildroot}", "$RPM_BUILD_ROOT")
 
        if (/^[ \t]*rm([ \t]+-[rf]+)*[ \t]+(\${?RPM_BUILD_ROOT}?|%{?buildroot}?)/ && did_rmroot==0) {
                did_rmroot=1
@@ -493,7 +507,7 @@ function b_makekey(a, b,    s) {
        }
 
        if (!/%{_lib}/) {
-               sub("\$RPM_BUILD_ROOT/%", "$RPM_BUILD_ROOT%")
+               sub("\\$RPM_BUILD_ROOT/%", "$RPM_BUILD_ROOT%")
        }
 
        use_macros()
@@ -551,15 +565,15 @@ function b_makekey(a, b,  s) {
        preamble = 0
 
        if (gsub("/usr/sbin/useradd", "%useradd")) {
-               sub(" 2> /dev/null \|\| :", "")
-               sub(" >/dev/null 2>&1 \|\|:", "")
+               sub(" 2> /dev/null \\|\\| :", "")
+               sub(" >/dev/null 2>&1 \\|\\|:", "")
        }
 
        # fedora extras macros
        if (/%__fe_useradd/) {
                sub("%__fe_useradd", "%useradd -u ")
-               sub(" 2> /dev/null \|\| :", "")
-               sub(" >/dev/null 2>&1 \|\|:", "")
+               sub(" 2> /dev/null \\|\\| :", "")
+               sub(" >/dev/null 2>&1 \\|\\|:", "")
                sub(" &>/dev/null \\|\\| :", "")
        }
 
@@ -585,7 +599,7 @@ function b_makekey(a, b,    s) {
 
        sub("update-desktop-database &> /dev/null \\|\\| :", "%update_desktop_database")
        sub("touch --no-create %{_datadir}/icons/hicolor", "%update_icon_cache_post hicolor")
-       sub("if \\[ -x %{_bindir}/gtk-update-icon-cache \\]; then\n\t%{_bindir}/gtk-update-icon-cache -q %{_datadir}/icons/hicolor \|\| :\nfi", "")
+       sub("if \\[ -x %{_bindir}/gtk-update-icon-cache \\]; then\n\t%{_bindir}/gtk-update-icon-cache -q %{_datadir}/icons/hicolor \\|\\| :\nfi", "")
 
        sub("export GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source`", "")
        if (/gconftool-2 --makefile-install-rule/) {
@@ -736,11 +750,16 @@ preamble == 1 {
                        next
                }
 
-               replace_requires(field)
+               replace_requires()
+       }
+
+       if (field ~ /triggerpostun/) {
+               # rpm 4.16 does not have Requires(triggerpostun):
+               sub(/triggerpostun/, "post", $1)
        }
 
        if (field == "requires:" || field ~ /^requires\(/ || field == "suggests:") {
-               replace_requires(field)
+               replace_requires()
        }
 
 
@@ -1167,6 +1186,8 @@ function use_macros()
 
        sub("%py2_build", "%py_build")
        sub("%py2_install", "%py_install")
+       sub("%{py2_build}", "%py_build")
+       sub("%{py2_install}", "%py_install")
 
        gsub(infodir, "%{_infodir}")
 
@@ -1323,7 +1344,7 @@ function use_macros()
                        continue
                if ($c ~ sysconfdir "/apm")
                        continue
-               if ($c ~ sysconfdir "/modules-load\.d")
+               if ($c ~ sysconfdir "/modules-load\\.d")
                        continue
                gsub(sysconfdir, "%{_sysconfdir}", $c)
        }
@@ -1339,6 +1360,7 @@ function use_macros()
        gsub(php_data_dir, "%{php_data_dir}")
        gsub("%{_datadir}/php", "%{php_data_dir}")
        gsub("%{php_home}", "%{php_data_dir}")
+       gsub("%{phpdir}", "%{php_data_dir}")
        gsub("%{php_extdir}", "%{php_extensiondir}")
 
        # change to %{_datadir}, with some exceptions
@@ -1458,7 +1480,7 @@ function use_macros()
        gsub("%optflags", "%{rpmcflags}")
        gsub("%{compat_perl_vendorarch}", "%{perl_vendorarch}")
 
-       gsub("^%{__make} install DESTDIR=\$RPM_BUILD_ROOT", "%{__make} install \\\n\tDESTDIR=$RPM_BUILD_ROOT")
+       gsub("^%{__make} install DESTDIR=\\$RPM_BUILD_ROOT", "%{__make} install \\\n\tDESTDIR=$RPM_BUILD_ROOT")
        gsub("^fix-info-dir$", "[ ! -x /usr/sbin/fix-info-dir ] || /usr/sbin/fix-info-dir -c %{_infodir} >/dev/null 2>\\&1")
        $0 = fixedsub("%buildroot", "$RPM_BUILD_ROOT", $0)
        $0 = fixedsub("%{buildroot}", "$RPM_BUILD_ROOT", $0)
@@ -1500,6 +1522,12 @@ function use_macros()
                add_br("BuildRequires:  rpmbuild(macros) >= 1.300")
        }
 
+       if (/^%meson / || /^%{meson}/) {
+               sub(/^meson/, "%meson")
+               sub(/^%{meson}/, "%meson")
+               add_br("BuildRequires:  rpmbuild(macros) >= 1.726")
+       }
+
        $0 = fixedsub("%(%{__cc} -dumpversion)", "%{cc_version}", $0)
        $0 = fixedsub("%(%{__cxx} -dumpversion)", "%{cxx_version}", $0)
 
@@ -1562,12 +1590,12 @@ function use_files_macros(      i, n, t, a, l)
        }
 
        # replace back
-       gsub("%{_sysconfdir}/cron\.d", "/etc/cron.d")
-       gsub("%{_sysconfdir}/crontab\.d", "/etc/crontab.d")
-       gsub("%{_sysconfdir}/logrotate\.d", "/etc/logrotate.d")
-       gsub("%{_sysconfdir}/pam\.d", "/etc/pam.d")
-       gsub("%{_sysconfdir}/profile\.d", "/etc/profile.d")
-       gsub("%{_sysconfdir}/rc\.d", "/etc/rc.d")
+       gsub("%{_sysconfdir}/cron\\.d", "/etc/cron.d")
+       gsub("%{_sysconfdir}/crontab\\.d", "/etc/crontab.d")
+       gsub("%{_sysconfdir}/logrotate\\.d", "/etc/logrotate.d")
+       gsub("%{_sysconfdir}/pam\\.d", "/etc/pam.d")
+       gsub("%{_sysconfdir}/profile\\.d", "/etc/profile.d")
+       gsub("%{_sysconfdir}/rc\\.d", "/etc/rc.d")
        gsub("%{_sysconfdir}/security", "/etc/security")
        gsub("%{_sysconfdir}/skel", "/etc/skel")
        gsub("%{_sysconfdir}/sysconfig", "/etc/sysconfig")
@@ -1660,7 +1688,7 @@ function use_files_macros(        i, n, t, a, l)
        }
 
        if (/%{_mandir}/) {
-               gsub("\.gz$", "*")
+               gsub("\\.gz$", "*")
                gsub("%ext_man$", "*")
        }
 
@@ -1713,8 +1741,8 @@ function use_files_macros(        i, n, t, a, l)
 function use_script_macros()
 {
        if (gsub("/sbin/service", "%service")) {
-               sub(" >/dev/null 2>&1 \|\|:", "")
-               sub(" 2> /dev/null \|\| :", "")
+               sub(" >/dev/null 2>&1 \\|\\|:", "")
+               sub(" 2> /dev/null \\|\\| :", "")
        }
 }
 
@@ -1763,7 +1791,7 @@ function cflags(var)
        }
 
        if (!/!\?debug/)
-               sub("\$RPM_OPT_FLAGS", "%{rpmcflags}")
+               sub("\\$RPM_OPT_FLAGS", "%{rpmcflags}")
        return 1
 }
 
@@ -1784,13 +1812,13 @@ function unify_url(url)
        sub("#.*", "", url)
 
        # 1. unify domains
-       sub("^http://prdownloads\.sourceforge\.net/", "http://downloads.sourceforge.net/", url)
-       sub("^http://download\.sf\.net/", "http://downloads.sourceforge.net/", url)
-       sub("^http://download\.sourceforge\.net/", "http://downloads.sourceforge.net/", url)
-       sub("^http://dl\.sourceforge\.net/", "http://downloads.sourceforge.net/", url)
-       sub("^http://.*\.dl\.sourceforge\.net/", "http://downloads.sourceforge.net/", url)
-       sub("^http://dl\.sf\.net/", "http://downloads.sourceforge.net/", url)
-       sub("^http://downloads\.sourceforge\.net/sourceforge/", "http://downloads.sourceforge.net/", url)
+       sub("^http://prdownloads\\.sourceforge\\.net/", "http://downloads.sourceforge.net/", url)
+       sub("^http://download\\.sf\\.net/", "http://downloads.sourceforge.net/", url)
+       sub("^http://download\\.sourceforge\\.net/", "http://downloads.sourceforge.net/", url)
+       sub("^http://dl\\.sourceforge\\.net/", "http://downloads.sourceforge.net/", url)
+       sub("^http://.*\\.dl\\.sourceforge\\.net/", "http://downloads.sourceforge.net/", url)
+       sub("^http://dl\\.sf\\.net/", "http://downloads.sourceforge.net/", url)
+       sub("^http://downloads\\.sourceforge\\.net/sourceforge/", "http://downloads.sourceforge.net/", url)
 
        # 3. unify urls
        if (url ~ /sourceforge.net/) {
@@ -1814,20 +1842,20 @@ function unify_url(url)
                url = sprintf("http://downloads.sourceforge.net/%s/%s", substr(url, 42, RLENGTH - 41), matchstr(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)
+       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)
+       sub("^ftp://ftp\\.gnu\\.org/", "http://ftp.gnu.org/", url)
+       sub("^http://ftp\\.gnu\\.org/pub/gnu/", "http://ftp.gnu.org/gnu/", url)
 
        # debian.org
-       sub("^ftp://ftp\.[^.]+\.debian\.org/", "ftp://ftp.debian.org/", url)
-       sub("^http://ftp\.[^.]+\.debian\.org/", "ftp://ftp.debian.org/", url)
-       sub("^ftp://ftp\.debian\.org/pub/debian/", "ftp://ftp.debian.org/debian/", url)
+       sub("^ftp://ftp\\.[^.]+\\.debian\\.org/", "ftp://ftp.debian.org/", url)
+       sub("^http://ftp\\.[^.]+\\.debian\\.org/", "ftp://ftp.debian.org/", url)
+       sub("^ftp://ftp\\.debian\\.org/pub/debian/", "ftp://ftp.debian.org/debian/", url)
 
        return url
 }
@@ -1864,6 +1892,13 @@ function demacroize(str)
        if (subver) {
                sub("%{subver}", subver, str)
        }
+
+       if (globals["gh_owner"]) {
+               sub("%{gh_owner}", globals["gh_owner"], str)
+       }
+       if (globals["gh_project"]) {
+               sub("%{gh_project}", globals["gh_project"], str)
+       }
        return str
 }
 
@@ -1897,7 +1932,7 @@ function get_epoch(pkg, ver,      epoch)
 #      freetype = 2.0.0 -> correct
 #      freetype = 2.1.9 -> with epoch 1, as epoch 1 was added in 2.1.7
 
-       shell = "grep -o '^" pkg ":[^:]\+' ../PLD-doc/BuildRequires.txt | awk '{print $NF}'"
+       shell = "grep -o '^" pkg ":[^:]\\+' ../PLD-doc/BuildRequires.txt | awk '{print $NF}'"
        shell | getline epoch
        return epoch
 }
@@ -2212,7 +2247,7 @@ function replace_pythonegg(pkg,    cmd, line) {
 # }}}
 
 # {{{ replace_requires
-function replace_requires(field,   pkg) {
+function replace_requires(pkg) { # "pkg' is local variable, not an argument
        # strip %{?_isa}
        if ($2 ~ /_isa/) {
                $2 = fixedsub("%{?_isa}", "", $2);
@@ -2355,6 +2390,7 @@ function replace_requires(field,   pkg) {
        sub(/^gnome-python2-gconf$/, "python-gnome-gconf", $2)
        sub(/^gnome-python2-gnomekeyring$/, "python-gnome-desktop-keyring", $2)
        sub(/^gnome-python2-gtkspell$/, "python-gnome-extras-gtkspell", $2)
+       sub(/^gstreamer-python$/, "python-gstreamer", $2)
        sub(/^gtk-sharp2-devel$/, "dotnet-gtk-sharp2-devel", $2)
        sub(/^gtk2$/, "gtk+2", $2)
        sub(/^gtk2-devel$/, "gtk+2-devel", $2)
@@ -2409,12 +2445,16 @@ function replace_requires(field,   pkg) {
        sub(/^mod_wsgi$/, "apache-mod_wsgi", $2)
        sub(/^newt-python$/, "python-snack", $2)
        sub(/^notify-python$/, "python-pynotify", $2)
+       sub(/^numpy$/, "python-numpy", $2)
+       sub(/^opencv-python$/, "python-opencv", $2)
        sub(/^oxygen-icon-theme$/, "kde4-icons-oxygen", $2)
        sub(/^pcsc-lite-ccid$/, "pcsc-driver-ccid", $2)
+       sub(/^protobuf-python$/, "python-protobuf", $2)
        sub(/^pulseaudio-libs-devel$/, "pulseaudio-devel", $2)
        sub(/^pyOpenSSL$/, "python-pyOpenSSL", $2)
        sub(/^pycairo$/, "python-pycairo", $2)
        sub(/^pyflakes$/, "python-pyflakes", $2)
+       sub(/^pygame$/, "python-pygame", $2)
        sub(/^pygobject2$/, "python-pygobject", $2)
        sub(/^pygobject3$/, "python-pygobject3", $2)
        sub(/^pygobject3-devel$/, "python-pygobject3-common-devel", $2)
@@ -2454,6 +2494,7 @@ function replace_requires(field,   pkg) {
        sub(/^python-zope-interface$/, "Zope-Interface", $2)
        sub(/^python-zope.component$/, "Zope-Component", $2)
        sub(/^python-zope.interface$/, "Zope-Interface", $2)
+       sub(/^python2-certifi$/, "python-certifi", $2)
        sub(/^python2-devel$/, "python-devel", $2)
        sub(/^python3-docker-py$/, "python3-docker", $2)
        sub(/^pytz$/, "python-pytz", $2)
@@ -2467,14 +2508,17 @@ function replace_requires(field,   pkg) {
        sub(/^qtlockedfile-devel$/, "QtLockedFile-devel", $2)
        sub(/^qtsingleapplication-devel$/, "QtSingleApplication-devel", $2)
        sub(/^rpm-python$/, "python-rpm", $2)
+       sub(/^scipy$/, "python-scipy", $2)
        sub(/^sip-devel$/, "python-sip-devel", $2)
        sub(/^tftp-server$/, "tftpdaemon", $2)
        sub(/^tkinter$/, "python-tkinter", $2)
        sub(/^urw-fonts$/, "fonts-Type1-urw", $2)
        sub(/^webkitgtk3-devel$/, "gtk-webkit3-devel", $2)
+       sub(/^webkitgtk4$/, "gtk-webkit4", $2)
        sub(/^xapian-bindings-python$/, "python-xapian", $2)
        sub(/^xorg-x11-proto-devel$/, "xorg-proto-xproto-devel", $2)
        sub(/^xorg-x11-server-sdk$/, "xorg-xserver-server-devel", $2)
+       sub(/^xorg-x11-server-utils$/, "xorg-app-iceauth xorg-app-rgb xorg-app-sessreg xorg-app-xgamma xorg-app-xhost xorg-app-xinput xorg-app-xkill xorg-app-xmodmap xorg-app-xrandr xorg-app-xrandr xorg-app-xrefresh xorg-app-xset xorg-app-xsetpointer xorg-app-xsetroot xorg-app-xstdcmap", $2)
        # }}}
 
        # {{{ mandriva
@@ -2491,10 +2535,12 @@ function replace_requires(field,   pkg) {
        sub(/^blkid-dev$/, "libblkid-devel", $2)
        sub(/^ext2fs-dev$/, "e2fsprogs-devel", $2)
        sub(/^libao-dev$/, "libao-devel", $2)
+       sub(/^libavahi-client-dev$/, "avahi-devel", $2)
        sub(/^libboost-filesystem[0-9.]+-dev$/, "boost-devel", $2)
        sub(/^libboost-program-options[0-9.]+-dev$/, "boost-devel", $2)
        sub(/^libboost-regex[0-9.]+-dev$/, "boost-devel", $2)
        sub(/^libboost-thread[0-9.]+-dev$/, "boost-devel", $2)
+       sub(/^libcups2-dev$/, "cups-devel", $2)
        sub(/^libcurl4-openssl-dev$/, "curl-devel", $2)
        sub(/^libdnet-dev$/, "libdnet-devel", $2)
        sub(/^libesd0-dev$/, "esound-devel", $2)
@@ -2540,9 +2586,10 @@ function replace_requires(field,   pkg) {
 
        # {{{ suse/opensuse
        sub(/^alsa-devel$/, "alsa-lib-devel", $2)
-       sub(/^python-djangorestframework$/, "python-django-rest-framework", $2)
-       sub(/^python-django_compressor$/, "python-django-compressor", $2)
+       sub(/^binutils-gold$/, "binutils", $2)
        sub(/^bitstream-vera$/, "fonts-TTF-bitstream-vera", $2)
+       sub(/^dbus-1-devel$/, "dbus-devel", $2)
+       sub(/^gconf2-devel$/, "GConf2-devel", $2)
        sub(/^gtk-sharp2$/, "dotnet-gtk-sharp2", $2)
        sub(/^gtkmm2-devel$/, "gtkmm-devel", $2)
        sub(/^libexpat-devel$/, "expat-devel", $2)
@@ -2551,11 +2598,15 @@ function replace_requires(field,   pkg) {
        sub(/^libopenssl-devel$/, "openssl-devel", $2)
        sub(/^libpulse-devel$/, "pulseaudio-devel", $2)
        sub(/^libqt4-devel$/, "qt4-build, qt4-qmake, QtCore-devel", $2)
+       sub(/^llvm-clang$/, "clang", $2)
        sub(/^monodoc-core$/, "mono-monodoc", $2)
+       sub(/^mozilla-nss-devel$/, "nss-devel", $2)
        sub(/^python-Babel$/, "python-babel", $2)
        sub(/^python-Django$/, "python-django", $2)
        sub(/^python-Pillow$/, "python-pillow", $2)
        sub(/^python-cairo$/, "python-pycairo", $2)
+       sub(/^python-django_compressor$/, "python-django-compressor", $2)
+       sub(/^python-djangorestframework$/, "python-django-rest-framework", $2)
        sub(/^python-gobject$/, "python-pygobject", $2)
        sub(/^python-gstreamer-0_10$/, "python-gstreamer", $2)
        sub(/^python-gtk$/, "python-pygtk-gtk", $2)
This page took 0.090732 seconds and 4 git commands to generate.