This repository has been archived by the owner on May 8, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #355 from fbelavenuto/docker-toolkit
New docker image syno-toolkit
- Loading branch information
Showing
9 changed files
with
171 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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
File renamed without changes.
This file contains 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
File renamed without changes.
File renamed without changes.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
FROM scratch | ||
ARG PLATFORM | ||
ARG TOOLKIT_VER | ||
ARG CACHE_DIR | ||
|
||
ENV PLATFORM=${PLATFORM} TOOLKIT_VER=${TOOLKIT_VER} | ||
ADD ${CACHE_DIR}/base_env-${TOOLKIT_VER}.txz / | ||
ADD ${CACHE_DIR}/ds.${PLATFORM}-${TOOLKIT_VER}.env.txz / | ||
ADD ${CACHE_DIR}/ds.${PLATFORM}-${TOOLKIT_VER}.dev.txz / | ||
ADD rootfs / | ||
|
||
WORKDIR /input | ||
VOLUME /input /output | ||
|
||
ENTRYPOINT ["/usr/bin/do.sh"] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
CACHE_DIR="cache" | ||
PLATFORM_FILE="../../PLATFORMS" | ||
TOOLKIT_VER=7.1 | ||
|
||
############################################################################### | ||
function trap_cancel() { | ||
echo "Press Control+C once more terminate the process (or wait 2s for it to restart)" | ||
sleep 2 || exit 1 | ||
} | ||
trap trap_cancel SIGINT SIGTERM | ||
cd `dirname $0` | ||
|
||
# Read platforms/kerver version | ||
echo "Reading platforms" | ||
declare -A PLATFORMS | ||
while read PLATFORM KVER; do | ||
PLATFORMS[${PLATFORM}]="${KVER}" | ||
done < ${PLATFORM_FILE} | ||
|
||
# Download toolkits | ||
mkdir -p ${CACHE_DIR} | ||
|
||
# Check base environment | ||
echo -n "Checking ${CACHE_DIR}/base_env-${TOOLKIT_VER}.txz... " | ||
if [ ! -f "${CACHE_DIR}/base_env-${TOOLKIT_VER}.txz" ]; then | ||
URL="https://global.download.synology.com/download/ToolChain/toolkit/${TOOLKIT_VER}/${PLATFORM}/base_env-${TOOLKIT_VER}.txz" | ||
echo "Downloading ${URL}" | ||
curl -L "${URL}" -o "${CACHE_DIR}/base_env-${TOOLKIT_VER}.txz" | ||
else | ||
echo "OK" | ||
fi | ||
|
||
# Check all platforms | ||
for PLATFORM in ${!PLATFORMS[@]}; do | ||
echo -n "Checking ${CACHE_DIR}/ds.${PLATFORM}-${TOOLKIT_VER}.dev.txz... " | ||
if [ ! -f "${CACHE_DIR}/ds.${PLATFORM}-${TOOLKIT_VER}.dev.txz" ]; then | ||
URL="https://global.download.synology.com/download/ToolChain/toolkit/${TOOLKIT_VER}/${PLATFORM}/ds.${PLATFORM}-${TOOLKIT_VER}.dev.txz" | ||
echo "Downloading ${URL}" | ||
curl -L "${URL}" -o "${CACHE_DIR}/ds.${PLATFORM}-${TOOLKIT_VER}.dev.txz" | ||
else | ||
echo "OK" | ||
fi | ||
echo -n "Checking ${CACHE_DIR}/ds.${PLATFORM}-${TOOLKIT_VER}.env.txz... " | ||
if [ ! -f "${CACHE_DIR}/ds.${PLATFORM}-${TOOLKIT_VER}.env.txz" ]; then | ||
URL="https://global.download.synology.com/download/ToolChain/toolkit/${TOOLKIT_VER}/${PLATFORM}/ds.${PLATFORM}-${TOOLKIT_VER}.env.txz" | ||
echo "Downloading ${URL}" | ||
curl -L "${URL}" -o "${CACHE_DIR}/ds.${PLATFORM}-${TOOLKIT_VER}.env.txz" | ||
else | ||
echo "OK" | ||
fi | ||
done | ||
|
||
# Generate docker images | ||
for PLATFORM in ${!PLATFORMS[@]}; do | ||
docker buildx build . --build-arg PLATFORM=${PLATFORM} --build-arg TOOLKIT_VER=${TOOLKIT_VER} --build-arg CACHE_DIR="${CACHE_DIR}" \ | ||
--tag fbelavenuto/syno-toolkit:${PLATFORM}-${TOOLKIT_VER} --load | ||
done |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[[ "$-" != *i* ]] && return | ||
export LS_OPTIONS='--color=auto' | ||
export SHELL='linux' | ||
eval "`dircolors`" | ||
alias ls='ls -F -h --color=always -v --author --time-style=long-iso' | ||
alias ll='ls -l' | ||
alias l='ls -l -a' | ||
alias h='history 25' | ||
alias j='jobs -l' | ||
export PATH="/opt/${PLATFORM}/bin:${PATH}" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
############################################################################### | ||
function compile-module { | ||
echo -e "Compiling module for \033[7m${PLATFORM}\033[0m..." | ||
cp -R /input /tmp | ||
make -C ${KSRC} M=/tmp/input ${PLATFORM^^}-Y=y ${PLATFORM^^}-M=m modules | ||
while read F; do | ||
strip -g "${F}" | ||
echo "Copying `basename ${F}`" | ||
cp "${F}" "/output" | ||
chown 1000.1000 "/output/`basename ${F}`" | ||
done < <(find /tmp/input -name \*.ko) | ||
} | ||
|
||
############################################################################### | ||
function compile-lkm { | ||
cp -R /input /tmp | ||
make -C "/tmp/input" dev-v7 | ||
strip -g "/tmp/input/redpill.ko" | ||
mv "/tmp/input/redpill.ko" "/output/redpill-dev.ko" | ||
chown 1000.1000 /output/redpill-dev.ko | ||
make -C "/tmp/input" clean | ||
make -C "/tmp/input" prod-v7 | ||
strip -g "/tmp/input/redpill.ko" | ||
mv "/tmp/input/redpill.ko" "/output/redpill-prod.ko" | ||
chown 1000.1000 /output/redpill-prod.ko | ||
} | ||
|
||
############################################################################### | ||
# function compile-drivers { | ||
# while read platform kver; do | ||
# SRC_PATH="/opt/${platform}" | ||
# echo "Compiling for ${platform}-${kver}" | ||
# cd /opt/linux-${kver}/drivers | ||
# while read dir; do | ||
# if [ -f "${dir}/Makefile" ]; then | ||
# echo "Driver `basename ${dir}`" | ||
# grep "CONFIG_.*/.*" "${dir}/Makefile" | sed 's/.*\(CONFIG_[^)]*\).*/\1=n/g' > /tmp/env | ||
# grep "CONFIG_.*\.o.*" "${dir}/Makefile" | sed 's/.*\(CONFIG_[^)]*\).*/\1=m/g' >> /tmp/env | ||
# make -C "${SRC_PATH}" M=$(readlink -f "${dir}") clean | ||
# cat /tmp/env | xargs -d '\n' make -C "${SRC_PATH}" M=$(readlink -f "${dir}") modules $@ | ||
# fi | ||
# done < <(find -type d) | ||
# DST_PATH="/output/compiled-mods/${platform}-${kver}" | ||
# mkdir -p "${DST_PATH}" | ||
# while read f; do | ||
# strip -g "${f}" | ||
# mv "${f}" "${DST_PATH}" | ||
# done < <(find -name \*.ko) | ||
# done </opt/platforms | ||
# } | ||
|
||
############################################################################### | ||
############################################################################### | ||
|
||
if [ $# -lt 1 ]; then | ||
echo "Use: <command> (<params>)" | ||
echo "Commands: shell | compile-module | compile-lkm" | ||
exit 1 | ||
fi | ||
export KSRC="/usr/local/x86_64-pc-linux-gnu/x86_64-pc-linux-gnu/sys-root/usr/lib/modules/DSM-${TOOLKIT_VER}/build" | ||
export LINUX_SRC="/usr/local/x86_64-pc-linux-gnu/x86_64-pc-linux-gnu/sys-root/usr/lib/modules/DSM-${TOOLKIT_VER}/build" | ||
case $1 in | ||
shell) shift && bash -l $@ ;; | ||
compile-module) compile-module ;; | ||
compile-lkm) compile-lkm ;; | ||
# compile-drivers) compile-drivers ;; | ||
*) echo "Command not recognized: $1" ;; | ||
esac |