-
Notifications
You must be signed in to change notification settings - Fork 259
[ new ] install script for the standard library #2895
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
Open
gallais
wants to merge
18
commits into
agda:master
Choose a base branch
from
gallais:install-script
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+207
−0
Open
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
273d05a
[ new ] install script for the standard library
gallais fdedd68
[ cosmetic ] cleanup big cases
gallais 4997342
[ cosmetic ] indentation
gallais 827c2fe
[ fix ] touch files before grepping them
gallais 5e9fe26
[ doc ] explain option choice
gallais 5866910
[ more ] check dependencies + debug mode
gallais a45495d
[ fix ] be more careful about overwriting dirs
gallais 493080f
[ cosmetic ] more structure
gallais eba7fa7
[ ergonomics ] make more of an effort
gallais b7e5775
[ doc ] the installation instruction
gallais 7c4e75f
[ cleanup ] follow the shellcheck advice
gallais 1f03bf6
[ admin ] add a step to the release guide
gallais 1b6ff01
[ more ] gracefully report that wget failed
gallais 6e055c0
[ cleanup ] wording
gallais d0eca1f
[ cleanup ] use variable rather than repetition
gallais 4a762a6
[ doc ] more structure in the README
gallais 732160f
[ fix ] remove redundant full stop
gallais 664159e
[ fix ] defaults-X.Y.Z is not supported yet
gallais File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,141 @@ | ||
| #!/bin/sh | ||
|
|
||
| set -eu | ||
|
|
||
| throwError() { | ||
| echo "\033[91m✗\033[0m $1." >&2 | ||
| exit 1 | ||
| } | ||
|
|
||
| logHappy() { | ||
| echo "\033[32m✔\033[0m $1" | ||
| } | ||
|
|
||
| # Pick the Agda executable to analyse | ||
| # unless the caller has specified one | ||
| if [ -z ${AGDA_EXEC-} ]; then | ||
| read -p "What's the name of your Agda executable (default: agda)? " AGDA_EXEC | ||
| if [ -z "$AGDA_EXEC" ]; then | ||
| AGDA_EXEC=agda | ||
| fi | ||
| fi | ||
|
|
||
| # Double check that the command exists | ||
| if ! [ -x "$(command -v $AGDA_EXEC)" ]; then | ||
| throwError "'$AGDA_EXEC' is not a valid executable" | ||
| fi | ||
|
|
||
| logHappy "Agda executable: $AGDA_EXEC" | ||
|
|
||
| # Ask the executable for its version number | ||
| # unless the caller has specified one | ||
| if [ -z ${AGDA_VERSION-} ]; then | ||
| AGDA_VERSION=$($AGDA_EXEC --version | head -n 1 | sed "s/^[a-zA-Z ]*\(2[0-9.]*\)\(-.*\)*$/\1/") | ||
| fi | ||
|
|
||
| # Double check that the version number is correct | ||
| if ! echo "$AGDA_VERSION" | grep -Eq "^2(\.[0-9]+)+$"; then | ||
| throwError "'$AGDA_VERSION' is not a valid version number" | ||
| fi | ||
|
|
||
| logHappy "Agda version number: $AGDA_VERSION" | ||
|
|
||
| # Pick the install directory | ||
| # unless the caller has specified one | ||
| if [ -z ${AGDA_DIR-} ]; then | ||
| AGDA_DIR=$($AGDA_EXEC --print-agda-app-dir | head -n 1 || true) | ||
| if echo "$AGDA_DIR" | grep -Eq "^Error.*$"; then | ||
| AGDA_DIR="$HOME/.agda" | ||
| fi | ||
| read -p "Where do you want to install the library (default: $AGDA_DIR)? " AGDA_DIR_OVERWRITE | ||
| if ! [ -z "$AGDA_DIR_OVERWRITE" ]; then | ||
| AGDA_DIR="$AGDA_DIR_OVERWRITE" | ||
| fi | ||
| fi | ||
|
|
||
| logHappy "Agda directory: $AGDA_DIR" | ||
|
|
||
| if [ -z ${STDLIB_VERSION-} ]; then | ||
| case "$AGDA_VERSION" in | ||
| "2.8.0") | ||
| STDLIB_VERSION=2.3 | ||
| ;; | ||
| "2.7.0.1") | ||
| STDLIB_VERSION=2.3 | ||
| ;; | ||
| "2.7.0") | ||
| STDLIB_VERSION=2.2 | ||
| ;; | ||
| "2.6.4.3") | ||
| STDLIB_VERSION=2.1 | ||
| ;; | ||
| "2.6.4.2") | ||
| STDLIB_VERSION=2.0 | ||
| ;; | ||
| "2.6.4.2") | ||
| STDLIB_VERSION=2.0 | ||
| ;; | ||
| "2.6.4.1") | ||
| STDLIB_VERSION=2.0 | ||
| ;; | ||
| "2.6.4") | ||
| STDLIB_VERSION=2.0 | ||
| ;; | ||
| "2.6.3") | ||
| STDLIB_VERSION=1.7.3 | ||
| ;; | ||
| "2.6.2.2") | ||
| STDLIB_VERSION=1.7.1 | ||
| ;; | ||
| "2.6.2.1") | ||
| STDLIB_VERSION=1.7.1 | ||
| ;; | ||
| "2.6.1") | ||
| STDLIB_VERSION=1.7.1 | ||
| ;; | ||
| *) | ||
| STDLIB_VERSION=experimental | ||
| ;; | ||
| esac | ||
| fi | ||
|
|
||
| logHappy "Standard library version: $STDLIB_VERSION" | ||
|
|
||
| case "$STDLIB_VERSION" in | ||
| "master") | ||
| STDLIB_TAG="refs/heads/master" | ||
| ;; | ||
| "experimental") | ||
| STDLIB_TAG="refs/heads/experimental" | ||
| ;; | ||
| *) | ||
| STDLIB_TAG="v$STDLIB_VERSION" | ||
| ;; | ||
| esac | ||
|
|
||
| # Setting up the Agda install directory | ||
| mkdir -p "$AGDA_DIR" | ||
| cd "$AGDA_DIR" | ||
| mkdir -p logs | ||
|
|
||
| # Downloading and extracting the standard library | ||
| STDLIB_TARBALL_NAME="/tmp/agda-stdlib-$STDLIB_VERSION.tar.gz" | ||
| STDLIB_TARBALL_URL="https://github.com/agda/agda-stdlib/archive/$STDLIB_TAG.tar.gz" | ||
| wget -O "$STDLIB_TARBALL_NAME" "$STDLIB_TARBALL_URL" -o logs/wget | ||
gallais marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| tar -zxvf "$STDLIB_TARBALL_NAME" > logs/tar | ||
|
|
||
| logHappy "Successfully downloaded the standard library" | ||
|
|
||
| # Adding the standard library to the list of installed and default libraries | ||
| STDLIB_PATH="$AGDA_DIR/agda-stdlib-$STDLIB_VERSION/standard-library.agda-lib" | ||
| AGDA_LIBRARIES_FILE="libraries-$AGDA_VERSION" | ||
|
|
||
| if ! grep -Eq "$STDLIB_PATH" "$AGDA_LIBRARIES_FILE"; then | ||
| echo "$STDLIB_PATH" >> "$AGDA_LIBRARIES_FILE" | ||
| fi | ||
|
|
||
| if ! grep -Eq "^standard-library$" "defaults-$AGDA_VERSION"; then | ||
| echo "standard-library" >> "defaults-$AGDA_VERSION" | ||
gallais marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| fi | ||
|
|
||
| logHappy "Successfully installed the standard library" | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we check if e.g.
$HOME/.cabal/bin/$AGDA_EXECexists and suggest that the user should be adding$HOME/.cabal/bin/to theirPATH?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can get
cabal's default install path fromcabalwithcabal path --installdir