From 6b8099f31d5c6d8cc64e7ed242073c4807d74421 Mon Sep 17 00:00:00 2001 From: Davide Madrisan Date: Fri, 30 Nov 2012 22:02:42 +0100 Subject: [PATCH] libtranslate.lib: new library Signed-off-by: Davide Madrisan --- ChangeLog | 9 +++++++++ lib/Makefile | 2 +- lib/libapse.lib.in | 2 ++ lib/libcfg.lib.in | 11 ++++++----- lib/libmsgmng.lib.in | 11 ++++++----- lib/libnetwork.lib.in | 11 +++++------ lib/libspec.lib.in | 11 ++++++----- lib/libtest.lib.in | 11 +++++------ lib/libtranslate.lib.in | 19 +++++++++++++++++++ plugins/config-getvar.in | 9 ++++----- plugins/pck-extract.in | 9 ++++----- plugins/pck-update.in | 9 ++++----- plugins/spec-create.in | 9 ++++----- tests/test00_specsyntax.in | 11 ++++++----- tests/test01_pkgquality.in | 11 ++++++----- tests/test02_pkgsecurity.in | 11 ++++++----- 16 files changed, 93 insertions(+), 63 deletions(-) create mode 100644 lib/libtranslate.lib.in diff --git a/ChangeLog b/ChangeLog index ba75d89..fa5dfd3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -18,6 +18,15 @@ Changes in version 1.16.1 The variables PO_COPYRIGH_HOLDER and PO_BUGS_ADDRESS are no longer required. Remove them. ++ update + * lib/libtranslate.lib - Davide Madrisan: + New library libtranslate.lib. + ++ update + * lib/*, plugins/*, tests/* - Davide Madrisan: + Use libtranslate.lib instead of duplicate the code in every library, + plugin, and test module. + ------------------------------------------------------------------------------- Changes in version 1.16.0 diff --git a/lib/Makefile b/lib/Makefile index 4f8e340..44abe7b 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -19,7 +19,7 @@ srcdir = .. include $(srcdir)/Makefile.env pck_libs := libapse.lib libcfg.lib libmsgmng.lib libnetwork.lib libspec.lib \ - libtest.lib + libtest.lib libtranslate.lib pck_libs_infiles := $(wildcard *.in) pck_libs_all := $(pck_libs) README.API diff --git a/lib/libapse.lib.in b/lib/libapse.lib.in index b8ce9e3..2fb1a25 100644 --- a/lib/libapse.lib.in +++ b/lib/libapse.lib.in @@ -9,6 +9,8 @@ libapse_is_loaded=1 [ -z "$BASH" ] || [ ${BASH_VERSION:0:1} -lt 2 ] && echo $"this script requires bash version 2 or better" >&2 && exit 1 +me=("libapse.lib" "@version@" "@date@") + [ -r @libdir@/libmsgmng.lib ] || { echo "$me: "$"library not found"": @libdir@/libmsgmng.lib" 1>&2 exit 1; } diff --git a/lib/libcfg.lib.in b/lib/libcfg.lib.in index 1d64a57..ac66a08 100644 --- a/lib/libcfg.lib.in +++ b/lib/libcfg.lib.in @@ -8,16 +8,17 @@ libcfg_is_loaded=1 [ -z "$BASH" ] || [ ${BASH_VERSION:0:1} -lt 2 ] && echo $"this script requires bash version 2 or better" >&2 && exit 1 +me=("libcfg.lib" "@version@" "@date@") + [ -r @libdir@/libmsgmng.lib ] || { echo "$me: "$"library not found"": @libdir@/libmsgmng.lib" 1>&2 exit 1; } . @libdir@/libmsgmng.lib -if [[ -z "$LANG" && -r /etc/sysconfig/i18n ]]; then - . /etc/sysconfig/i18n - [ "$LANG" ] && export LANG -fi -TEXTDOMAIN="@package@"; export TEXTDOMAIN +[ -r @libdir@/libtranslate.lib ] || + { echo "$me: "$"library not found"": @libdir@/libtranslate.lib" 1>&2 + exit 1; } +. @libdir@/libtranslate.lib # list of the configuration file(s) default_cfg_list=(\ diff --git a/lib/libmsgmng.lib.in b/lib/libmsgmng.lib.in index 7ee2a8b..48c422d 100644 --- a/lib/libmsgmng.lib.in +++ b/lib/libmsgmng.lib.in @@ -8,11 +8,12 @@ libmsgmng_is_loaded=1 [ -z "$BASH" ] || [ ${BASH_VERSION:0:1} -lt 2 ] && echo $"this script requires bash version 2 or better" >&2 && exit 1 -if [[ -z "$LANG" && -r /etc/sysconfig/i18n ]]; then - . /etc/sysconfig/i18n - [ "$LANG" ] && export LANG -fi -TEXTDOMAIN="@package@"; export TEXTDOMAIN +me=("libmsgmng.lib" "@version@" "@date@") + +[ -r @libdir@/libtranslate.lib ] || + { echo "$me: "$"library not found"": @libdir@/libtranslate.lib" 1>&2 + exit 1; } +. @libdir@/libtranslate.lib # notify family of message handling functions: # - notify.warning diff --git a/lib/libnetwork.lib.in b/lib/libnetwork.lib.in index 67f534a..6c73b6a 100644 --- a/lib/libnetwork.lib.in +++ b/lib/libnetwork.lib.in @@ -8,18 +8,17 @@ libnetwork_is_loaded=1 [ -z "$BASH" ] || [ ${BASH_VERSION:0:1} -lt 3 ] && { echo $"this script requires bash version 3 or better" >&2 && exit 1; } -me=(${0##*/} "@version@" "@date@") +me=("libnetwork.lib" "@version@" "@date@") [ -r @libdir@/libmsgmng.lib ] || { echo "$me: "$"library not found"": @libdir@/libmsgmng.lib" 1>&2 exit 1; } . @libdir@/libmsgmng.lib -if [[ -z "$LANG" && -r /etc/sysconfig/i18n ]]; then - . /etc/sysconfig/i18n - [ "$LANG" ] && export LANG -fi -TEXTDOMAIN="@package@"; export TEXTDOMAIN +[ -r @libdir@/libtranslate.lib ] || + { echo "$me: "$"library not found"": @libdir@/libtranslate.lib" 1>&2 + exit 1; } +. @libdir@/libtranslate.lib # check if all the needed tools are available # note: 'host' has been removed from this list because the package diff --git a/lib/libspec.lib.in b/lib/libspec.lib.in index 31db22b..bc7c1b8 100644 --- a/lib/libspec.lib.in +++ b/lib/libspec.lib.in @@ -8,16 +8,17 @@ libspec_is_loaded=1 [ -z "$BASH" ] || [ ${BASH_VERSION:0:1} -lt 2 ] && echo $"this script requires bash version 2 or better" >&2 && exit 1 +me=("libspec.lib" "@version@" "@date@") + [ -r @libdir@/libmsgmng.lib ] || { echo "$me: "$"library not found"": @libdir@/libmsgmng.lib" 1>&2 exit 1; } . @libdir@/libmsgmng.lib -if [[ -z "$LANG" && -r /etc/sysconfig/i18n ]]; then - . /etc/sysconfig/i18n - [ "$LANG" ] && export LANG -fi -TEXTDOMAIN="@package@"; export TEXTDOMAIN +[ -r @libdir@/libtranslate.lib ] || + { echo "$me: "$"library not found"": @libdir@/libtranslate.lib" 1>&2 + exit 1; } +. @libdir@/libtranslate.lib # function boolexpr.solve # calculate the boolean expression `$1' expanding the variables diff --git a/lib/libtest.lib.in b/lib/libtest.lib.in index 4f14693..305035e 100644 --- a/lib/libtest.lib.in +++ b/lib/libtest.lib.in @@ -8,18 +8,17 @@ libtest_is_loaded=1 [ -z "$BASH" ] || [ ${BASH_VERSION:0:1} -lt 3 ] && { echo $"this script requires bash version 3 or better" >&2 && exit 1; } -me=(${0##*/} "@version@" "@date@") +me=("libtest.lib" "@version@" "@date@") [ -r @libdir@/libmsgmng.lib ] || { echo "$me: "$"library not found"": @libdir@/libmsgmng.lib" 1>&2 exit 1; } . @libdir@/libmsgmng.lib -if [[ -z "$LANG" && -r /etc/sysconfig/i18n ]]; then - . /etc/sysconfig/i18n - [ "$LANG" ] && export LANG -fi -TEXTDOMAIN="@package@"; export TEXTDOMAIN +[ -r @libdir@/libtranslate.lib ] || + { echo "$me: "$"library not found"": @libdir@/libtranslate.lib" 1>&2 + exit 1; } +. @libdir@/libtranslate.lib [ -n "$testdir" ] || notify.error "\`testdir': "$"unset in the configuration files" diff --git a/lib/libtranslate.lib.in b/lib/libtranslate.lib.in new file mode 100644 index 0000000..522095b --- /dev/null +++ b/lib/libtranslate.lib.in @@ -0,0 +1,19 @@ +#!/bin/bash +# libtranslate.lib -- @package@ library used to setup translations +# Copyright (C) 2012 Davide Madrisan + +[ "$libtranslate_is_loaded" = 1 ] || { +libtest_is_loaded=1 + +[ -z "$BASH" ] || [ ${BASH_VERSION:0:1} -lt 2 ] && + { echo $"this script requires bash version 2 or better" >&2 && exit 1; } + +me=("libtranslate.lib" "@version@" "@date@") + +if [[ -z "$LANG" && -r /etc/sysconfig/i18n ]]; then + . /etc/sysconfig/i18n + [ "$LANG" ] && export LANG +fi +TEXTDOMAIN="@package@"; export TEXTDOMAIN + +} # endif $libtranslate_is_loaded diff --git a/plugins/config-getvar.in b/plugins/config-getvar.in index dc0da28..cec9a12 100644 --- a/plugins/config-getvar.in +++ b/plugins/config-getvar.in @@ -22,11 +22,10 @@ let "verbose = 1" exit 1; } . @libdir@/libcfg.lib -if [[ -z "$LANG" && -r /etc/sysconfig/i18n ]]; then - . /etc/sysconfig/i18n - [ "$LANG" ] && export LANG -fi -TEXTDOMAIN="@package@"; export TEXTDOMAIN +[ -r @libdir@/libtranslate.lib ] || + { echo "$me: "$"library not found"": @libdir@/libtranslate.lib" 1>&2 + exit 1; } +. @libdir@/libtranslate.lib function copying() { echo "\ diff --git a/plugins/pck-extract.in b/plugins/pck-extract.in index 0aa895c..e93bb87 100644 --- a/plugins/pck-extract.in +++ b/plugins/pck-extract.in @@ -27,11 +27,10 @@ let "verbose = 1" exit 1; } . @libdir@/libnetwork.lib -if [[ -z "$LANG" && -r /etc/sysconfig/i18n ]]; then - . /etc/sysconfig/i18n - [ "$LANG" ] && export LANG -fi -TEXTDOMAIN="@package@"; export TEXTDOMAIN +[ -r @libdir@/libtranslate.lib ] || + { echo "$me: "$"library not found"": @libdir@/libtranslate.lib" 1>&2 + exit 1; } +. @libdir@/libtranslate.lib function copying() { echo "\ diff --git a/plugins/pck-update.in b/plugins/pck-update.in index 7bd3a40..8a06dd6 100644 --- a/plugins/pck-update.in +++ b/plugins/pck-update.in @@ -64,11 +64,10 @@ unset ignore_test_list exit 1; } . @libdir@/libcfg.lib -if [[ -z "$LANG" && -r /etc/sysconfig/i18n ]]; then - . /etc/sysconfig/i18n - [ "$LANG" ] && export LANG -fi -TEXTDOMAIN="@package@"; export TEXTDOMAIN +[ -r @libdir@/libtranslate.lib ] || + { echo "$me: "$"library not found"": @libdir@/libtranslate.lib" 1>&2 + exit 1; } +. @libdir@/libtranslate.lib function copying() { echo "\ diff --git a/plugins/spec-create.in b/plugins/spec-create.in index 0d0d03b..c82ad22 100644 --- a/plugins/spec-create.in +++ b/plugins/spec-create.in @@ -66,11 +66,10 @@ preserve_dot_git=0 exit 1; } . @libdir@/libcfg.lib -if [[ -z "$LANG" && -r /etc/sysconfig/i18n ]]; then - . /etc/sysconfig/i18n - [ "$LANG" ] && export LANG -fi -TEXTDOMAIN="@package@"; export TEXTDOMAIN +[ -r @libdir@/libtranslate.lib ] || + { echo "$me: "$"library not found"": @libdir@/libtranslate.lib" 1>&2 + exit 1; } +. @libdir@/libtranslate.lib function copying() { echo "\ diff --git a/tests/test00_specsyntax.in b/tests/test00_specsyntax.in index af3e629..120cf03 100644 --- a/tests/test00_specsyntax.in +++ b/tests/test00_specsyntax.in @@ -5,17 +5,18 @@ [ -z "$BASH" ] || [ ${BASH_VERSION:0:1} -lt 2 ] && echo $"this script requires bash version 2 or better" >&2 && exit 1 +me=("test00_specsyntax" "@version@" "@date@") + [ -r @libdir@/libmsgmng.lib ] || { echo "$me: "$"library not found"": @libdir@/libmsgmng.lib" 1>&2 exit 1; } . @libdir@/libmsgmng.lib -if [[ -z "$LANG" && -r /etc/sysconfig/i18n ]]; then - . /etc/sysconfig/i18n - [ "$LANG" ] && export LANG -fi -TEXTDOMAIN="@package@"; export TEXTDOMAIN +[ -r @libdir@/libtranslate.lib ] || + { echo "$me: "$"library not found"": @libdir@/libtranslate.lib" 1>&2 + exit 1; } +. @libdir@/libtranslate.lib # check if all the needed tools are available for tool in cat file getopt grep sed; do diff --git a/tests/test01_pkgquality.in b/tests/test01_pkgquality.in index d7352f1..13848c5 100644 --- a/tests/test01_pkgquality.in +++ b/tests/test01_pkgquality.in @@ -5,17 +5,18 @@ [ -z "$BASH" ] || [ ${BASH_VERSION:0:1} -lt 2 ] && echo $"this script requires bash version 2 or better" >&2 && exit 1 +me=("test01_pkgquality" "@version@" "@date@") + [ -r @libdir@/libmsgmng.lib ] || { echo "$me: "$"library not found"": @libdir@/libmsgmng.lib" 1>&2 exit 1; } . @libdir@/libmsgmng.lib -if [[ -z "$LANG" && -r /etc/sysconfig/i18n ]]; then - . /etc/sysconfig/i18n - [ "$LANG" ] && export LANG -fi -TEXTDOMAIN="@package@"; export TEXTDOMAIN +[ -r @libdir@/libtranslate.lib ] || + { echo "$me: "$"library not found"": @libdir@/libtranslate.lib" 1>&2 + exit 1; } +. @libdir@/libtranslate.lib # check if all the needed tools are available for tool in file find getopt grep ls ldd; do diff --git a/tests/test02_pkgsecurity.in b/tests/test02_pkgsecurity.in index 3ac19aa..6bff201 100644 --- a/tests/test02_pkgsecurity.in +++ b/tests/test02_pkgsecurity.in @@ -5,17 +5,18 @@ [ -z "$BASH" ] || [ ${BASH_VERSION:0:1} -lt 2 ] && echo $"this script requires bash version 2 or better" >&2 && exit 1 +me=("test02_pkgsecurity" "@version@" "@date@") + [ -r @libdir@/libmsgmng.lib ] || { echo "$me: "$"library not found"": @libdir@/libmsgmng.lib" 1>&2 exit 1; } . @libdir@/libmsgmng.lib -if [[ -z "$LANG" && -r /etc/sysconfig/i18n ]]; then - . /etc/sysconfig/i18n - [ "$LANG" ] && export LANG -fi -TEXTDOMAIN="@package@"; export TEXTDOMAIN +[ -r @libdir@/libtranslate.lib ] || + { echo "$me: "$"library not found"": @libdir@/libtranslate.lib" 1>&2 + exit 1; } +. @libdir@/libtranslate.lib # check if all the needed tools are available for tool in file find getopt grep objdump sed; do