daml/dev-env/bin/dade-info
Digital Asset GmbH 05e691f558 open-sourcing daml
2019-04-04 09:33:38 +01:00

129 lines
3.4 KiB
Plaintext
Executable File

#!/usr/bin/env nix-shell
#! nix-shell -i bash -p coreutils nix-info getopt
set -Eeuo pipefail
DADE_CURRENT_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$DADE_CURRENT_SCRIPT_DIR/../lib/dade-common"
usage() {
cat <<EOF
Prints out information about DA development environment.
Usage: $0 [-h|--help] [-a|--all] [-n|--nix|--no-nix] [-d|--dev-env|--no-dev-env] [-t|--tools|--no-tools]
-h: print this message before exiting
-a: print all available information, enables all options below.
-n: print Nix configuration information, enabled by default.
--no-nix: disable printing Nix configuration information.
-d: print dev-env configuration information, enabled by default.
--no-dev-env: disable printing dev-env configuration information.
EOF
}
opt_nix=1
opt_devenv=1
opt_tools=0
PARAMS=`getopt -n $0 -o handp -l all,no-nix,no-dev-env,help -- "$@"`
if [ $? != 0 ]
then
usage
exit 1
fi
eval set -- "$PARAMS"
# Evaluate valid options
while [ $# -gt 0 ]
do
case "$1" in
-a | --all)
opt_nix=1;
opt_devenv=1;
opt_tools=1;
;;
-n)
opt_nix=1
;;
--no-nix)
opt_nix=0;
;;
-d)
opt_devenv=1
;;
--no-dev-env)
opt_devenv=0;
;;
-t)
opt_tools=1
;;
--no-tools)
opt_tools=0;
;;
-h|--help)
usage
exit 0
;;
esac
shift
done
removeLines() {
echo "$1" | tr '\n' ' '
}
toolInfo() {
local tool="$1"
local target="$DADE_GC_ROOTS/$tool"
local hashfile="${target}.hash"
local hash="missing"
test -e $hashfile && hash="$(cat $hashfile)"
echo "- $tool"
if [[ ! -e "$target" ]]; then
echo " * notice: missing local gcroot $target"
fi
if [[ "$hash" != "$currentHash" ]]; then
echo " * notice: hash mismatch (run the tool to update it, or use dade-preload):"
echo " expected:" $(removeLines "$currentHash")
echo " got: " $(removeLines "$hash")
fi
}
currentHash="$(dadeBaseHash)"
echo "This will output debugging information about development environment on this machine."
echo
if [[ "$opt_devenv" == "1" ]]; then
DADE_PACKAGE=$(nix-build --no-out-link -A cached.dev-env "$DADE_REPO_ROOT/nix" 2>/dev/null)
# dev-env derivation is system-agnostic, so we use Linux version on all machines.
DADE_LATEST_PACKAGE_LINUX=$(
curl -s -L -H"Accept: application/json" \
http://hydra.da-int.net/jobset/da/master-dade-linux/latest-eval/store-paths | \
jq 'map(select(contains ("dev-env")))[0]' -r)
echo "Base dade hashes:" $(removeLines "$currentHash")
echo
echo "Repo root: $DADE_REPO_ROOT"
echo "DADE root dir: $DADE_BASE_ROOT"
echo "DADE dev-env dir: $DADE_DEVENV_DIR"
echo "DADE var dir: $DADE_VAR_DIR"
echo "DADE lib dir: $DADE_LIB_DIR"
echo "DADE gcroots: $DADE_GC_ROOTS"
echo "DADE version: $DADE_PACKAGE ($(cat "$DADE_PACKAGE/VERSION"))"
echo "DADE latest version: $DADE_LATEST_PACKAGE_LINUX"
echo
fi
if [[ "$opt_nix" == "1" ]]; then
echo "nix-info output:"
nix-info -m
fi
if [[ "$opt_tools" == "1" ]]; then
echo "Available tools:"
for tool in $(dadeListTools); do
toolInfo $tool
done
fi