Mageia Bugzilla – Attachment 3422 Details for
Bug 4825
gi-find-deps.sh doesn't handle scripts without .py
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
New Account
|
Forgot Password
Patch with syncs with OpenSuse (adding file based probing for python files)
latest-upstream.patch (text/plain), 4.36 KB, created by
Colin Guthrie
on 2013-01-22 15:17:39 CET
(
hide
)
Description:
Patch with syncs with OpenSuse (adding file based probing for python files)
Filename:
MIME Type:
Creator:
Colin Guthrie
Created:
2013-01-22 15:17:39 CET
Size:
4.36 KB
patch
obsolete
>Index: gi-find-deps.sh.in >=================================================================== >--- gi-find-deps.sh.in (revision 7196) >+++ gi-find-deps.sh.in (working copy) >@@ -39,48 +39,112 @@ > done > } > >+function python_requires { >+ for module in $(grep -h -P "from gi\.repository import (\w+)" $1 | sed -e 's:#.*::' -e 's:raise ImportError.*::' | sed -e 's,from gi.repository import,,' -r -e 's:\s+$::g' -e 's:\s+as\s+\w+::g' -e 's:,: :g'); do >+ split_name_version $module >+ print_req_prov >+ echo "python-gi >= 2.90.2" >+ done >+ for module in $(grep -h -P -o "(gi\.require_version\(['\"][^'\"]+['\"],\s*['\"][^'\"]+['\"]\))" $1 | sed -e 's:gi.require_version::' -e "s:[()\"' ]::g" -e 's:,:-:'); do >+ split_name_version $module >+ print_req_prov >+ done >+} >+ >+function javascript_requires { >+ for module in $(grep -h -P -o "imports\.gi\.([^\s'\";]+)" $1 | grep -v "imports\.gi\.version" | sed -r -e 's,\s+$,,g' -e 's,imports.gi.,,'); do >+ split_name_version $module >+ print_req_prov >+ done >+ for module in $(grep -h -P -o "imports\.gi\.versions\.([^\s'\";]+)\s*=\s*['\"].+['\"]" $1 | \ >+ sed -e 's:imports.gi.versions.::' -e "s:['\"]::g" -e 's:=:-:' -e 's: ::g'); do >+ split_name_version $module >+ print_req_prov >+ done >+ >+} >+ >+function typelib_requires { >+ for module in $(@RPMVENDORDIR@/g-ir-extract-deps $1 | tr '|' ' '); do >+ split_name_version $module >+ print_req_prov >+ done >+} >+ >+# (cg) Below is the version used upstream. Should we use that instead? >+# It would require a patch to gobject-introspection to include g-ir-dep-tool >+# https://build.opensuse.org/package/show?package=gobject-introspection&project=GNOME%3AFactory >+# rather than our g-ir-extract-deps thing here. >+function typelib_requires_upstream_should_we_use_this_instead_of_above { >+ split_name_version $(basename $1 | sed 's,.typelib$,,') >+ oldIFS=$IFS >+ IFS=$'\n' >+ for req in $(g-ir-dep-tool $symbol $version); do >+ case $req in >+ typelib:*) >+ module=${req#typelib: } >+ split_name_version $module >+ print_req_prov >+ ;; >+ shlib:*) >+ echo "${req#shlib: }${shlib_64}" >+ ;; >+ esac >+ done >+ IFS=$oldIFS >+} >+ > 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] >+# . gi.require_version('Gtk', '3.0') (To specify a version.. there is still an import needed) > # . 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] >+# . imports.gi.versions.Gtk = '3.0'; > # . 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 >+ javascript_requires "$file" > ;; >- *.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:\s*,\s*: :g'); do >- split_name_version $module >- print_req_prov >- echo "python-gi >= 2.90.2" >- done >+ *.py) >+ python_requires "$file" > ;; >- *.typelib) >- for module in $(@RPMVENDORDIR@/g-ir-extract-deps $file | tr '|' ' '); do >- split_name_version $module >- print_req_prov >- done >+ *.typelib) >+ typelib_requires "$file" > ;; >+ *) >+ case $(file -b $file) in >+ Python\ script*) >+ python_requires "$file" >+ ;; >+ esac >+ ;; > esac > done > } > >+# (cg) The below for+if is only needed for the g-ir-dep-tool binary which is currently unused. >+for path in \ >+ $(for tlpath in \ >+ $(find ${RPM_BUILD_ROOT}/usr/lib64 ${RPM_BUILD_ROOT}/usr/lib /usr/lib64 /usr/lib -name '*.typelib' 2>/dev/null); do >+ dirname $tlpath; done | uniq ); do >+ export GI_TYPELIB_PATH=$GI_TYPELIB_PATH:$path >+done >+ >+if [ "${HOSTTYPE}" == "x86_64" -o "${HOSTTYPE}" == "ppc64" -o "${HOSTTYPE}" == "s390x" -o "${HOSTTYPE}" == "ia64" ]; then >+ shlib_64="()(64bit)" >+fi >+ >+ >+ > case $1 in > -P) > find_provides
Index: gi-find-deps.sh.in =================================================================== --- gi-find-deps.sh.in (revision 7196) +++ gi-find-deps.sh.in (working copy) @@ -39,48 +39,112 @@ done } +function python_requires { + for module in $(grep -h -P "from gi\.repository import (\w+)" $1 | sed -e 's:#.*::' -e 's:raise ImportError.*::' | sed -e 's,from gi.repository import,,' -r -e 's:\s+$::g' -e 's:\s+as\s+\w+::g' -e 's:,: :g'); do + split_name_version $module + print_req_prov + echo "python-gi >= 2.90.2" + done + for module in $(grep -h -P -o "(gi\.require_version\(['\"][^'\"]+['\"],\s*['\"][^'\"]+['\"]\))" $1 | sed -e 's:gi.require_version::' -e "s:[()\"' ]::g" -e 's:,:-:'); do + split_name_version $module + print_req_prov + done +} + +function javascript_requires { + for module in $(grep -h -P -o "imports\.gi\.([^\s'\";]+)" $1 | grep -v "imports\.gi\.version" | sed -r -e 's,\s+$,,g' -e 's,imports.gi.,,'); do + split_name_version $module + print_req_prov + done + for module in $(grep -h -P -o "imports\.gi\.versions\.([^\s'\";]+)\s*=\s*['\"].+['\"]" $1 | \ + sed -e 's:imports.gi.versions.::' -e "s:['\"]::g" -e 's:=:-:' -e 's: ::g'); do + split_name_version $module + print_req_prov + done + +} + +function typelib_requires { + for module in $(@RPMVENDORDIR@/g-ir-extract-deps $1 | tr '|' ' '); do + split_name_version $module + print_req_prov + done +} + +# (cg) Below is the version used upstream. Should we use that instead? +# It would require a patch to gobject-introspection to include g-ir-dep-tool +# https://build.opensuse.org/package/show?package=gobject-introspection&project=GNOME%3AFactory +# rather than our g-ir-extract-deps thing here. +function typelib_requires_upstream_should_we_use_this_instead_of_above { + split_name_version $(basename $1 | sed 's,.typelib$,,') + oldIFS=$IFS + IFS=$'\n' + for req in $(g-ir-dep-tool $symbol $version); do + case $req in + typelib:*) + module=${req#typelib: } + split_name_version $module + print_req_prov + ;; + shlib:*) + echo "${req#shlib: }${shlib_64}" + ;; + esac + done + IFS=$oldIFS +} + 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] +# . gi.require_version('Gtk', '3.0') (To specify a version.. there is still an import needed) # . 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] +# . imports.gi.versions.Gtk = '3.0'; # . 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 + javascript_requires "$file" ;; - *.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:\s*,\s*: :g'); do - split_name_version $module - print_req_prov - echo "python-gi >= 2.90.2" - done + *.py) + python_requires "$file" ;; - *.typelib) - for module in $(@RPMVENDORDIR@/g-ir-extract-deps $file | tr '|' ' '); do - split_name_version $module - print_req_prov - done + *.typelib) + typelib_requires "$file" ;; + *) + case $(file -b $file) in + Python\ script*) + python_requires "$file" + ;; + esac + ;; esac done } +# (cg) The below for+if is only needed for the g-ir-dep-tool binary which is currently unused. +for path in \ + $(for tlpath in \ + $(find ${RPM_BUILD_ROOT}/usr/lib64 ${RPM_BUILD_ROOT}/usr/lib /usr/lib64 /usr/lib -name '*.typelib' 2>/dev/null); do + dirname $tlpath; done | uniq ); do + export GI_TYPELIB_PATH=$GI_TYPELIB_PATH:$path +done + +if [ "${HOSTTYPE}" == "x86_64" -o "${HOSTTYPE}" == "ppc64" -o "${HOSTTYPE}" == "s390x" -o "${HOSTTYPE}" == "ia64" ]; then + shlib_64="()(64bit)" +fi + + + case $1 in -P) find_provides
View Attachment As Raw
Actions:
View
Attachments on
bug 4825
: 3422