Skip to content

Commit

Permalink
virt-v2v: Build our own fixed appliance on el8
Browse files Browse the repository at this point in the history
Similar to #226 but on el8 (the appliance used with el8 libguestfs does
not support qcow2 images so the image is still compressed within the
container image and extract by the 'entrypoint' script).

Signed-off-by: Arik Hadas <[email protected]>
  • Loading branch information
ahadas committed Aug 10, 2023
1 parent 13f9dd5 commit 76efe8a
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 20 deletions.
5 changes: 0 additions & 5 deletions cmd/forklift-controller/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ load(

container_image(
name = "forklift-controller-image",
#architecture = select({
# "@io_bazel_rules_go//go/platform:linux_arm64": "arm64",
# "//conditions:default": "amd64",
#}),
#base = "@centos-stream8//image",
base = "@ubi9-minimal//image",
directory = "/usr/local/bin/",
entrypoint = ["/usr/local/bin/forklift-controller"],
Expand Down
8 changes: 0 additions & 8 deletions virt-v2v/cold/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,6 @@ load(

container_repositories()

container_pull(
name = "ubi8-minimal",
# 'tag' is also supported, but digest is encouraged for reproducibility.
digest = "sha256:d1f8eff6032334a81d7cbfd73dacee680e8138db57ecbc91548b97bb45e698e5",
registry = "registry.access.redhat.com",
repository = "ubi8/ubi-minimal",
)

http_archive(
name = "bazeldnf",
sha256 = "404fc34e6bd3b568a7ca6fbcde70267d43830d0171d3192e3ecd83c14c320cfc",
Expand Down
6 changes: 6 additions & 0 deletions virt-v2v/warm/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Appliance build
# container_run_and_extract() does not work inside Podman and Docker
# sandboxes. Use slightly less secure but working processwrapper sandbox.
# NOTE: Same configuration is in .bazelrc in repository root.
build --strategy_regexp="Action appliance/libguestfs-appliance.tar"=processwrapper-sandbox

37 changes: 36 additions & 1 deletion virt-v2v/warm/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ load(
"container_image",
"container_push",
)
load(
"@io_bazel_rules_docker//docker/util:run.bzl",
"container_run_and_extract",
)

container_push(
name = "push-forklift-virt-v2v-warm",
Expand All @@ -14,9 +18,40 @@ container_push(
tag = "$${REGISTRY_TAG:-devel}",
)

# Appliance build
# NOTE: We deliberately do not use (and cannot use) rpmtree to build a base
# layer with packages. Supermin queries the RPM database to track package files
# and dependencies. Tar constructed by rpmtree is just a bunch of files and it
# does not preserve the RPM database info. Therefore we imitate a Dockerfile
# build here.
container_run_and_extract(
name = "appliance",
commands = [
"set -x",
"dnf -y update",
"dnf -y install libguestfs-devel libguestfs-appliance libguestfs-xfs libguestfs-winsupport supermin",
"depmod \\$(ls /lib/modules/ |tail -n1)",
"export LIBGUESTFS_BACKEND=direct",
"export LIBGUESTFS_DEBUG=1 LIBGUESTFS_TRACE=1",
"mkdir -p /usr/lib64/guestfs/appliance",
"cd /usr/lib64/guestfs/appliance",
"libguestfs-make-fixed-appliance --xz",
"cp /usr/lib64/guestfs/appliance/appliance-*.tar.xz /libguestfs-appliance.tar.xz",
],
extract_file = "/libguestfs-appliance.tar.xz",
image = "@centos-stream-8//image",
)

container_image(
name = "appliance-image",
base = "@ubi8-minimal//image",
directory = "/usr/lib64/guestfs",
files = [":appliance/libguestfs-appliance.tar.xz"],
)

container_image(
name = "virt-v2v-image",
base = "@libguestfs-appliance//image",
base = "appliance-image",
directory = "/",
tars = [":virt-v2v"],
)
Expand Down
9 changes: 4 additions & 5 deletions virt-v2v/warm/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,16 @@ container_repositories()

container_pull(
name = "ubi8-minimal",
# 'tag' is also supported, but digest is encouraged for reproducibility.
digest = "sha256:d1f8eff6032334a81d7cbfd73dacee680e8138db57ecbc91548b97bb45e698e5",
registry = "registry.access.redhat.com",
repository = "ubi8/ubi-minimal",
tag = "latest",
)

container_pull(
name = "libguestfs-appliance",
digest = "sha256:6abc2a68f4a42dbf3a7db1042a73862e763b6c864c1e04659dc6bd981e430ae5",
name = "centos-stream-8",
registry = "quay.io",
repository = "kubev2v/libguestfs-appliance",
repository = "centos/centos",
tag = "stream8",
)

http_archive(
Expand Down
2 changes: 1 addition & 1 deletion virt-v2v/warm/entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
shopt -s nullglob

export LIBGUESTFS_PATH=/usr/lib64/guestfs
set -- "$LIBGUESTFS_PATH"/appliance-*.tar.xz
set -- "$LIBGUESTFS_PATH"/libguestfs-appliance.tar.xz
if [ -f "$1" ] ; then
echo "Extracting libguestfs appliance..."
APPLIANCE="/var/tmp/libguestfs-appliance"
Expand Down

0 comments on commit 76efe8a

Please sign in to comment.