kewlfft / ansible-aur

Ansible module to manage packages from the AUR
GNU General Public License v3.0
299 stars 47 forks source link

Remove hardcoded locale environment variables #79

Open 11xx opened 1 year ago

11xx commented 1 year ago

Line 109 hardcodes the environment variable locales to C:

def_lang = ['env', 'LC_ALL=C', 'LANGUAGE=C']

but this conflicts with certain PKGBUILDs.

For example when extracting source files of the sabnzbd package bsdtar would complain:

bsdtar: Pathname can't be converted from UTF-8 to current locale.

and fail the playbook.

The host machine locales were right, with UTF-8.

So removing the locale variables: def_lang = ['env'] and using either:

environment:
  LC_ALL: en_US.UTF-8
  LANGUAGE: en_US.UTF-8

or nothing made it work.

Just as a note, setting:

environment:
  LC_ALL: C
  LANGUAGE: C

makes it fail again.

This can be tested with bsdtar directly:
Download the tar.gz source file from https://aur.archlinux.org/packages/sabnzbd

LC_ALL=C LANGUAGE=C bsdtar xf file.tar.gz

and it should error out.

Any special reason for keeping it? If anyone needs to specify them,
like any other env. var, the environment key works fine, given the use
of env. And the good thing is that it can be used at the play, block, or task level.

kftsehk commented 12 months ago

+1 for breaking sha512 of these package, some files will fail hash with LC_ALL=C

aur/cuda-11.7
aur/cuda-11.1

cannot be overridden by

      environment:
        LC_ALL: ""
        LANGUAGE: ""

or any other way that successfully hash these packages

kftsehk commented 12 months ago

@kewlfft How about add a variable to explicitly disable setting

command = def_lang + ...

this way will not break old behavior.

But for some package that cannot install with either LC_ALL=C or LANGUAGE=C for unknown reason, we can explicitly set disable_default_local: true and env LC_ALL=C LANGUAGE=C will not be added.

The only workaround now is to use

shell: |
  yay ......

I suppose it is not what should happen in ansible.