avatar
mikhailnov has added 3e3987c7ba
rpm-5.4.10-qml-dependency-generator (Patch517)

Add QML dependency generator

... ... --- a/Makefile.am
... ... +++ b/Makefile.am
... ... @@ -118,7 +118,7 @@ pkgcfgdir = $(pkgdatadir)/macros.d
118 118
pkgcfg_DATA = \
119 119
	macros/cmake macros/gstreamer macros/java macros/kernel macros/libtool \
120 120
	macros/mandriva macros/mono macros/perl macros/pkgconfig macros/php \
121
	macros/python macros/ruby macros/selinux macros/tcl
121
	macros/python macros/ruby macros/selinux macros/tcl macros/qml
122 122
123 123
noinst_HEADERS = build.h debug.h system.h
124 124
... ... --- a/configure.ac
... ... +++ b/configure.ac
... ... @@ -2572,7 +2572,7 @@ AC_CONFIG_FILES([ po/Makefile.in
2572 2572
    macros/macros macros/macros.rpmbuild
2573 2573
    macros/cmake macros/gstreamer macros/java macros/kernel macros/libtool
2574 2574
    macros/mandriva macros/suse macros/fedora macros/mono macros/perl macros/pkgconfig macros/php
2575
    macros/python macros/ruby macros/selinux macros/tcl
2575
    macros/python macros/ruby macros/selinux macros/tcl macros/qml
2576 2576
    doc/Makefile
2577 2577
    doc/manual/Makefile doc/fr/Makefile doc/ja/Makefile doc/ko/Makefile
2578 2578
    doc/pl/Makefile doc/ru/Makefile doc/sk/Makefile
... ... --- a/lib/rpmfc.c
... ... +++ b/lib/rpmfc.c
... ... @@ -647,6 +647,7 @@ static struct rpmfcTokens_s rpmfcTokens[] = {
647 647
648 648
  { "libtool library ",		RPMFC_LIBTOOL|RPMFC_INCLUDE },
649 649
  { "pkgconfig ",		RPMFC_PKGCONFIG|RPMFC_INCLUDE },
650
  { "qml ",			RPMFC_QML|RPMFC_INCLUDE },
650 651
651 652
  { "Bourne ",			RPMFC_BOURNE|RPMFC_INCLUDE },
652 653
  { "Bourne-Again ",		RPMFC_BOURNE|RPMFC_INCLUDE },
... ... @@ -952,6 +953,10 @@ static int rpmfcSCRIPT(rpmfc fc)
953 953
	if (is_executable)
954 954
#endif
955 955
	    xx = rpmfcHelper(fc, 'R', "pkgconfig");
956
    } else
957
        if (fc->fcolor->vals[fc->ix] & RPMFC_QML) {
958
            xx = rpmfcHelper(fc, 'P', "qml");
959
//            xx = rpmfcHelper(fc, 'R', "qml");
956 960
    } else
957 961
    if (fc->fcolor->vals[fc->ix] & RPMFC_BOURNE) {
958 962
#ifdef	NOTYET
... ... @@ -1147,7 +1152,7 @@ typedef struct rpmfcApplyTbl_s {
1152 1152
/*@unchecked@*/
1153 1153
static struct rpmfcApplyTbl_s rpmfcApplyTable[] = {
1154 1154
    { rpmfcELF,		RPMFC_ELF },
1155
    { 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) },
1155
    { 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) },
1156 1156
#if defined(RPM_VENDOR_MANDRIVA)
1157 1157
    { rpmfcSYMLINK,	RPMFC_SYMLINK },
1158 1158
#endif
... ... @@ -1455,6 +1460,14 @@ assert(s != NULL && *s == '/');
1460 1460
	    else if (_suffix(s, ".pc"))
1461 1461
		ftype = "pkgconfig file";
1462 1462
1463
	    /* XXX all files with extension ".qml" are qml for now. */
1464
	    else if (_suffix(s, ".qml"))
1465
		ftype = "qml file";
1466
1467
	    /* XXX all files named "qmldir" are qml for now. */
1468
	    else if (_suffix(s, "qmldir"))
1469
		ftype = "qml file";
1470
1463 1471
	    /* XXX all files with extension ".php" are PHP for now. */
1464 1472
	    else if (_suffix(s, ".php"))
1465 1473
		ftype = "PHP script text";
... ... --- a/lib/rpmfc.h
... ... +++ b/lib/rpmfc.h
... ... @@ -24,7 +24,7 @@ typedef enum FCOLOR_e {
24 24
#define	RPMFC_ELF	(RPMFC_ELF32|RPMFC_ELF64|RPMFC_ELFMIPSN32)
25 25
	/* (1 << 3) leaks into package headers, reserved */
26 26
27
	/* bit 4 unused */
27
    RPMFC_QML			= (1 <<  4),
28 28
    RPMFC_TYPELIB		= (1 <<  5),
29 29
    RPMFC_HASKELL		= (1 <<  6),
30 30
    RPMFC_RUBY			= (1 <<  7),
... ... --- a/macros/macros
... ... +++ b/macros/macros
... ... @@ -1060,6 +1060,10 @@ $_arbitrary_tags_tests Foo:Bar
1060 1060
# pkgconfig(...) configuration.
1061 1061
#%%{load:%{_usrlibrpm}/macros.d/pkgconfig}
1062 1062
1063
#------------------------------------------------------------------------
1064
# qml(...) configuration.
1065
#%%{load:%{_usrlibrpm}/macros.d/qml}
1066
1063 1067
#------------------------------------------------------------------------
1064 1068
# mono(...) configuration.
1065 1069
#%%{load:%{_usrlibrpm}/macros.d/mono}
view file @ 3e3987c7ba
... ... --- a/macros/macros.in
... ... +++ b/macros/macros.in
... ... @@ -1064,6 +1064,10 @@ $_arbitrary_tags_tests Foo:Bar
1064 1064
# pkgconfig(...) configuration.
1065 1065
%{load:%{_usrlibrpm}/macros.d/pkgconfig}
1066 1066
1067
#------------------------------------------------------------------------
1068
# qml(...) configuration.
1069
%{load:%{_usrlibrpm}/macros.d/qml}
1070
1067 1071
#------------------------------------------------------------------------
1068 1072
# mono(...) configuration.
1069 1073
%{load:%{_usrlibrpm}/macros.d/mono}
... ... --- /dev/null
... ... +++ b/macros/qml
... ... @@ -0,0 +1,11 @@
1
# QML specific macro definitions.
2
# To make use of these macros insert the following line into your spec file:
3
# %{load:%{_usrlibrpm}/macros.d/qml}
4
#
5
6
# Path to scripts to autogenerate QML package dependencies,
7
#
8
# Note: Used iff _use_internal_dependency_generator is non-zero. The
9
# helpers are also used by %{_rpmhome}/rpmdeps {--provides|--requires}.
10
%__qml_provides %{_rpmhome}/qmldeps.sh --provides
11
%__qml_requires %{_rpmhome}/qmldeps.sh --requires
... ... --- /dev/null
... ... +++ b/macros/qml.in
... ... @@ -0,0 +1,11 @@
1
# QML specific macro definitions.
2
# To make use of these macros insert the following line into your spec file:
3
# %{load:%{_usrlibrpm}/macros.d/qml}
4
#
5
6
# Path to scripts to autogenerate QML package dependencies,
7
#
8
# Note: Used iff _use_internal_dependency_generator is non-zero. The
9
# helpers are also used by %{_rpmhome}/rpmdeps {--provides|--requires}.
10
%__qml_provides %{_rpmhome}/qmldeps.sh --provides
11
%__qml_requires %{_rpmhome}/qmldeps.sh --requires
view file @ 3e3987c7ba
... ... --- a/scripts/Makefile.am
... ... +++ b/scripts/Makefile.am
... ... @@ -67,7 +67,8 @@ pkgdata_SCRIPTS = \
67 67
	rpm.daily rpm.log rpm.xinetd \
68 68
	rubygems.rb \
69 69
	tgpg u_pkg.sh \
70
	vcheck vpkg-provides.sh vpkg-provides2.sh
70
	vcheck vpkg-provides.sh vpkg-provides2.sh \
71
	qmldeps.sh
71 72
72 73
73 74
pkglibbindir =		@USRLIBRPM@/bin
view file @ 3e3987c7ba
... ... --- /dev/null
... ... +++ b/scripts/qmldeps.sh
... ... @@ -0,0 +1,88 @@
1
#!/bin/bash
2
# Copyright (C) 2012 Jolla Oy
3
# Contact: Bernd Wachter <bernd.wachter@jollamobile.com>
4
# Modified by Andrey Bondrov <andrey.bondrov@rosalab.ru>
5
#
6
# Try to locate module information for automatic provide generation from
7
# qmldir files as well as information about imported modules for automatic
8
# require generation from qml files.
9
#
10
# TODO:
11
# - figure out if type handling needs special attention in regard to versioning
12
# - stuff like Sailfish.Silica.theme currently can't get autodetected
13
# - implement requires generation
14
# - check if the regex include all valid characters allowed in module definitions
15
# - fine tune the regex -- they're currently not perfect, just "good enough"
16
#
17
# A note about versioning:
18
# A module package should provide the module in the version of the highest file
19
# included in the package. A package using a module should require the module
20
# in a version >= the one used for the import.
21
22
[ $# -ge 1 ] || {
23
    cat > /dev/null
24
    exit 0
25
}
26
27
# grep blows up with C/POSIX locale, so make sure we're using a working locale
28
if [ -z "$LANG" ] || [ "$LANG" = "C" ] || [ "$LANG" = "POSIX" ] ; then
29
    export LANG=en_US.UTF-8
30
fi
31
32
case $1 in
33
-P|--provides)
34
    while read file; do
35
        case "$file" in
36
            */qmldir)
37
                if head -1 "$file" | grep -iq '^module\s*' 2>/dev/null; then
38
                    provides="`head -1 ${file} | sed -r 's/^module\s+//'`"
39
                    version="`grep -i -E -o '^[a-z]*\s+[0-9.]*\s+[a-z0-9]*.qml' ${file} | awk '{print $2}' | sort -r | uniq | head -1`"
40
                    if [ -z "$version" ]; then
41
#                        echo "qmldeps: WARNING: no version number found, package version will be used." >&2
42
                        echo "qml($provides)"
43
                    else
44
                        echo "qml($provides) = $version"
45
                    fi
46
                else
47
                    echo "qmldeps: no valid module definition found in $file" >&2
48
                fi
49
                ;;
50
        esac
51
    done
52
    ;;
53
-R|--requires)
54
    while read file; do
55
        case "$file" in
56
            *.qml)
57
                # this first part is some hack to avoid depending on own provides
58
                # for modules
59
                qmldir=`echo ${file}|sed 's,/[^/]*$,,'`
60
                qmldir_noprivate=`echo ${file}|sed 's,private/[^/]*$,,'`
61
                if [ -f $qmldir/qmldir ]; then
62
                    module=`head -1 $qmldir/qmldir | sed -r 's/^.*\s+//'`
63
                elif [ -f $qmldir_noprivate/qmldir ]; then
64
                    module=`head -1 $qmldir_noprivate/qmldir | sed -r 's/^.*\s+//'`
65
                fi
66
                IFS=$'\n'
67
                imports=`grep -i -E -o '^\s*import\s+[a-z0-9.]*\s+[0-9.]*' ${file} | sed -r -e 's/^\s*import\s*//' | sort | uniq`
68
                if [ -z "$imports" ]; then
69
                    echo "qmldeps: no imports found in $file. Probably should not happen." >&2
70
                fi
71
                for i in $imports; do
72
                    import=`echo $i | awk '{ print $1 }'`
73
                    import_version=`echo $i | awk '{ print $2 }'`
74
                    if [ $import = "$module" ]; then
75
                        echo "qmldeps: skipping provide for own module '$module' in $file" >&2
76
                    elif echo $import | grep -q '\.private$'; then
77
                        echo "qmldeps: skipping private import '$import' in $file" >&2
78
                    else
79
                        # remove the >&2 to enable requires generation as well
80
                        echo "qml($import) >= $import_version"
81
                    fi
82
                done
83
                ;;
84
        esac
85
    done
86
    ;;
87
esac
88
exit 0

Comments