diff options
| author | CoprDistGit <infra@openeuler.org> | 2024-09-23 07:02:01 +0000 | 
|---|---|---|
| committer | CoprDistGit <infra@openeuler.org> | 2024-09-23 07:02:01 +0000 | 
| commit | 3a0cc1d64d158ffbe8027735d0acf54cfcabb2b8 (patch) | |
| tree | 2faf6bdf05a53ac7024c15b71d7fa367ed239203 | |
| parent | 45454475da3a5413fb8491d5ff1b919561e0a8cd (diff) | |
automatic import of gobject-introspection
| -rw-r--r-- | .gitignore | 1 | ||||
| -rwxr-xr-x | gi-find-deps.sh | 279 | ||||
| -rw-r--r-- | gobject-introspection.spec | 145 | ||||
| -rw-r--r-- | gobjectintrospection.attr | 4 | ||||
| -rw-r--r-- | sources | 1 | 
5 files changed, 430 insertions, 0 deletions
@@ -0,0 +1 @@ +/gobject-introspection-1.76.1.tar.xz diff --git a/gi-find-deps.sh b/gi-find-deps.sh new file mode 100755 index 0000000..b61b58e --- /dev/null +++ b/gi-find-deps.sh @@ -0,0 +1,279 @@ +#!/bin/bash + +# 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, because you can directly use imports.gi.Gdk.Settings.Foo in Javascript. +# We know that the symbol in this case is called 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 split_name_version2 { +  symbol=$(echo $1 | awk -F: '{sub(/^.*{/, "", $1); print $1}' | sed "s:[' ]::g") +  version=$(echo $1 | awk -F: '{print $2}' | sed "s:[' ]::g") +} + +# some javascript code imports gi like this (seen since GNOME 43, e.g. GNOME Maps) +# import 'gi://GeocodeGlib?version=2.0' +function split_name_versionjs_gi_name_version { +  symbol=$(echo $1 | awk -F? '{print $1}') +  version=$(echo $1 | awk -F? '/version=/ {print $2}' | sed 's/version=//') +} + +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 gresources_requires { +# GNOME is embedding .js files into ELF binaries for faster startup. +# As a result, we need to extract them and re-run the scanner over the +# embedded files. +# We extract all the gresources embedded in ELF binaries and start +# gi-find-deps.sh recusively over the extracted file list. +tmpdir=$(mktemp -d) +for resource in $($gresourcecmd list "$1" 2>/dev/null); do +  mkdir -p $tmpdir/$(dirname $resource) +  $gresourcecmd extract "$1" $resource > $tmpdir/$resource +done +find $tmpdir -type f | sort | sh $0 -R +rm -rf "$tmpdir" +} + +function python_requires { +	for module in $(grep -h -P "^\s*from gi\.repository import (\w+)" $1 | sed -e 's:#.*::' -e 's:raise ImportError.*::' -e 's:.*"from gi.repository import .*".*::' | 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 +		# Temporarly disabled... this is not true if the python code is written for python3... And there seems no real 'way' to identify this. +		# echo "python-gobject >= 2.21.4" +	done +	for module in $(grep -h -P -o ".*(gi\.require_version\(['\"][^'\"]+['\"],\s*['\"][^'\"]+['\"]\))" $1 | sed  -e 's:#.*::' -e 's:.*gi.require_version::' -e "s:[()\"' ]::g" -e 's:,:-:'); do +		split_name_version $module +		print_req_prov +	done +        # python glue layers (/gi/overrides) import their typelibs slightly different +	for module in $(grep -h -P -o "=\s+(get_introspection_module\(['\"][^'\"]+['\"]\))" $1 | sed -e 's:#.*::' -e 's:=.*get_introspection_module::' -e "s:[()\"' ]::g"); do +		split_name_version $module +		print_req_prov +	done +} + +function javascript_requires { +  # parse the new import style in 3.32 +	for module in $(grep -r -h -A2 'const {' $1 | paste -s -d ' ' | grep '} = imports.gi;' | sed 's/imports.gi;.*/imports.gi;/' | awk -F '[{}]' '{print $(NF>1?NF-1:"")}' | tr ',' '\n' | tr -d ' ' | awk -F ':' '{print $1}'); do +		split_name_version $module +		print_req_prov +	done +  # parse the old import style before 3.32 +	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 +  # some javascript code imports gi like this (seen since GNOME 43, e.g. GNOME Maps) +  # import 'gi://GeocodeGlib?version=2.0' +        for module in $(grep -h -P -o "['\"]gi://([^'\"]+)" $1 | sed "s|['\"]gi://||"); do +                split_name_versionjs_gi_name_version $module +                print_req_prov +        done +    # This is, at the moment, specifically for Polari where a "const { Foo, Bar } = imports.gi;" is used. +	for module in $(grep -h -E -o "\{ \w+(: \w+|, \w+)+ \} = imports.gi;" $1 | \ +        sed -r -e '0,/\w+:\s\w+/ s/:\s\w+//g' -e 's: = imports.gi;:: ; s:\{ :: ; s: \}:: ; s/,//g'); do +		split_name_version $module +		print_req_prov +	done +	# Remember files which contain a pkg.require() call +	if pcre2grep -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 pcre2grep -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 { +# For now this is a dummy function based on gnome-weather information +#for file in $jspkgfilt; do +#	FILTER=($(pcre2grep -M "const RECOGNIZED_MODULE_NAMES =([^;])*" $file | grep -o "'.*'" | sed "s:'::g")) +#done +  FILTER=('Lang' 'Mainloop' 'Signals' 'System' 'Params') +} + +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=$(pcre2grep -M "pkg.require\\(([^;])*" $file | grep -o -E "'?.*'?: '.*'") +	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 + +} + +function typelib_requires { +	split_name_version $(basename $1 | sed 's,.typelib$,,') +	oldIFS=$IFS +	IFS=$'\n' +	for req in $(g-ir-inspect --print-shlibs --print-typelibs $symbol --version $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 { +# 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.foo-1.0; [versioned requirement of 'foo'] +#   . imports.gi.versions.Gtk = '3.0'; +#   . const { foo, bar } = imports.gi; +#   . The imports can be listed on one line, and we catch them. + +while read file; do +	case $file in +		*.js) +			javascript_requires "$file" +			;; +		*.py) +			python_requires "$file" +			;; +		*.typelib) +			typelib_requires "$file" +			;; +		*.gresource) +			gresources_requires "$file" +			;; +		*) +			case $(file -b $file) in +				*[Pp]ython*script*) +					python_requires "$file" +					;; +				*JavaScript*source*) +		                        javascript_requires "$file" +					;; +				*ELF*) +					gresources_requires "$file" +					;; +			esac +			;; +	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() { +  for word in $1; do +    [[ "$word" = "$2" ]] && return 0 +  done +  return 1 +} + +# Confer with /usr/lib/rpm/platforms +x64bitarch="aarch64 mips64 mips64el mips64r6 mips64r6el loongarch64 sw64 ppc64 ppc64le riscv64 s390x sparc64 x86_64" + +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 | sort --unique ); do +	export GI_TYPELIB_PATH=$GI_TYPELIB_PATH:$path +done + +if which gresource >/dev/null 2>&1; then +  gresourcecmd=$(which gresource 2>/dev/null) +else +  grsourcecmd="false" +fi + +if inList "$x64bitarch" "${HOSTTYPE}"; then +	shlib_64="()(64bit)" +fi +case $1 in +	-P)	 +		find_provides +		;; +	-R) +		find_requires +		;; +esac + diff --git a/gobject-introspection.spec b/gobject-introspection.spec new file mode 100644 index 0000000..1eb7415 --- /dev/null +++ b/gobject-introspection.spec @@ -0,0 +1,145 @@ +%global glib2_version 2.76.0 + +Name:           gobject-introspection +Version:        1.76.1 +Release:        2 +Summary:        Introspection system for GObject-based libraries +License:        GPL-2.0-or-later AND LGPL-2.0-or-later AND LGPL-2.1-or-later AND BSD-2-Clause +URL:            https://gi.readthedocs.io/ +Source0:        https://download.gnome.org/sources/gobject-introspection/1.76/%{name}-%{version}.tar.xz +# gi-find-deps.sh is a rpm helper from openSUSE for Provides and Requires. +# Script creates typelib()-style Provides/Requires. +Source1:        gi-find-deps.sh +Source2:        gobjectintrospection.attr + +BuildRequires: gcc +BuildRequires: meson >= 0.60.0 +BuildRequires: pkgconfig(cairo) +BuildRequires: pkgconfig(cairo-gobject) +BuildRequires: pkgconfig(gio-2.0) >= %{glib2_version} +BuildRequires: pkgconfig(gio-unix-2.0) >= %{glib2_version} +BuildRequires: pkgconfig(glib-2.0) >= %{glib2_version} +BuildRequires: pkgconfig(gmodule-2.0) >= %{glib2_version} +BuildRequires: pkgconfig(gobject-2.0) >= %{glib2_version} +BuildRequires: pkgconfig(libffi) +BuildRequires: python3-devel >= 3.6 +BuildRequires: python3-mako +BuildRequires: python3-markdown +BuildRequires: gtk-doc +BuildRequires: /usr/bin/bison +BuildRequires: /usr/bin/flex +Requires:       glib2%{?_isa} >= %{glib2_version} + +%description +GObject Introspection can scan C header and source files in order to +generate introspection "typelib" files.  It also provides an API to examine +typelib files, useful for creating language bindings among other +things. + +%package devel +Summary:        Libraries and headers for gobject-introspection +Requires:       %{name}%{?_isa} = %{version}-%{release} +Requires:       glib2%{?_isa} >= %{glib2_version} +Requires:       libtool +Requires:       /usr/bin/file +Requires:       /usr/bin/pcre2grep +Requires:       python3-xml +Requires:       python3-mako +Requires:       python3-markdown +Requires:       python(abi) = %{python3_version} + +%description devel +Libraries and headers for gobject-introspection + +%package_help + +%prep +%autosetup -p1 + +%build +%meson -Ddoctool=enabled -Dgtk_doc=true -Dpython=%{__python3} +%meson_build + +%install +%meson_install + +install -D %{S:1} %{buildroot}%{_rpmconfigdir}/gi-find-deps.sh +install -D %{S:2} -m 0644 %{buildroot}%{_fileattrsdir}/gobjectintrospection.attr + +%check +%meson_test + +%files +%license COPYING COPYING.GPL COPYING.LGPL +%{_libdir}/lib*.so.* +%dir %{_libdir}/girepository-1.0 +%{_libdir}/girepository-1.0/*.typelib + +%files devel +%{_bindir}/g-ir-* +%{_libdir}/lib*.so +%{_libdir}/gobject-introspection/ +%{_libdir}/pkgconfig/* +%{_datadir}/gir-1.0 +%{_datadir}/gobject-introspection-1.0 +%{_datadir}/aclocal/introspection.m4 +%{_includedir}/* +%{_rpmconfigdir}/gi-find-deps.sh +%{_fileattrsdir}/gobjectintrospection.attr + +%files help +%doc NEWS README.rst +%dir %{_datadir}/gtk-doc +%dir %{_datadir}/gtk-doc/html +%{_datadir}/gtk-doc/html/gi +%{_mandir}/man1/*.1* + +%changelog +* Mon Sep 23 2024 Funda Wang <fundawang@yeah.net> - 1.76.1-2 +- Add gi-find-deps script from openSUSE to ease dependency solving + +* Sat Jan 27 2024 shixuantong <shixuantong1@huawei.com> - 1.76.1-1 +- upgrade version to 1.76.1 + +* Thu May 25 2023 fuanan <fuanan3@h-partners.com> - 1.74.0-2 +- enable test in check + +* Mon Jan 02 2023 lin zhang <lin.zhang@turbolinux.com.cn> - 1.74.0-1 +- update to 1.74.0 + +* Tue Oct 25 2022 yanglongkang <yanglongkang@h-partners.com> - 1.72.0-2 +- rebuild for next release + +* Fri Apr 22 2022 dillon chen <dillon.chen@gmail.com> - 1.72.0-1 +- Update to 1.72.0 + +* Sun Dec 26 2021 tianwei <tianwei12@huawei.com>  - 1.70.0-1 +- upgrade version to 1.70.0 + +* Thu Jul 22 2021 wuchaochao <wuchaochao4@huawei.com>  - 1.66.1-2 +- Remove BuildRequires gdb + +* Wed May 19 2021 weijin deng <weijin.deng@turbolinux.com.cn> - 1.66.1-1 +- Upgrade to 1.66.1 +- Update Version, Release, Source0 + +* Mon Sep 14 2020 Leo Fang <leofang_94@163.com> - 1.64.1-2 +- update Source0 in spec + +* Fri Jul 24 2020 openEuler Buildteam <buildteam@openeuler.org> - 1.64.1-1 +- update software to v1.64.1 + +* Sat Mar 14 2020 openEuler Buildteam <buildteam@openeuler.org> - 1.58.0-6 +- fixbug in self-building + +* Wed Nov 20 2019 fangyufa<fangyufa1@huawei.com> - 1.58.0-5 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC:fix build problem for x86_64 + +* Tue Oct 29 2019 openEuler Buildteam <buildteam@openeuler.org> - 1.58.0-4 +- fix provides for main package and devel + +* Mon Oct 14 2019 openEuler Buildteam <buildteam@openeuler.org> - 1.58.0-3 +- Package init diff --git a/gobjectintrospection.attr b/gobjectintrospection.attr new file mode 100644 index 0000000..a814b5f --- /dev/null +++ b/gobjectintrospection.attr @@ -0,0 +1,4 @@ +%__gobjectintrospection_provides       %{_rpmconfigdir}/gi-find-deps.sh -P +%__gobjectintrospection_requires       %{_rpmconfigdir}/gi-find-deps.sh -R +%__gobjectintrospection_path           ^((%{_libdir}|%{_datadir}/gir-1.0)/.*\.typelib)|(.*\.gresource)|(.*\.py)|(.*\.js)|(.*\.so)|(%{_bindir}/.*)$ +%__gobjectintrospection_exclude_path   ^/usr/share/doc/ @@ -0,0 +1 @@ +5cb554fdd139db79f9b1be13892fddac  gobject-introspection-1.76.1.tar.xz  | 
