Skip to content

Commit

Permalink
Various packaging improvements
Browse files Browse the repository at this point in the history
Separate building the docker image from generating fclones packages.
Run packaging as local user.
Add musl and rpm packages.
  • Loading branch information
pkolaczk committed Sep 25, 2022
1 parent dab531c commit c3c7381
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 43 deletions.
39 changes: 0 additions & 39 deletions package.sh

This file was deleted.

6 changes: 6 additions & 0 deletions Dockerfile → packaging/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,11 @@ RUN apt-get install -y fakeroot alien gcc-mingw-w64-x86-64 zip
RUN rustup component add rustfmt
RUN rustup component add clippy
RUN rustup toolchain install stable-x86_64-pc-windows-gnu
RUN rustup target add x86_64-unknown-linux-musl
RUN rustup target add i686-unknown-linux-musl
RUN rustup target add x86_64-pc-windows-gnu
RUN cargo install cargo-deb
RUN mkdir /rpmbuild
RUN chmod -R a+rwx /rpmbuild
RUN chmod -R a+rwx /usr/local/cargo/registry

5 changes: 5 additions & 0 deletions packaging/build-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

# Builds a docker image used for generating various fclones packages
IMAGE="pkolaczk/fclones-builder"
docker build -t $IMAGE $(realpath "$(dirname $0)")
36 changes: 36 additions & 0 deletions packaging/package-internal.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash
set -e
bold=$(tput bold)
normal=$(tput sgr0)

# This script generates packages for a release and places them in target/packages/<version>.
# Don't use it directly, use package.sh instead.

cd "$(dirname $0)/.."

echo "${bold}Building${normal}"
set -x
cargo build --release
cargo build --release --target i686-unknown-linux-musl
cargo build --release --target x86_64-unknown-linux-musl
cargo build --release --target x86_64-pc-windows-gnu
set +x

echo "${bold}Packaging${normal}"
set -x
VERSION=$(cargo pkgid | sed 's/.*#//')
PKG_DIR=target/packages/$VERSION
mkdir -p $PKG_DIR
rm -f $PKG_DIR/*

cargo deb
mv target/debian/*.deb $PKG_DIR

fakeroot alien --to-rpm -c $PKG_DIR/*.deb
mv *.rpm $PKG_DIR
fakeroot alien --to-tgz -c $PKG_DIR/*.deb
mv *.tgz $PKG_DIR/"fclones-$VERSION-linux-glibc-x86_64.tar.gz"

tar -zcvf $PKG_DIR/"fclones-$VERSION-linux-musl-x86_64.tar.gz" target/x86_64-unknown-linux-musl/release/fclones
tar -zcvf $PKG_DIR/"fclones-$VERSION-linux-musl-i686.tar.gz" target/i686-unknown-linux-musl/release/fclones
zip -j $PKG_DIR/"fclones-$VERSION-windows-x86_64.zip" target/x86_64-pc-windows-gnu/release/fclones.exe
9 changes: 6 additions & 3 deletions package-docker.sh → packaging/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
# Additionally the pulled in docker container includes an older libc, therefore generated packages
# will be compatible with older Linux distributions.

FCLONES_HOME=$(realpath "$(dirname $0)")
FCLONES_HOME=$(realpath "$(dirname $0)/..")
echo $FCLONES_HOME
IMAGE="pkolaczk/fclones-builder"
docker build -t $IMAGE "$FCLONES_HOME"
docker run -v "$FCLONES_HOME":/fclones -it $IMAGE /fclones/package.sh
docker run \
-v "$FCLONES_HOME":/fclones \
-u $(id -u ${USER}):$(id -g ${USER}) \
-it $IMAGE /fclones/packaging/package-internal.sh
2 changes: 1 addition & 1 deletion src/reflink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub fn reflink(src: &PathAndMetadata, dest: &PathAndMetadata, log: &dyn Log) ->
fn linux_reflink(
_target: &PathAndMetadata,
_link: &PathAndMetadata,
_log: &StdLog,
_log: &dyn Log,
) -> io::Result<()> {
unreachable!()
}
Expand Down

0 comments on commit c3c7381

Please sign in to comment.