Prepare environment
docker run -i -t --rm -v ${PWD}:/mnt \
-e PIP_BREAK_SYSTEM_PACKAGES=1 \
-e PIP_ROOT_USER_ACTION=ignore \
-e PIP_NO_WARN_SCRIPT_LOCATION=0 \
--name=buildenv alpine:latest \
sh -c 'apk add bash; bash'Install build tools:
apk update
apk add build-base
apk add curl
apk add gcc g++ gawk autoconf automake libtool
apk add pkgconf m4 gettext gettext-static gettext-dev
apk add cmake
apk add py3-pip
apk add acl-dev
apk add attr-dev
apk add xxhash-dev
apk add zstd-dev
apk add lz4-dev
apk add openssl-dev
python3 -m pip install --user commonmark
apk add musl-dev
apk add popt-dev
apk add zlib-dev
apk add openssl-libs-staticCreate work directory:
mkdir /work
cd /workPrepare zstd library:
curl -fsSLO https://github.com/facebook/zstd/releases/download/v1.5.7/zstd-1.5.7.tar.gz
tar -zxf zstd-1.5.7.tar.gz
cd zstd-1.5.7
make PREFIX=/opt/zstd install
cd ..Export zstd variables:
export LDFLAGS="-L/opt/zstd/lib${LDFLAGS:+ $LDFLAGS}"
export CPPFLAGS="-I/opt/zstd/include${CPPFLAGS:+ $CPPFLAGS}"
export PKG_CONFIG_PATH="/opt/zstd/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
pkg-config --cflags --libs --static libzstdPrepare lz4 library:
curl -fsSLO https://github.com/lz4/lz4/releases/download/v1.10.0/lz4-1.10.0.tar.gz
tar -zxf lz4-1.10.0.tar.gz
cd lz4-1.10.0
make PREFIX=/opt/lz4 install
cd ..Export lz4 variables:
export LDFLAGS="-L/opt/lz4/lib${LDFLAGS:+ $LDFLAGS}"
export CPPFLAGS="-I/opt/lz4/include${CPPFLAGS:+ $CPPFLAGS}"
export PKG_CONFIG_PATH="/opt/lz4/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
pkg-config --cflags --libs --static liblz4Prepare popt library:
curl -fsSLO https://github.com/rpm-software-management/popt/archive/refs/tags/popt-1.19-release.tar.gz
tar -zxf popt-1.19-release.tar.gz
cd popt-popt-1.19-release
./autogen.sh
./configure --prefix=/opt/popt
make install
cd ..Or from master with the static lib patch:
curl -fsSL https://github.com/rpm-software-management/popt/archive/refs/heads/master.zip -o popt-master.zip
unzip -q popt-master.zip
cd popt-master
curl -fsL https://github.com/rpm-software-management/popt/pull/104.diff | patch -p1
cmake -S . -B ./build -DBUILD_STATIC_LIBS=ON -DCMAKE_INSTALL_PREFIX=/opt/popt
cd build
make install
cd ../..Export popt variables:
export LDFLAGS="-L/opt/popt/lib${LDFLAGS:+ $LDFLAGS}"
export CPPFLAGS="-I/opt/popt/include${CPPFLAGS:+ $CPPFLAGS}"
export PKG_CONFIG_PATH="/opt/popt/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
pkg-config --cflags --libs --static poptPrepare attr library:
curl -fsSLO https://download.savannah.nongnu.org/releases/attr/attr-2.5.2.tar.xz
tar -xf attr-2.5.2.tar.xz
cd attr-2.5.2
sed -i '/#include <stdlib.h>/a #include <libgen.h>' tools/attr.c
./configure --prefix=/opt/attr
make install
cd ..Export attr variables:
export LDFLAGS="-L/opt/attr/lib${LDFLAGS:+ $LDFLAGS}"
export CPPFLAGS="-I/opt/attr/include${CPPFLAGS:+ $CPPFLAGS}"
export PKG_CONFIG_PATH="/opt/attr/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
pkg-config --cflags --libs --static libattrPrepare acl library:
curl -fsSLO https://download.savannah.nongnu.org/releases/acl/acl-2.3.2.tar.xz
tar -xf acl-2.3.2.tar.xz
cd acl-2.3.2
./configure --prefix=/opt/acl
make install
cd ..export LDFLAGS="-L/opt/acl/lib${LDFLAGS:+ $LDFLAGS}"
export CPPFLAGS="-I/opt/acl/include${CPPFLAGS:+ $CPPFLAGS}"
export PKG_CONFIG_PATH="/opt/acl/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
pkg-config --cflags --libs --static libaclPrepare xxHash library:
curl -fsSL https://github.com/Cyan4973/xxHash/archive/v0.8.3.tar.gz -o libxxhash-0.8.3.tar.gz
tar -zxf libxxhash-0.8.3.tar.gz
cd xxHash-0.8.3
make PREFIX=/opt/xxhash install
cd ..Export xxHash variables:
export LDFLAGS="-L/opt/xxhash/lib${LDFLAGS:+ $LDFLAGS}"
export CPPFLAGS="-I/opt/xxhash/include${CPPFLAGS:+ $CPPFLAGS}"
export PKG_CONFIG_PATH="/opt/xxhash/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
pkg-config --cflags --libs --static libxxhashDownload rsync source code:
curl -fsSLO https://rsync.samba.org/ftp/rsync/src/rsync-3.4.1.tar.gz
tar -zxf rsync-3.4.1.tar.gz
cd rsync-3.4.1Check https://rsync.samba.org/ftp/rsync/src/ for latest available version
Prepare build configuration:
./configureAs a result, you should see rsync 3.4.1 configuration successful message.
Compile:
make CFLAGS="-static" EXEEXT="-static"
strip rsync-static
cp rsync-static /mnt
exit$ file rsync-static
rsync-static: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, BuildID[sha1]=fde6468edf61242954e2dae866a6b63324178136, stripped