Skip to content

Commit dec71e3

Browse files
committed
Use GitHub Releases to distribute updates
1 parent e6f3fb6 commit dec71e3

File tree

4 files changed

+117
-31
lines changed

4 files changed

+117
-31
lines changed

simpleimage/make_rootfs.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,9 @@ EOF
363363
export DEBIAN_FRONTEND=noninteractive
364364
locale-gen en_US.UTF-8
365365
apt-get -y update
366-
apt-get -y install dosfstools curl xz-utils iw rfkill wpasupplicant openssh-server alsa-utils $EXTRADEBS
366+
apt-get -y install dosfstools curl xz-utils iw rfkill wpasupplicant openssh-server alsa-utils jq $EXTRADEBS
367+
/usr/local/sbin/install_mate_desktop.sh
368+
systemctl set-default graphical.target
367369
apt-get -y remove --purge ureadahead
368370
$ADDPPACMD
369371
apt-get -y update
@@ -383,6 +385,9 @@ iface eth0 inet dhcp
383385
EOF
384386
cat > "$DEST/etc/hostname" <<EOF
385387
$MODEL
388+
EOF
389+
cat > "$DEST/etc/pine_model" <<EOF
390+
$MODEL
386391
EOF
387392
cat > "$DEST/etc/hosts" <<EOF
388393
127.0.0.1 localhost
@@ -409,8 +414,6 @@ EOF
409414
rm -f "$DEST/etc/resolv.conf"
410415
rm -f "$DEST"/etc/ssh/ssh_host_*
411416
do_chroot ln -s /run/resolvconf/resolv.conf /etc/resolv.conf
412-
do_chroot /usr/local/sbin/install_mate_desktop.sh
413-
do_chroot systemctl set-default graphical.target
414417
;;
415418
*)
416419
;;

simpleimage/platform-scripts/pine64_update_kernel.sh

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,16 @@ if [ "$(id -u)" -ne "0" ]; then
77
exit 1
88
fi
99

10-
VERSION="latest"
11-
if [ -n "$1" ]; then
12-
VERSION="$1"
10+
VERSION="$1"
11+
12+
if [ -z "$1" ]; then
13+
VERSION=$(curl -s https://api.github.com/repos/ayufan-pine64/linux-build/releases/latest | jq -r ".tag_name")
14+
if [ -z "$VERSION" ]; then
15+
echo "Latest release was not found. Please go to: $LATEST_LIST"
16+
exit 1
17+
fi
18+
19+
echo "Using latest release: $VERSION."
1320
fi
1421

1522
VARIANTFILE="/var/lib/misc/pine64_update_kernel.variant"
@@ -29,8 +36,9 @@ if [ -n "$VARIANT" ]; then
2936
echo "Using Kernel variant: $VARIANT"
3037
fi
3138

32-
URL="https://www.stdin.xyz/downloads/people/longsleep/pine64-images/linux/linux-pine64$VARIANT-$VERSION.tar.xz"
33-
PUBKEY="https://www.stdin.xyz/downloads/people/longsleep/longsleep.asc"
39+
URL="https://github.com/ayufan-pine64/linux-build/releases/download/$1/linux-pine64-$1.tar.xz"
40+
# URL="https://www.stdin.xyz/downloads/people/longsleep/pine64-images/linux/linux-pine64$VARIANT-$VERSION.tar.xz"
41+
# PUBKEY="https://www.stdin.xyz/downloads/people/longsleep/longsleep.asc"
3442
CURRENTFILE="/var/lib/misc/pine64_update_kernel.status"
3543

3644
TEMP=$(mktemp -d -p /var/tmp)
@@ -65,15 +73,15 @@ FILENAME=$TEMP/$(basename ${URL})
6573

6674
downloadAndApply() {
6775
echo "Downloading Linux Kernel ..."
68-
curl "${URL}" -f --progress-bar --output "${FILENAME}"
69-
echo "Downloading signature ..."
70-
curl "${URL}.asc" -f --progress-bar --output "${FILENAME}.asc"
71-
echo "Downloading public key ..."
72-
curl "${PUBKEY}" -f --progress-bar --output "${TEMP}/pub.asc"
73-
74-
echo "Verifying signature ..."
75-
gpg --homedir "${TEMP}" --yes -o "${TEMP}/pub.gpg" --dearmor "${TEMP}/pub.asc"
76-
gpg --homedir "${TEMP}" --status-fd 1 --no-default-keyring --keyring "${TEMP}/pub.gpg" --trust-model always --verify "${FILENAME}.asc" 2>/dev/null
76+
curl -L "${URL}" -f --progress-bar --output "${FILENAME}"
77+
# echo "Downloading signature ..."
78+
# curl "${URL}.asc" -f --progress-bar --output "${FILENAME}.asc"
79+
# echo "Downloading public key ..."
80+
# curl "${PUBKEY}" -f --progress-bar --output "${TEMP}/pub.asc"
81+
82+
# echo "Verifying signature ..."
83+
# gpg --homedir "${TEMP}" --yes -o "${TEMP}/pub.gpg" --dearmor "${TEMP}/pub.asc"
84+
# gpg --homedir "${TEMP}" --status-fd 1 --no-default-keyring --keyring "${TEMP}/pub.gpg" --trust-model always --verify "${FILENAME}.asc" 2>/dev/null
7785

7886
echo "Extracting ..."
7987
mkdir $TEMP/update
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
VERSION="$1"
6+
7+
if [ -z "$1" ]; then
8+
VERSION=$(curl -s https://api.github.com/repos/ayufan-pine64/linux-build/releases/latest | jq -r ".tag_name")
9+
if [ -z "$VERSION" ]; then
10+
echo "Latest release was not found. Please go to: $LATEST_LIST"
11+
exit 1
12+
fi
13+
14+
echo "Using latest release: $VERSION."
15+
fi
16+
17+
DEVICE="/dev/mmcblk0"
18+
URL="https://github.com/ayufan-pine64/linux-build/releases/download/$1/linux-model-$(cat /etc/pine_model)-$1.deb"
19+
CURRENTFILE="/var/lib/misc/pine64_update_model.status"
20+
21+
if [ "$(id -u)" -ne "0" ]; then
22+
echo "This script requires root."
23+
exit 1
24+
fi
25+
26+
TEMP=$(mktemp -d -p /var/tmp)
27+
28+
cleanup() {
29+
if [ -d "$TEMP" ]; then
30+
rm -rf "$TEMP"
31+
fi
32+
}
33+
trap cleanup EXIT INT
34+
35+
CURRENT=""
36+
if [ -e "${CURRENTFILE}" ]; then
37+
CURRENT=$(cat $CURRENTFILE)
38+
fi
39+
40+
echo "Checking for update ..."
41+
ETAG=$(curl -L -f -I -H "If-None-Match: \"${CURRENT}\"" -s "${URL}"|grep ETag|awk -F'"' '{print $2}')
42+
43+
if [ -z "$ETAG" ]; then
44+
echo "Version $VERSION not found."
45+
exit 1
46+
fi
47+
48+
if [ "$ETAG" = "$CURRENT" ]; then
49+
echo "You are already on $VERSION version - abort."
50+
exit 0
51+
fi
52+
53+
FILENAME=$TEMP/$(basename ${URL})
54+
55+
if [ -z "$MARK_ONLY" ]; then
56+
echo "Downloading model package ..."
57+
curl -L "${URL}" -f --progress-bar --output "${FILENAME}"
58+
59+
echo "Installing model package ..."
60+
dpkg -i "${FILENAME}"
61+
62+
echo "Done - you should reboot now."
63+
else
64+
echo "Mark only."
65+
fi
66+
67+
echo $ETAG > "$CURRENTFILE"

simpleimage/platform-scripts/pine64_update_uboot.sh

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,22 @@
22

33
set -e
44

5-
VERSION="latest"
6-
if [ -n "$1" ]; then
7-
VERSION="$1"
5+
VERSION="$1"
6+
7+
if [ -z "$1" ]; then
8+
VERSION=$(curl -s https://api.github.com/repos/ayufan-pine64/linux-build/releases/latest | jq -r ".tag_name")
9+
if [ -z "$VERSION" ]; then
10+
echo "Latest release was not found. Please go to: $LATEST_LIST"
11+
exit 1
12+
fi
13+
14+
echo "Using latest release: $VERSION."
815
fi
916

1017
DEVICE="/dev/mmcblk0"
11-
URL="https://www.stdin.xyz/downloads/people/longsleep/pine64-images/simpleimage-pine64-$VERSION.img.xz"
12-
PUBKEY="https://www.stdin.xyz/downloads/people/longsleep/longsleep.asc"
18+
URL="https://github.com/ayufan-pine64/linux-build/releases/download/$1/simple-image-$(cat /etc/pine_model)-$1.tar.xz"
19+
# URL="https://www.stdin.xyz/downloads/people/longsleep/pine64-images/simpleimage-pine64-$VERSION.img.xz"
20+
# PUBKEY="https://www.stdin.xyz/downloads/people/longsleep/longsleep.asc"
1321
CURRENTFILE="/var/lib/misc/pine64_update_uboot.status"
1422

1523
if [ "$(id -u)" -ne "0" ]; then
@@ -48,15 +56,15 @@ FILENAME=$TEMP/$(basename ${URL})
4856

4957
downloadAndApply() {
5058
echo "Downloading U-Boot image ..."
51-
curl "${URL}" -f --progress-bar --output "${FILENAME}"
52-
echo "Downloading signature ..."
53-
curl "${URL}.asc" -f --progress-bar --output "${FILENAME}.asc"
54-
echo "Downloading public key ..."
55-
curl "${PUBKEY}" -f --progress-bar --output "${TEMP}/pub.asc"
56-
57-
echo "Verifying signature ..."
58-
gpg --homedir "${TEMP}" --yes -o "${TEMP}/pub.gpg" --dearmor "${TEMP}/pub.asc"
59-
gpg --homedir "${TEMP}" --status-fd 1 --no-default-keyring --keyring "${TEMP}/pub.gpg" --trust-model always --verify "${FILENAME}.asc" 2>/dev/null
59+
curl -L "${URL}" -f --progress-bar --output "${FILENAME}"
60+
# echo "Downloading signature ..."
61+
# curl "${URL}.asc" -f --progress-bar --output "${FILENAME}.asc"
62+
# echo "Downloading public key ..."
63+
# curl "${PUBKEY}" -f --progress-bar --output "${TEMP}/pub.asc"
64+
65+
# echo "Verifying signature ..."
66+
# gpg --homedir "${TEMP}" --yes -o "${TEMP}/pub.gpg" --dearmor "${TEMP}/pub.asc"
67+
# gpg --homedir "${TEMP}" --status-fd 1 --no-default-keyring --keyring "${TEMP}/pub.gpg" --trust-model always --verify "${FILENAME}.asc" 2>/dev/null
6068

6169
local boot0_position=8 # KiB
6270
local boot0_size=64 # KiB

0 commit comments

Comments
 (0)