From 5cab2bf049d5ed9492ab87de8b647b95ad688f9cc920c51538a97a4ddc316fbe Mon Sep 17 00:00:00 2001 From: Vincent Untz Date: Wed, 27 Apr 2011 14:45:13 +0000 Subject: [PATCH] Accepting request 68591 from home:dimstar:branches:Base:System thanks OBS-URL: https://build.opensuse.org/request/show/68591 OBS-URL: https://build.opensuse.org/package/show/GNOME:Factory/gobject-introspection?expand=0&rev=44 --- gi-find-deps.sh | 80 +++++++++++++++++++++++++++++++++++ gobject-introspection.changes | 6 +++ gobject-introspection.spec | 6 ++- 3 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 gi-find-deps.sh diff --git a/gi-find-deps.sh b/gi-find-deps.sh new file mode 100644 index 0000000..fd571e0 --- /dev/null +++ b/gi-find-deps.sh @@ -0,0 +1,80 @@ +#!/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 +symbol=${base%-*} +version=${base#*-} +# In case there is no '-' in the filename, then the split above 'fails' and version == symbol (thus: no version specified) +if [ "$symbol" = "$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 + /usr/lib[^/]*/girepository-1.0/*.typelib) + split_name_version $(basename $file | sed 's,.typelib$,,') + print_req_prov + ;; + esac +done +} + +function find_requires { +# FIXME: There are multiple ways how the 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 +# - 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. +# Not detected froms: +# - imports.gi.versions.Gtk = '3.0'; +# - 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 -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 + diff --git a/gobject-introspection.changes b/gobject-introspection.changes index 8b93c32..a05e9be 100644 --- a/gobject-introspection.changes +++ b/gobject-introspection.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Wed Apr 27 09:16:02 UTC 2011 - dimstar@opensuse.org + +- Add gi-find-deps.sh: automatically detect requires and provides + for gobject-introspected typelibs. + ------------------------------------------------------------------- Tue Apr 26 14:52:08 UTC 2011 - fcrozat@novell.com diff --git a/gobject-introspection.spec b/gobject-introspection.spec index d7734fb..c9e41ff 100644 --- a/gobject-introspection.spec +++ b/gobject-introspection.spec @@ -26,7 +26,9 @@ Summary: GObject Introspection Tools Url: http://live.gnome.org/GObjectIntrospection Group: Development/Libraries/GNOME Source0: %{name}-%{version}.tar.bz2 -Source1: %{name}-rpmlintrc +# gi-find-deps.sh installed as rpm helper for Provides and Requires. Script creates typelib()-style Provides/Requires. +Source1: gi-find-deps.sh +Source99: %{name}-rpmlintrc BuildRequires: bison BuildRequires: fdupes BuildRequires: flex @@ -86,6 +88,7 @@ a uniform, machine readable format. %install %makeinstall find %{buildroot} -type f -name "*.la" -delete -print +install -D %{S:1} %{buildroot}%{_prefix}/lib/rpm/gi-find-deps.sh %fdupes %{buildroot} %clean @@ -136,5 +139,6 @@ rm -rf %{buildroot} # FIXME: those two files should be moved to the main package when bgo#629930 gets fixed %{_libdir}/pkgconfig/gobject-introspection-1.0.pc %{_libdir}/pkgconfig/gobject-introspection-no-export-1.0.pc +%{_prefix}/lib/rpm/gi-find-deps.sh %changelog