diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 7f22f30..9ad6329 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -25,7 +25,7 @@ jobs: python -m pip install -U --upgrade-strategy=eager -r requirements.txt - name: Build run: | - SOURCE_DATE_EPOCH=$(git show -s --format=%ct) ./build.sh "" "" master + SOURCE_DATE_EPOCH=$(git show -s --format=%ct) ./build.sh --gitref=master - name: Get file name id: vars run: | diff --git a/README.md b/README.md index 16060cc..7dde678 100644 --- a/README.md +++ b/README.md @@ -59,10 +59,10 @@ Supported architectures: `x86_64`, `aarch64` ```bash # Build -./build.sh [$ARCH] [$GITREPO] [$GITREF] +./build.sh [--arch=$ARCH] [--gitrepo=$GITREPO] [--gitref=$GITREF] # Get new list of Python dependencies (for updating config.yml) -./get-dependencies.sh [$ARCH] [$GITREPO] [$GITREF] [$OPT_DEPS] +./get-dependencies.sh [--arch=$ARCH] [--gitrepo=$GITREPO] [--gitref=$GITREF] [depspec...] ``` The AppImages are reproducible when `SOURCE_DATE_EPOCH` is set: diff --git a/build.sh b/build.sh index b0f4eb3..010095d 100755 --- a/build.sh +++ b/build.sh @@ -3,9 +3,9 @@ set -euo pipefail -ARCH="${1:-$(uname -m)}" -GITREPO="${2:-}" -GITREF="${3:-}" +ARCH="$(uname -m)" +GITREPO="" +GITREF="" ROOT=$(git rev-parse --show-toplevel 2>/dev/null || dirname "$(readlink -f "${0}")") CONFIG="${ROOT}/config.yml" @@ -20,6 +20,10 @@ declare -A DEPS=( [docker]=docker ) +_OPTS=$(getopt --name "$0" --long 'help,arch:,gitrepo:,gitref:' --options 'help,a:' -- "$@") +eval set -- "${_OPTS}" +unset _OPTS + # ---- @@ -33,6 +37,50 @@ err() { exit 1 } +print_help() { + echo "Usage: ${0} [options]" + echo + echo "Options:" + echo " -a, --arch Target architecture" + echo " --gitrepo Source" + echo " --gitref Git branch/tag/commit" + exit 0 +} + + +# ---- + + +while true; do + case "${1}" in + -h | --help) + print_help + ;; + -a | --arch) + ARCH="${2}" + shift 2 + ;; + --gitrepo) + GITREPO="${2}" + shift 2 + ;; + --gitref) + GITREF="${2}" + shift 2 + ;; + --) + shift + break + ;; + *) + err "Invalid option: ${1}" + ;; + esac +done + + +# ---- + for dep in "${!DEPS[@]}"; do command -v "${dep}" >/dev/null 2>&1 || err "Missing dependency: ${DEPS["${dep}"]}" diff --git a/get-dependencies.sh b/get-dependencies.sh index c82a3d0..c660cca 100755 --- a/get-dependencies.sh +++ b/get-dependencies.sh @@ -3,11 +3,10 @@ set -euo pipefail -ARCH="${1:-$(uname -m)}" -GITREPO="${2:-}" -GITREF="${3:-}" -OPT_DEPSPEC=("${@}") -OPT_DEPSPEC=("${OPT_DEPSPEC[@]:3}") +ARCH="$(uname -m)" +GITREPO="" +GITREF="" +OPT_DEPSPEC=() ROOT=$(git rev-parse --show-toplevel 2>/dev/null || dirname "$(readlink -f "${0}")") CONFIG="${ROOT}/config.yml" @@ -18,6 +17,10 @@ declare -A DEPS=( [docker]=docker ) +_OPTS=$(getopt --name "$0" --long 'help,arch:,gitrepo:,gitref:' --options 'help,a:' -- "$@") +eval set -- "${_OPTS}" +unset _OPTS + # ---- @@ -31,6 +34,52 @@ err() { exit 1 } +print_help() { + echo "Usage: ${0} [options] [depspec]" + echo + echo "Options:" + echo " -a, --arch Target architecture" + echo " --gitrepo Source" + echo " --gitref Git branch/tag/commit" + exit 0 +} + + +# ---- + + +while true; do + case "${1}" in + -h | --help) + print_help + ;; + -a | --arch) + ARCH="${2}" + shift 2 + ;; + --gitrepo) + GITREPO="${2}" + shift 2 + ;; + --gitref) + GITREF="${2}" + shift 2 + ;; + --) + shift + break + ;; + *) + err "Invalid option: ${1}" + ;; + esac +done + +OPT_DEPSPEC+=("${@}") + + +# ---- + for dep in "${!DEPS[@]}"; do command -v "${dep}" >/dev/null 2>&1 || err "Missing dependency: ${DEPS["${dep}"]}"