Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to main and release branches #145

Merged
merged 2 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 15 additions & 16 deletions build
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,6 @@ TARGET="${1:-default}"
# See https://nixos.wiki/wiki/FAQ/How_can_I_install_a_proprietary_or_unfree_package%3F
export NIXPKGS_ALLOW_UNFREE=1

function ensure_branch {
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [ "$CURRENT_BRANCH" != "$1" ]; then
echo
echo "You should be on branch '$1', but you are currently on branch '$CURRENT_BRANCH'."
echo "Aborting."
exit 1
fi
}

if [ "$TARGET" == "vm" ]; then

(set -x; nix-build \
Expand All @@ -42,7 +32,8 @@ You can switch virtual consoles in the guest via QEMU monitor (ctrl-alt-2), send

elif [ "$TARGET" == "develop" ]; then

ensure_branch "develop"
scripts/info-branch-commit
scripts/confirm-or-abort

(set -x; nix-build \
--arg updateCert ./pki/develop/cert.pem \
Expand All @@ -56,7 +47,8 @@ elif [ "$TARGET" == "develop" ]; then

elif [ "$TARGET" == "validation" ]; then

ensure_branch "validation"
scripts/info-branch-commit
scripts/confirm-or-abort

(set -x; nix-build \
--arg updateCert ./pki/validation/cert.pem \
Expand All @@ -70,7 +62,8 @@ elif [ "$TARGET" == "validation" ]; then

elif [ "$TARGET" == "master" ]; then

ensure_branch "master"
scripts/info-branch-commit
scripts/confirm-or-abort

(set -x; nix-build \
--arg updateCert ./pki/master/cert.pem \
Expand All @@ -82,12 +75,18 @@ elif [ "$TARGET" == "master" ]; then
echo
echo "Run ./result/bin/deploy-update to deploy."

# Create a stuck system that will not self-update
# usage: ./build stuck https://url-for-kiosk
elif [ "$TARGET" == "stuck" ]; then

echo "Creating a stuck system that will not self-update."
echo

printf "Kiosk URL? "
read KIOSK_URL

KIOSK_URL=$(echo "$KIOSK_URL" | xargs) # Trim

(set -x; nix-build \
--arg kioskUrl "$2" \
--arg kioskUrl "$KIOSK_URL" \
--arg buildBundle false \
--arg buildDisk false)

Expand Down
15 changes: 15 additions & 0 deletions scripts/confirm-or-abort
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
set -euo pipefail
cd $(dirname "$0")

if [ -n "${1:-}" ]; then

QUESTION="$1"

else

QUESTION="Confirm?"

fi

./yes-no-question "$QUESTION" || (echo "Aborting." && exit 1)
11 changes: 11 additions & 0 deletions scripts/info-branch-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#! /usr/bin/env bash
set -euo pipefail

echo "On branch:"
echo
echo " $(git rev-parse --abbrev-ref HEAD)"
echo
echo "With last commit:"
echo
echo " $(git log -1 --pretty="%h %s")"
echo
21 changes: 21 additions & 0 deletions scripts/yes-no-question
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -euo pipefail

QUESTION="$1"

while true; do

printf "$QUESTION [y/n] "
read ANSWER

if [ "$ANSWER" == "y" ]; then

exit 0

elif [ "$ANSWER" == "n" ]; then

exit 1

fi

done