Mailinglist Archive: opensuse-buildservice (170 mails)

< Previous Next >
Re: [opensuse-buildservice] Checking md5sums in osc relies on English locales
  • From: "Dr. Peter Poeml" <poeml@xxxxxxx>
  • Date: Mon, 10 Dec 2007 14:11:32 +0100
  • Message-id: <20071210131132.GB797@xxxxxxx>
Hi,

thank you both for the report and the patch.

Additional comments below.

On Tue, Dec 04, 2007 at 05:06:19 +0100, Pavol Rusnak wrote:
Ladislav Michnovič wrote:
I have a little problem when using local build with osc. In file
/usr/lib64/python2.5/site-packages/osc/fetch.py

Peter: Problem is in call on line 144 and in the checks after it on
lines 150 and 156:

144: (i, o) = os.popen4(['/bin/rpm', '-K'] + pac_list)
150: if not 'OK' in line:
156: if 'NOT OK' in line:

English, German, French, Czech print "OK" or "NOT OK", but Slovak with
"V PORIADKU" or "NIE JE V PORIADKU" (as these strings are marked for
translation). Similar problem will arise with another languages that
have these strings translated. I see 2 possible solutions:

1) check packages one at a time and look for return value from RPM (do
not parse stdout)

That's what I wanted to avoid, because it would run 3 times slower.
Hence the ugly output parsing.

2) set environment (LC_ALL) before rpm call

That should work, indeed.

But since the popen is acting on "foreign" input (after retrieving the
buildinfo dependency list from the server), it might be harmful to run
it through execution of a shell, and I'm a bit hesitant of applying your
patch as is.

The only other way which cames to mind would be to save a possible
LC_ALL environmental value, change it, and re-set it after running the
external command.

I think I'll rather commit the following patch if you don't mind:

--- osc-stable/osc/fetch.py (revision 2686)
+++ osc-stable/osc/fetch.py (working copy)
@@ -141,8 +141,17 @@

# we can use os.popen4 because we don't care about the return value.
# we check the output anyway, and rpm always writes to stdout.
+
+ # save locale first (we rely on English rpm output here)
+ saved_LC_ALL = os.environ.get('LC_ALL')
+ os.environ['LC_ALL'] = 'en_EN'
+
(i, o) = os.popen4(['/bin/rpm', '-K'] + pac_list)

+ # restore locale
+ if saved_LC_ALL: os.environ['LC_ALL'] = saved_LC_ALL;
+ else: os.environ.pop('LC_ALL')
+
i.close()

for line in o.readlines():




Peter
--
"WARNING: This bug is visible to non-employees. Please be respectful!"

SUSE LINUX Products GmbH
Research & Development
< Previous Next >