diff options
author | Nicolas Vigier <boklm@mageia.org> | 2011-07-06 12:26:25 +0000 |
---|---|---|
committer | Nicolas Vigier <boklm@mageia.org> | 2011-07-06 12:26:25 +0000 |
commit | b3b2b4ae7fbc856b864084cc7b8b6ab2cb935fa1 (patch) | |
tree | e071b9701d8eaf06e4e2c4cf3487b43aa27f6f63 | |
parent | 0932515fd3934d60b28b98a6c7e0eddb769f5ce3 (diff) | |
download | rpm-setup-1.135.tar rpm-setup-1.135.tar.gz rpm-setup-1.135.tar.bz2 rpm-setup-1.135.tar.xz rpm-setup-1.135.zip |
1.135: add script for typelib() gobject-introspection bindings provides/requires1.135
-rw-r--r-- | Makefile.am | 3 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rwxr-xr-x | find-provides.in | 6 | ||||
-rwxr-xr-x | find-requires.in | 5 | ||||
-rwxr-xr-x | gi-find-deps.sh | 85 |
5 files changed, 99 insertions, 2 deletions
diff --git a/Makefile.am b/Makefile.am index b4d4666..aa517c1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -51,7 +51,8 @@ pkg_scripts = \ pythoneggs.py \ rubygems.rb \ desktop-file.prov \ - fontconfig.prov + fontconfig.prov \ + gi-find-deps.sh pkg_gscripts = \ find-provides \ diff --git a/configure.ac b/configure.ac index 6c6c163..cc9aeb0 100644 --- a/configure.ac +++ b/configure.ac @@ -4,7 +4,7 @@ # $Id: configure.ac 271266 2010-11-04 10:43:28Z fwang $ AC_PREREQ(2.59) -AC_INIT(rpm-mageia-setup, 1.134, pterjan@mageia.org) +AC_INIT(rpm-mageia-setup, 1.135, boklm@mars-attacks.org) AC_CANONICAL_TARGET AM_INIT_AUTOMAKE(1.9 -Wno-portability) AC_CONFIG_SRCDIR diff --git a/find-provides.in b/find-provides.in index cdfd147..cd9ba09 100755 --- a/find-provides.in +++ b/find-provides.in @@ -92,6 +92,12 @@ done | sort -u echo "$filelist" | tr '[:blank:]' \\n | @RPMVENDORDIR@/fontconfig.prov --provides | sort -u \ && test ${PIPESTATUS[2]} -ne 0 && echo 'error: @RPMVENDORDIR@/fontconfig.prov failed' >&2 && exit 1 +# +# --- typelib() gobject-introspection bindings +[ -x @RPMVENDORDIR@/gi-find-deps.sh ] && + echo "$filelist" | tr '[:blank:]' \\n | @RPMVENDORDIR@/gi-find-deps.sh -P | sort -u \ + && test ${PIPESTATUS[2]} -ne 0 && echo 'error: @RPMVENDORDIR@/gi-find-deps.sh failed' >&2 && exit 1 + if [ -n "$LIBTOOLDEP" ]; then # # --- libtooldep deps diff --git a/find-requires.in b/find-requires.in index b091797..008f34e 100755 --- a/find-requires.in +++ b/find-requires.in @@ -231,6 +231,11 @@ fi echo "$filelist" | tr '[:blank:]' \\n | @RPMVENDORDIR@/pkgconfigdeps.sh -R | sort -u \ && test ${PIPESTATUS[2]} -ne 0 && echo 'error: @RPMVENDORDIR@/pkgconfigdeps.sh failed' >&2 && exit 1 +# +# --- typelib() gobject-introspection bindings +[ -q @RPMVENDORDIR@/gi-find-deps.sh ] && + echo "$filelist" | tr '[:blank:]' \\n | @RPMVENDORDIR@/gi-find-deps.sh -R | sort -u \ + && test ${PIPESTATUS[2]} -ne 0 && echo 'error: @RPMVENDORDIR@/gi-find-deps.sh failed' >&2 && exit 1 if [ -n "$LIBTOOLDEP" ]; then # diff --git a/gi-find-deps.sh b/gi-find-deps.sh new file mode 100755 index 0000000..5cb3905 --- /dev/null +++ b/gi-find-deps.sh @@ -0,0 +1,85 @@ +#!/bin/sh + +# Automatically find Provides and Requires for typelib() gobject-introspection bindings. +# can be started with -R (Requires) and -P (Provides) + +# Copyright 2011 by Dominique Leuenberger, Amsterdam, Netherlands (dimstar [at] opensuse.org) +# This file is released under the GPLv2 or later. + +function split_name_version { +base=$1 +tsymbol=${base%-*} +# Sometimes we get a Requires on Gdk.Settings.foo, bebause you can directly use imports.gi.Gdk.Settings.Foo in Javascript. +# We know that the symbol in this case is call Gdk, so we cut everything after the . away. +symbol=$(echo $tsymbol | awk -F. '{print $1}') +version=${base#*-} +# In case there is no '-' in the filename, then the split above 'fails' and version == symbol (thus: no version specified) +if [ "$tsymbol" = "$version" ]; then + unset version +fi +} + +function print_req_prov { +echo -n "typelib($symbol)" +if [ ! -z "$version" ]; then + echo " = ${version}" +else + echo "" +fi +} + +function find_provides { +while read file; do + case $file in + *.typelib) + split_name_version $(basename $file | sed 's,.typelib$,,') + print_req_prov + ;; + esac +done +} + +function find_requires { +# FIXME: There are multiple ways gi bindings can be imported. We only catch the 'basic' one +# Currently, we detect: +# - in python: +# . from gi.repository import foo [Unversioned requirement of 'foo'] +# . from gi.repository import foo-1.0 [versioned requirement] +# . And we do not stumble over: +# from gi.repository import foo as _bar +# from gi.repository import foo, bar +# - in JS: +# . imports.gi.foo; [unversioned requirement of 'foo'] +# . imports.gi.goo-1.0; [versioned requirement] +# . The imports can be listed on one line, and we catch them. +# Forms currently not detected: +# - js: imports.gi.versions.Gtk = '3.0'; +# - py: gi.require_version('Gtk', '3.0') + +while read file; do + case $file in + *.js) + for module in $(grep -h -P -o "imports.gi.([^\s'\";]+)" $file | grep -v "imports.gi.version" | sed 's,imports.gi.,,'); do + split_name_version $module + print_req_prov + done + ;; + *.py) + for module in $(grep -h -P "from gi.repository import (\w+)" $file | sed 's:#.*::' | sed -e 's,from gi.repository import,,' -r -e 's:\s+as\s+\w+::g' -e 's:,::g'); do + split_name_version $module + print_req_prov + done + ;; + esac +done +} + +case $1 in + -P) + find_provides + ;; + -R) + find_requires + ;; +esac + |