mirror of
https://github.com/flatcar/scripts.git
synced 2025-12-07 18:31:54 +01:00
app-misc/ca-certificates: ignore UnicodeEncodeError when opening file
Now that we started encoding strings to unicode by default,
we should also take care of corner cases, where LC_CYPTE is set to a
different value from the systemd default value in `/etc/locale.gen`.
For example, under a build environment with `LC_CTYPE=C`, when the UTF-8
file name is `AC_Ra�z_Certic�mara_S.A..pem`,
build fails like that.
```
Traceback (most recent call last):
File "/var/tmp/portage/app-misc/ca-certificates-3.27.1-r2/files/certdata2pem.py",
line 127, in <module>
f = open(fname, 'w')
UnicodeEncodeError: 'ascii' codec can't encode character '\xed' in position 5: ordinal not in range(128)
* ERROR: app-misc/ca-certificates-3.27.1-r2::coreos failed (compile phase):
```
To fix that, encode filename with system encoding when opening the file.
This commit is contained in:
parent
d0ce77ec8e
commit
142dc04fd4
@ -124,7 +124,8 @@ for obj in objects:
|
||||
fname = fname.encode('latin1').decode('unicode_escape').encode('latin1').decode('utf8')
|
||||
except (UnicodeEncodeError, UnicodeDecodeError):
|
||||
pass
|
||||
f = open(fname, 'w')
|
||||
|
||||
f = open(fname.encode(encoding=sys.getfilesystemencoding(), errors="ignore"), 'w')
|
||||
f.write("-----BEGIN CERTIFICATE-----\n")
|
||||
# obj['CKA_VALUE'] is a string of octals like '\060\311…',
|
||||
# with a number not greater than octal 377 (which is 255,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user