From 1945a9052510d99afeef4f998beede519c4b2cc5 Mon Sep 17 00:00:00 2001 From: John Sanpe Date: Mon, 9 Oct 2023 19:27:59 +0800 Subject: [PATCH] initial commit Signed-off-by: John Sanpe --- .github/workflows/build.yml | 32 ++++++++++++ .gitmodules | 7 +++ build.sh | 100 ++++++++++++++++++++++++++++++++++++ linux | 1 + lk2nd | 1 + resize2fs.service | 10 ++++ 6 files changed, 151 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 .gitmodules create mode 100755 build.sh create mode 160000 linux create mode 160000 lk2nd create mode 100644 resize2fs.service diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..fe521ed --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,32 @@ +name: archlinux arm build nightly + +on: + repository_dispatch: + workflow_dispatch: + push: + pull_request: + schedule: + - cron: '0 0 * * *' + +jobs: + build: + strategy: + matrix: + os: [ubuntu-latest] + + name: Test on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Install dependencies + run: | + sudo apt update + sudo apt install make mkbootimg device-tree-compiler \ + gcc-arm-none-eabi gcc-aarch64-linux-gnu \ + libarchive-tools arch-install-scripts qemu-user-static + - name: Initialization submodule + run: git submodule update --init + - name: Build packets + run: sudo bash build.sh diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..cd19ce2 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,7 @@ +[submodule "linux"] + path = linux + url = https://github.com/msm8916-mainline/linux.git + branch = msm8916/6.5.2 +[submodule "lk2nd"] + path = lk2nd + url = https://github.com/msm8916-mainline/lk2nd.git diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..e1e102b --- /dev/null +++ b/build.sh @@ -0,0 +1,100 @@ +#!/usr/bin/env bash + +kerndtb="build/kernel-dtb" +bootimg="build/boot.img" +lk2ndimg="build/aboot.img" + +rootfs="build/rootfs" +ramdisk="$rootfs/boot/initramfs-linux.img" +rootimg="build/rootfs.img" + +function make_boot() +{ + kernel="linux/arch/arm64/boot/Image.gz" + dtbfile="linux/arch/arm64/boot/dts/qcom/msm8916-thwc-ufi001c.dtb" + cat ${kernel} ${dtbfile} > ${kerndtb} +} + +function make_image() +{ + unset options + options+=" --base 0x80000000" + options+=" --pagesize 2048" + options+=" --kernel_offset 0x00080000" + options+=" --second_offset 0x00f00000" + options+=" --tags_offset 0x01e00000" + options+=" --ramdisk_offset 0x02000000" + options+=" --kernel ${kerndtb}" + options+=" --ramdisk ${ramdisk}" + options+=" -o ${bootimg}" + + cmdline="earlycon root=PARTUUID=a7ab80e8-e9d1-e8cd-f157-93f69b1d141e console=ttyMSM0,115200 rw" + mkbootimg --cmdline "${cmdline}" ${options} +} + +function build_lk2nd() +{ + cd lk2nd + make TOOLCHAIN_PREFIX=arm-none-eabi- lk2nd-msm8916 -j$[$(nproc) * 2] + + cd - + cp -p lk2nd/build-lk2nd-msm8916/emmc_appsboot.mbn $lk2ndimg +} + +function build_linux() +{ + cd linux + make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- msm8916_defconfig + make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j$[$(nproc) * 2] + make INSTALL_MOD_PATH=$rootfs modules_install + cd - +} + +function prepare_rootfs() +{ + url="http://os.archlinuxarm.org/os/ArchLinuxARM-aarch64-latest.tar.gz" + rootpack="build/ArchLinuxARM-aarch64-latest.tar.gz" + + if [ ! -e $rootpack ]; then + curl -L -o $rootpack $url + fi + + dd if=/dev/zero of=$rootimg bs=1MiB count=2048 + mkfs.ext4 $rootimg + + mkdir -p $rootfs + mount -o loop $rootimg $rootfs + bsdtar -xpf $rootpack -C $rootfs + sync +} + +function pack_rootfs() +{ + umount $rootfs + tune2fs -M / $rootimg + e2fsck -yf -E discard $rootimg + + resize2fs -M $rootimg + e2fsck -yf $rootimg + zstd $rootimg -o $rootimg.zst +} + +function generate_checksum() +{ + sha256sum $lk2ndimg > $lk2ndimg.sha256sum + sha256sum $bootimg > $bootimg.sha256sum + sha256sum $rootimg.zst > $rootimg.zst.sha256sum +} + +set -ev +mkdir -p build + +prepare_rootfs +build_lk2nd +build_linux + +make_boot +make_image + +pack_rootfs +generate_checksum diff --git a/linux b/linux new file mode 160000 index 0000000..702e255 --- /dev/null +++ b/linux @@ -0,0 +1 @@ +Subproject commit 702e2551f6a48c3df82212c842a662be41184281 diff --git a/lk2nd b/lk2nd new file mode 160000 index 0000000..3c9739a --- /dev/null +++ b/lk2nd @@ -0,0 +1 @@ +Subproject commit 3c9739aaf183d94782ab0dfb5a0f7b4a6808c08b diff --git a/resize2fs.service b/resize2fs.service new file mode 100644 index 0000000..30d20a2 --- /dev/null +++ b/resize2fs.service @@ -0,0 +1,10 @@ +[Unit] +Description=Resize the root filesystem to fill partition + +[Service] +Type=oneshot +ExecStart=/usr/sbin/resize2fs /dev/disk/by-partlabel/rootfs +ExecStartPost=/usr/bin/systemctl disable resize2fs.service + +[Install] +WantedBy=multi-user.target