Skip to content

Commit

Permalink
Add experimental install script
Browse files Browse the repository at this point in the history
  • Loading branch information
DvvCz committed Apr 28, 2024
1 parent e3c26ed commit c1b9c0c
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ git clone https://github.com/DvvCz/cpkg
cargo install --path cpkg
```

### 🛜 cURL script

The other options are preferred, but there is an install script.

```bash
curl -fsSL https://raw.githubusercontent.com/DvvCz/cpkg/master/install.sh | bash
```

### 🔄 Upgrading

You can easily upgrade your `cpkg` binary using the `cpkg upgrade` command.
33 changes: 33 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
repo=DvvCz/cpkg
triple=x86_64-unknown-linux-gnu

if command -v cpkg &> /dev/null; then
echo "Failed to install cpkg -- already exists."
exit 1
fi

# Get latest release
release_json=$(curl -s https://api.github.com/repos/$repo/releases/latest)
release_url=$(grep -o "https://.*/cpkg-v.*-$triple" <<< $release_json)
release_filename=$(grep -o "cpkg-v.*" <<< $release_url)

# CPKG_DIR defaults to ~/.cpkg
cpkg_dir=${CPKG_DIR:=~/.cpkg}

if ! test -v $cpkg_dir; then
mkdir $cpkg_dir
fi

if ! test -v $cpkg_dir/bin; then
mkdir $cpkg_dir/bin
fi

# wget handles folder creation for you
wget -qi - <<< $release_url -O $cpkg_dir/bin/cpkg

chmod +x $cpkg_dir/bin/cpkg

echo -e "\nexport CPKG_INSTALL=\"$cpkg_dir\"" >> ~/.bashrc
echo -e 'export PATH=$CPKG_INSTALL/bin:$PATH\n' >> ~/.bashrc

echo "Installed cpkg to $cpkg_dir and to PATH in ~/.bashrc.\nYou may need to run source ~/.bashrc."

0 comments on commit c1b9c0c

Please sign in to comment.