install.sh: Script usage
This commit is contained in:
parent
408a78d48a
commit
db6a5cf704
5 changed files with 178 additions and 15 deletions
|
|
@ -23,6 +23,8 @@ it depends on from ../sub/lib.
|
||||||
> variables as we must compile d2 directly on each release target to include dagre.
|
> variables as we must compile d2 directly on each release target to include dagre.
|
||||||
> See https://github.com/terrastruct/d2/issues/31
|
> See https://github.com/terrastruct/d2/issues/31
|
||||||
|
|
||||||
|
Use `--host-only` to build only the release for the host's OS-ARCH pair.
|
||||||
|
|
||||||
### build_docker.sh
|
### build_docker.sh
|
||||||
|
|
||||||
Helper script called by build.sh to build D2 on each linux runner inside Docker.
|
Helper script called by build.sh to build D2 on each linux runner inside Docker.
|
||||||
|
|
|
||||||
|
|
@ -6,4 +6,71 @@ cd -- "$(dirname "$0")/../.."
|
||||||
. ./ci/sub/lib/flag.sh
|
. ./ci/sub/lib/flag.sh
|
||||||
cd -
|
cd -
|
||||||
|
|
||||||
doing installation here
|
help() {
|
||||||
|
arg0="$0"
|
||||||
|
if [ "$0" = sh ]; then
|
||||||
|
arg0="curl -fsSL https://d2lang.com/install.sh | sh -s --"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat <<EOF
|
||||||
|
usage: $arg0 [--dryrun] [--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
|
||||||
|
the installation of standalone releases from GitHub. If you pass --edge, it will clone the
|
||||||
|
source, build a release and install from it.
|
||||||
|
|
||||||
|
Flags:
|
||||||
|
|
||||||
|
--dryrun
|
||||||
|
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.
|
||||||
|
|
||||||
|
--edge
|
||||||
|
Pass to build and install D2 from source.
|
||||||
|
|
||||||
|
--method [detect | standalone]
|
||||||
|
Pass to control the method by which to install. Right now we only support standalone
|
||||||
|
releases from GitHub but later we'll add support for brew, rpm, deb and more.
|
||||||
|
|
||||||
|
- detect is currently unimplemented but would use your OS's package manager
|
||||||
|
automatically.
|
||||||
|
- standalone installs a standalone release archive into ~/.local
|
||||||
|
Add ~/.local/bin to your \$PATH to use it.
|
||||||
|
Control the unix hierarchy path with --prefix
|
||||||
|
|
||||||
|
--prefix ~/.local
|
||||||
|
Controls the unix hierarchy path into which standalone releases are installed.
|
||||||
|
Defaults to ~/.local. You may also want to use /usr/local
|
||||||
|
Remember that whatever you use, you must have the bin directory of your prefix
|
||||||
|
path in \$PATH to execute the d2 binary. For example, if my prefix directory is
|
||||||
|
/usr/local then my \$PATH must contain /usr/local/bin.
|
||||||
|
|
||||||
|
--tala
|
||||||
|
Install Terrastruct's closed source TALA for improved layouts.
|
||||||
|
See https://github.com/terrastruct/TALA
|
||||||
|
|
||||||
|
--tala-version vX.X.X
|
||||||
|
Install the passed version of tala instead of latest.
|
||||||
|
|
||||||
|
--force:
|
||||||
|
Force installation over the existing version even if they match. It will attempt a clean
|
||||||
|
uninstall first before installing the new version. The install assets will not be deleted
|
||||||
|
from ~/.cache/d2/install.
|
||||||
|
|
||||||
|
--uninstall:
|
||||||
|
Uninstall the installed version of d2. The --method flag must be the same as for
|
||||||
|
installation. i.e if you used --method standalone you must again use --method standalone
|
||||||
|
for uninstallation. With detect, the install script will try to use the OS package manager
|
||||||
|
to uninstall instead.
|
||||||
|
|
||||||
|
All downloaded assets are cached into ~/.cache/d2/install. use \$XDG_CACHE_HOME to change
|
||||||
|
path of the cached assets.
|
||||||
|
|
||||||
|
You can rerun install.sh to update your version of D2. install.sh will avoid reinstalling
|
||||||
|
if the installed version is the latest unless --force is passed.
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ cd -- "$(dirname "$0")/../.."
|
||||||
|
|
||||||
help() {
|
help() {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
usage: $0 [--rebuild] [--local] [--dryrun]
|
usage: $0 [--rebuild] [--local] [--dryrun] [--run=regex] [--host-only]
|
||||||
|
|
||||||
$0 builds D2 release archives into ./ci/release/build/<version>/d2-<version>.tar.gz
|
$0 builds D2 release archives into ./ci/release/build/<version>/d2-<version>.tar.gz
|
||||||
|
|
||||||
|
|
@ -14,15 +14,24 @@ commit if available.
|
||||||
|
|
||||||
Flags:
|
Flags:
|
||||||
|
|
||||||
--rebuild: By default build.sh will avoid rebuilding finished assets if they
|
--rebuild
|
||||||
already exist but if you changed something and need to force rebuild, use
|
By default build.sh will avoid rebuilding finished assets if they already exist but if you
|
||||||
this flag.
|
changed something and need to force rebuild, use this flag.
|
||||||
--local: By default build.sh uses \$TSTRUCT_MACOS_AMD64_BUILDER,
|
|
||||||
\$TSTRUCT_MACOS_ARM64_BUILDER, \$TSTRUCT_LINUX_AMD64_BUILDER and
|
--local
|
||||||
\$TSTRUCT_LINUX_ARM64_BUILDER to build the release archives. It's required for
|
By default build.sh uses \$TSTRUCT_MACOS_AMD64_BUILDER, \$TSTRUCT_MACOS_ARM64_BUILDER,
|
||||||
now due to the following issue: https://github.com/terrastruct/d2/issues/31
|
\$TSTRUCT_LINUX_AMD64_BUILDER and \$TSTRUCT_LINUX_ARM64_BUILDER to build the release
|
||||||
With --local, build.sh will cross compile locally.
|
archives. It's required for now due to the following issue:
|
||||||
warning: This is only for testing purposes, do not use in production!
|
https://github.com/terrastruct/d2/issues/31 With --local, build.sh will cross compile
|
||||||
|
locally. warning: This is only for testing purposes, do not use in production!
|
||||||
|
|
||||||
|
--host-only
|
||||||
|
Use to build the release archive for the host OS-ARCH only. All logging is done to stderr
|
||||||
|
so in a script you can read from stdout to get the path to the release archive.
|
||||||
|
|
||||||
|
--run=regex
|
||||||
|
Use to run only the OS-ARCH jobs that match the given regex. e.g. --run=linux only runs
|
||||||
|
the linux jobs. --run=linux-amd64 only runs the linux-amd64 job.
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -52,6 +61,10 @@ main() {
|
||||||
flag_reqarg && shift "$FLAGSHIFT"
|
flag_reqarg && shift "$FLAGSHIFT"
|
||||||
JOBFILTER="$FLAGARG"
|
JOBFILTER="$FLAGARG"
|
||||||
;;
|
;;
|
||||||
|
host-only)
|
||||||
|
flag_noarg && shift "$FLAGSHIFT"
|
||||||
|
HOST_ONLY=1
|
||||||
|
;;
|
||||||
'')
|
'')
|
||||||
shift "$FLAGSHIFT"
|
shift "$FLAGSHIFT"
|
||||||
break
|
break
|
||||||
|
|
@ -66,6 +79,12 @@ main() {
|
||||||
flag_errusage "no arguments are accepted"
|
flag_errusage "no arguments are accepted"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${HOST_ONLY-}" ]; then
|
||||||
|
runjob $(os)-$(arch) "OS=$(os) ARCH=$(arch) build" &
|
||||||
|
waitjobs
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
runjob linux-amd64 'OS=linux ARCH=amd64 build' &
|
runjob linux-amd64 'OS=linux ARCH=amd64 build' &
|
||||||
runjob linux-arm64 'OS=linux ARCH=arm64 build' &
|
runjob linux-arm64 'OS=linux ARCH=arm64 build' &
|
||||||
runjob macos-amd64 'OS=macos ARCH=amd64 build' &
|
runjob macos-amd64 'OS=macos ARCH=amd64 build' &
|
||||||
|
|
@ -99,13 +118,13 @@ build() {
|
||||||
RHOST=$TSTRUCT_LINUX_ARM64_BUILDER build_rhost
|
RHOST=$TSTRUCT_LINUX_ARM64_BUILDER build_rhost
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
COLOR=3 logp warn "no builder for OS=$OS, building locally..."
|
warn "no builder for OS=$OS, building locally..."
|
||||||
build_local
|
build_local
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
COLOR=3 logp warn "no builder for OS=$OS, building locally..."
|
warn "no builder for OS=$OS, building locally..."
|
||||||
build_local
|
build_local
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
|
||||||
2
ci/sub
2
ci/sub
|
|
@ -1 +1 @@
|
||||||
Subproject commit d064c179a5c102c4f54cf63be058461b21b8e28a
|
Subproject commit 30d7e137c97f2d2e2960a52adadc5019a02bfa30
|
||||||
77
install.sh
Normal file → Executable file
77
install.sh
Normal file → Executable file
|
|
@ -152,6 +152,14 @@ logcat() {
|
||||||
COLOR=5 catp log "$@" >&2
|
COLOR=5 catp log "$@" >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
warn() {
|
||||||
|
COLOR=3 logp warn "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
warnf() {
|
||||||
|
COLOR=3 logfp warn "$@"
|
||||||
|
}
|
||||||
|
|
||||||
sh_c() {
|
sh_c() {
|
||||||
COLOR=3 logp exec "$*"
|
COLOR=3 logp exec "$*"
|
||||||
if [ -z "${DRYRUN-}" ]; then
|
if [ -z "${DRYRUN-}" ]; then
|
||||||
|
|
@ -347,4 +355,71 @@ EOF
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
|
|
||||||
doing installation here
|
help() {
|
||||||
|
arg0="$0"
|
||||||
|
if [ "$0" = sh ]; then
|
||||||
|
arg0="curl -fsSL https://d2lang.com/install.sh | sh -s --"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat <<EOF
|
||||||
|
usage: $arg0 [--dryrun] [--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
|
||||||
|
the installation of standalone releases from GitHub. If you pass --edge, it will clone the
|
||||||
|
source, build a release and install from it.
|
||||||
|
|
||||||
|
Flags:
|
||||||
|
|
||||||
|
--dryrun
|
||||||
|
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.
|
||||||
|
|
||||||
|
--edge
|
||||||
|
Pass to build and install D2 from source.
|
||||||
|
|
||||||
|
--method [detect | standalone]
|
||||||
|
Pass to control the method by which to install. Right now we only support standalone
|
||||||
|
releases from GitHub but later we'll add support for brew, rpm, deb and more.
|
||||||
|
|
||||||
|
- detect is currently unimplemented but would use your OS's package manager
|
||||||
|
automatically.
|
||||||
|
- standalone installs a standalone release archive into ~/.local
|
||||||
|
Add ~/.local/bin to your \$PATH to use it.
|
||||||
|
Control the unix hierarchy path with --prefix
|
||||||
|
|
||||||
|
--prefix ~/.local
|
||||||
|
Controls the unix hierarchy path into which standalone releases are installed.
|
||||||
|
Defaults to ~/.local. You may also want to use /usr/local
|
||||||
|
Remember that whatever you use, you must have the bin directory of your prefix
|
||||||
|
path in \$PATH to execute the d2 binary. For example, if my prefix directory is
|
||||||
|
/usr/local then my \$PATH must contain /usr/local/bin.
|
||||||
|
|
||||||
|
--tala
|
||||||
|
Install Terrastruct's closed source TALA for improved layouts.
|
||||||
|
See https://github.com/terrastruct/TALA
|
||||||
|
|
||||||
|
--tala-version vX.X.X
|
||||||
|
Install the passed version of tala instead of latest.
|
||||||
|
|
||||||
|
--force:
|
||||||
|
Force installation over the existing version even if they match. It will attempt a clean
|
||||||
|
uninstall first before installing the new version. The install assets will not be deleted
|
||||||
|
from ~/.cache/d2/install.
|
||||||
|
|
||||||
|
--uninstall:
|
||||||
|
Uninstall the installed version of d2. The --method flag must be the same as for
|
||||||
|
installation. i.e if you used --method standalone you must again use --method standalone
|
||||||
|
for uninstallation. With detect, the install script will try to use the OS package manager
|
||||||
|
to uninstall instead.
|
||||||
|
|
||||||
|
All downloaded assets are cached into ~/.cache/d2/install. use \$XDG_CACHE_HOME to change
|
||||||
|
path of the cached assets.
|
||||||
|
|
||||||
|
You can rerun install.sh to update your version of D2. install.sh will avoid reinstalling
|
||||||
|
if the installed version is the latest unless --force is passed.
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue