diff --git a/README.md b/README.md index e3d525e..96b3443 100644 --- a/README.md +++ b/README.md @@ -20,17 +20,17 @@ # 如何使用? -1. (在宿主机中) 复制`user_config.simple.json`为`user_config.json` -1. (在宿主机中) 调整`Makefile`文件配置的配置项 `TARGET_PLATFORM` (默认: apollolake) 和 `TARGET_VERSION` (默认: 7.0 - 将会构建 7.0-41890) -1. (在宿主机中) 构建编译镜像: `make build_image` -1. (在宿主机中) 启动容器构建引导: `make build_boot` +1. 复制`user_config.simple.json`为`user_config.json` +1. 为你想要的平台和版本构建编译镜像: + 比如 `redpill_tool_chain.sh build apollolake-7.0-41890` +1. 为你想要的平台和版本构建引导: + 比如 `redpill_tool_chain.sh img apollolake-7.0-41890` -`make build_boot`运行结束之后,将会在宿主机的`./image`文件夹中生成 RedPill引导镜像。 +`redpill_tool_chain.sh img`运行结束之后,将会在宿主机的`./image`文件夹中生成 RedPill引导镜像。 -依赖: `make` 和 `docker` +依赖: `docker` # 其他说明 为了方便我自己 - `docker/Dockerfile` 中补入了阿里云镜像 -- 如果是网络不好可以在`make build_image`之前执行`make build_download` -- `make run_container`自定义引导构建过程 +- `redpill_tool_chain.sh run `自定义引导构建过程 diff --git a/README_EN.md b/README_EN.md index b13aca5..dc941d7 100644 --- a/README_EN.md +++ b/README_EN.md @@ -2,36 +2,26 @@ [中文说明](README.md "English") THX @haydibe +# Inofficial redpill toolchain image builder +- Creates a OCI Container (~= Docker) image based tool chain. +- Takes care of downloading (and caching) the required sources to compile redpill.ko and the required os packages that the build process depends on. +- Caches .pat downloads inside the container on the host. -# What is this? +## Changes +- Migrated from Make to Bash (requires `jq`, instead of `make` now ) +- Removed Synology toolchain, the tool chain now consists of debian packages +- Configuration is now done in the JSON file `global_config.json` +- The configuration allows to specify own configurations -> just copy a block underneath the `building_configs` block and make sure it has a unique value for the id attribute. The id is used what actualy is used to determine the . -The redpill tool chain docker image builder is updated to v0.4: +## Usage -- proper DSM7 support for apollolake (thnx @jumkey) -- switched from kernel sources based build to toolkit dev based builds for DSM6.2.4 and DSM7.0 (thnx @jumkey) -- make targets for bromolow and apollolake merged: platform and version must be configure in the Makefile now -- image is ~720-780MB instead of ~1.200-1.500MB now +1. Create `user_config.json` according https://github.com/RedPill-TTG/redpill-load +2. Build the image for the platform and version you want: + `redpill_tool_chain.sh build ` +3. Run the image for the platform and version you want: + `redpill_tool_chain.sh run ` +4. Inside the container, run `make build_all` to build the loader for the platform_version - -> PS: since toolkit dev lacks the required sources for fs/proc, they are taken from the extracted DSM6.2.4 kernel sources. -The build requires the sources for this single folder, but does not use the kernel source to build the redpill.ko module. +Note: run `redpill_tool_chain.sh build` to get the list of supported -If you see something is wrong in how the toolchain is build or have ideas how to make it better: please let me know. - -For every other problem: please address it to the community - I don't know more than others do. - -> PS2: before someone asks: I haven't managed a successfull installation/migration with the created bootloader so far. I am testing exclusivly on ESXi 6.7. The migration always stops at 56% and bails out with error 13. - - -# How to use it? - -1. (on host) configure the Makefile and configure TARGET_PLATFORM (default: bromolow) and TARGET_VERSION (default: 6.2 - will build 6.2.4) -1. (on host) create your own user_config.json or edit the USERCONFIG_* variables in the Makefile -1. (on host) build image: make build_image -1. (on host) build boot image: make build_boot - -After running `make build_boot` the created redpill bootloader image will be present in the ./image folder on the host. - -Tested with hosts: Ubuntu 18.04 VM, Ubuntu 20.04 WSL2 and XPE (the make binary to build on Synology/XPE can be found here) - -Dependencies: make and docker \ No newline at end of file +After set 4. the redpill load image should be build and can be found in the host folder "images". \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile index 5530a2b..90ec62f 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,12 +1,9 @@ -ARG DOCKER_BASE_IMAGE=debian:8 +ARG DOCKER_BASE_IMAGE=ubuntu:20.04 # extract kernel and toolkit dev FROM ${DOCKER_BASE_IMAGE} AS extract -ARG TOOLKIT_DEV_FILENAME -ADD downloads/${TOOLKIT_DEV_FILENAME} / - -ARG KERNEL_FILENAME -ADD downloads/${KERNEL_FILENAME} / +ARG KERNEL_SRC_FILENAME +ADD downloads/${KERNEL_SRC_FILENAME} / # tool chain image FROM ${DOCKER_BASE_IMAGE} @@ -16,42 +13,53 @@ RUN cp /etc/apt/sources.list /etc/apt/sources.list.bak && \ sed -i "s/archive.ubuntu.com/mirrors.aliyun.com/g" /etc/apt/sources.list && \ sed -i "s/security.ubuntu.com/mirrors.aliyun.com/g" /etc/apt/sources.list && \ apt-get update && \ - apt-get install --yes --no-install-recommends ca-certificates build-essential git libssl-dev curl cpio bspatch vim gettext bc bison flex dosfstools kmod bsdiff patch jq xz-utils && \ + apt-get install --yes --no-install-recommends ca-certificates build-essential git libssl-dev curl cpio bspatch vim gettext bc bison flex dosfstools kmod jq && \ rm -rf /var/lib/apt/lists/* /tmp/* -ARG TOOLCHAIN_FILENAME -ADD downloads/${TOOLCHAIN_FILENAME} /opt/ - ARG REDPILL_LKM_REPO=https://github.com/RedPill-TTG/redpill-lkm.git ARG REDPILL_LKM_BRANCH=master -RUN git clone --depth 1 ${REDPILL_LKM_REPO} -b ${REDPILL_LKM_BRANCH} /opt/redpill-lkm +ARG REDPILL_LKM_SRC=/opt/redpill-lkm -ARG REDPILL_LOAD=https://github.com/RedPill-TTG/redpill-load.git +ARG REDPILL_LOAD_REPO=https://github.com/RedPill-TTG/redpill-load.git ARG REDPILL_LOAD_BRANCH=master -RUN git clone --depth 1 ${REDPILL_LOAD} -b ${REDPILL_LOAD_BRANCH} /opt/redpill-load +ARG REDPILL_LOAD_SRC=/opt/redpill-load + +RUN git clone --depth 1 ${REDPILL_LKM_REPO} -b ${REDPILL_LKM_BRANCH} ${REDPILL_LKM_SRC} && \ + git clone --depth 1 ${REDPILL_LOAD_REPO} -b ${REDPILL_LOAD_BRANCH} ${REDPILL_LOAD_SRC} -ARG TARGET_VERSION ARG TARGET_PLATFORM -COPY --from=extract /usr/local/x86_64-pc-linux-gnu/x86_64-pc-linux-gnu/sys-root/usr/lib/modules/DSM-${TARGET_VERSION}/build /opt/redpill-lkm/kernel-${TARGET_PLATFORM}-${TARGET_VERSION} -COPY --from=extract /linux*/fs/proc/ /opt/redpill-lkm/kernel-${TARGET_PLATFORM}-${TARGET_VERSION}/fs/proc/ +ARG TARGET_VERSION +ARG DSM_VERSION +ARG COMPILE_WITH +ARG TARGET_REVISION + +ENV ARCH=x86_64 \ + LINUX_SRC=${REDPILL_LKM_SRC}/${COMPILE_WITH}-${TARGET_PLATFORM}-${TARGET_VERSION}-${TARGET_REVISION} \ + REDPILL_LKM_SRC=${REDPILL_LKM_SRC} \ + REDPILL_LOAD_SRC=${REDPILL_LOAD_SRC} \ + TARGET_PLATFORM=${TARGET_PLATFORM} \ + TARGET_VERSION=${TARGET_VERSION} \ + TARGET_REVISION=${TARGET_REVISION} + +ARG EXTRACTED_KSRC +COPY --from=extract ${EXTRACTED_KSRC} ${LINUX_SRC} + +RUN if [ "apollolake" = "$TARGET_PLATFORM" ]; then echo '+' > ${LINUX_SRC}/.scmversion; fi && \ + if [ "$COMPILE_WITH" = "kernel" ]; then \ + cp ${LINUX_SRC}/synoconfigs/${TARGET_PLATFORM} ${LINUX_SRC}/.config && \ + make -C ${LINUX_SRC} oldconfig && \ + make -C ${LINUX_SRC} modules_prepare ;\ + fi WORKDIR "/opt" COPY Makefile user_config.json.template /opt/ -ARG BUILD_REDPILL_LOADER_VERSION ARG USERCONFIG_VID= ARG USERCONFIG_PID= ARG USERCONFIG_SN= ARG USERCONFIG_MAC1= -# LINUX_SRC=/usr/local/x86_64-pc-linux-gnu/x86_64-pc-linux-gnu/sys-root/usr/lib/modules/DSM-${TARGET_VERSION}/build \ - -ENV ARCH=x86_64 \ - CROSS_COMPILE=/opt/x86_64-pc-linux-gnu/bin/x86_64-pc-linux-gnu- \ - LINUX_SRC=/opt/redpill-lkm/kernel-${TARGET_PLATFORM}-${TARGET_VERSION} \ - TARGET_PLATFORM=${TARGET_PLATFORM} \ - BUILD_REDPILL_LOADER_VERSION=${BUILD_REDPILL_LOADER_VERSION} \ - USERCONFIG_VID=${USERCONFIG_VID} \ +ENV USERCONFIG_VID=${USERCONFIG_VID} \ USERCONFIG_PID=${USERCONFIG_PID} \ USERCONFIG_SN=${USERCONFIG_SN} \ USERCONFIG_MAC1=${USERCONFIG_MAC1} diff --git a/docker/Makefile b/docker/Makefile index 32a0611..c325b0a 100644 --- a/docker/Makefile +++ b/docker/Makefile @@ -5,10 +5,12 @@ SHELL := bash .DELETE_ON_ERROR: .SUFFIXES: -export REDPILL_SRC := /opt/redpill-lkm -export REDPILL_LOADER_SRC := /opt/redpill-load +export REDPILL_LKM_SRC := ${REDPILL_LKM_SRC} +export REDPILL_LOAD_SRC := ${REDPILL_LOAD_SRC} -export TARGET_PLATFORM :=${TARGET_PLATFORM} +export TARGET_PLATFORM := ${TARGET_PLATFORM} +export TARGET_VERSION := ${TARGET_VERSION} +export TARGET_REVISION := ${TARGET_REVISION} export LINUX_SRC := ${LINUX_SRC} export USERCONFIG_VID := ${USERCONFIG_VID} @@ -16,43 +18,41 @@ export USERCONFIG_PID := ${USERCONFIG_PID} export USERCONFIG_SN := ${USERCONFIG_SN} export USERCONFIG_MAC1 := ${USERCONFIG_MAC1} -export BUILD_REDPILL_LOADER_VERSION := ${BUILD_REDPILL_LOADER_VERSION} - .PHONY: all all: @echo "Possible Targets:" - @cat Makefile |grep .PHONY[:] |cut -f2 -d ' ' |xargs -n1 echo " - " |grep -v " - all" + @less Makefile |grep .PHONY[:] |cut -f2 -d ' ' |xargs -n1 echo " - " |grep -v " - all" .PHONY: build_redpill_lkm build_redpill_lkm: - @$(MAKE) -C $(REDPILL_SRC) LINUX_SRC=$(LINUX_SRC) && \ + @$(MAKE) -C $(REDPILL_LKM_SRC) LINUX_SRC=$(LINUX_SRC) && \ echo "#############################################" && \ - modinfo $(REDPILL_SRC)/redpill.ko + modinfo $(REDPILL_LKM_SRC)/redpill.ko .PHONY: build_redpill_load build_redpill_load: - @mkdir -p $(REDPILL_LOADER_SRC)/ext/rp-lkm/ - @if [ ! -e $(REDPILL_LOADER_SRC)/user_config.json ]; then envsubst < user_config.json.template > $(REDPILL_LOADER_SRC)/user_config.json; fi + @mkdir -p $(REDPILL_LOAD_SRC)/ext/rp-lkm/ + @if [ ! -e $(REDPILL_LOAD_SRC)/user_config.json ]; then envsubst < user_config.json.template > $(REDPILL_LOAD_SRC)/user_config.json; fi @echo "#############################################" && \ - echo "Using user_config.json:" && cat $(REDPILL_LOADER_SRC)/user_config.json && \ + echo "Using user_config.json:" && cat $(REDPILL_LOAD_SRC)/user_config.json && \ echo "#############################################" @if [ "$(TARGET_PLATFORM)" == "bromolow" ]; then \ - pushd $(REDPILL_LOADER_SRC) && \ - if [ "$(BUILD_REDPILL_LOADER_VERSION)" == "7.0-41890" ];then \ - cp -f $(REDPILL_SRC)/redpill.ko $(REDPILL_LOADER_SRC)/ext/rp-lkm/redpill-linux-v3.10.108.ko ; \ + pushd $(REDPILL_LOAD_SRC) && \ + if [ "$(TARGET_VERSION)-$(TARGET_REVISION)" == "7.0-41222" ];then \ + cp -f $(REDPILL_LKM_SRC)/redpill.ko $(REDPILL_LOAD_SRC)/ext/rp-lkm/redpill-linux-v3.10.108.ko ; \ else \ - cp -f $(REDPILL_SRC)/redpill.ko $(REDPILL_LOADER_SRC)/ext/rp-lkm/redpill-linux-v3.10.105.ko ; \ + cp -f $(REDPILL_LKM_SRC)/redpill.ko $(REDPILL_LOAD_SRC)/ext/rp-lkm/redpill-linux-v3.10.105.ko ; \ fi && \ - ./build-loader.sh 'DS3615xs' '$(BUILD_REDPILL_LOADER_VERSION)'; \ + ./build-loader.sh 'DS3615xs' '$(TARGET_VERSION)-$(TARGET_REVISION)'; \ fi @if [ "$(TARGET_PLATFORM)" == "apollolake" ]; then \ - pushd $(REDPILL_LOADER_SRC) && \ - if [ "$(BUILD_REDPILL_LOADER_VERSION)" == "7.0-41890" ];then \ - cp -f $(REDPILL_SRC)/redpill.ko $(REDPILL_LOADER_SRC)/ext/rp-lkm/redpill-linux-v4.4.180+.ko; \ + pushd $(REDPILL_LOAD_SRC) && \ + if [ "$(TARGET_VERSION)-$(TARGET_REVISION)" == "7.0-41890" ];then \ + cp -f $(REDPILL_LKM_SRC)/redpill.ko $(REDPILL_LOAD_SRC)/ext/rp-lkm/redpill-linux-v4.4.180+.ko; \ else \ - cp -f $(REDPILL_SRC)/redpill.ko $(REDPILL_LOADER_SRC)/ext/rp-lkm/redpill-linux-v4.4.59+.ko; \ + cp -f $(REDPILL_LKM_SRC)/redpill.ko $(REDPILL_LOAD_SRC)/ext/rp-lkm/redpill-linux-v4.4.59+.ko; \ fi && \ - ./build-loader.sh 'DS918+' '$(BUILD_REDPILL_LOADER_VERSION)'; \ + ./build-loader.sh 'DS918+' '$(TARGET_VERSION)-$(TARGET_REVISION)'; \ fi .PHONY: build_all @@ -60,4 +60,4 @@ build_all: build_redpill_lkm build_redpill_load .PHONY: clean_redpill_lkm clean_redpill_lkm: - @$(MAKE) -C $(REDPILL_SRC) clean + @$(MAKE) -C $(REDPILL_LKM_SRC) clean diff --git a/global_config.json b/global_config.json new file mode 100644 index 0000000..f244aae --- /dev/null +++ b/global_config.json @@ -0,0 +1,81 @@ +{ + "docker": { + "use_buildkit": "true", + "image_name": "redpill-tool-chain", + "download_folder": "docker/downloads" + }, + "build_configs": [ + { + "id": "bromolow-6.2.4-25556", + "platform_version": "bromolow-6.2.4-25556", + "docker_base_image": "debian:8-slim", + "compile_with": "kernel", + "download_urls": { + "kernel": "https://sourceforge.net/projects/dsgpl/files/Synology%20NAS%20GPL%20Source/25426branch/bromolow-source/linux-3.10.x.txz/download", + "toolkit_dev": "https://sourceforge.net/projects/dsgpl/files/toolkit/DSM6.2/ds.bromolow-6.2.dev.txz/download" + }, + "redpill_lkm": { + "source_url": "https://github.com/RedPill-TTG/redpill-lkm.git", + "branch": "master" + }, + "redpill_load": { + "source_url": "https://github.com/RedPill-TTG/redpill-load.git", + "branch": "master" + } + }, + { + "id": "bromolow-7.0-41222", + "platform_version": "bromolow-7.0-41222", + "docker_base_image": "debian:8-slim", + "compile_with": "toolkit_dev", + "download_urls": { + "kernel": "https://sourceforge.net/projects/dsgpl/files/Synology%20NAS%20GPL%20Source/25426branch/bromolow-source/linux-3.10.x.txz/download", + "toolkit_dev": "https://sourceforge.net/projects/dsgpl/files/toolkit/DSM7.0/ds.bromolow-7.0.dev.txz/download" + }, + "redpill_lkm": { + "source_url": "https://github.com/RedPill-TTG/redpill-lkm.git", + "branch": "master" + }, + "redpill_load": { + "source_url": "https://github.com/RedPill-TTG/redpill-load.git", + "branch": "master" + } + }, + { + "id": "apollolake-6.2.4-25556", + "platform_version": "apollolake-6.2.4-25556", + "docker_base_image": "debian:8-slim", + "compile_with": "kernel", + "download_urls": { + "kernel": "https://sourceforge.net/projects/dsgpl/files/Synology%20NAS%20GPL%20Source/25426branch/apollolake-source/linux-4.4.x.txz/download", + "toolkit_dev": "https://sourceforge.net/projects/dsgpl/files/toolkit/DSM6.2/ds.apollolake-6.2.dev.txz/download" + }, + "redpill_lkm": { + "source_url": "https://github.com/RedPill-TTG/redpill-lkm.git", + "branch": "master" + }, + "redpill_load": { + "source_url": "https://github.com/RedPill-TTG/redpill-load.git", + "branch": "master" + } + }, + { + "id": "apollolake-7.0-41890", + "platform_version": "apollolake-7.0-41890", + "docker_base_image": "debian:10-slim", + "compile_with": "toolkit_dev", + "download_urls": { + "kernel": "https://sourceforge.net/projects/dsgpl/files/Synology%20NAS%20GPL%20Source/25426branch/apollolake-source/linux-4.4.x.txz/download", + "toolkit_dev": "https://sourceforge.net/projects/dsgpl/files/toolkit/DSM7.0/ds.apollolake-7.0.dev.txz/download" + }, + "redpill_lkm": { + "source_url": "https://github.com/RedPill-TTG/redpill-lkm.git", + "branch": "master" + }, + "redpill_load": { + "source_url": "https://github.com/jumkey/redpill-load.git", + "branch": "7.0-41890" + } + } + ] +} \ No newline at end of file diff --git a/redpill_tool_chain.sh b/redpill_tool_chain.sh new file mode 100755 index 0000000..31d15a6 --- /dev/null +++ b/redpill_tool_chain.sh @@ -0,0 +1,153 @@ +##!/usr/bin/env bash +set -eu + +USERCONFIG_VID=changeme +USERCONFIG_PID=changeme +USERCONFIG_SN=changeme +USERCONFIG_MAC1=changeme + +function readConfig() { + cat global_config.json +} + +function getValueByJsonPath(){ + local JSONPATH=${1} + local CONFIG=${2} + jq -r "${JSONPATH}" <<<${CONFIG} +} + +function buildImage(){ + [ "${USE_BUILDKIT}" == "true" ] && export DOCKER_BUILDKIT=1 + docker build --file docker/Dockerfile --force-rm --pull \ + --build-arg DOCKER_BASE_IMAGE="${DOCKER_BASE_IMAGE}" \ + --build-arg COMPILE_WITH="${COMPILE_WITH}" \ + --build-arg EXTRACTED_KSRC="${EXTRACTED_KSRC}" \ + --build-arg KERNEL_SRC_FILENAME="$( [ "${COMPILE_WITH}" == "kernel" ] && echo "${KERNEL_FILENAME}" || echo "${TOOLKIT_DEV_FILENAME}")" \ + --build-arg REDPILL_LKM_REPO="${REDPILL_LKM_REPO}" \ + --build-arg REDPILL_LKM_BRANCH="${REDPILL_LKM_BRANCH}" \ + --build-arg REDPILL_LOAD_REPO="${REDPILL_LOAD_REPO}" \ + --build-arg REDPILL_LOAD_BRANCH="${REDPILL_LOAD_BRANCH}" \ + --build-arg TARGET_PLATFORM="${TARGET_PLATFORM}" \ + --build-arg TARGET_VERSION="${TARGET_VERSION}" \ + --build-arg DSM_VERSION="${DSM_VERSION}" \ + --build-arg TARGET_REVISION="${TARGET_REVISION}" \ + --build-arg USERCONFIG_VID="${USERCONFIG_VID}" \ + --build-arg USERCONFIG_PID="${USERCONFIG_PID}" \ + --build-arg USERCONFIG_SN="${USERCONFIG_SN}" \ + --build-arg USERCONFIG_MAC1="${USERCONFIG_MAC1}" \ + -t ${DOCKER_IMAGE_NAME}:${TARGET_PLATFORM}-${TARGET_VERSION}-${TARGET_REVISION} ./docker + } + +function runContainer(){ + config=$( [ -e user_config.json ] && echo "-v ${PWD}/user_config.json:/opt/redpill-load/user_config.json") + final_cmd="docker run -ti --rm --privileged -v /dev:/dev \ + -v ${REDPILL_LOAD_CACHE}:/opt/redpill-load/cache \ + -v ${REDPILL_LOAD_IMAGES}:/opt/redpill-load/images \ + $config \ + -e USERCONFIG_VID="${USERCONFIG_VID}" \ + -e USERCONFIG_PID="${USERCONFIG_PID}" \ + -e USERCONFIG_SN="${USERCONFIG_SN}" \ + -e USERCONFIG_MAC1="${USERCONFIG_MAC1}" \ + -e TARGET_PLATFORM="${TARGET_PLATFORM}" \ + -e TARGET_VERSION="${TARGET_VERSION}" \ + -e DSM_VERSION="${DSM_VERSION}" \ + -e REVISION="${TARGET_REVISION}" \ + ${DOCKER_IMAGE_NAME}:${TARGET_PLATFORM}-${TARGET_VERSION}-${TARGET_REVISION} bash $@" + eval ${final_cmd} +} + +function downloadFromUrlIfNotExists(){ + local DOWNLOAD_URL="${1}" + local OUT_FILE="${2}" + local MSG="${3}" + if [ ! -e ${OUT_FILE} ]; then + echo "Downloading ${MSG}" + curl --progress-bar --location ${DOWNLOAD_URL} --output ${OUT_FILE} + fi +} + +function showHelp(){ +cat << EOF +Usage: ${0} + +Actions: build run img debug + +Available platform versions: +--------------------- +${AVAILABLE_IDS} +EOF +} + +# mount-bind host folder with absolute path into redpill-load cache folder +# will not work with relativfe path! If single name is used, a docker volume will be created! +REDPILL_LOAD_CACHE=${PWD}/cache + +# mount bind hots folder with absolute path into redpill load images folder +REDPILL_LOAD_IMAGES=${PWD}/images + + +#################################################### +# Do not touch anything below, unless you know what you are doing... +#################################################### + +# parse paramters from config +CONFIG=$(readConfig) +AVAILABLE_IDS=$(getValueByJsonPath ".build_configs[].id" "${CONFIG}") + +if [ $# -lt 2 ]; then + showHelp + exit 1 +fi + +ACTION=${1} +ID=${2} +BUILD_CONFIG=$(getValueByJsonPath ".build_configs[] | select(.id==\"${ID}\")" "${CONFIG}") +if [ -z "${BUILD_CONFIG}" ];then + echo "Error: Platform version ${ID} not specified in global_config.json" + echo + showHelp + exit 1 +fi +USE_BUILDKIT=$(getValueByJsonPath ".docker.use_buildkit" "${CONFIG}") +DOCKER_IMAGE_NAME=$(getValueByJsonPath ".docker.image_name" "${CONFIG}") +DOWNLOAD_FOLDER=$(getValueByJsonPath ".docker.download_folder" "${CONFIG}") +TARGET_PLATFORM=$(getValueByJsonPath ".platform_version | split(\"-\")[0]" "${BUILD_CONFIG}") +TARGET_VERSION=$(getValueByJsonPath ".platform_version | split(\"-\")[1]" "${BUILD_CONFIG}") +DSM_VERSION=$(getValueByJsonPath ".platform_version | split(\"-\")[1][0:3]" "${BUILD_CONFIG}") +TARGET_REVISION=$(getValueByJsonPath ".platform_version | split(\"-\")[2]" "${BUILD_CONFIG}") +DOCKER_BASE_IMAGE=$(getValueByJsonPath ".docker_base_image" "${BUILD_CONFIG}") +KERNEL_DOWNLOAD_URL=$(getValueByJsonPath ".download_urls.kernel" "${BUILD_CONFIG}") +COMPILE_WITH=$(getValueByJsonPath ".compile_with" "${BUILD_CONFIG}") +KERNEL_FILENAME=$(getValueByJsonPath ".download_urls.kernel | split(\"/\")[] | select ( . | endswith(\".txz\"))" "${BUILD_CONFIG}") +TOOLKIT_DEV_DOWNLOAD_URL=$(getValueByJsonPath ".download_urls.toolkit_dev" "${BUILD_CONFIG}") +TOOLKIT_DEV_FILENAME=$(getValueByJsonPath ".download_urls.toolkit_dev | split(\"/\")[] | select ( . | endswith(\".txz\"))" "${BUILD_CONFIG}") +REDPILL_LKM_REPO=$(getValueByJsonPath ".redpill_lkm.source_url" "${BUILD_CONFIG}") +REDPILL_LKM_BRANCH=$(getValueByJsonPath ".redpill_lkm.branch" "${BUILD_CONFIG}") +REDPILL_LOAD_REPO=$(getValueByJsonPath ".redpill_load.source_url" "${BUILD_CONFIG}") +REDPILL_LOAD_BRANCH=$(getValueByJsonPath ".redpill_load.branch" "${BUILD_CONFIG}") + +EXTRACTED_KSRC='/linux*' +if [ "${COMPILE_WITH}" == "toolkit_dev" ]; then + EXTRACTED_KSRC="/usr/local/x86_64-pc-linux-gnu/x86_64-pc-linux-gnu/sys-root/usr/lib/modules/DSM-${DSM_VERSION}/build/" +fi + +case "${ACTION}" in + build) downloadFromUrlIfNotExists "${KERNEL_DOWNLOAD_URL}" "${DOWNLOAD_FOLDER}/${KERNEL_FILENAME}" "Kernel" + downloadFromUrlIfNotExists "${TOOLKIT_DEV_DOWNLOAD_URL}" "${DOWNLOAD_FOLDER}/${TOOLKIT_DEV_FILENAME}" "Toolkit Dev" + buildImage + ;; + img) runContainer -c "'make build_all'" + ;; + debug) runContainer -c "'BRP_DEBUG=1 make build_all'" + ;; + run) runContainer + ;; + *) if [ ! -z ${ACTION} ];then + echo "Error: action ${ACTION} does not exist" + echo "" + fi + showHelp + exit 1 + ;; +esac +