FS#49342 - [libalpm] may discard packages when the locale is not set

Attached to Project: Pacman
Opened by Alad Wenter (Alad) - Sunday, 15 May 2016, 11:12 GMT
Task Type Bug Report
Category Backend/Core
Status Assigned
Assigned To Andrew Gregory (andrewgregory)
Architecture All
Severity Medium
Priority Normal
Reported Version 5.0.1
Due in Version Undecided
Due Date Undecided
Percent Complete 0%
Votes 0
Private No


pkgver may not contain hyphens or colomons, per PKGBUILD(5), but otherwise arbitrary values are allowed. This includes UTF-8 characters.

However, when a package has an UTF-8 character in pkgver, any packages appearing after it (in alphabetical order) are discarded silently. This happens with pacman when LANG=C is set, or generally with libalpm front-ends like pacutils and expac which do not set the locale.

It was suggested for libalpm to either throw an error, or have it read the databases regardless of locale (as binary data). Śee: https://github.com/andrewgregory/pacutils/issues/9


How to reproduce:

Build packages in ("c" contains α in pkgver)


Create a new (local) repository, and add the packages with:

% repo-add locale-test.db.tar a-1-1-any.pkg.tar.xz b-1-1-any.pkg.tar.xz c-1.α-1-any.pkg.tar.xz d-1-1-any.pkg.tar.xz e-1-1-any.pkg.tar.xz

Sync databases, and query the db:

% pacman -Syu
% pacman -Slq locale-test

% LANG=C pacman -Slq locale-test

% pacsift --repo=locale-test

% expac -S '%n' a b c d e
This task depends upon

Comment by Andrew Gregory (andrewgregory) - Friday, 20 May 2016, 05:01 GMT
Unfortunately, libarchives handling of pathname encoding is complicated due to differences between various formats: https://github.com/libarchive/libarchive/wiki/Filenames. There does not appear to be a way to allow libalpm to read the db independent of locale. Calling repo-add with LANG=C does appear to at least allow libalpm to fully read the db, but it causes bsdtar to issue some warnings and the version is still broken in --info output.