Skip to content

Commit defa425

Browse files
committed
ci: generate ext4 image after downloading artifacts
Signed-off-by: Pablo Barbáchano <[email protected]>
1 parent a4cced0 commit defa425

File tree

2 files changed

+13
-20
lines changed

2 files changed

+13
-20
lines changed

resources/rebuild.sh

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,6 @@ function install_dependencies {
1818
sudo apt install -y bc flex bison gcc make libelf-dev libssl-dev squashfs-tools busybox-static tree cpio curl
1919
}
2020

21-
function dir2ext4img {
22-
# ext4
23-
# https://unix.stackexchange.com/questions/503211/how-can-an-image-file-be-created-for-a-directory
24-
local DIR=$1
25-
local IMG=$2
26-
# Default size for the resulting rootfs image is 300M
27-
local SIZE=${3:-300M}
28-
local TMP_MNT=$(mktemp -d)
29-
truncate -s "$SIZE" "$IMG"
30-
mkfs.ext4 -F "$IMG"
31-
sudo mount "$IMG" "$TMP_MNT"
32-
sudo tar c -C $DIR . |sudo tar x -C "$TMP_MNT"
33-
# cleanup
34-
sudo umount "$TMP_MNT"
35-
rmdir $TMP_MNT
36-
}
37-
38-
3921
function compile_and_install {
4022
local C_FILE=$1
4123
local BIN_FILE=$2
@@ -89,8 +71,6 @@ EOF
8971
rootfs_img="$OUTPUT_DIR/$ROOTFS_NAME.squashfs"
9072
sudo mv $rootfs/root/manifest $OUTPUT_DIR/$ROOTFS_NAME.manifest
9173
sudo mksquashfs $rootfs $rootfs_img -all-root -noappend
92-
rootfs_ext4=$OUTPUT_DIR/$ROOTFS_NAME.ext4
93-
dir2ext4img $rootfs $rootfs_ext4
9474
sudo rm -rf $rootfs
9575
sudo chown -Rc $USER. $OUTPUT_DIR
9676
}

tools/test.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,19 @@ if [ -f $CGROUP/cgroup.controllers -a -e $CGROUP/cgroup.type ]; then
3131
> $CGROUP/cgroup.subtree_control
3232
fi
3333

34+
cd build/img/$(uname -m)
35+
for SQUASHFS in *.squashfs; do
36+
EXT4=$(basename $SQUASHFS .squashfs).ext4
37+
# Create rw ext4 image from ro squashfs
38+
[ -f $EXT4 ] && continue
39+
say "Converting $SQUASHFS to $EXT4"
40+
truncate -s 400M $EXT4
41+
unsquashfs $SQUASHFS
42+
mkfs.ext4 -F $EXT4 -d squashfs-root
43+
rm -rf squashfs-root
44+
done
45+
cd -
46+
3447
say "Copy CI artifacts to /srv, so hardlinks work"
3548
cp -ruvf build/img /srv
3649

0 commit comments

Comments
 (0)