Commit 64f91e5f authored by Dalton Durst's avatar Dalton Durst

Add automatic tarball builder

Make it possible for the builder script to run inside a privileged
Docker container, and download all of its needed artifacts from an
appropriate CI source.
parent 5176e6d6
Pipeline #153743972 passed with stage
in 1 minute and 23 seconds
image: ubuntu:20.04
build:
stage: build
script:
- apt update
- apt install xz-utils unzip sudo u-boot-tools wget ca-certificates -y --no-install-recommends
- ./build.sh
artifacts:
paths:
- out/*
......@@ -2,6 +2,8 @@
This repository is used for documentation, issue tracking, and project management for the [Pine64 PinePhone](https://www.pine64.org/pinephone/) port of Ubuntu Touch. Unlike the other Community Ports repositories, it does not contain Android binaries for building system images.
This repository also contains configuration and scripts to build a device tarball, which is installed over an Ubuntu Touch tarball during a system-image installation process.
## How do I install Ubuntu Touch on my PinePhone?
Please note that our PinePhone images are currently **not suitable for daily use**. See [this repository's Issues tab][] for more information. You must reinstall using these instructions often.
......@@ -85,3 +87,10 @@ And yes, the Pinephone is maybe not your daily driver yet. See the list to get a
* USB: MTP access
* USB: RNDIS access
## Building a device image
The remainder of the files in this repository build the PinePhone device tarball, which system-image installs alongside the Ubuntu Touch tarball to create the final Ubuntu Touch software on your device.
You can create a device tarball by running `./build.sh` in this repository. See the [.gitlab-ci.yml](.gitlab-ci.yml) file to see an example run of this script along with installation of dependencies. You will need sudoer rights to your machine, and the script will likely ask for your password before it finishes.
Currently this script will download a Linux kernel, u-boot, and recovery image from Pine64 or UBports CI, whichever is upstream. We would like to allow users to pack a local build of any of these items as well, and for that we welcome contributions.
......@@ -2,39 +2,43 @@
set -xe
OUT=$(realpath $1)
OUT=$(realpath $1 2>/dev/null || echo 'out')
mkdir -p "$OUT"
TMP=$(mktemp -d)
HERE=$(pwd)
SCRIPT=$(dirname $(realpath $0))/build
mkdir ${TMP}/system
mkdir ${TMP}/partitions
mkdir "${TMP}/system"
mkdir "${TMP}/partitions"
TMPDOWN=$(mktemp -d)
cd $TMPDOWN
wget -O u.zip https://gitlab.com/pine64-org/u-boot/-/jobs/artifacts/universalsuperbox/testing-new-partitions/download?job=build
wget -O k.zip https://gitlab.com/pine64-org/linux/-/jobs/artifacts/pine64-kernel-ubports/download?job=build
unzip k.zip
unzip u.zip
ls .
cd $HERE
$SCRIPT/deb-to-bootimg.sh ${TMPDOWN}/linux-image-*-pine64_*.deb ${HERE}/initrd.img ${TMP}/partitions/boot.img
$SCRIPT/wget-extract-deb.sh http://repo.ubports.com/pool/xenial/main/l/linux-firmware-rtlwifi/linux-firmware-rtlwifi_20200316+0ubports0+0~xenial20200412191958.2~1.gbpdcaffd_all.deb ${TMP}/system
$SCRIPT/wget-extract-deb.sh http://repo.ubports.com/pool/xenial/main/l/linux-firmware-pine64-rtl8723-bt/linux-firmware-pine64-rtl8723-bt_20190223+0ubports0+0~xenial20200412190853.3~1.gbp327449_all.deb ${TMP}/system
$SCRIPT/mk-scr.sh uboot ${TMP}/partitions/
$SCRIPT/mk-persist.sh uboot ${TMP}/partitions/
cp ${TMPDOWN}/u-boot-sunxi-with-spl-pinephone.bin ${TMP}/partitions/loader.img
cp recovery-pinephone.img ${TMP}/partitions/recovery.img
cp -av overlay/* ${TMP}/
$SCRIPT/build-tarball-mainline.sh pinephone ${OUT} ${TMP}
cd ${HERE}
rm -r ${TMP}
rm -r ${TMPDOWN}
wget -O 'uboot.zip' 'https://gitlab.com/pine64-org/u-boot/-/jobs/artifacts/universalsuperbox/testing-new-partitions/download?job=build'
wget -O 'kernel.zip' 'https://gitlab.com/pine64-org/linux/-/jobs/artifacts/pine64-kernel-ubports/download?job=build'
wget -O 'recovery-pinephone.img.xz' 'https://gitlab.com/ubports/core/jumpdrive-ubports/-/jobs/artifacts/ubports-recovery/raw/recovery-pinephone.img.xz?job=build'
wget -O 'initrd.img-touch-arm64' 'https://gitlab.com/ubports/core/initramfs-tools-ubuntu-touch/-/jobs/artifacts/xenial_-_edge_-_pine/raw/out/initrd.img-touch-arm64?job=build'
unzip "$TMPDOWN/uboot.zip"
unzip "$TMPDOWN/kernel.zip"
unxz 'recovery-pinephone.img.xz'
ls .
cd "$HERE"
$SCRIPT/deb-to-bootimg.sh "${TMPDOWN}/linux-image-*-pine64_*.deb" "${TMPDOWN}/initrd.img-touch-arm64" "${TMP}/partitions/boot.img"
$SCRIPT/wget-extract-deb.sh 'https://repo.ubports.com/pool/xenial/main/l/linux-firmware-rtlwifi/linux-firmware-rtlwifi_20200316+0ubports0+0~xenial20200412191958.2~1.gbpdcaffd_all.deb' "${TMP}/system"
$SCRIPT/wget-extract-deb.sh 'https://repo.ubports.com/pool/xenial/main/l/linux-firmware-pine64-rtl8723-bt/linux-firmware-pine64-rtl8723-bt_20190223+0ubports0+0~xenial20200412190853.3~1.gbp327449_all.deb' "${TMP}/system"
$SCRIPT/mk-scr.sh 'uboot' "${TMP}/partitions/"
$SCRIPT/mk-persist.sh 'uboot' "${TMP}/partitions/"
cd "${HERE}"
cp "${TMPDOWN}/u-boot-sunxi-with-spl-pinephone.bin" "${TMP}/partitions/loader.img"
cp "${TMPDOWN}/recovery-pinephone.img" "${TMP}/partitions/recovery.img"
cp -av overlay/* "${TMP}/"
$SCRIPT/build-tarball-mainline.sh pinephone "${OUT}" "${TMP}"
rm -r "${TMP}"
rm -r "${TMPDOWN}"
echo "done"
set -e
set -ex
device=$1
output=$(realpath $2)
......@@ -13,5 +13,5 @@ if [ ! -f "$dir/partitions/recovery.img" ]; then
echo "recovery.img does not exist!"
exit 1; fi
tar cfJ "$output/mainline_"$device".tar.xz" -C $dir partitions/ system/
tar -cJf "$output/mainline_"$device".tar.xz" -C $dir partitions/ system/
echo "$(date +%Y%m%d)-$RANDOM" > "$output/mainline_"$device".tar.build"
......@@ -2,6 +2,8 @@
set -xe
source "$(dirname $0)/mk-loopdev.sh"
DEB=$(realpath $1)
INT=$(realpath $2)
OUT=$(realpath $3)
......@@ -18,7 +20,7 @@ cd ${HERE}
truncate --size 50M ${OUT}
mkfs.ext4 ${OUT}
sudo mount ${OUT} ${TMPMNT}
LOOPDEV=$(mount_loopdev "$OUT" "$TMPMNT")
sudo mv ${TMP}/boot/* ${TMPMNT}
sudo mv ${TMPMNT}/vmlinuz-* ${TMPMNT}/vmlinuz
......@@ -26,8 +28,6 @@ sudo mv ${TMP}/usr/lib/linux-image-*/allwinner/sun50i-a64-pinephone-1.1.dtb ${TM
sudo mv ${TMP}/lib/modules ${TMPMNT}/modules
sudo cp ${INT} ${TMPMNT}/
sudo umount ${TMPMNT}
rm -r ${TMPMNT}
rm -r ${TMP}
cleanup_loopdev "$LOOPDEV"
echo "done"
#!/bin/bash
# Functions to create and mount a loop device.
# Useful in Docker containers where /dev/loop cannot be populated after the
# container starts so manual losetup is needed.
# Mounts $1 at $2, taking care of silly loopdev creation.
# Echoes the name of the created loop device. Send this back to cleanup_loopdev()
# when you're finished.
# $1: Image file to mount
# $2: Desired point to mount image file to
mount_loopdev() {
IMG="$1"
MOUNTPOINT="$2"
TMP=$(mktemp -d)
NEXTLOOP=$(sudo losetup -f) || return 1
NEXTLOOPNUM=$(echo "$NEXTLOOP" | cut -b 10-14)
LOOPDEV="$TMP/mk-loopdev-loop$NEXTLOOPNUM"
sudo mknod "$LOOPDEV" b 7 "$NEXTLOOPNUM" || return 1
sudo losetup "$LOOPDEV" "$IMG" || return 1
sudo mount "$LOOPDEV" "$MOUNTPOINT" || return 1
echo "$LOOPDEV"
return 0
}
# Cleans up and removes a loopdev created by mount_loopdev.
# $1: Value echoed by mount_loopdev()
cleanup_loopdev() {
LOOPDEV="$1"
sudo umount "$LOOPDEV" || return 1
sudo losetup -d "$LOOPDEV" || return 1
return 0
}
......@@ -2,20 +2,21 @@
set -xe
source "$(dirname $0)/mk-loopdev.sh"
SRC=$1
OUT=$2
TMP=$(mktemp -d)
truncate --size 500K scr.img
mkfs.ext4 scr.img
mkdir mnt
sudo mount scr.img mnt
LOOPDEV=$(mount_loopdev scr.img "$TMP")
sudo mkimage -A arm -O linux -T script -C none -n "U-Boot boot script" -d $SRC/boot.txt mnt/boot.scr
ls mnt
sudo mkimage -A arm -O linux -T script -C none -n "U-Boot boot script" -d $SRC/boot.txt "$TMP/boot.scr"
sudo umount mnt
rm -r mnt
cleanup_loopdev "$LOOPDEV"
mv scr.img $OUT
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment