#!/bin/sh # pdep installer for macOS (Apple silicon) and Linux (x64): curl -fsSL https://pdep.dev/install.sh | sh # # Downloads the latest pdep (or the version in $PDEP_VERSION) from https://pdep.dev, checks it against the release's # SHA256SUMS, and puts it in ~/.pdep/bin. No root needed. To remove pdep, delete ~/.pdep. # Everything runs inside main, so a download cut short runs nothing. set -eu main() { site='https://pdep.dev' os=$(uname -s) arch=$(uname -m) # A terminal running under Rosetta reports x86_64 on Apple silicon. if [ "$os" = Darwin ] && [ "$(sysctl -n sysctl.proc_translated 2>/dev/null || echo 0)" = 1 ]; then arch=arm64; fi case "$os-$arch" in Linux-x86_64 | Linux-amd64) file=pdep-linux-x64 ;; Darwin-arm64) file=pdep-osx-arm64 ;; *) fail "pdep is not built for $os $arch yet (it runs on Windows x64, Linux x64 and Apple silicon Macs)." ;; esac version=${PDEP_VERSION:-$(curl -fsSL "$site/download/latest")} case "$version" in *[!0-9a-z.-]* | '') fail "Not a pdep version: '$version'." ;; esac dir="$HOME/.pdep/bin" mkdir -p "$dir" download="$dir/pdep.download" echo "Downloading pdep $version ..." curl -fsSL "$site/download/$version/$file" -o "$download" expected=$(curl -fsSL "$site/download/$version/SHA256SUMS" | awk -v f="$file" '$2 == f || $2 == "*" f { print $1 }') if command -v sha256sum >/dev/null 2>&1; then actual=$(sha256sum "$download" | awk '{ print $1 }') else actual=$(shasum -a 256 "$download" | awk '{ print $1 }') fi if [ -z "$expected" ] || [ "$actual" != "$expected" ]; then rm -f "$download" fail "The download does not match its SHA-256 checksum; nothing was installed. Try again." fi chmod +x "$download" mv -f "$download" "$dir/pdep" echo echo "pdep $version is installed: $dir/pdep" case ":$PATH:" in *":$dir:"*) ;; *) echo "Add it to your PATH, in ~/.zshrc or ~/.bashrc:" echo " export PATH=\"\$HOME/.pdep/bin:\$PATH\"" ;; esac echo "Next, inside a Git repository: pdep init" } fail() { echo "pdep install: $1" >&2 exit 1 } main "$@"