mirror of
https://github.com/veeso/termscp.git
synced 2026-09-25 21:41:20 -07:00
Install cargo dependencies when building with cargo (rust too); build without default features on bsd
This commit is contained in:
@@ -34,6 +34,8 @@ Released on FIXME: ??
|
|||||||
- libdbus is now a dependency
|
- libdbus is now a dependency
|
||||||
- added `with-keyring` feature
|
- added `with-keyring` feature
|
||||||
- **❗ BREAKING CHANGE ❗**: if you start using keyring on Linux, all the saved password will be lost
|
- **❗ BREAKING CHANGE ❗**: if you start using keyring on Linux, all the saved password will be lost
|
||||||
|
- **Installation script**:
|
||||||
|
- From now on, in case cargo is used to install termscp, all the cargo dependencies will be installed
|
||||||
- Bugfix:
|
- Bugfix:
|
||||||
- Fixed broken input cursor when typing UTF8 characters (tui-realm 0.3.2)
|
- Fixed broken input cursor when typing UTF8 characters (tui-realm 0.3.2)
|
||||||
- Dependencies:
|
- Dependencies:
|
||||||
|
|||||||
+103
-10
@@ -81,6 +81,17 @@ download() {
|
|||||||
return $rc
|
return $rc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test_writeable() {
|
||||||
|
local path
|
||||||
|
path="${1:-}/test.txt"
|
||||||
|
if touch "${path}" 2>/dev/null; then
|
||||||
|
rm "${path}"
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
elevate_priv() {
|
elevate_priv() {
|
||||||
if ! has sudo; then
|
if ! has sudo; then
|
||||||
error 'Could not find the command "sudo", needed to install termscp on your system.'
|
error 'Could not find the command "sudo", needed to install termscp on your system.'
|
||||||
@@ -95,15 +106,16 @@ elevate_priv() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
test_writeable() {
|
elevate_priv_ex() {
|
||||||
local path
|
check_dir="$1"
|
||||||
path="${1:-}/test.txt"
|
if test_writeable "$check_dir"; then
|
||||||
if touch "${path}" 2>/dev/null; then
|
sudo=""
|
||||||
rm "${path}"
|
else
|
||||||
return 0
|
warn "Root permissions are required to install dependecies"
|
||||||
else
|
elevate_priv
|
||||||
return 1
|
sudo="sudo"
|
||||||
fi
|
fi
|
||||||
|
echo $sudo
|
||||||
}
|
}
|
||||||
|
|
||||||
# Currently supporting:
|
# Currently supporting:
|
||||||
@@ -275,11 +287,92 @@ install_on_macos() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# -- cargo installation
|
||||||
|
|
||||||
|
install_bsd_cargo_deps() {
|
||||||
|
set -e
|
||||||
|
confirm "${YELLOW}libssh, gcc${NO_COLOR} are required to install ${GREEN}termscp${NO_COLOR}; would you like to proceed?"
|
||||||
|
sudo="$(elevate_priv_ex /usr/local/bin)"
|
||||||
|
$sudo pkg install -y curl wget libssh gcc
|
||||||
|
info "Dependencies installed successfully"
|
||||||
|
}
|
||||||
|
|
||||||
|
install_linux_cargo_deps() {
|
||||||
|
local debian_deps="gcc pkg-config libssl-dev libssh2-1-dev libdbus-1-dev"
|
||||||
|
local rpm_deps="gcc openssl pkgconfig libdbus-devel openssl-devel"
|
||||||
|
local arch_deps="gcc openssl pkg-config dbus"
|
||||||
|
local deps_cmd=""
|
||||||
|
# Get pkg manager
|
||||||
|
if has apt; then
|
||||||
|
deps_cmd="apt install -y $debian_deps"
|
||||||
|
elif has apt-get; then
|
||||||
|
deps_cmd="apt-get install -y $debian_deps"
|
||||||
|
elif has yum; then
|
||||||
|
deps_cmd="yum -y install $rpm_deps"
|
||||||
|
elif has dnf; then
|
||||||
|
deps_cmd="dnf -y install $rpm_deps"
|
||||||
|
elif has pacman; then
|
||||||
|
deps_cmd="pacman -S --noconfirm $arch_deps"
|
||||||
|
else
|
||||||
|
error "Could not find any suitable package manager for your linux distro 🙄"
|
||||||
|
error "Supported package manager are: 'apt', 'apt-get', 'yum', 'dnf', 'pacman'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
set -e
|
||||||
|
confirm "${YELLOW}libssh, gcc, openssl, pkg-config, libdbus${NO_COLOR} are required to install ${GREEN}termscp${NO_COLOR}. The following command will be used to install the dependencies: '${BOLD}${YELLOW}${deps_cmd}${NO_COLOR}'. Would you like to proceed?"
|
||||||
|
sudo="$(elevate_priv_ex /usr/local/bin)"
|
||||||
|
$sudo $deps_cmd
|
||||||
|
info "Dependencies installed successfully"
|
||||||
|
}
|
||||||
|
|
||||||
|
install_cargo() {
|
||||||
|
if has cargo; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
cargo_env="$HOME/.cargo/env"
|
||||||
|
# Check if cargo is already installed (actually), but not loaded
|
||||||
|
if [ -f $cargo_env ]; then
|
||||||
|
. $cargo_env
|
||||||
|
fi
|
||||||
|
# Check again cargo
|
||||||
|
if has cargo; then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
confirm "${YELLOW}rust${NO_COLOR} is required to build termscp with cargo; would you like to install it now?"
|
||||||
|
set -e
|
||||||
|
rustup=$(get_tmpfile "sh")
|
||||||
|
info "Downloading rustup.sh…"
|
||||||
|
download "${rustup}" "https://sh.rustup.rs"
|
||||||
|
chmod +x $rustup
|
||||||
|
$rustup -y
|
||||||
|
info "Rust installed with success"
|
||||||
|
. $cargo_env
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
try_with_cargo() {
|
try_with_cargo() {
|
||||||
err="$1"
|
err="$1"
|
||||||
|
# Install cargo
|
||||||
|
install_cargo
|
||||||
if has cargo; then
|
if has cargo; then
|
||||||
info "Installing ${GREEN}termscp${NO_COLOR} via Cargo…"
|
info "Installing ${GREEN}termscp${NO_COLOR} via Cargo…"
|
||||||
cargo install termscp
|
case $PLATFORM in
|
||||||
|
"freebsd")
|
||||||
|
install_bsd_cargo_deps
|
||||||
|
cargo install --no-default-features termscp
|
||||||
|
;;
|
||||||
|
|
||||||
|
"linux")
|
||||||
|
install_linux_cargo_deps
|
||||||
|
cargo install termscp
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
cargo install termscp
|
||||||
|
;;
|
||||||
|
|
||||||
|
esac
|
||||||
else
|
else
|
||||||
error "$err"
|
error "$err"
|
||||||
error "Alternatively you can opt for installing Cargo <https://www.rust-lang.org/tools/install>"
|
error "Alternatively you can opt for installing Cargo <https://www.rust-lang.org/tools/install>"
|
||||||
|
|||||||
Reference in New Issue
Block a user