image: alpine/latest packages: - coreutils - procps - py3-requests - xz sources: - "https://gitlab.com/postmarketOS/pmaports.git/" - "https://gitlab.com/postmarketOS/pmbootstrap.git/" - "https://gitlab.com/postmarketOS/build.postmarketos.org.git/" environment: BPO_TOKEN_FILE: "/home/build/.token" BPO_API_HOST: https://build.postmarketos.org BPO_JOB_NAME: build_image BPO_WIP_REPO_URL: https://build.postmarketos.org/wip/v23.06/ BPO_WIP_REPO_ARG: '-mp http://build.postmarketos.org/wip/' secrets: - 482975ec-22f7-49fd-9b54-486b0b1947c3 triggers: - action: webhook condition: failure url: https://build.postmarketos.org/api/public/update-job-status tasks: - bpo_setup: | export BPO_JOB_ID="$JOB_ID" # Switch branch and release channel mkdir -p ~/.config ( echo "[pmbootstrap]" echo "is_default_channel = False" ) > ~/.config/pmbootstrap.cfg git -C pmaports checkout v23.06 sudo ln -s "$PWD"/pmbootstrap/pmbootstrap.py /usr/bin/pmbootstrap yes "" | pmbootstrap --aports=$PWD/pmaports -q init sudo modprobe binfmt_misc sudo mount -t binfmt_misc none /proc/sys/fs/binfmt_misc branch="$(git -C pmaports rev-parse --abbrev-ref HEAD)" if [ "$branch" != v23.06 ]; then echo "ERROR: pmbootstrap switched to the wrong branch: $branch" exit 1 fi # Put apk cache into tmpfs to use less disk space (pma#1623) sudo mkdir -p /mnt/tmpfs-for-apks sudo mount -t tmpfs -o size=1500M tmpfs /mnt/tmpfs-for-apks WORK="$(pmbootstrap config work)" for arch in x86_64 aarch64 armv7; do mkdir -p /mnt/tmpfs-for-apks/cache_apk_"$arch" rm -rf "$WORK"/cache_apk_"$arch" ln -s /mnt/tmpfs-for-apks/cache_apk_"$arch" "$WORK" done - img_prepare: | export BPO_JOB_ID="$JOB_ID" IMG_DATE="$(date +%Y%m%d-%H%M)" echo "$IMG_DATE" > img-date # Image prefix format: # -postmarketOS---- UI_VERSION=$(grep "^pkgver=" "$(pmbootstrap config aports \ )"/main/postmarketos-ui-phosh/APKBUILD | cut -d= -f2) IMG_PREFIX="$IMG_DATE"-postmarketOS-v23.06-phosh IMG_PREFIX="$IMG_PREFIX"-"$UI_VERSION"-pine64-pinephone echo "$IMG_PREFIX" > img-prefix pmbootstrap config ui phosh pmbootstrap config device pine64-pinephone mkdir out - img: | export BPO_JOB_ID="$JOB_ID" IMG_PREFIX=$(cat img-prefix) pmbootstrap config kernel '' pmbootstrap config extra_space 0 pmbootstrap config extra_packages lang,musl-locales,osk-sdl pmbootstrap -q -y zap -p printf "%s\n%s\n" 147147 147147 | pmbootstrap \ -m http://dl-cdn.alpinelinux.org/alpine/ \ -mp http://mirror.postmarketos.org/postmarketos/ \ --details-to-stdout \ install \ --no-sshd \ --no-local-pkgs if [ -e $(pmbootstrap config work)/chroot_native/home/pmos/rootfs/pine64-pinephone.img ]; then sudo mv $(pmbootstrap config work)/chroot_native/home/pmos/rootfs/pine64-pinephone.img \ "out/$IMG_PREFIX.img" else # Boot and root partitions in separate files (pmbootstrap!1871) # Name the second file -bootpart.img instead of -boot.img to # avoid confusion with Android boot.img files. sudo mv $(pmbootstrap config work)/chroot_native/home/pmos/rootfs/pine64-pinephone-root.img \ "out/$IMG_PREFIX.img" sudo mv $(pmbootstrap config work)/chroot_native/home/pmos/rootfs/pine64-pinephone-boot.img \ "out/$IMG_PREFIX-bootpart.img" fi ls -lh out - img_bootimg: | export BPO_JOB_ID="$JOB_ID" IMG_PREFIX=$(cat img-prefix) for i in $(pmbootstrap config work)/chroot_rootfs_pine64-pinephone/boot/boot.img*; do if [ -e "$i" ]; then sudo mv "$i" "out/$IMG_PREFIX-boot.img" fi done ls -lh out - img_installer: | export BPO_JOB_ID="$JOB_ID" IMG_PREFIX=$(cat img-prefix) pmbootstrap config extra_space 100 pmbootstrap config extra_packages none pmbootstrap -q -y zap -p # Use less space by hardlinking rootfs.img instead of copying sudo mkdir -p $(pmbootstrap config work)/chroot_installer_pine64-pinephone/var/lib sudo ln "out/$IMG_PREFIX.img" \ $(pmbootstrap config work)/chroot_installer_pine64-pinephone/var/lib/rootfs.img pmbootstrap \ -m http://dl-cdn.alpinelinux.org/alpine/ \ -mp http://mirror.postmarketos.org/postmarketos/ \ --details-to-stdout \ install \ --no-sshd \ --no-local-pkgs \ --ondev \ --no-rootfs # Remove hardlink again, so we can compress the file in-place sudo rm $(pmbootstrap config work)/chroot_installer_pine64-pinephone/var/lib/rootfs.img if [ -e $(pmbootstrap config work)/chroot_native/home/pmos/rootfs/pine64-pinephone.img ]; then sudo mv $(pmbootstrap config work)/chroot_native/home/pmos/rootfs/pine64-pinephone.img \ "out/$IMG_PREFIX-installer.img" else # Boot and root partitions in separate files (pmbootstrap!1871) # Move the root partition to -installer.img and ignore the boot # partition (it's the same as the -bootpart.img saved in the # img task above). sudo mv $(pmbootstrap config work)/chroot_native/home/pmos/rootfs/pine64-pinephone-root.img \ "out/$IMG_PREFIX-installer.img" fi ls -lh out - compress: | export BPO_JOB_ID="$JOB_ID" sudo chown "$(id -u):$(id -g)" out/*.img for i in out/*.img; do xz -0 -T0 "$i" done ls -lh out - checksums: | export BPO_JOB_ID="$JOB_ID" cd out for i in *; do sha256sum "$i" | tee "$i.sha256" sha512sum "$i" | tee "$i.sha512" done - submit: | export BPO_JOB_ID="$JOB_ID" export BPO_API_ENDPOINT="build-image" export BPO_ARCH="" export BPO_BRANCH=v23.06 export BPO_DEVICE=pine64-pinephone export BPO_UI=phosh export BPO_PAYLOAD_IS_JSON="0" export BPO_PKGNAME="" export BPO_VERSION="$(cat img-date)" # Upload one file at a time prev="" for i in out/*; do export BPO_PAYLOAD_FILES_PREVIOUS="$prev" export BPO_PAYLOAD_FILES="$i" build.postmarketos.org/helpers/submit.py prev="$prev$(basename "$i")#" done # Finalize upload export BPO_PAYLOAD_FILES_PREVIOUS="$prev" export BPO_PAYLOAD_FILES="" build.postmarketos.org/helpers/submit.py