ci/release: DRYRUN -> DRY_RUN

This commit is contained in:
Anmol Sethi 2022-11-13 23:20:30 -08:00
parent ca336e8fcf
commit 2eff0d4caa
4 changed files with 89 additions and 10 deletions

View file

@ -7,7 +7,7 @@ tag="$(sh_c docker build \
--build-arg GOVERSION="1.19.3.linux-$ARCH" \
-qf ./ci/release/builders/Dockerfile ./ci/release/builders)"
docker_run \
-e DRYRUN \
-e DRY_RUN \
-e HW_BUILD_DIR \
-e VERSION \
-e OS \

View file

@ -11,7 +11,7 @@ version: $VERSION
## Install
\`\`\`sh
make install PREFIX=/usr/local DRYRUN=1
make install PREFIX=/usr/local DRY_RUN=1
# If it looks right, run:
make install PREFIX=/usr/local
\`\`\`
@ -19,7 +19,7 @@ make install PREFIX=/usr/local
## Uninstall
\`\`\`sh
make uninstall PREFIX=/usr/local DRYRUN=1
make uninstall PREFIX=/usr/local DRY_RUN=1
# If it looks right, run:
make uninstall PREFIX=/usr/local
\`\`\`

View file

@ -127,7 +127,7 @@ logcat() {
sh_c() {
COLOR=3 logp exec "$*"
if [ -z "${DRYRUN-}" ]; then
if [ -z "${DRY_RUN-}" ]; then
"$@"
fi
}

View file

@ -162,7 +162,7 @@ warnf() {
sh_c() {
COLOR=3 logp exec "$*"
if [ -z "${DRYRUN-}" ]; then
if [ -z "${DRY_RUN-}" ]; then
eval "$@"
fi
}
@ -271,9 +271,9 @@ flag_parse() {
-*=*)
# Remove everything after first equal sign.
FLAG="${1%%=*}"
FLAGRAW="$FLAG"
# Remove leading hyphens.
FLAG="${FLAG#-}"; FLAG="${FLAG#-}"
FLAGRAW="$(flag_fmt)"
# Remove everything before first equal sign.
FLAGARG="${1#*=}"
FLAGSHIFT=1
@ -293,7 +293,7 @@ flag_parse() {
-*)
# Remove leading hyphens.
FLAG="${1#-}"; FLAG="${FLAG#-}"
FLAGRAW=$1
FLAGRAW=$(flag_fmt)
unset FLAGARG
FLAGSHIFT=1
if [ $# -gt 1 ]; then
@ -351,6 +351,14 @@ Run with --help for usage.
EOF
return 1
}
flag_fmt() {
if [ "$(printf %s "$FLAG" | wc -c)" -eq 1 ]; then
echo "-$FLAG"
else
echo "--$FLAG"
fi
}
#!/bin/sh
set -eu
@ -362,7 +370,7 @@ help() {
fi
cat <<EOF
usage: $arg0 [--dryrun] [--version vX.X.X] [--edge] [--method detect] [--prefix ~/.local]
usage: $arg0 [--dry-run] [--version vX.X.X] [--edge] [--method detect] [--prefix ~/.local]
[--tala] [--tala-version vX.X.X] [--force] [--uninstall]
install.sh automates the installation of D2 onto your system. It currently only supports
@ -371,15 +379,20 @@ source, build a release and install from it.
Flags:
--dryrun
--dry-run
Pass to have install.sh show the install method and flags that will be used to install
without executing them. Very useful to understand what changes it will make to your system.
--version vX.X.X
Pass to have install.sh install the given version instead of the latest version.
note: currently unimplemented.
--edge
Pass to build and install D2 from source.
Pass to build and install D2 from source. This will still use --method if set to detect
to install the release archive for your OS, whether it's apt, yum, brew or standalone
if an unsupported package manager is used. To install from source like a dev would,
use go install oss.terrastruct.com/d2
note: currently unimplemented.
--method [detect | standalone]
Pass to control the method by which to install. Right now we only support standalone
@ -404,6 +417,7 @@ Flags:
--tala-version vX.X.X
Install the passed version of tala instead of latest.
note: currently unimplemented.
--force:
Force installation over the existing version even if they match. It will attempt a clean
@ -423,3 +437,68 @@ You can rerun install.sh to update your version of D2. install.sh will avoid rei
if the installed version is the latest unless --force is passed.
EOF
}
main() {
while :; do
flag_parse "$@"
case "$FLAG" in
h|help)
help
return 0
;;
dry-run)
flag_noarg && shift "$FLAGSHIFT"
DRY_RUN=1
;;
version)
flag_nonemptyarg && shift "$FLAGSHIFT"
VERSION=$FLAGARG
echoerr "$FLAGRAW is currently unimplemented"
exit 1
;;
tala-version)
flag_nonemptyarg && shift "$FLAGSHIFT"
TALA_VERSION=$FLAGARG
echoerr "$FLAGRAW is currently unimplemented"
exit 1
;;
edge)
flag_noarg && shift "$FLAGSHIFT"
EDGE=1
echoerr "$FLAGRAW is currently unimplemented"
exit 1
;;
method)
flag_nonemptyarg && shift "$FLAGSHIFT"
METHOD=$FLAGARG
echoerr "$FLAGRAW is currently unimplemented"
exit 1
;;
prefix)
flag_nonemptyarg && shift "$FLAGSHIFT"
export PREFIX=$FLAGARG
;;
force)
flag_noarg && shift "$FLAGSHIFT"
FORCE=1
;;
uninstall)
flag_noarg && shift "$FLAGSHIFT"
UNINSTALL=1
;;
'')
shift "$FLAGSHIFT"
break
;;
*)
flag_errusage "unrecognized flag $FLAGRAW"
;;
esac
done
if [ $# -gt 0 ]; then
flag_errusage "no arguments are accepted"
fi
}
main "$@"