Use sh, not bash

This commit is contained in:
Georges Dupéron 2019-05-28 20:54:37 +02:00
parent 47409db7db
commit c47daad439
8 changed files with 80 additions and 34 deletions

View File

@ -16,16 +16,16 @@ ADD . /ligo
# the upcoming scripts # the upcoming scripts
WORKDIR /ligo WORKDIR /ligo
# Setup a custom opam repository where ligo is published
RUN bash scripts/setup_ligo_opam_repository.sh
# Install required native dependencies # Install required native dependencies
RUN bash scripts/install_native_dependencies.sh RUN sh scripts/install_native_dependencies.sh
# Setup a custom opam repository where ligo is published
RUN sh scripts/setup_ligo_opam_repository.sh
RUN opam update RUN opam update
# Install ligo # Install ligo
RUN bash scripts/install_ligo_with_dependencies.sh RUN sh scripts/install_ligo_with_dependencies.sh
# Use the ligo binary as a default command # Use the ligo binary as a default command
ENTRYPOINT [ "/home/opam/.opam/4.06/bin/ligo" ] ENTRYPOINT [ "/home/opam/.opam/4.06/bin/ligo" ]

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/sh
set -euET -o pipefail set -e
docker build -t ligolang/ligo -f docker/Dockerfile . docker build -t ligolang/ligo -f docker/Dockerfile .

View File

@ -1,4 +1,5 @@
#!/bin/bash #!/bin/sh
set -euET -o pipefail set -e
cd src && opam install . --yes cd src
opam install . --yes

View File

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/sh
set -euET -o pipefail set -e
# TODO: this has many different modes of failure (file temp.opam-2.0.1-x86_64-linux.download-in-progress already exists, /usr/local/bin/opam already exists and is a directory or hard link, …) # TODO: this has many different modes of failure (file temp.opam-2.0.1-x86_64-linux.download-in-progress already exists, /usr/local/bin/opam already exists and is a directory or hard link, …)
# Try to improve these aspects. # Try to improve these aspects.

View File

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/sh
set -euET -o pipefail set -e
# You can run this installer like this: # You can run this installer like this:
# curl https://gitlab.com/ligolang/ligo/blob/master/scripts/installer.sh | bash # curl https://gitlab.com/ligolang/ligo/blob/master/scripts/installer.sh | bash
@ -68,7 +68,7 @@ else
&& (umask 0600 > /dev/null 2>&1; UMASK=0600 touch /usr/local/bin/.temp.ligo.before-atomic-move) \ && (umask 0600 > /dev/null 2>&1; UMASK=0600 touch /usr/local/bin/.temp.ligo.before-atomic-move) \
&& chmod 0600 /usr/local/bin/.temp.ligo.before-atomic-move \ && chmod 0600 /usr/local/bin/.temp.ligo.before-atomic-move \
&& cat > /usr/local/bin/.temp.ligo.before-atomic-move \ && cat > /usr/local/bin/.temp.ligo.before-atomic-move \
) || rm /usr/local/bin/.temp.ligo.before-atomic-move' ) || (rm /usr/local/bin/.temp.ligo.before-atomic-move; exit 1)'
# sudo become root (sudo) for the rest of the commands # sudo become root (sudo) for the rest of the commands
# ( subshell (to clean up temporary file if anything goes wrong) # ( subshell (to clean up temporary file if anything goes wrong)
@ -88,7 +88,7 @@ else
&& if test -d /usr/local/bin/ligo; then printf "/usr/local/bin/ligo already exists and is a directory, cancelling installation"'\\\\'n; rm /usr/local/bin/.temp.ligo.before-atomic-move; \ && if test -d /usr/local/bin/ligo; then printf "/usr/local/bin/ligo already exists and is a directory, cancelling installation"'\\\\'n; rm /usr/local/bin/.temp.ligo.before-atomic-move; \
elif test -L /usr/local/bin/ligo; then printf "/usr/local/bin/ligo already exists and is a symbolic link, cancelling installation"'\\\\'n; rm /usr/local/bin/.temp.ligo.before-atomic-move; \ elif test -L /usr/local/bin/ligo; then printf "/usr/local/bin/ligo already exists and is a symbolic link, cancelling installation"'\\\\'n; rm /usr/local/bin/.temp.ligo.before-atomic-move; \
else mv -i /usr/local/bin/.temp.ligo.before-atomic-move /usr/local/bin/ligo; fi \ else mv -i /usr/local/bin/.temp.ligo.before-atomic-move /usr/local/bin/ligo; fi \
) || rm /usr/local/bin/.temp.ligo.before-atomic-move' ) || (rm /usr/local/bin/.temp.ligo.before-atomic-move; exit 1)'
# Installation finished, try running 'ligo' from your CLI # Installation finished, try running 'ligo' from your CLI
printf \\n'Installation successful, try to run '\''ligo --help'\'' now.'\\n printf \\n'Installation successful, try to run '\''ligo --help'\'' now.'\\n

View File

@ -1,6 +1,9 @@
#!/bin/bash #!/bin/sh
if true; then set -e
set -euET -o pipefail if [ test "x$PWD" = "x" ]; then
echo "Cannot detect the current directory, the environment variable PWD is empty."
exit 1
else
docker run -it -v "$PWD":"$PWD" -w "$PWD" ligolang/ligo:latest "$@" docker run -it -v "$PWD":"$PWD" -w "$PWD" ligolang/ligo:latest "$@"
fi fi
# Do not remove the next line. It is used as an approximate witness that the download of this file was complete. This string should not appear anywhere else in the file. # Do not remove the next line. It is used as an approximate witness that the download of this file was complete. This string should not appear anywhere else in the file.

View File

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/sh
set -euET -o pipefail set -e
vendors/opam-repository-tools/rewrite-local-opam-repository.sh vendors/opam-repository-tools/rewrite-local-opam-repository.sh
opam repo add ligo-opam-repository ./vendors/ligo-opam-repository-local-generated opam repo add ligo-opam-repository ./vendors/ligo-opam-repository-local-generated

View File

@ -1,13 +1,55 @@
#!/bin/bash #!/bin/sh
set -euET -o pipefail
main(){ # Stop on error.
root_dir="$(pwd | sed -e 's/\\/\\\\/' | sed -e 's/&/\\\&/' | sed -e 's/~/\\~/')" set -e
rm -fr vendors/ligo-opam-repository-local-generated
mkdir vendors/ligo-opam-repository-local-generated # Defensive checks. We're going to remove an entire folder so this script is somewhat dangerous. Better check in advance what can go wrong in the entire execution of the script.
cp -a index.tar.gz packages repo urls.txt vendors/ligo-opam-repository-local-generated if test -e index.tar.gz && test -e packages && test -e repo && test -e urls.txt; then
cd vendors/ligo-opam-repository-local-generated if test -d vendors/; then
grep -r --null -l src: | grep -z 'opam$' | xargs -0 \ if test -d "$PWD"; then
sed -i -e 's~src: *"https://gitlab.com/ligolang/ligo/-/archive/master/ligo\.tar\.gz"~src: "file://'"$root_dir"'"~' if command -v sed >/dev/null 2>&1 \
# TODO: run the update.sh script adequately to regenerate the index.tar.gz etc. in the local repo && command -v rm >/dev/null 2>&1 \
} && command -v mkdir >/dev/null 2>&1 \
if main; then exit 0; else exit $?; fi && command -v cp >/dev/null 2>&1 \
&& command -v find >/dev/null 2>&1 \
&& command -v xargs >/dev/null 2>&1 \
&& command -v opam >/dev/null 2>&1; then
# Escape the current directory, to be used as the replacement part of the sed regular expression
escaped_project_root="$(printf %s "$PWD" | sed -e 's/\\/\\\\/' | sed -e 's/&/\\\&/' | sed -e 's/~/\\~/')"
# Recreate vendors/ligo-opam-repository-local-generated which contains a copy of the files related to the opam repository
rm -fr vendors/ligo-opam-repository-local-generated
mkdir vendors/ligo-opam-repository-local-generated
cp -pR index.tar.gz packages repo urls.txt vendors/ligo-opam-repository-local-generated
# Rewrite the URLs in the opam repository to point to the project root
(
cd vendors/ligo-opam-repository-local-generated
find . -type f -name opam -print0 | | xargs -0 sed -i -e 's~src: *"https://gitlab.com/ligolang/ligo/-/archive/master/ligo\.tar\.gz"~src: "file://'"$escaped_project_root"'"~'
)
# Regenerate the index.tar.gz etc. in the local repo
(
cd vendors/ligo-opam-repository-local-generated
opam admin index
opam admin cache
)
else
echo "One of the following commands is unavailable: sed rm mkdir cp find xargs opam."
exit 1
fi
else
echo "Unable to access the current directory as indicated by PWD. Was the CWD of the current shell removed?"
exit 1
fi
else
echo "Cannot find the directory vendors/ in the current directory"
exit 1
fi
else
echo "Cannot find some of the following files in the current directory"
echo "index.tar.gz packages repo urls.txt"
exit 1
fi