Skip to content

Commit

Permalink
Always use apt for installing packages, so that we don't rely on `d…
Browse files Browse the repository at this point in the history
…ebootstrap`'s broken resolver; also, upgrade the `pkgserver_logsync` image to Debian Bullseye (#220)

* Always use `apt` for installing packages, so that we don't rely on `debootstrap`'s broken resolver

* Upgrade the `pkgserver_logsync` image to Debian Bullseye
  • Loading branch information
DilumAluthge authored Aug 30, 2022
1 parent d917b43 commit 5d9cd9a
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 19 deletions.
20 changes: 15 additions & 5 deletions linux/agent_linux.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,20 @@ packages = [
artifact_hash, tarball_path, = debootstrap(arch, image; archive, packages) do rootfs, chroot_ENV
my_chroot(args...) = root_chroot(rootfs, "bash", "-eu", "-o", "pipefail", "-c", args...; ENV=chroot_ENV)

apt_update_and_upgrade = () -> begin
my_chroot("DEBIAN_FRONTEND=noninteractive apt update")
my_chroot("DEBIAN_FRONTEND=noninteractive apt upgrade -y")
end
apt_update_and_upgrade()

@info("Installing buildkite-agent...")
buildkite_install_cmd = """
echo 'deb https://apt.buildkite.com/buildkite-agent stable main' >> /etc/apt/sources.list && \\
curl -sfL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x32A37959C2FA5C3C99EFBC32A79206696452D198" | apt-key add - && \\
apt-get update && \\
DEBIAN_FRONTEND=noninteractive apt-get install -y buildkite-agent
apt update && \\
DEBIAN_FRONTEND=noninteractive apt install -y buildkite-agent
"""
my_chroot(buildkite_install_cmd)
my_chroot("which buildkite-agent")
my_chroot("which -a buildkite-agent")
my_chroot("buildkite-agent --help")

@info("Installing yq...")
yq_install_cmd = """
Expand All @@ -47,6 +50,13 @@ artifact_hash, tarball_path, = debootstrap(arch, image; archive, packages) do ro
rm -rfv /tmp-install-yq
"""
my_chroot(yq_install_cmd)

apt_update_and_upgrade()

my_chroot("which buildkite-agent")
my_chroot("which -a buildkite-agent")
my_chroot("buildkite-agent --help")

my_chroot("which yq")
my_chroot("which -a yq")
my_chroot("yq --version")
Expand Down
5 changes: 4 additions & 1 deletion linux/pkgserver_logsync.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ packages = String[
"zstd",
]

artifact_hash, tarball_path, = debootstrap(arch, image; archive, packages)
release = "bullseye"

artifact_hash, tarball_path, = debootstrap(arch, image; archive, packages, release)

upload_gha(tarball_path)
test_sandbox(artifact_hash)
1 change: 0 additions & 1 deletion linux/python_latex_kitchen_sink.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ packages = [
"dbus-user-session",
"python3-sip",


# Get a C compiler, for compiling python extensions
"build-essential",
# Get latex, so that we can invoke `pdflatex` and friends
Expand Down
11 changes: 8 additions & 3 deletions linux/rr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,14 @@ artifact_hash, tarball_path, = debootstrap(arch, image; archive, packages, relea
gpp = "g++-multilib"
end

my_chroot("apt-get update")
my_chroot("DEBIAN_FRONTEND=noninteractive apt-get install -y gdb")
my_chroot("DEBIAN_FRONTEND=noninteractive apt-get install -y $(gpp)")
apt_update_and_upgrade = () -> begin
my_chroot("DEBIAN_FRONTEND=noninteractive apt update")
my_chroot("DEBIAN_FRONTEND=noninteractive apt upgrade -y")
end
apt_update_and_upgrade()
my_chroot("DEBIAN_FRONTEND=noninteractive apt install -y gdb")
my_chroot("DEBIAN_FRONTEND=noninteractive apt install -y $(gpp)")
apt_update_and_upgrade()

my_chroot("cmake --version")
end
Expand Down
33 changes: 24 additions & 9 deletions src/build_img/debian.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,10 @@ function debootstrap(f::Function, arch::String, name::String;
end
end

@info("Running debootstrap", release, variant, packages)
@info("Running debootstrap", release, variant, arch)
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)")
p = run(setenv(debootstrap_cmd, chroot_ENV), (stdin, stdout, stderr); wait = false)
Expand All @@ -105,17 +99,38 @@ function debootstrap(f::Function, arch::String, name::String;
chroot(rootfs, "/usr/bin/c_rehash"; ENV=chroot_ENV, uid=0, gid=0)
end

apt_packages = filter!(x -> !isempty(x), strip.(packages))
@info("Installing and upgrading apt packages", apt_packages)
apt_env = copy(chroot_ENV)
apt_env["DEBIAN_FRONTEND"] = "noninteractive"
apt_update_and_upgrade = () -> begin
chroot(rootfs, "apt", "update"; ENV=apt_env, uid=0, gid=0)
chroot(rootfs, "apt", "upgrade", "-y"; ENV=apt_env, uid=0, gid=0)
end
apt_update_and_upgrade()
if !isempty(apt_packages)
chroot(rootfs, "apt", "install", "-y", apt_packages...; ENV=apt_env, uid=0, gid=0)
end
apt_update_and_upgrade()

# Call user callback, if requested
f(rootfs, chroot_ENV)

# Remove special `dev` files, take ownership, force symlinks to be relative, etc...
# Construct the `rootfs_info` string
if isempty(apt_packages)
info_pkgs_str = "(no packages)"
else
info_pkgs_str = join(strip.(apt_packages), ",")
end
rootfs_info="""
rootfs_type=debootstrap
release=$(release)
variant=$(variant)
packages=$(packages_string)
packages=$(info_pkgs_str)
build_date=$(Dates.now())
"""

# Remove special `dev` files, take ownership, force symlinks to be relative, etc...
cleanup_rootfs(rootfs; rootfs_info)

# Remove `_apt` user so that `apt` doesn't try to `setgroups()`
Expand Down

0 comments on commit 5d9cd9a

Please sign in to comment.