[libvirt] Remove bashisms from libvirt-guests

Hi, The attached patch removes bashisms from libvirt-guests. TEXTDOMAINDIR is not specified, so system default will be used ("/usr/share/locale" on Debian, I don't know if it's the same on Fedora). "xgettext -L Shell" output is the same with gettext shell functions as with $"..." deprecated Bash-specific syntax. Please generate po files somewhere in the source tree. Thank you, -- Laurent Léonard

On 12/17/2010 04:09 AM, Laurent Léonard wrote:
Hi,
The attached patch removes bashisms from libvirt-guests.
TEXTDOMAINDIR is not specified, so system default will be used ("/usr/share/locale" on Debian, I don't know if it's the same on Fedora).
Hmm; that should be derived from one of the autoconf-provided installation directory names; I'll look more into the correct value to use (that is, it should line up with whatever ./configure --prefix=... you used, by using some form of @prefix@ in the .in version of the script). For example, see how we set $sysconfdir.
"xgettext -L Shell" output is the same with gettext shell functions as with $"..." deprecated Bash-specific syntax.
Please generate po files somewhere in the source tree.
That's just a matter of modifying po/POTFILES.in to recognize that our init scripts have translatable strings.
+++ b/tools/libvirt-guests.init.in @@ -31,6 +31,11 @@ libvirtd=@sbindir@/libvirtd # Source function library. . "$sysconfdir"/rc.d/init.d/functions
+. gettext.sh
Must be specified as an absolute path, to avoid accidentally sourcing a trojan script.
+ +TEXTDOMAIN=libvirt-guests +export TEXTDOMAIN
We can assume POSIX sh here, and do this on one line instead of two. And the domain should be libvirt, rather than libvirt-guests (that is, share the same .mo files as the rest of libvirt).
if [ "x$ON_BOOT" != xstart ]; then - echo $"libvirt-guests is configured not to start any guests on boot" + gettext "libvirt-guests is configured not to start any guests on boot"; echo
So gettext(1) doesn't output a trailing newline? Okay.
name=$(guest_name $uri $guest) - label=$"Suspending $name: " + label="`eval_gettext \"Suspending \\$name: \"`"
Assume a POSIX sh; we do NOT want to use `` in this script, and the outer "" are not necessary in assignment context. This is much more legible as: label=$(eval_gettext "Suspending \$name: ")
echo -n "$label" run_virsh $uri managedsave $guest >/dev/null & virsh_pid=$! @@ -187,7 +192,7 @@ suspend_guest() printf '\r%s%-12s ' "$label" "..." fi done - retval wait $virsh_pid && printf '\r%s%-12s\n' "$label" $"done" + retval wait $virsh_pid && printf '\r%s%-12s\n' "$label" "`gettext \"done\"`"
Likewise: "$(gettext "done")" But thanks for taking this on; we're getting closer to a nice solution. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

Le vendredi 17 décembre 2010 15:08:44, Eric Blake a écrit :
On 12/17/2010 04:09 AM, Laurent Léonard wrote:
Hi,
The attached patch removes bashisms from libvirt-guests.
TEXTDOMAINDIR is not specified, so system default will be used ("/usr/share/locale" on Debian, I don't know if it's the same on Fedora).
Hmm; that should be derived from one of the autoconf-provided installation directory names; I'll look more into the correct value to use (that is, it should line up with whatever ./configure --prefix=... you used, by using some form of @prefix@ in the .in version of the script). For example, see how we set $sysconfdir.
"xgettext -L Shell" output is the same with gettext shell functions as with $"..." deprecated Bash-specific syntax.
Please generate po files somewhere in the source tree.
That's just a matter of modifying po/POTFILES.in to recognize that our init scripts have translatable strings.
+++ b/tools/libvirt-guests.init.in @@ -31,6 +31,11 @@ libvirtd=@sbindir@/libvirtd
# Source function library. . "$sysconfdir"/rc.d/init.d/functions
+. gettext.sh
Must be specified as an absolute path, to avoid accidentally sourcing a trojan script.
+ +TEXTDOMAIN=libvirt-guests +export TEXTDOMAIN
We can assume POSIX sh here, and do this on one line instead of two. And the domain should be libvirt, rather than libvirt-guests (that is, share the same .mo files as the rest of libvirt).
if [ "x$ON_BOOT" != xstart ]; then
- echo $"libvirt-guests is configured not to start any guests on boot" + gettext "libvirt-guests is configured not to start any guests on boot"; echo
So gettext(1) doesn't output a trailing newline? Okay.
name=$(guest_name $uri $guest)
- label=$"Suspending $name: " + label="`eval_gettext \"Suspending \\$name: \"`"
Assume a POSIX sh; we do NOT want to use `` in this script, and the outer "" are not necessary in assignment context. This is much more legible as:
label=$(eval_gettext "Suspending \$name: ")
echo -n "$label" run_virsh $uri managedsave $guest >/dev/null & virsh_pid=$!
@@ -187,7 +192,7 @@ suspend_guest()
printf '\r%s%-12s ' "$label" "..."
fi
done
- retval wait $virsh_pid && printf '\r%s%-12s\n' "$label" $"done" + retval wait $virsh_pid && printf '\r%s%-12s\n' "$label" "`gettext \"done\"`"
Likewise: "$(gettext "done")"
But thanks for taking this on; we're getting closer to a nice solution.
I followed: http://www.gnu.org/software/hello/manual/gettext/Preparing-Shell-Scripts.htm... but totally agree with your comments. Indeed gettext(1) doesn't output a trailing newline. Don't forget the - timeout=$[timeout - 1] + timeout=$((timeout - 1)) I also added in the "Remove bashisms" patch, if you did'nt noticed it. Thank you, -- Laurent Léonard

On 12/18/2010 04:51 AM, Laurent Léonard wrote:
- retval wait $virsh_pid && printf '\r%s%-12s\n' "$label" $"done" + retval wait $virsh_pid && printf '\r%s%-12s\n' "$label" "`gettext \"done\"`"
Likewise: "$(gettext "done")"
But thanks for taking this on; we're getting closer to a nice solution.
I followed: http://www.gnu.org/software/hello/manual/gettext/Preparing-Shell-Scripts.htm... but totally agree with your comments.
The gettext manual assumes that you are trying to be portable to all sorts of /bin/sh, including Solaris's horribly-dated version that lacks lots of POSIX features, hence it uses `` instead of $(). But for a Linux init script, we can safely assume a decent POSIX shell. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

Le lundi 20 décembre 2010 17:01:14, Eric Blake a écrit :
On 12/18/2010 04:51 AM, Laurent Léonard wrote:
- retval wait $virsh_pid && printf '\r%s%-12s\n' "$label" $"done" + retval wait $virsh_pid && printf '\r%s%-12s\n' "$label" "`gettext \"done\"`"
Likewise: "$(gettext "done")"
But thanks for taking this on; we're getting closer to a nice solution.
I followed: http://www.gnu.org/software/hello/manual/gettext/Preparing-Shell-Scripts. html but totally agree with your comments.
The gettext manual assumes that you are trying to be portable to all sorts of /bin/sh, including Solaris's horribly-dated version that lacks lots of POSIX features, hence it uses `` instead of $(). But for a Linux init script, we can safely assume a decent POSIX shell.
Any news about fixing those bashisms ? Thank you, -- Laurent Léonard

On 12/25/2010 12:44 PM, Laurent Léonard wrote:
Le lundi 20 décembre 2010 17:01:14, Eric Blake a écrit :
On 12/18/2010 04:51 AM, Laurent Léonard wrote:
- retval wait $virsh_pid && printf '\r%s%-12s\n' "$label" $"done" + retval wait $virsh_pid && printf '\r%s%-12s\n' "$label" "`gettext \"done\"`"
Likewise: "$(gettext "done")"
But thanks for taking this on; we're getting closer to a nice solution.
I followed: http://www.gnu.org/software/hello/manual/gettext/Preparing-Shell-Scripts. html but totally agree with your comments.
The gettext manual assumes that you are trying to be portable to all sorts of /bin/sh, including Solaris's horribly-dated version that lacks lots of POSIX features, hence it uses `` instead of $(). But for a Linux init script, we can safely assume a decent POSIX shell.
Any news about fixing those bashisms ?
I'm in favor of the ideas, but the patch isn't quite polished yet. I've been a bit short on time to clean the patch up myself, and was hoping you would be willing to submit another version based on my comments from the previous round. But given the current goal of releasing 0.8.7 in the very near future, I'm afraid this has missed the release deadline and you will have to maintain it as a backport for another release cycle. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

Le lundi 03 janvier 2011 22:35:48, Eric Blake a écrit :
On 12/25/2010 12:44 PM, Laurent Léonard wrote:
Le lundi 20 décembre 2010 17:01:14, Eric Blake a écrit :
On 12/18/2010 04:51 AM, Laurent Léonard wrote:
- retval wait $virsh_pid && printf '\r%s%-12s\n' "$label" $"done" + retval wait $virsh_pid && printf '\r%s%-12s\n' "$label" "`gettext \"done\"`"
Likewise: "$(gettext "done")"
But thanks for taking this on; we're getting closer to a nice solution.
I followed: http://www.gnu.org/software/hello/manual/gettext/Preparing-Shell-Script s. html but totally agree with your comments.
The gettext manual assumes that you are trying to be portable to all sorts of /bin/sh, including Solaris's horribly-dated version that lacks lots of POSIX features, hence it uses `` instead of $(). But for a Linux init script, we can safely assume a decent POSIX shell.
Any news about fixing those bashisms ?
I'm in favor of the ideas, but the patch isn't quite polished yet. I've been a bit short on time to clean the patch up myself, and was hoping you would be willing to submit another version based on my comments from the previous round. But given the current goal of releasing 0.8.7 in the very near future, I'm afraid this has missed the release deadline and you will have to maintain it as a backport for another release cycle.
The attached patch should match with your comments. Thank you, -- Laurent Léonard

On 01/04/2011 11:13 AM, Laurent Léonard wrote:
The attached patch should match with your comments.
Thank you,
Thank you for the work.
+++ b/tools/Makefile.am @@ -146,6 +146,9 @@ BUILT_SOURCES += libvirt-guests.init
libvirt-guests.init: libvirt-guests.init.in $(top_builddir)/config.status $(AM_V_GEN)sed \ + -e s!\@PACKAGE\@!@PACKAGE@!g \ + -e s!\@bindir\@!@bindir@!g \ + -e s!\@localedir\@!@localedir@!g \
Phooey - 'make syntax-check' doesn't like this. Changing it to $(PACKAGE) instead of @PACKAGE@ solved that, though. And in the process, I added better makefile quoting, to avoid other (unlikely) issues with spaces in $(bindir), for example. I also had to add a comment with the string _("dummy") in it in order to keep 'make syntax-check' happy on sc_po_check (otherwise it complained about adding libvirt-guests.init.in to POTFILES.in).
+++ b/tools/libvirt-guests.init.in @@ -32,6 +32,13 @@ libvirtd=@sbindir@/libvirtd test ! -r "$sysconfdir"/rc.d/init.d/functions || . "$sysconfdir"/rc.d/init.d/functions
+. @bindir@/gettext.sh
Just to be safe in case @bindir@ contains spaces, I'm changing this to: . "@bindir@"/gettext.sh
+ +TEXTDOMAIN=@PACKAGE@ +export TEXTDOMAIN
POSIX requires the shorter form to work, plus more quoting for safety: export TEXTDOMAIN="@PACKAGE@"
@@ -173,7 +180,7 @@ suspend_guest() guest=$2
name=$(guest_name $uri $guest) - label=$"Suspending $name: " + label=$(eval_gettext "Suspending \$name: ") echo -n "$label"
'echo -n' is a bash-ism (and worse, a non-portable bash-ism, since 'shopt -s xpg_echo' disables it). I've replaced all 'echo -n' with 'printf %s'.
@@ -226,7 +233,7 @@ stop() { if [ "x$ON_SHUTDOWN" = xshutdown ]; then suspending=false if [ $SHUTDOWN_TIMEOUT -le 0 ]; then - echo $"Shutdown action requested but SHUTDOWN_TIMEOUT was not set" + gettext "Shutdown action requested but SHUTDOWN_TIMEOUT was not set"; echo
I also broke up some lines where your patch made things go longer than 80 columns.
@@ -305,7 +312,8 @@ rh_status() { # usage [val] # Display usage string, then exit with VAL (defaults to 2). usage() { - echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|gueststatus|shutdown}" + program_name=$0 + eval_gettext "Usage: \$program_name {start|stop|status|restart|condrestart|try-restart|reload|force-reload|gueststatus|shutdown}"; echo
this one was already longer than 80 columns, but I broke it up as well. Here's what I'm planning on squashing in. However, I still have one nagging problem, that I haven't been able to figure out yet - even though we listed libvirt-guests.init.in in po/POTFILES.in, xgettext doesn't seem to be picking it up into po/libvirt.pot. So until I can figure that out, I'm holding off on pushing this just a bit longer. diff --git i/tools/Makefile.am w/tools/Makefile.am index de5f662..87cf9bd 100644 --- i/tools/Makefile.am +++ w/tools/Makefile.am @@ -146,12 +146,12 @@ BUILT_SOURCES += libvirt-guests.init libvirt-guests.init: libvirt-guests.init.in $(top_builddir)/config.status $(AM_V_GEN)sed \ - -e s!\@PACKAGE\@!@PACKAGE@!g \ - -e s!\@bindir\@!@bindir@!g \ - -e s!\@localedir\@!@localedir@!g \ - -e s!\@localstatedir\@!@localstatedir@!g \ - -e s!\@sbindir\@!@sbindir@!g \ - -e s!\@sysconfdir\@!@sysconfdir@!g \ + -e 's!\@PACKAGE\@!$(PACKAGE)!g' \ + -e 's!\@bindir\@!$(bindir)!g' \ + -e 's!\@localedir\@!$(localedir)!g' \ + -e 's!\@localstatedir\@!$(localstatedir)!g' \ + -e 's!\@sbindir\@!$(sbindir)!g' \ + -e 's!\@sysconfdir\@!$(sysconfdir)!g' \ < $< > $@-t && \ chmod a+x $@-t && \ mv $@-t $@ diff --git i/tools/libvirt-guests.init.in w/tools/libvirt-guests.init.in index ea404b7..8823d06 100644 --- i/tools/libvirt-guests.init.in +++ w/tools/libvirt-guests.init.in @@ -24,27 +24,27 @@ # See http://libvirt.org # -sysconfdir=@sysconfdir@ -localstatedir=@localstatedir@ -libvirtd=@sbindir@/libvirtd +sysconfdir="@sysconfdir@" +localstatedir="@localstatedir@" +libvirtd="@sbindir@"/libvirtd # Source function library. test ! -r "$sysconfdir"/rc.d/init.d/functions || - . "$sysconfdir"/rc.d/init.d/functions + . "$sysconfdir"/rc.d/init.d/functions -. @bindir@/gettext.sh +# Source gettext library. +# Make sure this file is recognized as having translations: _("dummy") +. "@bindir@"/gettext.sh -TEXTDOMAIN=@PACKAGE@ -export TEXTDOMAIN -TEXTDOMAINDIR=@localedir@ -export TEXTDOMAINDIR +export TEXTDOMAIN="@PACKAGE@" TEXTDOMAINDIR="@localedir@" URIS=default ON_BOOT=start ON_SHUTDOWN=suspend SHUTDOWN_TIMEOUT=0 -test -f "$sysconfdir"/sysconfig/libvirt-guests && . "$sysconfdir"/sysconfig/libvirt-guests +test -f "$sysconfdir"/sysconfig/libvirt-guests && + . "$sysconfdir"/sysconfig/libvirt-guests LISTFILE="$localstatedir"/lib/libvirt/libvirt-guests VAR_SUBSYS_LIBVIRT_GUESTS="$localstatedir"/lock/subsys/libvirt-guests @@ -136,7 +136,8 @@ start() { [ -f "$LISTFILE" ] || { started; return 0; } if [ "x$ON_BOOT" != xstart ]; then - gettext "libvirt-guests is configured not to start any guests on boot"; echo + gettext "libvirt-guests is configured not to start any guests on boot" + echo rm -f "$LISTFILE" started return 0 @@ -181,7 +182,7 @@ suspend_guest() name=$(guest_name $uri $guest) label=$(eval_gettext "Suspending \$name: ") - echo -n "$label" + printf %s "$label" run_virsh $uri managedsave $guest >/dev/null & virsh_pid=$! while true; do @@ -205,7 +206,7 @@ shutdown_guest() name=$(guest_name $uri $guest) label=$(eval_gettext "Shutting down \$name: ") - echo -n "$label" + printf %s "$label" retval run_virsh $uri shutdown $guest >/dev/null || return timeout=$SHUTDOWN_TIMEOUT while [ $timeout -gt 0 ]; do @@ -218,7 +219,8 @@ shutdown_guest() if guest_is_on $uri $guest; then if $guest_running; then - printf '\r%s%-12s\n' "$label" "$(gettext "failed to shutdown in time")" + printf '\r%s%-12s\n' "$label" \ + "$(gettext "failed to shutdown in time")" else printf '\r%s%-12s\n' "$label" "$(gettext "done")" fi @@ -233,7 +235,8 @@ stop() { if [ "x$ON_SHUTDOWN" = xshutdown ]; then suspending=false if [ $SHUTDOWN_TIMEOUT -le 0 ]; then - gettext "Shutdown action requested but SHUTDOWN_TIMEOUT was not set"; echo + gettext "Shutdown action requested but SHUTDOWN_TIMEOUT was not set" + echo RETVAL=6 return fi @@ -253,7 +256,7 @@ stop() { empty=true for uuid in $list; do $empty || printf ", " - echo -n $(guest_name $uri $uuid) + printf %s "$(guest_name $uri $uuid)" empty=false done if $empty; then @@ -313,7 +316,8 @@ rh_status() { # Display usage string, then exit with VAL (defaults to 2). usage() { program_name=$0 - eval_gettext "Usage: \$program_name {start|stop|status|restart|condrestart|try-restart|reload|force-reload|gueststatus|shutdown}"; echo + eval_gettext "Usage: \$program_name {start|stop|status|restart|"\ +"condrestart|try-restart|reload|force-reload|gueststatus|shutdown}"; echo exit ${1-2} } -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

Le mardi 04 janvier 2011 22:42:15, Eric Blake a écrit :
On 01/04/2011 11:13 AM, Laurent Léonard wrote:
The attached patch should match with your comments.
Thank you,
Thank you for the work.
+++ b/tools/Makefile.am @@ -146,6 +146,9 @@ BUILT_SOURCES += libvirt-guests.init
libvirt-guests.init: libvirt-guests.init.in $(top_builddir)/config.status
$(AM_V_GEN)sed \
+ -e s!\@PACKAGE\@!@PACKAGE@!g \ + -e s!\@bindir\@!@bindir@!g \ + -e s!\@localedir\@!@localedir@!g \
Phooey - 'make syntax-check' doesn't like this. Changing it to $(PACKAGE) instead of @PACKAGE@ solved that, though. And in the process, I added better makefile quoting, to avoid other (unlikely) issues with spaces in $(bindir), for example.
I also had to add a comment with the string _("dummy") in it in order to keep 'make syntax-check' happy on sc_po_check (otherwise it complained about adding libvirt-guests.init.in to POTFILES.in).
+++ b/tools/libvirt-guests.init.in @@ -32,6 +32,13 @@ libvirtd=@sbindir@/libvirtd
test ! -r "$sysconfdir"/rc.d/init.d/functions ||
. "$sysconfdir"/rc.d/init.d/functions
+. @bindir@/gettext.sh
Just to be safe in case @bindir@ contains spaces, I'm changing this to:
. "@bindir@"/gettext.sh
+ +TEXTDOMAIN=@PACKAGE@ +export TEXTDOMAIN
POSIX requires the shorter form to work, plus more quoting for safety:
export TEXTDOMAIN="@PACKAGE@"
@@ -173,7 +180,7 @@ suspend_guest()
guest=$2
name=$(guest_name $uri $guest)
- label=$"Suspending $name: " + label=$(eval_gettext "Suspending \$name: ")
echo -n "$label"
'echo -n' is a bash-ism (and worse, a non-portable bash-ism, since 'shopt -s xpg_echo' disables it). I've replaced all 'echo -n' with 'printf %s'.
@@ -226,7 +233,7 @@ stop() {
if [ "x$ON_SHUTDOWN" = xshutdown ]; then
suspending=false if [ $SHUTDOWN_TIMEOUT -le 0 ]; then
- echo $"Shutdown action requested but SHUTDOWN_TIMEOUT was not set" + gettext "Shutdown action requested but SHUTDOWN_TIMEOUT was not set"; echo
I also broke up some lines where your patch made things go longer than 80 columns.
@@ -305,7 +312,8 @@ rh_status() {
# usage [val] # Display usage string, then exit with VAL (defaults to 2). usage() {
- echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|g ueststatus|shutdown}" + program_name=$0 + eval_gettext "Usage: \$program_name {start|stop|status|restart|condrestart|try-restart|reload|force-reload|g ueststatus|shutdown}"; echo
this one was already longer than 80 columns, but I broke it up as well.
Here's what I'm planning on squashing in. However, I still have one nagging problem, that I haven't been able to figure out yet - even though we listed libvirt-guests.init.in in po/POTFILES.in, xgettext doesn't seem to be picking it up into po/libvirt.pot. So until I can figure that out, I'm holding off on pushing this just a bit longer.
Can you tell me what command line you are using to call xgettext ? "xgettext -L Shell -o - tools/libvirt-guests.init.in" works fine. Thank you, -- Laurent Léonard

On 01/04/2011 04:50 PM, Laurent Léonard wrote:
Here's what I'm planning on squashing in. However, I still have one nagging problem, that I haven't been able to figure out yet - even though we listed libvirt-guests.init.in in po/POTFILES.in, xgettext doesn't seem to be picking it up into po/libvirt.pot. So until I can figure that out, I'm holding off on pushing this just a bit longer.
Can you tell me what command line you are using to call xgettext ?
"xgettext -L Shell -o - tools/libvirt-guests.init.in" works fine.
Whatever command line is being produced automatically by the autotools. 'make -B -C po libvirt.pot' shows it to be: /usr/bin/xgettext --default-domain=libvirt --directory=.. \ --add-comments=TRANSLATORS: --keyword=_ --keyword=N_ --flag=_:1:pass-c-format --flag=N_:1:pass-c-format --flag=error:3:c-format --flag=error_at_line:5:c-format --flag=virAsprintf:2:c-format --from-code=UTF-8 ${end_of_xgettext_options+} \ --files-from=./POTFILES.in \ --copyright-holder='Red Hat, Inc.' \ --msgid-bugs-address='libvir-list@redhat.com' /usr/bin/xgettext: warning: file `tools/libvirt-guests.init.in' extension `init' is unknown; will try C Oh, that warning is a good hint. Maybe if we rename the file libvirt-guests.init.sh instead of .in, xgettext would be smart enough to auto-detect it as Shell. At which point, we'd have to tweak some Makefile rules. I'll play with that idea. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

Le mercredi 05 janvier 2011 01:17:23, Eric Blake a écrit :
On 01/04/2011 04:50 PM, Laurent Léonard wrote:
Here's what I'm planning on squashing in. However, I still have one nagging problem, that I haven't been able to figure out yet - even though we listed libvirt-guests.init.in in po/POTFILES.in, xgettext doesn't seem to be picking it up into po/libvirt.pot. So until I can figure that out, I'm holding off on pushing this just a bit longer.
Can you tell me what command line you are using to call xgettext ?
"xgettext -L Shell -o - tools/libvirt-guests.init.in" works fine.
Whatever command line is being produced automatically by the autotools. 'make -B -C po libvirt.pot' shows it to be:
/usr/bin/xgettext --default-domain=libvirt --directory=.. \ --add-comments=TRANSLATORS: --keyword=_ --keyword=N_ --flag=_:1:pass-c-format --flag=N_:1:pass-c-format --flag=error:3:c-format --flag=error_at_line:5:c-format --flag=virAsprintf:2:c-format --from-code=UTF-8 ${end_of_xgettext_options+} \ --files-from=./POTFILES.in \ --copyright-holder='Red Hat, Inc.' \ --msgid-bugs-address='libvir-list@redhat.com' /usr/bin/xgettext: warning: file `tools/libvirt-guests.init.in' extension `init' is unknown; will try C
Oh, that warning is a good hint. Maybe if we rename the file libvirt-guests.init.sh instead of .in, xgettext would be smart enough to auto-detect it as Shell. At which point, we'd have to tweak some Makefile rules. I'll play with that idea.
"xgettext -o - tools/libvirt-guests.init.in.sh" works fine so it should be a good idea if we can't specify the -L option to xgettext for this file. -- Laurent Léonard

* tools/libvirt-guests.init.in: Rename... * tools/libvirt-guests.init.sh: ...so that xgettext's language detection via suffix will work. * po/POTFILES.in: Update all references. * tools/Makefile.am (EXTRA_DIST, libvirt-guests.init): Likewise. ---
"xgettext -o - tools/libvirt-guests.init.in.sh" works fine so it should be a good idea if we can't specify the -L option to xgettext for this file.
Indeed - this patch, on top of my modifications to your patch made po/libvirt.pot pick up the translations. It feels a bit hackish, but it solves the problem (without having to wait for an upstream gettext solution to my feature request report: http://lists.gnu.org/archive/html/bug-gnu-utils/2011-01/msg00000.html) po/POTFILES.in | 2 +- tools/Makefile.am | 4 ++-- ...bvirt-guests.init.in => libvirt-guests.init.sh} | 0 3 files changed, 3 insertions(+), 3 deletions(-) rename tools/{libvirt-guests.init.in => libvirt-guests.init.sh} (100%) diff --git a/po/POTFILES.in b/po/POTFILES.in index 9d9a86f..cb7c772 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -118,5 +118,5 @@ src/xen/xs_internal.c src/xenapi/xenapi_driver.c src/xenapi/xenapi_utils.c tools/console.c -tools/libvirt-guests.init.in +tools/libvirt-guests.init.sh tools/virsh.c diff --git a/tools/Makefile.am b/tools/Makefile.am index 87cf9bd..f008078 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -13,7 +13,7 @@ EXTRA_DIST = \ virt-xml-validate.in \ virt-pki-validate.in \ virsh.pod \ - libvirt-guests.init.in \ + libvirt-guests.init.sh \ libvirt-guests.sysconf bin_SCRIPTS = virt-xml-validate virt-pki-validate @@ -144,7 +144,7 @@ uninstall-init: BUILT_SOURCES += libvirt-guests.init -libvirt-guests.init: libvirt-guests.init.in $(top_builddir)/config.status +libvirt-guests.init: libvirt-guests.init.sh $(top_builddir)/config.status $(AM_V_GEN)sed \ -e 's!\@PACKAGE\@!$(PACKAGE)!g' \ -e 's!\@bindir\@!$(bindir)!g' \ diff --git a/tools/libvirt-guests.init.in b/tools/libvirt-guests.init.sh similarity index 100% rename from tools/libvirt-guests.init.in rename to tools/libvirt-guests.init.sh -- 1.7.3.4
participants (2)
-
Eric Blake
-
Laurent Léonard