falconindy / pkgbuild-introspection

Tools for generating .SRCINFO files and PKGBUILD data extraction
MIT License
39 stars 9 forks source link

Bash quoting with certain locales #21

Closed tweerwag closed 9 years ago

tweerwag commented 9 years ago

Running mkaurball on any package with LANG=nl_NL.utf8 yields: (with translations between the brackets.)

$ env LANG=nl_NL.utf8 mkaurball -f
bsdtar: could not chdir to '--'

chmod: ontbrekend argument [missing argument]
Typ 'chmod --help' voor meer informatie. [Type 'chmod --help' for more information.]
ERROR: Failed to repack tarball

It is caused by

  # chmod files before re-tarring. This enforces that all files are 644 or 755.
  if ! fakeroot -- sh -c 'chmod og=rX -R "$1/$2" && bsdtar -C "$1" -czLf "$3" "$2"' \
      _ "$tmpdir" "$tarball_basename" "$tarball_fullname"; then
    die 'Failed to repack tarball'
  fi

on lines 98-102 of mkaurball.in. It seems that the command following '-c' is broken down in several arguments before being passed to sh. Changing that line to

  if ! fakeroot -- sh -c "'"'chmod og=rX -R "$1/$2" && bsdtar -C "$1" -czLf "$3" "$2"'"'" \

fixes the issue for me. (But I don't know if this is a proper fix.) Somehow, this doesn't occur with LANG=C or LANG=en_US.utf8.

falconindy commented 9 years ago

Amusing. I've distilled this down to the following:

$ getopt --version
getopt from util-linux 2.25.388-819d9
$ LANG=nl_NL.utf8 getopt --version
'getopt' uit util-linux 2.25.388-819d9

And, fakeroot has the following logic to determine which flavor of getopt is available:

GETOPTEST=`getopt --version`
case $GETOPTEST in
getopt*) # GNU getopt 
    ...
*) # POSIX getopt ?
    ...

So this now fails because a translator decided to add superfluous decorations. Looking at the PO files, this is equally broken in tr_TR.utf8 where the word order has been localized:

$ LANG=tr_TR.utf8 getopt --version
util-linux 2.25.388-819d9 deki getopt

While I'm disappointed by fakeroot's brittle detection mechanism, parsing version strings isn't an uncommon thing to do for programs which insist on being highly portable. I think this is a util-linux bug to allow translations of such strings. @karelzak, thoughts about removing this?

In the meantime, I'm just going to bandaid mkaurball (which will be dead, anyways, with pacman 4.3).

falconindy commented 9 years ago

Fixed by 220a1b4dfbd53768ed1ee6eebe728dcf4f565827

karelzak commented 9 years ago

On Tue, Nov 11, 2014 at 05:11:22AM -0800, Dave Reisner wrote:

While I'm disappointed by fakeroot's brittle detection mechanism, parsing version strings isn't an uncommon thing to do for programs which insist on being highly portable. I think this is a util-linux bug to allow translations of such strings. @karelzak, thoughts about removing this?

Well, we don't have any procedure to check translations and I have doubts it's possible to implement something usable for this purpose. Maybe in some languages add extra chars makes sense (for example to avoid misinterpretation of the untranslated words).

It would be better to discuss this topic on util-linux mailing list.

Karel

Karel Zak kzak@redhat.com http://karelzak.blogspot.com