Conty/create-utils.sh

130 lines
4.1 KiB
Bash
Raw Normal View History

2021-03-28 18:31:25 +02:00
#!/usr/bin/env bash
# Dependencies: gawk grep lz4 zstd wget gcc make autoconf libtool pkgconf
# libcap fuse2 (or fuse3) lzo xz zlib findutils
2021-08-06 14:10:31 +02:00
#
# Dwarfs dependencies: fuse2 (or fuse3) openssl jemalloc xxhash boost lz4
# xz zstd libarchive libunwind google-glod gtest fmt gflags double-conversion
# cmake ruby-ronn libevent libdwarf
2021-08-06 14:10:31 +02:00
#
# Dwarfs compilation is optional and disabled by default.
2021-04-11 22:47:10 +02:00
2021-03-28 18:31:25 +02:00
script_dir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
2021-08-06 14:10:31 +02:00
build_dwarfs="false"
2021-04-11 22:57:53 +02:00
squashfuse_version="0.1.104"
2021-03-28 18:31:25 +02:00
bwrap_version="0.4.1"
lz4_version="1.9.3"
2021-05-15 11:51:44 +02:00
zstd_version="1.5.0"
squashfs_tools_version="4.5"
2021-08-06 14:10:31 +02:00
dwarfs_version="0.5.6"
2021-03-28 18:31:25 +02:00
export CC=gcc
export CXX=g++
export CFLAGS="-O2"
export CXXFLAGS="${CFLAGS}"
mkdir -p "${script_dir}"/build-utils
cd "${script_dir}"/build-utils || exit 1
wget -q --show-progress -O lz4.tar.gz https://github.com/lz4/lz4/archive/refs/tags/v${lz4_version}.tar.gz
wget -q --show-progress -O zstd.tar.gz https://github.com/facebook/zstd/archive/refs/tags/v${zstd_version}.tar.gz
2021-04-11 22:00:04 +02:00
wget -q --show-progress -O squashfuse.tar.gz https://github.com/vasi/squashfuse/archive/refs/tags/${squashfuse_version}.tar.gz
2021-03-28 18:31:25 +02:00
wget -q --show-progress -O bwrap.tar.gz https://github.com/containers/bubblewrap/archive/refs/tags/v${bwrap_version}.tar.gz
wget -q --show-progress -O sqfstools.tar.gz https://github.com/plougher/squashfs-tools/archive/refs/tags/${squashfs_tools_version}.tar.gz
2021-03-28 18:31:25 +02:00
tar xf lz4.tar.gz
tar xf zstd.tar.gz
tar xf squashfuse.tar.gz
tar xf bwrap.tar.gz
tar xf sqfstools.tar.gz
2021-03-28 18:31:25 +02:00
cd bubblewrap-${bwrap_version}
./autogen.sh
./configure --disable-selinux --disable-man
make -j$(nproc) DESTDIR="${script_dir}"/build-utils/bin install
cd ../lz4-${lz4_version}
make -j$(nproc) DESTDIR="${script_dir}"/build-utils/bin install
cd ../zstd-${zstd_version}
make -j$(nproc) DESTDIR="${script_dir}"/build-utils/bin install
2021-04-11 22:00:04 +02:00
cd ../squashfuse-${squashfuse_version}
2021-03-28 18:31:25 +02:00
./autogen.sh
2021-06-10 16:58:12 +02:00
./configure
2021-03-28 18:31:25 +02:00
make -j$(nproc) DESTDIR="${script_dir}"/build-utils/bin install
cd ../squashfs-tools-${squashfs_tools_version}/squashfs-tools
make -j$(nproc) GZIP_SUPPORT=1 XZ_SUPPORT=1 LZO_SUPPORT=1 LZMA_XZ_SUPPORT=1 \
LZ4_SUPPORT=1 ZSTD_SUPPORT=1 XATTR_SUPPORT=1
make INSTALL_DIR="${script_dir}"/build-utils/bin/usr/local/bin install
2021-03-28 18:31:25 +02:00
cd "${script_dir}"/build-utils
mkdir utils
mv bin/usr/local/bin/bwrap utils
mv bin/usr/local/bin/squashfuse utils
mv bin/usr/local/bin/squashfuse_ll utils
mv bin/usr/local/bin/mksquashfs utils
mv bin/usr/local/bin/unsquashfs utils
2021-03-28 18:31:25 +02:00
mv bin/usr/local/lib/liblz4.so.${lz4_version} utils/liblz4.so.1
mv bin/usr/local/lib/libzstd.so.${zstd_version} utils/libzstd.so.1
mv bin/usr/local/lib/libfuseprivate.so.0.0.0 utils/libfuseprivate.so.0
mv bin/usr/local/lib/libsquashfuse.so.0.0.0 utils/libsquashfuse.so.0
if [ ! "$(ldd utils/squashfuse | grep libfuse.so.2)" ]; then
mv utils/squashfuse utils/squashfuse3
mv utils/squashfuse_ll utils/squashfuse3_ll
2021-03-28 18:31:25 +02:00
fi
2021-08-06 14:10:31 +02:00
if [ "${build_dwarfs}" = "true" ]; then
wget -q --show-progress -O dwarfs.tar.xz https://github.com/mhx/dwarfs/releases/download/v${dwarfs_version}/dwarfs-${dwarfs_version}.tar.xz
tar xf dwarfs.tar.xz
2021-08-06 14:10:31 +02:00
mkdir build
cmake -B build -S dwarfs-${dwarfs_version} -DCMAKE_BUILD_TYPE=Release \
-DPREFER_SYSTEM_ZSTD=ON -DPREFER_SYSTEM_XXHASH=ON \
-DPREFER_SYSTEM_GTEST=ON
make -C build -j$(nproc)
make -C build DESTDIR="${script_dir}"/build-utils/bin install
2021-08-06 14:10:31 +02:00
mv bin/usr/local/sbin/dwarfs2 utils/dwarfs
mv bin/usr/local/sbin/dwarfs utils/dwarfs3
mv bin/usr/local/bin/mkdwarfs utils
mv bin/usr/local/bin/dwarfsextract utils
fi
2021-08-06 14:10:31 +02:00
libs_list="$(ldd utils/* | grep "=> /" | awk '{print $3}' | xargs)"
for i in ${libs_list}; do
2021-08-06 14:10:31 +02:00
if [ ! -f utils/"$(basename "${i}")" ]; then
cp -L "${i}" utils
fi
done
2021-03-28 18:31:25 +02:00
find utils -type f -exec strip --strip-unneeded {} \; 2>/dev/null
2021-04-11 22:05:50 +02:00
cat <<EOF > utils/info
squashfuse ${squashfuse_version}
squashfs-tools ${squashfs_tools_version}
2021-04-11 22:05:50 +02:00
bubblewrap ${bwrap_version}
lz4 ${lz4_version}
zstd ${zstd_version}
EOF
2021-08-06 14:10:31 +02:00
if [ "${build_dwarfs}" = "true" ]; then
echo "dwarfs ${dwarfs_version}" >> utils/info
fi
tar -zcf utils.tar.gz utils
mv "${script_dir}"/utils.tar.gz "${script_dir}"/utils_old.tar.gz
mv utils.tar.gz "${script_dir}"
2021-03-28 18:31:25 +02:00
cd "${script_dir}" || exit 1
rm -rf build-utils
clear
echo "Done!"