Last active
March 7, 2026 00:55
-
-
Save dotysan/815d7dacccd4ad2d4f6e0d858277fea5 to your computer and use it in GitHub Desktop.
Install fclones on a Rust-less system using Rust in Docker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /usr/bin/env bash | |
| # | |
| # Install fclones on a Rust-less system using Rust in Docker. | |
| # | |
| set -e | |
| set -u | |
| set -x | |
| # latest stable release | |
| FC_TAG=v0.35.0 | |
| RUST_VER=1-trixie | |
| MACH=$(uname --machine) | |
| TARGET="$MACH-unknown-linux-musl" | |
| main() { | |
| src | |
| cd fclones.git | |
| git switch --detach $FC_TAG | |
| img | |
| bld | |
| ins | |
| cd .. | |
| cln | |
| } | |
| src() { | |
| ! test -d fclones.git ||return 0 | |
| git clone git@github.com:pkolaczk/fclones.git fclones.git | |
| } | |
| img() { | |
| docker pull rust:$RUST_VER | |
| docker build -t build-fclones - <<-EOF | |
| FROM rust:$RUST_VER | |
| # give make build proper perms in .:/fclones | |
| RUN useradd --uid $UID --user-group \ | |
| --create-home --shell /bin/bash $USER | |
| # needed so we can build static | |
| RUN rustup target add $TARGET | |
| WORKDIR /fclones | |
| EOF | |
| } | |
| bld() { | |
| # TODO: --user-group above doesn't always mean :$UID below | |
| docker run --rm \ | |
| --volume "$PWD:/fclones" \ | |
| --user "$UID:$UID" \ | |
| build-fclones \ | |
| cargo build --release --target="$TARGET" | |
| } | |
| ins() { | |
| mkdir --parents ~/.local/bin | |
| cp --force --preserve "target/$TARGET/release/fclones" ~/.local/bin/ | |
| } | |
| cln() { | |
| rm --force --recursive fclones.git | |
| docker image rm build-fclones | |
| } | |
| main | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment