From 524b04e76c7bc8160967b2ab07bb76fcae6aa449416e9b6a7cbf183a005e9dc3 Mon Sep 17 00:00:00 2001 From: Dominique Leuenberger Date: Tue, 13 Aug 2013 12:41:22 +0000 Subject: [PATCH] Accepting request 186786 from home:dimstar:branches:GNOME:Factory Enhance gi-find-deps: it works for gnome-weather now OBS-URL: https://build.opensuse.org/request/show/186786 OBS-URL: https://build.opensuse.org/package/show/GNOME:Factory/gobject-introspection?expand=0&rev=124 --- gi-find-deps.sh | 70 ++++++++++++++++++++++++++++++++++- gobject-introspection.changes | 10 +++++ gobject-introspection.spec | 2 + 3 files changed, 81 insertions(+), 1 deletion(-) diff --git a/gi-find-deps.sh b/gi-find-deps.sh index 84a1a6c..ed68d7f 100644 --- a/gi-find-deps.sh +++ b/gi-find-deps.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Automatically find Provides and Requires for typelib() gobject-introspection bindings. # can be started with -R (Requires) and -P (Provides) @@ -19,6 +19,11 @@ if [ "$tsymbol" = "$version" ]; then fi } +function split_name_version2 { + symbol=$(echo $1 | awk -F: '{print $1}' | sed "s:[' ]::g") + version=$(echo $1 | awk -F: '{print $2}' | sed "s:[' ]::g") +} + function print_req_prov { echo -n "typelib($symbol)" if [ ! -z "$version" ]; then @@ -62,6 +67,61 @@ function javascript_requires { split_name_version $module print_req_prov done + # Remember files which contain a pkg.require() call + if pcregrep -M "pkg.require\\(([^;])*" $1 > /dev/null; then + # the file contains a pkg.require(..) list... let's remember th is file for the in-depth scanner + if [ -n "$jspkg" ]; then + jspkg=$1:${jspkg} + else + jspkg=$1 + fi + fi + # remember files which contain exlucde filters used against pkg.require() + if pcregrep -M "const RECOGNIZED_MODULE_NAMES =([^;])*" $1 > /dev/null; then + # the file contains RECOGNIZED_MODULE_NAMES list. We remember the file name for the follow up filtering + if [ -n "$jspkgfilt" ]; then + jspkgfilt=$1:${jspkgfilt} + else + jspkgfilt=$1 + fi + fi + +} + +function javascript_pkg_filter { +# This function needs to be extended to actually READ the known items from the javascript code as well. +# Currently, this is a place holder function based on the content from gnome-weather (which, in fact, is the +# only package so far declaring the pkg dependencies in this form +# Packages listed here are exluced from the dependency addition if they are only specified in pkg.require(..) +for file in $jspkgfilt; do + FILTER=($(pcregrep -M "const RECOGNIZED_MODULE_NAMES =([^;])*" $file | grep -o "'.*'" | sed "s:'::g")) +done +} + +function javascript_pkg_requires { +# javascript files were found which specify pkg.require('..': '..'[,'..': '']); list +# This is used in some apps in order to have a 'centralized' point to specify all package dependencies. +# once we reach this function, we already know which file(s) contain the pkg.require(..) list. +oldIFS=$IFS +IFS=: +for file in $jspkg; do + IFS=$'\n' + PKGS=$(pcregrep -M "pkg.require\\(([^;])*" $file | grep -o "'.*': '.*'") + for pkg in $PKGS; do + split_name_version2 $pkg + found=0 + for (( i=0 ; i<${#FILTER[@]} ; i++ )); do + if [ "$symbol" = "${FILTER[$i]}" ]; then + found=1 + fi + done + if [ $found -eq 0 ]; then + print_req_prov + fi + done + IFS=: +done +IFS=$oldIFS } @@ -119,6 +179,14 @@ while read file; do ;; esac done +# The pkg filter is a place holder. This should read the filter from the javascript files. +if [ -n "$jspkgfilt" ]; then + javascript_pkg_filter +fi +# in case the javascript parser above detected files which specify pkg.require, we enter the more in-depth scanning scheme for those files. +if [ -n "$jspkg" ]; then + javascript_pkg_requires +fi } function inList() { diff --git a/gobject-introspection.changes b/gobject-introspection.changes index c4d52eb..d9f3708 100644 --- a/gobject-introspection.changes +++ b/gobject-introspection.changes @@ -1,3 +1,13 @@ +------------------------------------------------------------------- +Fri Aug 9 20:49:53 UTC 2013 - dimstar@opensuse.org + +- Enhance gi-find-deps.sh: gnome-weather came up with a nice idea + of specifying all dependencies in a pkg.requires(..) list + (hopefully this counts as standardized). Enhance the scanner to + identify this listing method of dependencies (bnc#811652). +- Add pcre-tools Requires to the main package: gi-find-deps.sh uses + pcregrep for multi line matching. + ------------------------------------------------------------------- Wed Jul 10 18:37:19 UTC 2013 - dimstar@opensuse.org diff --git a/gobject-introspection.spec b/gobject-introspection.spec index 1884b4d..5cef167 100644 --- a/gobject-introspection.spec +++ b/gobject-introspection.spec @@ -49,6 +49,8 @@ BuildRequires: pkgconfig(gobject-2.0) # gi-find-deps makes use of 'file' to identify the types. Requires: file Requires: libgirepository-1_0-1 = %{version} +# gi-find-deps uses the enhanced grep variant in order to do multi-line matching (for pkg.requires(..)) +Requires: pcre-tools Requires: python-xml BuildRoot: %{_tmppath}/%{name}-%{version}-build