install.sh: Fixes from @code-asher's review

This commit is contained in:
Anmol Sethi 2020-05-21 15:34:34 -04:00
parent 510d84898c
commit c80b2748e1
No known key found for this signature in database
GPG Key ID: 8CEF1878FF10ADEB

View File

@ -49,9 +49,9 @@ echo_latest_version() {
echo_static_postinstall() { echo_static_postinstall() {
echo echo
cat << EOF cat << EOF
Static release has been installed into $STATIC_INSTALL_PREFIX/code-server-$VERSION Static release has been installed into $STATIC_INSTALL_PREFIX/lib/code-server-$VERSION
Please extend your path to use code-server: Please extend your path to use code-server:
PATH="$STATIC_INSTALL_PREFIX/code-server-$VERSION/bin:\$PATH" PATH="$STATIC_INSTALL_PREFIX/bin:\$PATH"
Then you can run: Then you can run:
code-server code-server
EOF EOF
@ -76,7 +76,7 @@ main() {
DRY_RUN \ DRY_RUN \
STATIC \ STATIC \
STATIC_INSTALL_PREFIX \ STATIC_INSTALL_PREFIX \
SKIP_LOG \ SKIP_ECHO \
VERSION \ VERSION \
OPTIONAL OPTIONAL
@ -118,12 +118,7 @@ main() {
done done
VERSION="${VERSION-$(echo_latest_version)}" VERSION="${VERSION-$(echo_latest_version)}"
STATIC_INSTALL_PREFIX="${STATIC_INSATLL_PREFIX-$HOME/.local}" STATIC_INSTALL_PREFIX="${STATIC_INSTALL_PREFIX-$HOME/.local}"
echo "${DRY_RUN-}"
echo "${STATIC_INSTALL_PREFIX-}"
echo "${VERSION-}"
exit 1
OS="$(os)" OS="$(os)"
if [ ! "$OS" ]; then if [ ! "$OS" ]; then
@ -144,7 +139,7 @@ main() {
exit 0 exit 0
fi fi
CACHE_DIR="$(cache_dir)" CACHE_DIR="$(echo_cache_dir)"
mkdir -p "$CACHE_DIR" mkdir -p "$CACHE_DIR"
if [ "${STATIC-}" ]; then if [ "${STATIC-}" ]; then
@ -217,7 +212,7 @@ fetch() {
-Ro "$FILE.incomplete" \ -Ro "$FILE.incomplete" \
-C - \ -C - \
"$URL" "$URL"
mv "$FILE.incomplete" "$FILE" SKIP_ECHO=1 sh_c mv "$FILE.incomplete" "$FILE"
} }
install_macos() { install_macos() {
@ -260,7 +255,7 @@ install_aur() {
tmp_dir="$(mktemp -d)" tmp_dir="$(mktemp -d)"
( (
cd "$tmp_dir" cd "$tmp_dir"
tar -xzf "$CACHE_DIR/code-server-aur.tar.gz" --strip-components 1 SKIP_ECHO=1 sh_c tar -xzf "$CACHE_DIR/code-server-aur.tar.gz" --strip-components 1
sh_c makepkg -si sh_c makepkg -si
) )
rm -Rf "$tmp_dir" rm -Rf "$tmp_dir"
@ -285,11 +280,16 @@ install_static() {
if [ ! -w "$STATIC_INSTALL_PREFIX" ]; then if [ ! -w "$STATIC_INSTALL_PREFIX" ]; then
sh_c="sudo_sh_c" sh_c="sudo_sh_c"
fi fi
SKIP_ECHO=1 sh_c mkdir -p "$STATIC_INSTALL_PREFIX/lib" "$STATIC_INSTALL_PREFIX/bin"
"$sh_c" tar -C "$STATIC_INSTALL_PREFIX" -xzf "$CACHE_DIR/code-server-$VERSION-$OS-$ARCH.tar.gz" if [[ -e "$STATIC_INSTALL_PREFIX/lib/code-server-$VERSION" ]]; then
# In case previously installed. echo
SKIP_LOG=1 "$sh_c" rm -Rf "$STATIC_INSTALL_PREFIX/code-server-$VERSION" echoerr "code-server-$VERSION is already installed at $STATIC_INSTALL_PREFIX/lib/code-server-$VERSION"
"$sh_c" mv -f "$STATIC_INSTALL_PREFIX/code-server-$VERSION-$OS-$ARCH" "$STATIC_INSTALL_PREFIX/code-server-$VERSION" echoerr "Please remove it to reinstall."
exit 1
fi
"$sh_c" tar -C "$STATIC_INSTALL_PREFIX/lib" -xzf "$CACHE_DIR/code-server-$VERSION-$OS-$ARCH.tar.gz"
"$sh_c" mv -f "$STATIC_INSTALL_PREFIX/lib/code-server-$VERSION-$OS-$ARCH" "$STATIC_INSTALL_PREFIX/lib/code-server-$VERSION"
echo_static_postinstall echo_static_postinstall
} }
@ -390,7 +390,7 @@ command_exists() {
} }
sh_c() { sh_c() {
if [ ! "${SKIP_LOG-}" ]; then if [ ! "${SKIP_ECHO-}" ]; then
echo echo
echo "+ $*" echo "+ $*"
fi fi