Skip to content

Commit

Permalink
Add the test_rootfs.jl file for testing rootfs images locally (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
DilumAluthge authored Jul 23, 2021
1 parent 0ea62b3 commit d847c17
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@
Our CI setup makes use of rootfs images that contain our build tools.
These rootfs images are built using the fairly simple scripts held within this repository.
Most images are based on Debian, making use of `debootstrap` to provide a quick and easy rootfs with packages installed through an initial `apt` invocation.

## Testing out a rootfs image

If you want to test a rootfs image locally, you can use the `test_roofs.jl` script, passing in the URL of the rootfs you want to test. It will drop you into a shell within the build environment, where you can recreate build failures more reliably.
38 changes: 38 additions & 0 deletions test_rootfs.jl
Original file line number Diff line number Diff line change
@@ -1 +1,39 @@
#!/usr/bin/env julia
using Sandbox, Pkg.Artifacts

if length(ARGS) < 1 || length(ARGS) > 2
println("Usage: test_rootfs.jl <url> [gitsha]")
exit(1)
end

url = ARGS[1]
hash = Base.SHA1(get(ARGS, 2, nothing))

if hash === nothing
@warn("hash not provided; this will download the tarball, then fail, so you can see the true hash")
hash = Base.SHA1("0000000000000000000000000000000000000000")
end

# If the artifact is not locally existent, download it
if !artifact_exists(hash)
@info("Artifact did not exist, downloading")
download_artifact(hash, url; verbose=true)
end

config = SandboxConfig(
Dict("/" => artifact_path(hash)),
Dict{String,String}(),
Dict(
"PATH" => "/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin",
"HOME" => "/home/juliaci",
"USER" => "juliaci",
);
stdin,
stdout,
stderr,
uid=Sandbox.getuid(),
gid=Sandbox.getgid(),
)
with_executor() do exe
run(exe, config, `/bin/bash`)
end

0 comments on commit d847c17

Please sign in to comment.