Skip to content

Commit

Permalink
Add Korean locale to tester_linux (#208)
Browse files Browse the repository at this point in the history
We need this for the locale tests in the Julia test suite.
We don't add this to `tester_musl` because locales there are broken.
X-ref: https://musl.openwall.narkive.com/kO1vpTWJ/setlocale-behavior-with-missing-locales
  • Loading branch information
staticfloat authored Jun 27, 2022
1 parent e15b301 commit 1571a26
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
4 changes: 2 additions & 2 deletions linux/debian_minimal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ archive = args.archive
image = args.image

packages = String[]
locale = nothing
locales = String[]

artifact_hash, tarball_path, = debootstrap(arch, image; archive, packages, locale)
artifact_hash, tarball_path, = debootstrap(arch, image; archive, packages, locales)
upload_gha(tarball_path)
test_sandbox(artifact_hash)
9 changes: 8 additions & 1 deletion linux/tester_linux.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ packages = [
"zstd",
]

artifact_hash, tarball_path, = debootstrap(arch, image; archive, packages)
# The test suites use a non-english locale as part of their tests;
# we provide it in the testing image.
locales = [
"en_US.UTF-8 UTF-8",
"ko_KR.EUC-KR EUC-KR",
]

artifact_hash, tarball_path, = debootstrap(arch, image; archive, packages, locales)
upload_gha(tarball_path)
test_sandbox(artifact_hash)
24 changes: 13 additions & 11 deletions src/build_img/debian.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ end
function debootstrap(f::Function, arch::String, name::String;
archive::Bool = true,
force::Bool = false,
locale::Union{Nothing,String} = "en_US.UTF-8 UTF-8",
locales::Vector{String} = ["en_US.UTF-8 UTF-8"],
packages::Vector{String} = String[],
release::String = "buster",
variant::String = "minbase")
if Sys.which("debootstrap") === nothing
error("Must install `debootstrap`!")
end

if locale !== nothing
if !isempty(locales)
if "locales" packages
msg = string(
"You have set the `locale` keyword argument to `true`. ",
"You have set the `locales` keyword argument. ",
"However, the `packages` vector does not include the `locales` package. ",
"Either ",
"(1) add the `locales` package to the `packages` vector, or ",
"(2) set the `locale` keyword arguement to `false`.",
"(2) set the `locale` keyword arguement to an empty vector.",
)
throw(ArgumentError(msg))
end
Expand All @@ -42,18 +42,20 @@ function debootstrap(f::Function, arch::String, name::String;
"PATH" => "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
)

# If `locale` is set, pass that through as `LANG`
if locale !== nothing
chroot_ENV["LANG"] = first(split(locale))
# If `locale` is set, pass the first element through as `LANG`
if !isempty(locales)
chroot_ENV["LANG"] = first(split(first(locales)))
end

return create_rootfs(name; archive, force) do rootfs
# If `locale` is set, the first thing we do is to pre-populate `/etc/locales.gen`
if locale !== nothing
@info("Setting up locale", locale)
if !isempty(locales)
@info("Setting up locale", locales)
mkpath(joinpath(rootfs, "etc"))
open(joinpath(rootfs, "etc", "locale.gen"), "a") do io
println(io, locale)
for locale in locales
println(io, locale)
end
end
end

Expand Down Expand Up @@ -116,7 +118,7 @@ function debootstrap(f::Function, arch::String, name::String;
end

# If we have locale support, ensure that `locale-gen` is run at least once.
if locale !== nothing
if !isempty(locales)
chroot(rootfs, "locale-gen"; ENV=chroot_ENV)
end

Expand Down

0 comments on commit 1571a26

Please sign in to comment.