diff --git a/.github/workflows/image.yml b/.github/workflows/image.yml index 11c42ba..86b51bd 100644 --- a/.github/workflows/image.yml +++ b/.github/workflows/image.yml @@ -4,20 +4,28 @@ on: push: branches: - main + pull_request: jobs: build: runs-on: ubuntu-latest + container: + image: archlinux:base-devel + options: --privileged + strategy: + matrix: + platform: [odroid, rpi3, rpi4] steps: - uses: actions/checkout@v2 + - run: echo -e "[aurto]\nSigLevel = Optional\nServer = https://aur.raccube.net/" >> /etc/pacman.conf - name: Install dependencies - run: sudo apt install -y libarchive-tools curl fdisk qemu-user-static zstd + run: pacman -Syu --noconfirm gptfdisk arch-install-scripts git qemu-user-static-bin archlinuxarm-keyring python dosfstools - name: Build ODroid image - run: sudo ./build.sh odroid.img + run: sudo ./build.py ${{ matrix.platform }} robot-${{ matrix.platform }}.img - name: Compress image - run: zstd odroid.img + run: zstd robot-${{ matrix.platform }}.img - name: Publish compressed image uses: actions/upload-artifact@v2 with: - name: ODroid Image - path: odroid.img.zst + name: ${{ matrix.platform }} + path: robot-${{ matrix.platform }}.img.zst diff --git a/README.md b/README.md index 8fc4c7c..cda3185 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,6 @@ Scripts used to create a system image for SR brain board SD cards. - bash - Python 3.8 or newer -- curl - fdisk - [arch-install-scripts](https://archlinux.org/packages/extra/any/arch-install-scripts/) - [archlinuxarm-keyring](http://mirror.archlinuxarm.org/armv6h/core/archlinuxarm-keyring-20140119-1-any.pkg.tar.xz) diff --git a/build.py b/build.py index 890f654..1250b1e 100755 --- a/build.py +++ b/build.py @@ -112,6 +112,7 @@ def run_stage(stage: Path, environment, build_dir): print("SR Image Builder") print(f"Build directory: {args.build_dir}") + Path(args.build_dir).mkdir(parents=True, exist_ok=True) stages = determine_stage_list() @@ -127,6 +128,7 @@ def run_stage(stage: Path, environment, build_dir): "CACHE_DIR": str(args.cache_dir), "PLATFORM": args.platform, } + # TODO: Pass through GITHUB_* environment variables atexit.register(cleanup, args.build_dir) diff --git a/stage0/00-host_setup-disk.sh b/stage0/00-host_setup-disk.sh index 2e0ece6..850e27b 100755 --- a/stage0/00-host_setup-disk.sh +++ b/stage0/00-host_setup-disk.sh @@ -1,5 +1,6 @@ #!/bin/bash set -e +set -x source ./util.sh @@ -34,25 +35,34 @@ info "Partitioning disk image" echo # last sector (accept default) echo w # write changes -) | /sbin/fdisk "$IMAGE_OUTPUT_PATH" > /dev/null +) | /sbin/fdisk "$IMAGE_OUTPUT_PATH" #> /dev/null if [[ "$OUTPUT_DEVICE" =~ ^/dev/loop ]]; then info "Setting up loop device" - losetup -P "$OUTPUT_DEVICE" "$IMAGE_OUTPUT_PATH" - boot_part="${OUTPUT_DEVICE}p1" - root_part="${OUTPUT_DEVICE}p2" + + mkdir -p "$BUILD_DIR" + mount -t ext4 -o loop,offset=413696 "$IMAGE_OUTPUT_PATH" "$BUILD_DIR" + mkdir -p "$BUILD_DIR/boot" + mount -t vfat -o loop,offset=4096 "$IMAGE_OUTPUT_PATH" "$BUILD_DIR/boot" else boot_part="${OUTPUT_DEVICE}1" root_part="${OUTPUT_DEVICE}2" fi +/sbin/fdisk -l "$IMAGE_OUTPUT_PATH" +file "$IMAGE_OUTPUT_PATH" +losetup +file "$OUTPUT_DEVICE" +file "$boot_part" +file "$root_part" +ls -lRa /dev/ + info "Creating boot filesystem" mkfs.vfat -F 32 "$boot_part" info "Creating root filesystem" mkfs.ext4 -q "$root_part" -mkdir -p "$BUILD_DIR" info "Mounting root partition" mount -t ext4 -o rw,defaults,noatime "$root_part" "$BUILD_DIR"