diff --git a/.github/workflows/install.yml b/.github/workflows/install.yml new file mode 100644 index 0000000..a3b0513 --- /dev/null +++ b/.github/workflows/install.yml @@ -0,0 +1,19 @@ +name: Install.sh + +on: [push, pull_request] + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Install dependencies + run: sudo apt update && sudo apt install -y curl wget + - name: Install termscp from script + run: | + ./install.sh -v=0.10.0 -f + which termscp || exit 1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 15b4e98..c967219 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ Released on ?? - **Default ssh config path**: - SSH configuration path is now `~/.ssh/config` by default +- Added ARM64 Linux builds - **Bugfix**: - Fixed [Issue 126](https://github.com/veeso/termscp/issues/126) - Fixed [Issue 141](https://github.com/veeso/termscp/issues/141) diff --git a/dist/build/aarch64_centos7/Dockerfile b/dist/build/aarch64_centos7/Dockerfile new file mode 100644 index 0000000..90c4660 --- /dev/null +++ b/dist/build/aarch64_centos7/Dockerfile @@ -0,0 +1,30 @@ +FROM centos:centos7 as builder + +ARG branch +ENV branch=$branch +WORKDIR /usr/src/ +# Install dependencies +RUN yum -y install \ + git \ + gcc \ + pkgconfig \ + gcc \ + make \ + dbus-devel \ + bash \ + rpm-build +# Install rust +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > /tmp/rust.sh && \ + chmod +x /tmp/rust.sh && \ + /tmp/rust.sh -y +# Clone repository +RUN git clone --branch $branch https://github.com/veeso/termscp.git +# Set workdir to termscp +WORKDIR /usr/src/termscp/ +# Build for x86_64 +RUN source $HOME/.cargo/env && cargo build --release +# Install cargo rpm +RUN source $HOME/.cargo/env && cargo install cargo-rpm +# Build pkgs +RUN source $HOME/.cargo/env && cargo rpm init && cargo rpm build +CMD ["sh"] diff --git a/dist/build/aarch64_debian9/Dockerfile b/dist/build/aarch64_debian9/Dockerfile new file mode 100644 index 0000000..fd4b0cf --- /dev/null +++ b/dist/build/aarch64_debian9/Dockerfile @@ -0,0 +1,31 @@ +FROM debian:stretch + +ARG branch +ENV branch=$branch +WORKDIR /usr/src/ +# Install dependencies +RUN apt update && apt install -y \ + git \ + gcc \ + pkg-config \ + libdbus-1-dev \ + build-essential \ + bash \ + curl + +# Install rust +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > /tmp/rust.sh && \ + chmod +x /tmp/rust.sh && \ + /tmp/rust.sh -y +# Clone repository +RUN git clone --branch $branch https://github.com/veeso/termscp.git +# Set workdir to termscp +WORKDIR /usr/src/termscp/ +# Install cargo deb +RUN . $HOME/.cargo/env && cargo install cargo-deb +# Build for x86_64 +RUN . $HOME/.cargo/env && cargo build --release +# Build pkgs +RUN . $HOME/.cargo/env && cargo deb + +CMD ["bash"] diff --git a/dist/build/linux-aarch64.sh b/dist/build/linux-aarch64.sh new file mode 100755 index 0000000..803349c --- /dev/null +++ b/dist/build/linux-aarch64.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +if [ -z "$1" ]; then + echo "Usage: $0 " + exit 1 +fi + +VERSION=$1 + +set -e # Don't fail + +# Create pkgs directory +cd .. +PKGS_DIR=$(pwd)/pkgs +cd - +mkdir -p ${PKGS_DIR}/ +# Build aarch64_deb +cd aarch64_debian9/ +docker buildx build --platform linux/arm64 --build-arg branch=${VERSION} --tag termscp-${VERSION}-aarch64_debian9 . +cd - +mkdir -p ${PKGS_DIR}/deb/ +mkdir -p ${PKGS_DIR}/aarch64-unknown-linux-gnu/ +CONTAINER_NAME=$(docker create termscp-${VERSION}-aarch64_debian9 /bin/bash) +docker cp ${CONTAINER_NAME}:/usr/src/termscp/target/debian/termscp_${VERSION}_arm64.deb ${PKGS_DIR}/deb/ +docker cp ${CONTAINER_NAME}:/usr/src/termscp/target/release/termscp ${PKGS_DIR}/aarch64-unknown-linux-gnu/ +# Make tar.gz +cd ${PKGS_DIR}/aarch64-unknown-linux-gnu/ +tar cvzf termscp-v${VERSION}-aarch64-unknown-linux-gnu.tar.gz termscp +rm termscp +cd - +# Build aarch64_centos7 +cd aarch64_centos7/ +docker buildx build --platform linux/arm64 --build-arg branch=${VERSION} --tag termscp-${VERSION}-aarch64_centos7 . +cd - +mkdir -p ${PKGS_DIR}/rpm/ +CONTAINER_NAME=$(docker create termscp-${VERSION}-aarch64_centos7 /bin/bash) +docker cp ${CONTAINER_NAME}:/usr/src/termscp/target/release/rpmbuild/RPMS/aarch64/termscp-${VERSION}-1.el7.aarch64.rpm ${PKGS_DIR}/rpm/termscp-${VERSION}-1.aarch64.rpm + +exit $? diff --git a/dist/build/docker.sh b/dist/build/linux-x86_64.sh similarity index 96% rename from dist/build/docker.sh rename to dist/build/linux-x86_64.sh index c39dd54..7802f60 100755 --- a/dist/build/docker.sh +++ b/dist/build/linux-x86_64.sh @@ -1,7 +1,7 @@ #!/bin/bash if [ -z "$1" ]; then - echo "Usage: docker.sh " + echo "Usage: $0 " exit 1 fi diff --git a/install.sh b/install.sh index 3f1ef4a..8932e6f 100755 --- a/install.sh +++ b/install.sh @@ -10,8 +10,10 @@ TERMSCP_VERSION="0.11.0" GITHUB_URL="https://github.com/veeso/termscp/releases/download/v${TERMSCP_VERSION}" -DEB_URL="${GITHUB_URL}/termscp_${TERMSCP_VERSION}_amd64.deb" -RPM_URL="${GITHUB_URL}/termscp-${TERMSCP_VERSION}-1.x86_64.rpm" +DEB_URL_AMD64="${GITHUB_URL}/termscp_${TERMSCP_VERSION}_amd64.deb" +DEB_URL_AARCH64="${GITHUB_URL}/termscp_${TERMSCP_VERSION}_arm64.deb" +RPM_URL_AMD64="${GITHUB_URL}/termscp-${TERMSCP_VERSION}-1.x86_64.rpm" +RPM_URL_AARCH64="${GITHUB_URL}/termscp-${TERMSCP_VERSION}-1.aarch64.rpm" PATH="$PATH:/usr/sbin" @@ -30,6 +32,15 @@ NO_COLOR="$(tput sgr0 2>/dev/null || printf '')" # Functions +set_termscp_version() { + TERMSCP_VERSION="$1" + GITHUB_URL="https://github.com/veeso/termscp/releases/download/v${TERMSCP_VERSION}" + DEB_URL_AMD64="${GITHUB_URL}/termscp_${TERMSCP_VERSION}_amd64.deb" + DEB_URL_AARCH64="${GITHUB_URL}/termscp_${TERMSCP_VERSION}_arm64.deb" + RPM_URL_AMD64="${GITHUB_URL}/termscp-${TERMSCP_VERSION}-1.x86_64.rpm" + RPM_URL_AARCH64="${GITHUB_URL}/termscp-${TERMSCP_VERSION}-1.aarch64.rpm" +} + info() { printf '%s\n' "${BOLD}${GREY}>${NO_COLOR} $*" } @@ -215,49 +226,51 @@ install_on_linux() { elif has pikaur; then install_on_arch_linux pikaur elif has dpkg; then - if [ "${ARCH}" != "x86_64" ]; then # It's okay on AUR; not on other distros - try_with_cargo "we don't distribute packages for ${ARCH} at the moment" "linux" + case "${ARCH}" in + x86_64) DEB_URL="$DEB_URL_AMD64" ;; + aarch64) DEB_URL="$DEB_URL_AARCH64" ;; + *) try_with_cargo "we don't distribute packages for ${ARCH} at the moment" && return $? ;; + esac + info "Detected dpkg on your system" + info "Installing ${GREEN}termscp${NO_COLOR} via Debian package" + archive=$(get_tmpfile "deb") + download "${archive}" "${DEB_URL}" + info "Downloaded debian package to ${archive}" + if test_writeable "/usr/bin"; then + sudo="" + msg="Installing ${GREEN}termscp${NO_COLOR}, please wait…" else - info "Detected dpkg on your system" - info "Installing ${GREEN}termscp${NO_COLOR} via Debian package" - archive=$(get_tmpfile "deb") - download "${archive}" "${DEB_URL}" - info "Downloaded debian package to ${archive}" - if test_writeable "/usr/bin"; then - sudo="" - msg="Installing ${GREEN}termscp${NO_COLOR}, please wait…" - else - warn "Root permissions are required to install ${GREEN}termscp${NO_COLOR}…" - elevate_priv - sudo="sudo" - msg="Installing ${GREEN}termscp${NO_COLOR} as root, please wait…" - fi - info "$msg" - $sudo dpkg -i "${archive}" - rm -f ${archive} + warn "Root permissions are required to install ${GREEN}termscp${NO_COLOR}…" + elevate_priv + sudo="sudo" + msg="Installing ${GREEN}termscp${NO_COLOR} as root, please wait…" fi + info "$msg" + $sudo dpkg -i "${archive}" + rm -f ${archive} elif has rpm; then - if [ "${ARCH}" != "x86_64" ]; then # It's okay on AUR; not on other distros - try_with_cargo "we don't distribute packages for ${ARCH} at the moment" "linux" + case "${ARCH}" in + x86_64) RPM_URL="$RPM_URL_AMD64" ;; + aarch64) RPM_URL="$RPM_URL_AARCH64" ;; + *) try_with_cargo "we don't distribute packages for ${ARCH} at the moment" && return $? ;; + esac + info "Detected rpm on your system" + info "Installing ${GREEN}termscp${NO_COLOR} via RPM package" + archive=$(get_tmpfile "rpm") + download "${archive}" "${RPM_URL}" + info "Downloaded rpm package to ${archive}" + if test_writeable "/usr/bin"; then + sudo="" + msg="Installing ${GREEN}termscp${NO_COLOR}, please wait…" else - info "Detected rpm on your system" - info "Installing ${GREEN}termscp${NO_COLOR} via RPM package" - archive=$(get_tmpfile "rpm") - download "${archive}" "${RPM_URL}" - info "Downloaded rpm package to ${archive}" - if test_writeable "/usr/bin"; then - sudo="" - msg="Installing ${GREEN}termscp${NO_COLOR}, please wait…" - else - warn "Root permissions are required to install ${GREEN}termscp${NO_COLOR}…" - elevate_priv - sudo="sudo" - msg="Installing ${GREEN}termscp${NO_COLOR} as root, please wait…" - fi - info "$msg" - $sudo rpm -U "${archive}" - rm -f ${archive} + warn "Root permissions are required to install ${GREEN}termscp${NO_COLOR}…" + elevate_priv + sudo="sudo" + msg="Installing ${GREEN}termscp${NO_COLOR} as root, please wait…" fi + info "$msg" + $sudo rpm -U "${archive}" + rm -f ${archive} else try_with_cargo "No suitable installation method found for your Linux distribution; if you're running on Arch linux, please install an AUR package manager (such as yay). Currently only Arch, Debian based and Red Hat based distros are supported" "linux" fi @@ -401,6 +414,7 @@ fi # parse argv variables while [ "$#" -gt 0 ]; do + echo $1 case "$1" in -V | --verbose) @@ -419,7 +433,10 @@ while [ "$#" -gt 0 ]; do FORCE="${1#*=}" shift 1 ;; - + -v=* | --version=*) + set_termscp_version "${1#*=}" + shift 1 + ;; *) error "Unknown option: $1" exit 1 diff --git a/src/system/watcher/mod.rs b/src/system/watcher/mod.rs index e94facd..143c974 100644 --- a/src/system/watcher/mod.rs +++ b/src/system/watcher/mod.rs @@ -173,7 +173,6 @@ impl FsWatcher { mod test { use super::*; - use crate::utils::test_helpers; use pretty_assertions::assert_eq; use tempfile::TempDir;