Skip to content

Commit

Permalink
Replace LC_ALL=C with LC_ALL=C.UTF-8
Browse files Browse the repository at this point in the history
Starting with glibc 2.39, LC_ALL=C.UTF-8 overrides LANGUAGE, just like
LC_ALL=C. See https://sourceware.org/bugzilla/show_bug.cgi?id=16621 for
details.

This means we can stop using a non-UTF-8 locale and avoid any potential
issues that brings.
  • Loading branch information
nl6720 committed Feb 7, 2024
1 parent 5ba6189 commit 5db56e2
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ man/%: man/%.adoc Makefile
-a manmanual="mkinitcpio manual" $<

check:
LC_ALL=C bats --jobs $(JOBS) $(BATS_ARGS) test/cases/
LC_ALL=C.UTF-8 bats --jobs $(JOBS) $(BATS_ARGS) test/cases/

coverage:
kcov \
Expand Down
2 changes: 1 addition & 1 deletion functions
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ add_binary() {
# non-binaries
if ! lddout="$(ldd "$binary" 2>/dev/null)"; then
# detect if the file has a shebang
if IFS='' LC_ALL=C read -rn2 -d '' shebang <"$binary" && [[ "$shebang" == '#!' ]]; then
if IFS='' LC_ALL=C.UTF-8 read -rn2 -d '' shebang <"$binary" && [[ "$shebang" == '#!' ]]; then
read -r shebang <"$binary"
interpreter="${shebang##\#\!*([[:space:]])}"
# strip /usr/bin/env and warn if it is missing
Expand Down
2 changes: 1 addition & 1 deletion install/microcode
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ build() {
# as a last resort, find and extract a precompiled image in /boot
if [[ ! -e "${ucode_dest}/${ucode_bin[$vendor]}" && -r "/boot/${ucode_img[$vendor]}" ]]; then
quiet "extracting precompiled microcode image: '/boot/%s'" "${ucode_img[$vendor]}"
LC_ALL=C bsdtar -C "$EARLYROOT" -xf "/boot/${ucode_img[$vendor]}" 'kernel/*/microcode/*.bin'
LC_ALL=C.UTF-8 bsdtar -C "$EARLYROOT" -xf "/boot/${ucode_img[$vendor]}" 'kernel/*/microcode/*.bin'
fi
done
}
Expand Down
4 changes: 2 additions & 2 deletions lsinitcpio
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ detect_filetype() {
detect_early_img() {
local early=0
# early cpio archives can have a file called early_cpio in them
early="$(LC_ALL=C bsdtar -xOf "$1" early_cpio 2>/dev/null)"
early="$(LC_ALL=C.UTF-8 bsdtar -xOf "$1" early_cpio 2>/dev/null)"
if [[ -z "$early" ]]; then
# but not all do
if LC_ALL=C bsdtar -tf "$1" 'kernel/*/microcode/*.bin' &>/dev/null; then
if LC_ALL=C.UTF-8 bsdtar -tf "$1" 'kernel/*/microcode/*.bin' &>/dev/null; then
early=1
fi
fi
Expand Down
8 changes: 4 additions & 4 deletions mkinitcpio
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ create_image() {
# If this pipeline changes, |pipeprogs| below needs to be updated as well.
find . -mindepth 1 -printf '%P\0' \
| sort -z \
| LC_ALL=C bsdtar --uid 0 --gid 0 --null -cnf - -T - \
| LC_ALL=C bsdtar --null -cf - --format=newc @- \
| LC_ALL=C.UTF-8 bsdtar --uid 0 --gid 0 --null -cnf - -T - \
| LC_ALL=C.UTF-8 bsdtar --null -cf - --format=newc @- \
| "$compress_cmd" "${COMPRESSION_OPTIONS[@]}" >>"$compressout"

pipestatus=("${PIPESTATUS[@]}")
Expand Down Expand Up @@ -344,9 +344,9 @@ uki_init() {
# reproducibility, preserve dates of used files
_uki_objcopy_args+=(-p)

_uki_alignment="$(LC_ALL=C objdump -p "${uefistub}" \
_uki_alignment="$(LC_ALL=C.UTF-8 objdump -p "${uefistub}" \
| awk '/SectionAlignment/ {print strtonum("0x"$2)}')"
_uki_increase_offset "$(LC_ALL=C objdump -h "${uefistub}" \
_uki_increase_offset "$(LC_ALL=C.UTF-8 objdump -h "${uefistub}" \
| awk 'NF==7 {size=strtonum("0x"$3); offset=strtonum("0x"$4)} END {print size + offset}')"
}

Expand Down
2 changes: 1 addition & 1 deletion test/cases/functions.bats
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ setup() {
ln -s -- 3 "${dir}/testdir2/testsubdir2/4"

run add_full_dir "$dir"
LC_ALL=C diff -r "${dir}/" "${BUILDROOT}/${dir}/"
LC_ALL=C.UTF-8 diff -r "${dir}/" "${BUILDROOT}/${dir}/"
}

@test "add_full_dir glob" {
Expand Down

1 comment on commit 5db56e2

@beginner3456789
Copy link

@beginner3456789 beginner3456789 commented on 5db56e2 Mar 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SOLVED! SEE AT END.
The change from LC_ALL=C to LC_ALL=C.UTF-8 in the functions file causes errors when generating a new initramfs. The error is "cannot change locale...". My locale is en_US.UTF-8 with LC_ALL="" . There were no errors with v37.3 just with v38 mkinitcpio. I am using mkinitcpio with Void linux (no system.d) and there are a number of patches except the functions file is unchanged from your source.

==> Starting build: '6.7.7_1'
  -> Running build hook: [base]
/usr/lib/initcpio/functions: line 838: warning: setlocale: LC_ALL: cannot change locale (C.UTF-8): No such file or directory
  -> Running build hook: [udev]
  -> Running build hook: [modconf]
  -> Running build hook: [block]
==> WARNING: Possibly missing firmware for module: 'bfa'
==> WARNING: Possibly missing firmware for module: 'advansys'
==> WARNING: Possibly missing firmware for module: 'qla1280'
==> WARNING: Possibly missing firmware for module: 'wd719x'
==> WARNING: Possibly missing firmware for module: 'isci'
==> WARNING: Possibly missing firmware for module: 'qed'
==> WARNING: Possibly missing firmware for module: 'qla2xxx'
==> WARNING: Possibly missing firmware for module: 'aic94xx'
==> WARNING: Possibly missing firmware for module: 'xhci_pci'
==> WARNING: Possibly missing firmware for module: 'ums_eneub6250'
  -> Running build hook: [filesystems]
  -> Running build hook: [fsck]
/usr/lib/initcpio/functions: line 838: warning: setlocale: LC_ALL: cannot change locale (C.UTF-8)
==> Generating module dependencies
==> Creating gzip-compressed initcpio image: '/boot/initramfs-6.7.7_1.img'
bsdtar: Failed to set default localebsdtar: 
Failed to set default locale
==> Initcpio image generation successful

EDIT: SOLVED! Fixed by adding C UTF-8 to /etc/default/glibc-locales (even though that was not an option in the Void glibc-locales 2.38_5 choices) and then rebuilding locales:

$ xbps-reconfigure -f glibc-locales
glibc-locales: configuring ...
Generating GNU libc locales...
  en_US.UTF-8... done.
  en_US.ISO-8859-1... done.
  C.UTF-8... done.
glibc-locales: configured successfully.

Please sign in to comment.