BuildSourceImage: expose "unpack" as subcommand
This may be a pattern we can do for some of the more useful functions. But for now, folks can build, push, etc. and once they skopeo copy an image to their host, they can ```bash ./BuildSourceImage unpack <src> <dest> ``` and it will be nicely exposed in the container build too Also included, exporting the defaults into the bats test for easier direct running. Perhaps we can move the srpm caching into bats too, so the Makefile target isn't strictly required. Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
e565987415
commit
8e438c7a6d
5 changed files with 82 additions and 5 deletions
|
@ -3,6 +3,7 @@
|
|||
load helpers
|
||||
|
||||
@test "Build from image reference" {
|
||||
#skip "this takes like 20min ..."
|
||||
local d
|
||||
d=$(mktemp -d)
|
||||
echo "temporary directory: ${d}"
|
||||
|
|
32
test/03-unpack.bats
Normal file
32
test/03-unpack.bats
Normal file
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/env bats -t
|
||||
|
||||
load helpers
|
||||
|
||||
@test "unpack - no args" {
|
||||
run_ctr $CTR_IMAGE unpack
|
||||
[ "$status" -eq 1 ]
|
||||
[[ ${lines[0]} =~ "[SrcImg][ERROR] [unpack_img] blank arguments provided" ]]
|
||||
}
|
||||
|
||||
@test "unpack - Help" {
|
||||
run_ctr $CTR_IMAGE unpack -h
|
||||
[ "$status" -eq 1 ]
|
||||
[[ ${lines[0]} =~ "BuildSourceImage.sh unpack <oci layout path> <unpack path>" ]]
|
||||
}
|
||||
|
||||
@test "unpack - from a SRPM build" {
|
||||
local d
|
||||
local r
|
||||
|
||||
d=$(mktemp -d)
|
||||
echo "temporary directories: output - ${d}"
|
||||
run_ctr -v $(pwd)/.testprep/srpms/:/src:ro --mount type=bind,source=${d},destination=/output $CTR_IMAGE -s /src -o /output
|
||||
[ "$status" -eq 0 ]
|
||||
[ -f "${d}/index.json" ]
|
||||
|
||||
r=$(mktemp -d)
|
||||
echo "temporary directories: unpacked - ${r}"
|
||||
run_ctr --mount type=bind,source=${d},destination=/output -v ${r}:/unpacked/ $CTR_IMAGE unpack /output/ /unpacked/
|
||||
[ "$(find ${r} -type f | wc -l)" -eq 3 ] # regular files
|
||||
[ "$(find ${r} -type l | wc -l)" -eq 3 ] # and symlinks
|
||||
}
|
|
@ -1,3 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
export CTR_IMAGE="${CTR_IMAGE:-localhost/containers/buildsourceimage}"
|
||||
export CTR_ENGINE="${CTR_ENGINE:-podman}"
|
||||
|
||||
function run_ctr() {
|
||||
run $CTR_ENGINE run --security-opt label=disable --rm "$@"
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue