generated from ranajahanzaib/opensource
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
64 lines (53 loc) · 1.4 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
# Exit on any error
set -e
# Constants
PGLS_REPO="https://github.com/ranajahanzaib/pgls.git"
INSTALL_DIR="/usr/local/bin"
RUST_VERSION="1.80" # Adjust to the required Rust version
# Function to check and install Rust if not already installed
install_rust() {
if ! command -v rustup &>/dev/null; then
echo "Rust is not installed. Installing Rust..."
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source "$HOME/.cargo/env"
else
echo "Rust is already installed."
fi
echo "Ensuring required Rust version is installed..."
rustup install $RUST_VERSION
rustup default $RUST_VERSION
}
# Clone the pgls repository
clone_pgls_repo() {
if [ -d "pgls" ]; then
echo "Removing existing pgls directory..."
rm -rf pgls
fi
echo "Cloning pgls repository..."
git clone $PGLS_REPO
}
# Build pgls with cargo
build_pgls() {
echo "Building pgls..."
cd pgls
cargo build --release
cd ..
}
# Move the pgls binary to the system PATH
install_pgls_binary() {
echo "Installing pgls binary to $INSTALL_DIR..."
sudo mv pgls/target/release/pgls "$INSTALL_DIR"
echo "Pgls installed successfully and is accessible as 'pgls'."
}
# Main script execution
main() {
install_rust
clone_pgls_repo
build_pgls
install_pgls_binary
# Cleanup
echo "Cleaning up..."
rm -rf pgls
}
main