From 8b5efcb93dae2bca85334dcc688c6e05d10a6dc0 Mon Sep 17 00:00:00 2001 From: ludeeus Date: Tue, 23 Oct 2018 19:48:04 +0200 Subject: [PATCH 1/2] Add developer-test-pr to bash autocomplete --- package/etc/bash_completion.d/hassbian-config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/etc/bash_completion.d/hassbian-config b/package/etc/bash_completion.d/hassbian-config index 30512e48..3c7dcbcd 100644 --- a/package/etc/bash_completion.d/hassbian-config +++ b/package/etc/bash_completion.d/hassbian-config @@ -4,7 +4,7 @@ _hassbian-config() COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" - opts="install upgrade remove show log share-log --version --help" + opts="developer-test-pr install upgrade remove show log share-log --version --help" altopts="--accept --force --debug --version --help --dev --beta" inst=$(find /opt/hassbian/suites/ -maxdepth 1 -type f | awk -F'/|_' ' {print $NF}' | awk -F. '{print $1}') From 49cec57b845bd7e3472ed01417f139715d27306e Mon Sep 17 00:00:00 2001 From: ludeeus Date: Tue, 23 Oct 2018 20:16:26 +0200 Subject: [PATCH 2/2] Add function and CLI option for developer-test-pr --- package/usr/local/bin/hassbian-config | 28 +++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/package/usr/local/bin/hassbian-config b/package/usr/local/bin/hassbian-config index dfc0c7dd..f27b14a6 100755 --- a/package/usr/local/bin/hassbian-config +++ b/package/usr/local/bin/hassbian-config @@ -102,6 +102,29 @@ function check-permission { return 0 } +function developer-test-pr { # This function fetches a active PR and build a installation package from that and install it on the system. + # This should only be used by maintainers to test PR's! + readonly PRNUMBER="$1" + readonly INSTALLDIR="/tmp/hassbian_config_install_${PRNUMBER}" + if [[ -z "$PRNUMBER" ]]; then + echo "Error: Missing PR argument." + echo "" + echo "Run: bash test_pr.sh PRNUMBER" + return 1 + fi + git clone https://github.com/home-assistant/hassbian-scripts.git "$INSTALLDIR" + cd "$INSTALLDIR" || return 1 + git fetch origin +refs/pull/"$PRNUMBER"/merge || return 1 + git checkout FETCH_HEAD + + chmod 755 -R package + dpkg-deb --build package/ + apt install -y "$INSTALLDIR"/package.deb --reinstall --allow-downgrades + + cd || return 1 + rm -r "$INSTALLDIR" +} + function raspberry_pi_zero_check { ## Start check for Raspberry Pi Zero if [ "$FORCE" != "true" ]; then @@ -308,6 +331,11 @@ case $COMMAND in shift # past argument shift # past value ;; + "developer-test-pr") + RUN="developer-test-pr $2" + shift # past argument + shift # past value + ;; "log") RUN="more $LOGFILE" shift # past argument