synology-wireguard/release.sh

86 lines
2.0 KiB
Bash
Raw Normal View History

#!/bin/bash
VERSIONS=(7.0 7.1 7.2)
ARCHS=(
2021-01-21 07:45:49 +07:00
"apollolake"
"armada38x"
"avoton"
"braswell"
"broadwell"
2020-12-30 21:39:47 +07:00
"broadwellnk"
"bromolow"
"cedarview"
"denverton"
2020-12-30 21:39:47 +07:00
"geminilake"
"kvmx64"
"monaco"
"rtd1296"
2021-01-21 07:45:49 +07:00
"x64"
)
set -e
# Check that we are running as root
if [ `id -u` -ne 0 ]; then
echo "This script must be run as root"
exit 1
fi
# Download all necessary tarballs before calling into the docker containers.
echo "Downloading environment tarballs"
2021-01-21 07:45:49 +07:00
for ver in ${VERSIONS[@]}; do
url_base="https://global.synologydownload.com/download/ToolChain/toolkit/$ver"
mkdir -p toolkit_tarballs
2021-01-21 07:45:49 +07:00
pushd toolkit_tarballs/
if [ ! -f base_env-$ver.txz ]; then
wget -q --show-progress "$url_base/base/base_env-$ver.txz"
fi
2021-01-21 07:45:49 +07:00
for arch in ${ARCHS[@]}; do
if [ ! -f ds.$arch-$ver.dev.txz ]; then
wget -q --show-progress "$url_base/$arch/ds.$arch-$ver.dev.txz"
2021-01-21 07:45:49 +07:00
fi
if [ ! -f ds.$arch-$ver.env.txz ]; then
wget -q --show-progress "$url_base/$arch/ds.$arch-$ver.env.txz"
2021-01-21 07:45:49 +07:00
fi
done
popd
done
# Ensure that we are using an up to date docker image
docker build -t synobuild .
2021-01-21 07:45:49 +07:00
for ver in ${VERSIONS[@]}; do
# Create release directory if needed
mkdir -p target/$ver
2021-01-21 07:45:49 +07:00
for arch in ${ARCHS[@]}; do
echo "Building '$arch'"
# Remove old artifact directory
if [ -d artifacts/ ]; then
rm -rf artifacts/
fi
2021-01-21 07:45:49 +07:00
docker run \
--rm \
--privileged \
--env PACKAGE_ARCH=$arch \
--env DSM_VER=$ver \
-v $(pwd)/artifacts:/result_spk \
-v $(pwd)/toolkit_tarballs:/toolkit_tarballs \
synobuild
2021-01-21 07:45:49 +07:00
mv artifacts/WireGuard-*/* target/$ver/
done
done
# Clean up artifact directory
if [ -d artifacts/ ]; then
rm -rf artifacts/
fi
# Change permissions of the target directory to match the local user if called
# using sudo
if [ ! -z ${SUDO_USER+x} ]; then
chown "$SUDO_USER:$SUDO_USER" -R target/
fi