Skip to content

Commit

Permalink
Add the debian_minimal rootfs image (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
DilumAluthge authored Aug 12, 2021
1 parent 5b14c5e commit 336201e
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 10 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ jobs:
- 'agent_linux.armv7l'
- 'agent_linux.ppc64le'
- 'agent_linux.x86_64'

# The `debian_minimal` image is a `debian`-based image that
# contains no packages.
- 'debian_minimal.x86_64'

# The `package_linux` images are all `debian`-based.
- 'package_linux.aarch64'
Expand Down
1 change: 1 addition & 0 deletions images/agent_linux.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ packages = [
# We use these in our buildkite plugins a lot
"git",
"jq",
"locales",
"openssl",
"python3",
# Debugging
Expand Down
13 changes: 13 additions & 0 deletions images/debian_minimal.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using RootfsUtils

arch, image, = parse_build_args(ARGS, @__FILE__)

# Build debian-based image with the following extra packages:
packages = String[]
artifact_hash, tarball_path, = debootstrap(arch, image; packages, locale = false)

# Upload it
upload_rootfs_image_github_actions(tarball_path)

# Test that we can use our new rootfs image with Sandbox.jl
test_sandbox(artifact_hash)
1 change: 1 addition & 0 deletions images/llvm_passes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ packages = [
"git",
"less",
"libatomic1",
"locales",
"m4",
"perl",
"pkg-config",
Expand Down
1 change: 1 addition & 0 deletions images/package_linux.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ packages = [
"less",
"libatomic1",
"libtool",
"locales",
"m4",
"make",
"perl",
Expand Down
1 change: 1 addition & 0 deletions images/package_linux_qemu.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ packages = [
"less",
"libatomic1",
"libtool",
"locales",
"m4",
"make",
"perl",
Expand Down
1 change: 1 addition & 0 deletions images/tester_linux.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ packages = [
"bash",
"curl",
"gdb",
"locales",
"vim",
]
artifact_hash, tarball_path, = debootstrap(arch, image; packages)
Expand Down
33 changes: 23 additions & 10 deletions src/build/debian.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ function debian_arch(image_arch::String)
end

function debootstrap(f::Function, arch::String, name::String;
release::String="buster",
variant::String="minbase",
packages::Vector{String}=String[],
force::Bool=false)
force::Bool = false,
locale::Bool = true,
packages::Vector{String} = String[],
release::String = "buster",
variant::String = "minbase")
if Sys.which("debootstrap") === nothing
error("Must install `debootstrap`!")
end
Expand All @@ -24,9 +25,19 @@ function debootstrap(f::Function, arch::String, name::String;
end

return create_rootfs(name; force) do rootfs
packages_string = join(push!(packages, "locales"), ",")
@info("Running debootstrap", release, variant, packages)
run(`sudo debootstrap --arch=$(debian_arch(arch)) --variant=$(variant) --include=$(packages_string) $(release) "$(rootfs)"`)
debootstrap_cmd = `sudo debootstrap`
push!(debootstrap_cmd.exec, "--arch=$(debian_arch(arch))")
push!(debootstrap_cmd.exec, "--variant=$(variant)")
if isempty(packages)
packages_string = "(no packages)"
else
packages_string = join(strip.(packages), ",")
push!(debootstrap_cmd.exec, "--include=$(packages_string)")
end
push!(debootstrap_cmd.exec, "$(release)")
push!(debootstrap_cmd.exec, "$(rootfs)")
run(debootstrap_cmd)

# This is necessary on any 32-bit userspaces to work around the
# following bad interaction between qemu, linux and openssl:
Expand Down Expand Up @@ -60,11 +71,13 @@ function debootstrap(f::Function, arch::String, name::String;
end

# Set up the one true locale
@info("Setting up UTF-8 locale")
open(joinpath(rootfs, "etc", "locale.gen"), "a") do io
println(io, "en_US.UTF-8 UTF-8")
if locale
@info("Setting up UTF-8 locale")
open(joinpath(rootfs, "etc", "locale.gen"), "a") do io
println(io, "en_US.UTF-8 UTF-8")
end
chroot(rootfs, "locale-gen")
end
chroot(rootfs, "locale-gen")
end
end

Expand Down

0 comments on commit 336201e

Please sign in to comment.