From 8659907d622c46fb1dc3fbb397417d434562465b Mon Sep 17 00:00:00 2001 From: Adphi Date: Wed, 15 Feb 2023 10:20:37 +0100 Subject: [PATCH] fix Alpine 3.17 support (close #16) Signed-off-by: Adphi --- builder_test.go | 6 ++++++ cmd/d2vm/convert.go | 5 +++-- templates/alpine.Dockerfile | 7 +++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/builder_test.go b/builder_test.go index e5eb2b2..a317e06 100644 --- a/builder_test.go +++ b/builder_test.go @@ -121,6 +121,12 @@ func TestSyslinuxCfg(t *testing.T) { initrd: "/initrd.img", sysconfig: syslinuxCfgDebian, }, + { + image: "alpine:3.16", + kernel: "/boot/vmlinuz-virt", + initrd: "/boot/initramfs-virt", + sysconfig: syslinuxCfgAlpine, + }, { image: "alpine", kernel: "/boot/vmlinuz-virt", diff --git a/cmd/d2vm/convert.go b/cmd/d2vm/convert.go index b0adc09..b6d4bee 100644 --- a/cmd/d2vm/convert.go +++ b/cmd/d2vm/convert.go @@ -60,6 +60,7 @@ var ( if parts := strings.Split(img, ":"); len(parts) > 1 { img, tag = parts[0], parts[1] } + img = fmt.Sprintf("%s:%s", img, tag) size, err := parseSize(size) if err != nil { return err @@ -75,9 +76,9 @@ var ( if err != nil { return err } - found = len(imgs) == 1 && imgs[0] == fmt.Sprintf("%s:%s", img, tag) + found = len(imgs) == 1 && imgs[0] == img if found { - logrus.Infof("using local image %s:%s", img, tag) + logrus.Infof("using local image %s", img) } } if pull || !found { diff --git a/templates/alpine.Dockerfile b/templates/alpine.Dockerfile index ecc3de5..0727b02 100644 --- a/templates/alpine.Dockerfile +++ b/templates/alpine.Dockerfile @@ -6,7 +6,14 @@ RUN apk update --no-cache && \ apk add \ util-linux \ linux-virt \ +{{ if ge .Release.VersionID "3.17" }} \ + busybox-openrc \ + busybox-mdev-openrc \ + busybox-extras-openrc \ + busybox-mdev-openrc \ +{{ else }} busybox-initscripts \ +{{ end }} openrc RUN for s in bootmisc hostname hwclock modules networking swap sysctl urandom syslog; do rc-update add $s boot; done