From 2648ae2f7d4ff35711a679cf6d09e69c516f72bd Mon Sep 17 00:00:00 2001 From: Archlinux-Jerry Build Bot Date: Wed, 23 Oct 2019 23:38:09 +0800 Subject: [PATCH] change: create update hook for scrcpy --- scrcpy/autobuild.yaml | 3 + .../0001-fix-aarch64-compilation.patch | 20 ++++ scrcpy/buildbot.update.d/update.sh | 94 +++++++++++++++++++ 3 files changed, 117 insertions(+) create mode 100644 scrcpy/buildbot.update.d/0001-fix-aarch64-compilation.patch create mode 100755 scrcpy/buildbot.update.d/update.sh diff --git a/scrcpy/autobuild.yaml b/scrcpy/autobuild.yaml index f9e1b29..0a22a4f 100644 --- a/scrcpy/autobuild.yaml +++ b/scrcpy/autobuild.yaml @@ -2,3 +2,6 @@ type: auto priority: 10 +extra: + - update: + - bash buildbot.update.d/update.sh diff --git a/scrcpy/buildbot.update.d/0001-fix-aarch64-compilation.patch b/scrcpy/buildbot.update.d/0001-fix-aarch64-compilation.patch new file mode 100644 index 0000000..baa607e --- /dev/null +++ b/scrcpy/buildbot.update.d/0001-fix-aarch64-compilation.patch @@ -0,0 +1,20 @@ +diff --git a/PKGBUILD b/PKGBUILD +index 690e344..81978b4 100644 +--- a/PKGBUILD ++++ b/PKGBUILD +@@ -22,8 +22,13 @@ build() { + cd "${src_name}" + + rm -rf build +- meson build --buildtype release --strip -Db_lto=true \ +- -Dprebuilt_server="../${src_server}" ++ if [[ "$CARCH" != 'aarch64' ]]; then ++ meson build --buildtype release --strip -Db_lto=true \ ++ -Dprebuilt_server="../${src_server}" ++ else ++ meson build --buildtype release --strip \ ++ -Dprebuilt_server="../${src_server}" ++ fi + cd build + ninja + } diff --git a/scrcpy/buildbot.update.d/update.sh b/scrcpy/buildbot.update.d/update.sh new file mode 100755 index 0000000..d291c64 --- /dev/null +++ b/scrcpy/buildbot.update.d/update.sh @@ -0,0 +1,94 @@ +#!/bin/bash +# buildbot update hook for aur packages +set -e -o pipefail + +assertPkgname() { + if [[ "$(basename $(pwd))" != "$PKGNAME" ]]; then + echo "Please run this script inside the $PKGNAME dir." + exit 1 + fi +} + +## This section does essential preparations +PKGNAME='scrcpy' && assertPkgname +PKGBUILD='PKGBUILD' +UPDATE_DIR='buildbot.update.d' +git pull --ff-only +git checkout $PKGBUILD +VER=$(source $PKGBUILD; printf "%s-%s" "$pkgver" "$pkgrel") + +# apply patches to the upstream aur package +PATCHES=( + '0001-fix-aarch64-compilation.patch' +) + +# prepare upstream source +prepare() { + sed -i "s/^arch=.*$/arch=('aarch64')/g" PKGBUILD +} + +# which files to include, overrides exclude_files below +INCLUDE_FILES=( +# 'PKGBUILD' +# '.gitignore' +) + +# which files to exclude, use '*' and '.*' to exclude all +EXCLUDE_FILES=( + '.SRCINFO' + '.git' +) + +# This section does actual jobs +newPkgVer() { + # do not print anything to stdout other than new pkgver here + + ver=$(curl -s "https://aur.archlinux.org/rpc/?v=5&type=info&arg[]=${PKGNAME}"| \ + python3 -c 'import json; j=json.loads(input()); print(j.get("results", [dict()])[0].get("Version", 0))') + if [[ "$ver" == "$VER" ]]; then + echo "${PKGNAME} is up to date with aur." >&2 + else + echo "${PKGNAME} has new ver form aur: ${ver}" >&2 + echo "$ver" + fi +} + +newpkgver=$(newPkgVer) +[ -z "$newpkgver" ] && exit 0 + +incfiles='' +for f in "${INCLUDE_FILES[@]}"; do + incfiles="$incfiles"$'\n'"$f" +done + +excfiles='{' +for f in "${EXCLUDE_FILES[@]}"; do + excfiles="${excfiles}${f}," +done +excfiles="${excfiles}}" +[[ "$excfiles" == '{}' ]] && excfiles='' + +pushd "$UPDATE_DIR" >/dev/null +rm -rf "$PKGNAME" +git clone --depth 1 "https://aur.archlinux.org/${PKGNAME}.git" "$PKGNAME" + +cd "$PKGNAME" && prepare +for patch in "${PATCHES[@]}"; do + git apply "../${patch}" +done + +add_files=$(eval ls -1 --almost-all --ignore=${excfiles}) +add_files="${add_files}"$'\n'"${incfiles}" + +while read f; do + [[ -z "$f" ]] && continue + cp -av "$f" ../../ + (cd ../../ && git add "$f") +done <<< "$add_files" + +cd .. +rm -rf "$PKGNAME" +popd >/dev/null + +git commit -m "autoupdate: ${PKGNAME} to ${newpkgver} from aur" +git push