Skip to content

Commit 98f867f

Browse files
authored
Merge pull request #80 from Itxaka/provider_cross_arch_artifacts
Restore cross-arch build of arm images
2 parents f94e1de + 758e97a commit 98f867f

File tree

7 files changed

+46
-105
lines changed

7 files changed

+46
-105
lines changed

tools-image/Dockerfile

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,19 @@ RUN go build \
2020
-o /usr/bin/enki
2121

2222
FROM opensuse/leap:$LEAP_VERSION as default
23-
COPY --from=luet /usr/bin/luet /usr/bin/luet
24-
ENV LUET_NOLOCK=true
25-
ENV TMPDIR=/tmp
26-
COPY luet.yaml /etc/luet/luet.yaml
27-
2823
RUN zypper ref && zypper dup -y
2924
## ISO+ Arm image + Netboot + cloud images Build depedencies
3025
RUN zypper ref && zypper in -y bc qemu-tools jq cdrtools docker git curl gptfdisk kpartx sudo xfsprogs parted util-linux-systemd e2fsprogs curl util-linux udev rsync grub2 dosfstools grub2-x86_64-efi squashfs mtools xorriso lvm2 zstd
26+
COPY --from=luet /usr/bin/luet /usr/bin/luet
27+
ENV LUET_NOLOCK=true
28+
ENV TMPDIR=/tmp
29+
ARG BUILDARCH
30+
# copy both arches
31+
COPY luet-arm64.yaml /tmp/luet-arm64.yaml
32+
COPY luet-amd64.yaml /tmp/luet-amd64.yaml
33+
# Set the default luet config to the current build arch
34+
RUN mkdir -p /etc/luet/
35+
RUN cp /tmp/luet-${BUILDARCH}.yaml /etc/luet/luet.yaml
3136

3237
## Live CD artifacts
3338
RUN luet install -y livecd/grub2 --system-target /grub2
@@ -39,11 +44,23 @@ RUN luet install -y firmware/u-boot-rpi64 firmware/raspberrypi-firmware firmware
3944
## PineBook64 Pro
4045
RUN luet install -y arm-vendor-blob/u-boot-rockchip --system-target /pinebookpro/u-boot
4146

42-
## RAW images
47+
## Odroid fw
48+
RUN luet install -y firmware/odroid-c2 --system-target /firmware/odroid-c2
49+
50+
## RAW images for current arch
4351
RUN luet install -y static/grub-efi --system-target /raw/grub
4452
RUN luet install -y static/grub-config --system-target /raw/grubconfig
4553
RUN luet install -y static/grub-artifacts --system-target /raw/grubartifacts
4654

55+
## RAW images for arm64
56+
# Luet will install this artifacts from the current arch repo, so in x86 it will
57+
# get them from the x86 repo and we want it to do it from the arm64 repo, even on x86
58+
# so we use the arm64 luet config and use that to install those on x86
59+
# This is being used by the prepare_arm_images.sh and build-arch-image.sh scripts
60+
RUN luet install --config /tmp/luet-arm64.yaml -y static/grub-efi --system-target /arm/raw/grub
61+
RUN luet install --config /tmp/luet-arm64.yaml -y static/grub-config --system-target /arm/raw/grubconfig
62+
RUN luet install --config /tmp/luet-arm64.yaml -y static/grub-artifacts --system-target /arm/raw/grubartifacts
63+
4764
# remove luet tmp files. Side effect of setting the system-target is that it treats it as a root fs
4865
# so temporal files are stored in each dir
4966
RUN rm -Rf /grub2/var/tmp

tools-image/arm/boards/odroid_c2.sh

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,7 @@ if [ -z "$image" ]; then
77
exit 1
88
fi
99

10-
if [ ! -e "$WORKDIR/luet.yaml" ]; then
11-
ls -liah $WORKDIR
12-
echo "No valid config file"
13-
cat "$WORKDIR/luet.yaml"
14-
exit 1
15-
fi
16-
17-
sudo luet install --config $WORKDIR/luet.yaml -y --system-target $WORKDIR firmware/odroid-c2
1810
# conv=notrunc ?
19-
dd if=$WORKDIR/bl1.bin.hardkernel of=$image conv=fsync bs=1 count=442
20-
dd if=$WORKDIR/bl1.bin.hardkernel of=$image conv=fsync bs=512 skip=1 seek=1
21-
dd if=$WORKDIR/u-boot.odroidc2 of=$image conv=fsync bs=512 seek=97
11+
dd if=/firmware/odroid-c2/bl1.bin.hardkernel of=$image conv=fsync bs=1 count=442
12+
dd if=/firmware/odroid-c2/bl1.bin.hardkernel of=$image conv=fsync bs=512 skip=1 seek=1
13+
dd if=/firmware/odroid-c2/u-boot.odroidc2 of=$image conv=fsync bs=512 seek=97

tools-image/build-arm-image.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,9 @@ cp -rfv ${STATEDIR}/cOS/active.img ${RECOVERY}/cOS/recovery.img
321321
tune2fs -L ${SYSTEM_LABEL} ${RECOVERY}/cOS/recovery.img
322322

323323
# Install real grub config to recovery
324-
cp -rfv /raw/grubconfig/* $RECOVERY
324+
cp -rfv /arm/raw/grubconfig/* $RECOVERY
325325
mkdir -p $RECOVERY/grub2/fonts
326-
cp -rfv /raw/grubartifacts/* $RECOVERY/grub2
326+
cp -rfv /arm/raw/grubartifacts/* $RECOVERY/grub2
327327
mv $RECOVERY/grub2/*pf2 $RECOVERY/grub2/fonts
328328

329329
sync

tools-image/enki/pkg/utils/utils_test.go

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -291,78 +291,4 @@ var _ = Describe("Utils", Label("utils"), func() {
291291
Expect(err).To(HaveOccurred())
292292
})
293293
})
294-
Describe("CleanStack", Label("CleanStack"), func() {
295-
var cleaner *utils.CleanStack
296-
BeforeEach(func() {
297-
cleaner = utils.NewCleanStack()
298-
})
299-
It("Adds a callback to the stack and pops it", func() {
300-
var flag bool
301-
callback := func() error {
302-
flag = true
303-
return nil
304-
}
305-
Expect(cleaner.Pop()).To(BeNil())
306-
cleaner.Push(callback)
307-
poppedJob := cleaner.Pop()
308-
Expect(poppedJob).NotTo(BeNil())
309-
poppedJob()
310-
Expect(flag).To(BeTrue())
311-
})
312-
It("On Cleanup runs callback stack in reverse order", func() {
313-
result := ""
314-
callback1 := func() error {
315-
result = result + "one "
316-
return nil
317-
}
318-
callback2 := func() error {
319-
result = result + "two "
320-
return nil
321-
}
322-
callback3 := func() error {
323-
result = result + "three "
324-
return nil
325-
}
326-
cleaner.Push(callback1)
327-
cleaner.Push(callback2)
328-
cleaner.Push(callback3)
329-
cleaner.Cleanup(nil)
330-
Expect(result).To(Equal("three two one "))
331-
})
332-
It("On Cleanup keeps former error and all callbacks are executed", func() {
333-
err := errors.New("Former error")
334-
count := 0
335-
callback := func() error {
336-
count++
337-
if count == 2 {
338-
return errors.New("Cleanup Error")
339-
}
340-
return nil
341-
}
342-
cleaner.Push(callback)
343-
cleaner.Push(callback)
344-
cleaner.Push(callback)
345-
err = cleaner.Cleanup(err)
346-
Expect(count).To(Equal(3))
347-
Expect(err.Error()).To(ContainSubstring("Former error"))
348-
})
349-
It("On Cleanup error reports first error and all callbacks are executed", func() {
350-
var err error
351-
count := 0
352-
callback := func() error {
353-
count++
354-
if count >= 2 {
355-
return errors.New(fmt.Sprintf("Cleanup error %d", count))
356-
}
357-
return nil
358-
}
359-
cleaner.Push(callback)
360-
cleaner.Push(callback)
361-
cleaner.Push(callback)
362-
err = cleaner.Cleanup(err)
363-
Expect(count).To(Equal(3))
364-
Expect(err.Error()).To(ContainSubstring("Cleanup error 2"))
365-
Expect(err.Error()).To(ContainSubstring("Cleanup error 3"))
366-
})
367-
})
368294
})

tools-image/luet-amd64.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
general:
2+
debug: false
3+
spinner_charset: 9
4+
logging:
5+
enable_emoji: false
6+
repositories:
7+
- name: "kairos"
8+
description: "kairos repository"
9+
type: "docker"
10+
cached: true
11+
enable: true
12+
priority: 2
13+
urls:
14+
- "quay.io/kairos/packages"
15+
reference: 20230718103103-repository.yaml
Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,11 @@ general:
44
logging:
55
enable_emoji: false
66
repositories:
7-
- name: "kairos"
8-
description: "kairos repository"
9-
type: "docker"
10-
arch: amd64
11-
cached: true
12-
priority: 2
13-
urls:
14-
- "quay.io/kairos/packages"
15-
reference: 20230718103103-repository.yaml
167
- name: "kairos-arm64"
178
description: "kairos repository arm64"
189
type: "docker"
19-
arch: arm64
2010
cached: true
11+
enable: true
2112
priority: 2
2213
urls:
2314
- "quay.io/kairos/packages-arm64"

tools-image/prepare_arm_images.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ cp -rfv ${STATEDIR}/cOS/active.img ${RECOVERY}/cOS/recovery.img
9393
tune2fs -L ${SYSTEM_LABEL} ${RECOVERY}/cOS/recovery.img
9494

9595
# Install real grub config to recovery
96-
cp -rfv /raw/grubconfig/* $RECOVERY
96+
cp -rfv /arm/raw/grubconfig/* $RECOVERY
9797
mkdir -p $RECOVERY/grub2/fonts
98-
cp -rfv /raw/grubartifacts/* $RECOVERY/grub2
98+
cp -rfv /arm/raw/grubartifacts/* $RECOVERY/grub2
9999
mv $RECOVERY/grub2/*pf2 $RECOVERY/grub2/fonts
100100

101101
dd if=/dev/zero of=recovery_partition.img bs=1M count=$recovery_size

0 commit comments

Comments
 (0)