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
stage: build
- apt update
- apt install xz-utils unzip sudo u-boot-tools wget ca-certificates -y --no-install-recommends
- ./
- out/*
......@@ -2,6 +2,8 @@
This repository is used for documentation, issue tracking, and project management for the [Pine64 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 `./` 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)
SCRIPT=$(dirname $(realpath $0))/build
mkdir ${TMP}/system
mkdir ${TMP}/partitions
mkdir "${TMP}/system"
mkdir "${TMP}/partitions"
TMPDOWN=$(mktemp -d)
wget -O
wget -O
ls .
cd $HERE
$SCRIPT/ ${TMPDOWN}/linux-image-*-pine64_*.deb ${HERE}/initrd.img ${TMP}/partitions/boot.img
$SCRIPT/ ${TMP}/system
$SCRIPT/ ${TMP}/system
$SCRIPT/ uboot ${TMP}/partitions/
$SCRIPT/ 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/ pinephone ${OUT} ${TMP}
cd ${HERE}
rm -r ${TMP}
rm -r ${TMPDOWN}
wget -O '' ''
wget -O '' ''
wget -O 'recovery-pinephone.img.xz' ''
wget -O 'initrd.img-touch-arm64' ''
unzip "$TMPDOWN/"
unzip "$TMPDOWN/"
unxz 'recovery-pinephone.img.xz'
ls .
cd "$HERE"
$SCRIPT/ "${TMPDOWN}/linux-image-*-pine64_*.deb" "${TMPDOWN}/initrd.img-touch-arm64" "${TMP}/partitions/boot.img"
$SCRIPT/ '' "${TMP}/system"
$SCRIPT/ '' "${TMP}/system"
$SCRIPT/ 'uboot' "${TMP}/partitions/"
$SCRIPT/ '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/ pinephone "${OUT}" "${TMP}"
rm -r "${TMP}"
rm -r "${TMPDOWN}"
echo "done"
set -e
set -ex
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""
......@@ -2,6 +2,8 @@
set -xe
source "$(dirname $0)/"
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"
# 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() {
TMP=$(mktemp -d)
NEXTLOOP=$(sudo losetup -f) || return 1
NEXTLOOPNUM=$(echo "$NEXTLOOP" | cut -b 10-14)
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() {
sudo umount "$LOOPDEV" || return 1
sudo losetup -d "$LOOPDEV" || return 1
return 0
......@@ -2,20 +2,21 @@
set -xe
source "$(dirname $0)/"
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
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment