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
This commit is contained in:
Dominique Leuenberger 2013-08-13 12:41:22 +00:00 committed by Git OBS Bridge
parent 000267bb11
commit 524b04e76c
3 changed files with 81 additions and 1 deletions

View File

@ -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() {

View File

@ -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

View File

@ -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