Skip to content

Commit

Permalink
rework install_ddev_head.sh because individual tarballs [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
rfay committed Nov 14, 2024
1 parent f8742b3 commit 194e043
Showing 1 changed file with 10 additions and 30 deletions.
40 changes: 10 additions & 30 deletions scripts/install_ddev_head.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ set -o nounset
if [ ! -d /usr/local/bin ]; then echo 'using sudo to mkdir missing /usr/local/bin' && sudo mkdir -p /usr/local/bin; fi

GITHUB_OWNER=${GITHUB_OWNER:-ddev}
ARTIFACTS="ddev"
TMPDIR=/tmp

RED='\033[31m'
Expand All @@ -22,7 +21,6 @@ OS=$(uname)
BINOWNER=$(ls -ld /usr/local/bin | awk '{print $3}')
USER=$(whoami)
SHACMD=""
FILEBASE=""

if [[ $EUID -eq 0 ]]; then
echo "This script must NOT be run with sudo/root. Please re-run without sudo." 1>&2
Expand All @@ -43,7 +41,7 @@ esac

if [[ "$OS" == "Darwin" ]]; then
SHACMD="shasum -a 256"
OS="darwin"
OS="macos"
elif [[ "$OS" == "Linux" ]]; then
SHACMD="sha256sum"
OS="linux"
Expand All @@ -56,21 +54,18 @@ if ! docker --version >/dev/null 2>&1; then
printf "${YELLOW}A docker provider is required for ddev. Please see https://ddev.readthedocs.io/en/stable/users/install/docker-installation/.${RESET}\n"
fi

ARTIFACTS_URL="https://nightly.link/${GITHUB_OWNER}/ddev/workflows/master-build/master/ddev-head-artifacts.zip"
printf "${GREEN}Downloading latest HEAD build from GitHub Actions...${RESET}\n"
# Define artifact URLs based on OS and architecture
ARTIFACTS_BASE_URL="https://nightly.link/${GITHUB_OWNER}/ddev/workflows/master-build/master"
BINARY_ARTIFACT_URL="${ARTIFACTS_BASE_URL}/ddev-${OS}-${ARCH}.zip"

cd ${TMPDIR}
curl -fsSL "$ARTIFACTS_URL" -o ddev-head-artifacts.zip || (printf "${RED}Failed downloading $ARTIFACTS_URL${RESET}\n" && exit 108)
printf "${GREEN}Downloading artifacts for ${OS}_${ARCH}...${RESET}\n"

printf "${GREEN}Extracting artifacts...${RESET}\n"
unzip -o ddev-head-artifacts.zip
cd ${TMPDIR}

# Verify checksums
${SHACMD} -c checksums.txt || (printf "${RED}Checksum verification failed${RESET}\n" && exit 109)
curl -fsSLO "$BINARY_ARTIFACT_URL" || (printf "${RED}Failed downloading $BINARY_ARTIFACT_URL${RESET}\n" && exit 108)

# Extract the OS/arch specific archive
INNER_ARCHIVE="ddev_${OS}_${ARCH}.zip"
unzip -o ${INNER_ARCHIVE}
# Extract the binary
unzip -o "ddev-${OS}-${ARCH}.zip"

printf "${GREEN}Download verified. Ready to place ddev in your /usr/local/bin.${RESET}\n"

Expand All @@ -97,23 +92,8 @@ fi
chmod +x ddev
${SUDO} mv ddev /usr/local/bin/

# Install completions if available
if command -v brew >/dev/null ; then
if [ -d "$(brew --prefix)/etc/bash_completion.d" ]; then
bash_completion_dir=$(brew --prefix)/etc/bash_completion.d
cp ddev_bash_completion.sh $bash_completion_dir/ddev
printf "${GREEN}Installed ddev bash completions in $bash_completion_dir${RESET}\n"
fi

if [ -d "$(brew --prefix)/share/zsh-completions" ] && [ -f ddev_zsh_completion.sh ]; then
zsh_completion_dir=$(brew --prefix)/share/zsh-completions
cp ddev_zsh_completion.sh $zsh_completion_dir/_ddev
printf "${GREEN}Installed ddev zsh completions in $zsh_completion_dir${RESET}\n"
fi
fi

# Cleanup
rm -f ddev-head-artifacts.zip ${INNER_ARCHIVE} checksums.txt ddev_*_completion.sh
rm -f "ddev-${OS}-${ARCH}.zip"

hash -r

Expand Down

0 comments on commit 194e043

Please sign in to comment.