[packages/pootle/dev-2.7] move language tagging to standalone script

glen glen at pld-linux.org
Sun May 8 11:14:26 CEST 2016


commit e30776630c87e8b49d133895dccd5b4a9427ea7b
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Sun May 8 12:01:47 2016 +0300

    move language tagging to standalone script

 find-lang.sh | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 pootle.spec  | 51 +++++++----------------------------------
 2 files changed, 82 insertions(+), 43 deletions(-)
---
diff --git a/pootle.spec b/pootle.spec
index 468f0ff..5464b1c 100644
--- a/pootle.spec
+++ b/pootle.spec
@@ -4,12 +4,13 @@
 Summary:	Localization and translation management web application
 Name:		pootle
 Version:	2.7.3
-Release:	0.8
+Release:	0.9
 License:	GPL v2
 Group:		Development/Tools
 Source0:	https://github.com/translate/pootle/releases/download/%{version}/Pootle-%{version}.tar.bz2
 # Source0-md5:	b1bac7ae18dc3632c471c63e72852949
 Source1:	apache.conf
+Source2:	find-lang.sh
 Patch0:		settings.patch
 Patch1:		paths.patch
 Patch2:		homedir.patch
@@ -32,6 +33,8 @@ Suggests:	python-memcached
 BuildArch:	noarch
 BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
 
+%define		find_lang	sh %{_sourcedir}/find-lang.sh %{buildroot}
+
 %define		_webapps	/etc/webapps
 %define		_webapp		%{name}
 %define		_sysconfdir	%{_webapps}/%{_webapp}
@@ -90,45 +93,7 @@ mv $RPM_BUILD_ROOT%{py_sitescriptdir}/%{name}/{locale,static,assets} \
 %py_comp $RPM_BUILD_ROOT%{py_sitescriptdir}
 %py_postclean
 
-> %{name}.lang
-# application language
-%if 0
-for a in $RPM_BUILD_ROOT%{_datadir}/pootle/mo/[a-z]*; do
-	# path file and lang
-	p=${a#$RPM_BUILD_ROOT} l=${a##*/}
-	echo "%lang($l) $p" >> %{name}.lang
-done
-%endif
-
-# such recursive magic is because we need to have different permissions for
-# directories and files and we want to language tag both of them
-scan_mo() {
-	for obj in "$@"; do
-		# skip bad globs (happens when we recurse)
-		[ -e "$obj" ] || continue
-		# path file and lang
-		path=${obj#$RPM_BUILD_ROOT} lang=${MO_LANG:-${obj##*/}}
-
-		if [ -d $obj ]; then
-			attr='%dir %attr(770,root,http)'
-		else
-			attr='%attr(660,root,http) %config(noreplace) %verify(not md5 mtime size)'
-		fi
-		case $lang in
-		templates)
-			echo "$attr $path" >> %{name}.lang
-			;;
-		*)
-			echo "%lang($lang) $attr $path" >> %{name}.lang
-			;;
-		esac
-		if [ -d $obj ]; then
-			MO_LANG=$lang scan_mo $obj/*
-			unset MO_LANG
-		fi
-	done
-}
-scan_mo $RPM_BUILD_ROOT%{_sharedstatedir}/%{name}/po/{pootle,terminology,tutorial}/* >> %{name}.lang
+%find_lang %{name}.lang
 
 # don't clobber user $PATH
 #mv $RPM_BUILD_ROOT{%{_bindir},%{_sbindir}}/PootleServer
@@ -164,11 +129,11 @@ rm -rf $RPM_BUILD_ROOT
 %dir %{_datadir}/%{name}
 %{_datadir}/%{name}/assets
 %{_datadir}/%{name}/static
+%dir %{_datadir}/%{name}/locale
+%{_datadir}/%{name}/locale/LINGUAS
+%{_datadir}/%{name}/locale/templates
 %if 0
-%{_datadir}/pootle/mo/README
 %attr(755,root,root) %{_datadir}/pootle/wsgi.py
-%{_datadir}/pootle/templates
-%dir %{_datadir}/pootle/mo
 %endif
 
 %{py_sitescriptdir}/%{name}
diff --git a/find-lang.sh b/find-lang.sh
new file mode 100755
index 0000000..6cc5627
--- /dev/null
+++ b/find-lang.sh
@@ -0,0 +1,74 @@
+#!/bin/sh
+PROG=${0##*/}
+
+# application language
+scan_locale() {
+	local dir path lang
+	for dir in "$@"; do
+		dir=${dir%/}
+		path=${dir#$RPM_BUILD_ROOT}
+		lang=${dir##*/}
+
+		case "$lang" in
+		templates)
+			continue
+			;;
+		esac
+
+		echo "%lang($lang) $path"
+	done
+}
+
+# such recursive magic is because we need to have different permissions for
+# directories and files and we want to language tag both of them
+scan_mo() {
+	for obj in "$@"; do
+		# skip bad globs (happens when we recurse)
+		[ -e "$obj" ] || continue
+
+		# path file and lang
+		path=${obj#$RPM_BUILD_ROOT} lang=${MO_LANG:-${obj##*/}}
+
+		if [ -d $obj ]; then
+			attr='%dir %attr(770,root,http)'
+		else
+			attr='%attr(660,root,http) %config(noreplace) %verify(not md5 mtime size)'
+		fi
+
+		case $lang in
+		templates)
+			echo "$attr $path"
+			;;
+		*)
+			echo "%lang($lang) $attr $path"
+			;;
+		esac
+		if [ -d $obj ]; then
+			MO_LANG=$lang scan_mo $obj/*
+			unset MO_LANG
+		fi
+	done
+}
+
+if [ $# = 2 ]; then
+	# for using same syntax as rpm own find-lang
+	RPM_BUILD_ROOT=$1
+	shift
+fi
+
+langfile=$1
+localedir=$RPM_BUILD_ROOT/usr/share/pootle/locale
+podir=$RPM_BUILD_ROOT/var/lib/pootle/po
+
+echo '%defattr(644,root,root,755)' > $langfile
+
+scan_locale $localedir/*/ >> $langfile
+scan_mo $podir/terminology/* >> $langfile
+scan_mo $podir/tutorial/* >> $langfile
+
+if [ "$(grep -Ev '(^%defattr|^$)' $langfile | wc -l)" -le 0 ]; then
+	echo >&2 "$PROG: Error: international files not found!"
+	exit 1
+fi
+
+exit 0
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/pootle.git/commitdiff/e30776630c87e8b49d133895dccd5b4a9427ea7b



More information about the pld-cvs-commit mailing list