Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
Signed-off-by: John Sanpe <[email protected]>
  • Loading branch information
sanpeqf committed Oct 9, 2023
0 parents commit a057b3a
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
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 gcc-arm-none-eabi gcc-aarch64-linux-gnu mkbootimg \
bsdtar qemu-user-static libarchive-tools arch-install-scripts
- name: build packets
run: sudo build.sh
7 changes: 7 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -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
100 changes: 100 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions linux
Submodule linux added at 702e25
1 change: 1 addition & 0 deletions lk2nd
Submodule lk2nd added at 3c9739
10 changes: 10 additions & 0 deletions resize2fs.service
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit a057b3a

Please sign in to comment.