From 0abf39a42a409e21ba9c6a47c53d126a4b5137c7 Mon Sep 17 00:00:00 2001 From: Andrey Bondrov Date: Wed, 12 Oct 2016 19:40:22 +1000 Subject: [PATCH] Add QML dependency generator --- rpm-5.4.10-qml-dependency-generator.patch | 243 ++++++++++++++++++++++ rpm.spec | 6 +- 2 files changed, 248 insertions(+), 1 deletion(-) create mode 100644 rpm-5.4.10-qml-dependency-generator.patch diff --git a/rpm-5.4.10-qml-dependency-generator.patch b/rpm-5.4.10-qml-dependency-generator.patch new file mode 100644 index 0000000..b7c7bed --- /dev/null +++ b/rpm-5.4.10-qml-dependency-generator.patch @@ -0,0 +1,243 @@ +diff -urN rpm-5.4.10/configure.ac rpm-5.4.10-patched/configure.ac +--- rpm-5.4.10/configure.ac 2016-10-12 19:02:21.996240456 +1000 ++++ rpm-5.4.10-patched/configure.ac 2016-10-12 19:24:51.993205021 +1000 +@@ -2572,7 +2572,7 @@ + macros/macros macros/macros.rpmbuild + macros/cmake macros/gstreamer macros/java macros/kernel macros/libtool + macros/mandriva macros/suse macros/fedora macros/mono macros/perl macros/pkgconfig macros/php +- macros/python macros/ruby macros/selinux macros/tcl ++ macros/python macros/ruby macros/selinux macros/tcl macros/qml + doc/Makefile + doc/manual/Makefile doc/fr/Makefile doc/ja/Makefile doc/ko/Makefile + doc/pl/Makefile doc/ru/Makefile doc/sk/Makefile +diff -urN rpm-5.4.10/lib/rpmfc.c rpm-5.4.10-patched/lib/rpmfc.c +--- rpm-5.4.10/lib/rpmfc.c 2016-10-12 19:02:22.178240451 +1000 ++++ rpm-5.4.10-patched/lib/rpmfc.c 2016-10-12 19:30:22.128196356 +1000 +@@ -647,6 +647,7 @@ + + { "libtool library ", RPMFC_LIBTOOL|RPMFC_INCLUDE }, + { "pkgconfig ", RPMFC_PKGCONFIG|RPMFC_INCLUDE }, ++ { "qml ", RPMFC_QML|RPMFC_INCLUDE }, + + { "Bourne ", RPMFC_BOURNE|RPMFC_INCLUDE }, + { "Bourne-Again ", RPMFC_BOURNE|RPMFC_INCLUDE }, +@@ -953,6 +954,10 @@ + #endif + xx = rpmfcHelper(fc, 'R', "pkgconfig"); + } else ++ if (fc->fcolor->vals[fc->ix] & RPMFC_QML) { ++ xx = rpmfcHelper(fc, 'P', "qml"); ++ xx = rpmfcHelper(fc, 'R', "qml"); ++ } else + if (fc->fcolor->vals[fc->ix] & RPMFC_BOURNE) { + #ifdef NOTYET + xx = rpmfcHelper(fc, 'P', "executable"); +@@ -1147,7 +1152,7 @@ + /*@unchecked@*/ + static struct rpmfcApplyTbl_s rpmfcApplyTable[] = { + { rpmfcELF, RPMFC_ELF }, +- { rpmfcSCRIPT, (RPMFC_SCRIPT|RPMFC_FONT|RPMFC_HASKELL|RPMFC_RUBY|RPMFC_PERL|RPMFC_PYTHON|RPMFC_LIBTOOL|RPMFC_PKGCONFIG|RPMFC_BOURNE|RPMFC_JAVA|RPMFC_PHP|RPMFC_MONO|RPMFC_TYPELIB|RPMFC_NODEJS) }, ++ { rpmfcSCRIPT, (RPMFC_SCRIPT|RPMFC_FONT|RPMFC_HASKELL|RPMFC_RUBY|RPMFC_PERL|RPMFC_PYTHON|RPMFC_LIBTOOL|RPMFC_PKGCONFIG|RPMFC_QML|RPMFC_BOURNE|RPMFC_JAVA|RPMFC_PHP|RPMFC_MONO|RPMFC_TYPELIB|RPMFC_NODEJS) }, + #if defined(RPM_VENDOR_MANDRIVA) + { rpmfcSYMLINK, RPMFC_SYMLINK }, + #endif +@@ -1455,6 +1460,10 @@ + else if (_suffix(s, ".pc")) + ftype = "pkgconfig file"; + ++ /* XXX all files with extension ".qml" are qml for now. */ ++ else if (_suffix(s, ".qml")) ++ ftype = "qml file"; ++ + /* XXX all files with extension ".php" are PHP for now. */ + else if (_suffix(s, ".php")) + ftype = "PHP script text"; +diff -urN rpm-5.4.10/lib/rpmfc.h rpm-5.4.10-patched/lib/rpmfc.h +--- rpm-5.4.10/lib/rpmfc.h 2016-10-12 19:02:22.177240451 +1000 ++++ rpm-5.4.10-patched/lib/rpmfc.h 2016-10-12 19:23:54.535206529 +1000 +@@ -24,7 +24,7 @@ + #define RPMFC_ELF (RPMFC_ELF32|RPMFC_ELF64|RPMFC_ELFMIPSN32) + /* (1 << 3) leaks into package headers, reserved */ + +- /* bit 4 unused */ ++ RPMFC_QML = (1 << 4), + RPMFC_TYPELIB = (1 << 5), + RPMFC_HASKELL = (1 << 6), + RPMFC_RUBY = (1 << 7), +diff -urN rpm-5.4.10/macros/macros rpm-5.4.10-patched/macros/macros +--- rpm-5.4.10/macros/macros 2016-10-12 19:02:22.164240451 +1000 ++++ rpm-5.4.10-patched/macros/macros 2016-10-12 19:31:19.166194859 +1000 +@@ -1061,6 +1061,10 @@ + #%%{load:%{_usrlibrpm}/macros.d/pkgconfig} + + #------------------------------------------------------------------------ ++# qml(...) configuration. ++#%%{load:%{_usrlibrpm}/macros.d/qml} ++ ++#------------------------------------------------------------------------ + # mono(...) configuration. + #%%{load:%{_usrlibrpm}/macros.d/mono} + +diff -urN rpm-5.4.10/macros/macros.in rpm-5.4.10-patched/macros/macros.in +--- rpm-5.4.10/macros/macros.in 2016-10-12 19:02:22.012240455 +1000 ++++ rpm-5.4.10-patched/macros/macros.in 2016-10-12 19:31:02.004195309 +1000 +@@ -1065,6 +1065,10 @@ + %{load:%{_usrlibrpm}/macros.d/pkgconfig} + + #------------------------------------------------------------------------ ++# qml(...) configuration. ++%{load:%{_usrlibrpm}/macros.d/qml} ++ ++#------------------------------------------------------------------------ + # mono(...) configuration. + %{load:%{_usrlibrpm}/macros.d/mono} + +diff -urN rpm-5.4.10/macros/qml rpm-5.4.10-patched/macros/qml +--- rpm-5.4.10/macros/qml 1970-01-01 10:00:00.000000000 +1000 ++++ rpm-5.4.10-patched/macros/qml 2016-10-12 19:22:37.988208539 +1000 +@@ -0,0 +1,11 @@ ++# QML specific macro definitions. ++# To make use of these macros insert the following line into your spec file: ++# %{load:%{_usrlibrpm}/macros.d/qml} ++# ++ ++# Path to scripts to autogenerate pkgconfig package dependencies, ++# ++# Note: Used iff _use_internal_dependency_generator is non-zero. The ++# helpers are also used by %{_rpmhome}/rpmdeps {--provides|--requires}. ++%__qml_provides %{_rpmhome}/qmldeps.sh --provides ++%__qml_requires %{_rpmhome}/qmldeps.sh --requires +diff -urN rpm-5.4.10/macros/qml.in rpm-5.4.10-patched/macros/qml.in +--- rpm-5.4.10/macros/qml.in 1970-01-01 10:00:00.000000000 +1000 ++++ rpm-5.4.10-patched/macros/qml.in 2016-10-12 19:22:19.668209019 +1000 +@@ -0,0 +1,11 @@ ++# QML specific macro definitions. ++# To make use of these macros insert the following line into your spec file: ++# %{load:%{_usrlibrpm}/macros.d/qml} ++# ++ ++# Path to scripts to autogenerate pkgconfig package dependencies, ++# ++# Note: Used iff _use_internal_dependency_generator is non-zero. The ++# helpers are also used by %{_rpmhome}/rpmdeps {--provides|--requires}. ++%__qml_provides %{_rpmhome}/qmldeps.sh --provides ++%__qml_requires %{_rpmhome}/qmldeps.sh --requires +diff -urN rpm-5.4.10/Makefile.am rpm-5.4.10-patched/Makefile.am +--- rpm-5.4.10/Makefile.am 2012-03-17 11:24:19.000000000 +1100 ++++ rpm-5.4.10-patched/Makefile.am 2016-10-12 19:32:29.862193003 +1000 +@@ -118,7 +118,7 @@ + pkgcfg_DATA = \ + macros/cmake macros/gstreamer macros/java macros/kernel macros/libtool \ + macros/mandriva macros/mono macros/perl macros/pkgconfig macros/php \ +- macros/python macros/ruby macros/selinux macros/tcl ++ macros/python macros/ruby macros/selinux macros/tcl macros/qml + + noinst_HEADERS = build.h debug.h system.h + +diff -urN rpm-5.4.10/scripts/Makefile.am rpm-5.4.10-patched/scripts/Makefile.am +--- rpm-5.4.10/scripts/Makefile.am 2016-10-12 19:02:20.941240483 +1000 ++++ rpm-5.4.10-patched/scripts/Makefile.am 2016-10-12 19:35:18.934188565 +1000 +@@ -67,7 +67,8 @@ + rpm.daily rpm.log rpm.xinetd \ + rubygems.rb \ + tgpg u_pkg.sh \ +- vcheck vpkg-provides.sh vpkg-provides2.sh ++ vcheck vpkg-provides.sh vpkg-provides2.sh \ ++ qmldeps.sh + + + pkglibbindir = @USRLIBRPM@/bin +diff -urN rpm-5.4.10/scripts/qmldeps.sh rpm-5.4.10-patched/scripts/qmldeps.sh +--- rpm-5.4.10/scripts/qmldeps.sh 1970-01-01 10:00:00.000000000 +1000 ++++ rpm-5.4.10-patched/scripts/qmldeps.sh 2016-10-12 19:33:57.000000000 +1000 +@@ -0,0 +1,90 @@ ++#!/bin/bash ++# Copyright (C) 2012 Jolla Oy ++# Contact: Bernd Wachter ++# Modified by Andrey Bondrov ++# ++# Try to locate module information for automatic provide generation from ++# qmldir files as well as information about imported modules for automatic ++# require generation from qml files. ++# ++# TODO: ++# - figure out if type handling needs special attention in regard to versioning ++# - stuff like Sailfish.Silica.theme currently can't get autodetected ++# - implement requires generation ++# - check if the regex include all valid characters allowed in module definitions ++# - fine tune the regex -- they're currently not perfect, just "good enough" ++# ++# A note about versioning: ++# A module package should provide the module in the version of the highest file ++# included in the package. A package using a module should require the module ++# in a version >= the one used for the import. ++ ++[ $# -ge 2 ] || { ++ cat > /dev/null ++ exit 0 ++} ++ ++# grep blows up with C/POSIX locale, so make sure we're using a working locale ++if [ -z "$LANG" ] || [ "$LANG" = "C" ] || [ "$LANG" = "POSIX" ] ; then ++ export LANG=en_US.UTF-8 ++fi ++ ++case $1 in ++-P|--provides) ++ shift ++ RPM_BUILD_ROOT="$1" ++ while read file; do ++ case "$file" in ++ */qmldir) ++ if head -1 "$file" | grep -iq '^module\s*' 2>/dev/null; then ++ provides="`head -1 ${file} | sed -r 's/^module\s+//'`" ++ version="`grep -i -E -o '^[a-z]*\s+[0-9.]*\s+[a-z0-9]*.qml' ${file} | awk '{print $2}' | sort -r | uniq | head -1`" ++ if [ -z "$version" ]; then ++ echo "qmldeps: WARNING: no version number found, package version will be used." >&2 ++ echo "qml($provides)" ++ else ++ echo "qml($provides) = $version" ++ fi ++ else ++ echo "qmldeps: no valid module definition found in $file" >&2 ++ fi ++ ;; ++ esac ++ done ++ ;; ++-R|--requires) ++ while read file; do ++ case "$file" in ++ *.qml) ++ # this first part is some hack to avoid depending on own provides ++ # for modules ++ qmldir=`echo ${file}|sed 's,/[^/]*$,,'` ++ qmldir_noprivate=`echo ${file}|sed 's,private/[^/]*$,,'` ++ if [ -f $qmldir/qmldir ]; then ++ module=`head -1 $qmldir/qmldir | sed -r 's/^.*\s+//'` ++ elif [ -f $qmldir_noprivate/qmldir ]; then ++ module=`head -1 $qmldir_noprivate/qmldir | sed -r 's/^.*\s+//'` ++ fi ++ IFS=$'\n' ++ imports=`grep -i -E -o '^\s*import\s+[a-z0-9.]*\s+[0-9.]*' ${file} | sed -r -e 's/^\s*import\s*//' | sort | uniq` ++ if [ -z "$imports" ]; then ++ echo "qmldeps: no imports found in $file. Probably should not happen." >&2 ++ fi ++ for i in $imports; do ++ import=`echo $i | awk '{ print $1 }'` ++ import_version=`echo $i | awk '{ print $2 }'` ++ if [ $import = "$module" ]; then ++ echo "qmldeps: skipping provide for own module '$module' in $file" >&2 ++ elif echo $import | grep -q '\.private$'; then ++ echo "qmldeps: skipping private import '$import' in $file" >&2 ++ else ++ # remove the >&2 to enable provides generation as well ++ echo "qml($import) >= $import_version" >&2 ++ fi ++ done ++ ;; ++ esac ++ done ++ ;; ++esac ++exit 0 diff --git a/rpm.spec b/rpm.spec index 63dc0cf..6c1f022 100644 --- a/rpm.spec +++ b/rpm.spec @@ -61,7 +61,7 @@ Summary: The RPM package management system Name: rpm Epoch: 1 Version: %{libver}.%{minorver} -Release: %{?prereldate:0.%{prereldate}.}68 +Release: %{?prereldate:0.%{prereldate}.}69 License: LGPLv2.1+ Group: System/Configuration/Packaging Url: http://rpm5.org/ @@ -515,6 +515,9 @@ Patch515: rpm-5.4.10-fix-addsign-check.patch # Add _appdatadir macro definition Patch516: rpm-5.4.10-appdatadir.patch +# Add QML dependency generator +Patch517: rpm-5.4.10-qml-dependency-generator.patch + BuildRequires: autoconf >= 2.57 BuildRequires: bzip2-devel BuildRequires: automake >= 1.8 @@ -1174,6 +1177,7 @@ This package contains the RPM API documentation generated in HTML format. %patch514 -p1 -b .kde5-find-lang %patch515 -p1 -b .fix-addsign-check %patch516 -p1 -b .appdatadir~ +%patch517 -p1 -b .qmldeps~ #required by P55, P80, P81, P94.. ./autogen.sh