first commit

This commit is contained in:
Fabio Belavenuto
2022-07-01 13:57:55 -03:00
commit a08662802d
1085 changed files with 341425 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
FROM alpine:3.14 AS stage
ARG PLATFORMS="@@@PLATFORMS@@@"
ARG TOOLKIT_VER="@@@TOOLKIT_VER@@@"
# Copy downloaded toolkits
ADD cache /cache
# Extract toolkits
RUN for V in ${PLATFORMS}; do \
echo "${V}" | while IFS=':' read PLATFORM KVER; do \
echo "Extracting ds.${PLATFORM}-${TOOLKIT_VER}.dev.txz" && \
mkdir "/opt/${PLATFORM}" && \
tar -xaf "/cache/ds.${PLATFORM}-${TOOLKIT_VER}.dev.txz" -C "/opt/${PLATFORM}" --strip-components=10 \
"usr/local/x86_64-pc-linux-gnu/x86_64-pc-linux-gnu/sys-root/usr/lib/modules/DSM-7.0/build" && \
echo -e "${PLATFORM}\t${KVER}" >> /opt/platforms; \
done; \
done
# Final image
FROM debian:8-slim
ENV SHELL=/bin/bash \
ARCH=x86_64
RUN apt update --yes && \
apt install --yes --no-install-recommends --no-install-suggests \
build-essential nano make && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
COPY --from=stage /opt /opt
COPY files/ /
WORKDIR /input
VOLUME /input /output
ENTRYPOINT ["/opt/do.sh"]

43
docker/build.sh Executable file
View File

@@ -0,0 +1,43 @@
#!/usr/bin/env bash
###############################################################################
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
# Read platforms/kerver version
echo "Reading platforms"
declare -A PLATFORMS
while read PLATFORM KVER; do
PLATFORMS[${PLATFORM}]="${KVER}"
done <../PLATFORMS
# Download toolkits
TOOLKIT_VER="7.0"
for PLATFORM in ${!PLATFORMS[@]}; do
echo -n "Checking cache/ds.${PLATFORM}-${TOOLKIT_VER}.dev.txz... "
if [ ! -f "cache/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/ds.${PLATFORM}-${TOOLKIT_VER}.dev.txz"
else
echo "OK"
fi
done
# Generate Dockerfile
echo "Generating Dockerfile"
cp Dockerfile.template Dockerfile
VALUE=""
for PLATFORM in ${!PLATFORMS[@]}; do
VALUE+="${PLATFORM}:${PLATFORMS[${PLATFORM}]} "
done
sed -i "s|@@@PLATFORMS@@@|${VALUE::-1}|g" Dockerfile
sed -i "s|@@@TOOLKIT_VER@@@|${TOOLKIT_VER}|g" Dockerfile
# Build
echo "Building... Drink a coffee and wait!"
docker image rm syno-compiler >/dev/null 2>&1
docker buildx build . --load --tag syno-compiler

View File

@@ -0,0 +1,9 @@
[[ "$-" != *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'

55
docker/files/opt/do.sh Executable file
View File

@@ -0,0 +1,55 @@
#!/usr/bin/env bash
function compile-module {
# Validate
if [ -z "${1}" ]; then
echo "Use: compile-module <platform>"
exit 1
fi
VALID=0
while read PLATFORM KVER; do
if [ "${PLATFORM}" = "${1}" ]; then
VALID=1
break
fi
done </opt/platforms
if [ $VALID -eq 0 ]; then
echo "Platform ${PLATFORM} not found."
exit 1
fi
echo "Compiling module for ${PLATFORM}-${KVER}..."
cp -R /input /tmp
make -C "/opt/${PLATFORM}" M="/tmp/input" modules
while read F; do
strip -g "${F}"
echo "Copying `basename ${F}`"
cp "${F}" "/output"
done < <(find /tmp/input -name \*.ko)
}
function compile-lkm {
PLATFORM=${1}
if [ -z "${PLATFORM}" ]; then
echo "Use: compile-lkm <platform>"
exit 1
fi
cp -R /input /tmp
make -C "/tmp/input" LINUX_SRC="/opt/${PLATFORM}" dev-v7
strip -g "/tmp/input/redpill.ko"
mv "/tmp/input/redpill.ko" "/output/redpill-dev.ko"
make -C "/tmp/input" LINUX_SRC="/opt/${PLATFORM}" clean
make -C "/tmp/input" LINUX_SRC="/opt/${PLATFORM}" prod-v7
strip -g "/tmp/input/redpill.ko"
mv "/tmp/input/redpill.ko" "/output/redpill-prod.ko"
}
if [ $# -lt 1 ]; then
echo "Use: <command> (<params>)"
exit 1
fi
case $1 in
bash) bash -l ;;
compile-module) compile-module $2 ;;
compile-lkm) compile-lkm $2 ;;
*) echo "Command not recognized: $1" ;;
esac