Skip to content

Commit

Permalink
Merge pull request #10 from wjz304/master
Browse files Browse the repository at this point in the history
Pull latest commits
  • Loading branch information
pocopico authored May 1, 2023
2 parents cde72f0 + 67d2295 commit 5231b9c
Show file tree
Hide file tree
Showing 28 changed files with 951 additions and 552 deletions.
298 changes: 274 additions & 24 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,296 @@
#
# Copyright (C) 2022 Ing <https://github.com/wjz304>
#
# This is free software, licensed under the MIT License.
# See /LICENSE for more information.
#

# # 注意:所有 include 组合会在 exclude 之后处理。 这允许你使用 include 添加回以前排除的组合。
# version: [ 6.2, 7.1, 7.2 ]
# platform: [ apollolake, broadwell, broadwellnk, bromolow, denverton, epyc7002, geminilake, purley, r1000, v1000 ]
# exclude:
# - version: 7.1
# platform: broadwell
# include:
# - version: "7.2"
# platform: "broadwell"

name: Build lkms

# Controls when the workflow will run
on:
# When a release is published
on:
release:
types: [published]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
version:
description: 'format %y.%-m.$i or auto'
required: false
type: string

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
strategy:
matrix:
include:
- version: 6.2
platform: apollolake
parm: 'dev-v6 prod-v6 test-v6'
- version: 6.2
platform: braswell
parm: 'dev-v6 prod-v6 test-v6'
- version: 6.2
platform: broadwell
parm: 'dev-v6 prod-v6 test-v6'
- version: 6.2
platform: broadwellnk
parm: 'dev-v6 prod-v6 test-v6'
- version: 6.2
platform: bromolow
parm: 'dev-v6 prod-v6 test-v6'
- version: 6.2
platform: denverton
parm: 'dev-v6 prod-v6 test-v6'

- version: 7.1
platform: apollolake
parm: 'dev-v7 prod-v7 test-v7'
- version: 7.1
platform: braswell
parm: 'dev-v7 prod-v7 test-v7'
- version: 7.1
platform: broadwell
parm: 'dev-v7 prod-v7 test-v7'
- version: 7.1
platform: broadwellnk
parm: 'dev-v7 prod-v7 test-v7'
- version: 7.1
platform: bromolow
parm: 'dev-v7 prod-v7 test-v7'
- version: 7.1
platform: denverton
parm: 'dev-v7 prod-v7 test-v7'
#- version: 7.1
# platform: epyc7002
# parm: 'dev-v7 prod-v7 test-v7'
- version: 7.1
platform: geminilake
parm: 'dev-v7 prod-v7 test-v7'
- version: 7.1
platform: purley
parm: 'dev-v7 prod-v7 test-v7'
- version: 7.1
platform: r1000
parm: 'dev-v7 prod-v7 test-v7'
- version: 7.1
platform: v1000
parm: 'dev-v7 prod-v7 test-v7'

- version: 7.2
platform: apollolake
parm: 'dev-v7 prod-v7 test-v7'
- version: 7.2
platform: braswell
parm: 'dev-v7 prod-v7 test-v7'
- version: 7.2
platform: broadwell
parm: 'dev-v7 prod-v7 test-v7'
- version: 7.2
platform: broadwellnk
parm: 'dev-v7 prod-v7 test-v7'
#- version: 7.2
# platform: bromolow
# parm: 'dev-v7 prod-v7 test-v7'
- version: 7.2
platform: denverton
parm: 'dev-v7 prod-v7 test-v7'
- version: 7.2
platform: epyc7002
parm: 'dev-v7 prod-v7 test-v7'
- version: 7.2
platform: geminilake
parm: 'dev-v7 prod-v7 test-v7'
- version: 7.2
platform: purley
parm: 'dev-v7 prod-v7 test-v7'
- version: 7.2
platform: r1000
parm: 'dev-v7 prod-v7 test-v7'
- version: 7.2
platform: v1000
parm: 'dev-v7 prod-v7 test-v7'

runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Checkout
uses: actions/checkout@main

- name: Init Env
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
sudo timedatectl set-timezone "Asia/Shanghai"
# - name: Cache EnvDeploy
# id: cache-env
# uses: actions/cache@v3
# env:
# cache-name: cache-env
# with:
# path: |
# ${{ github.workspace }}/pkgscripts-ng
# ${{ github.workspace }}/build_env
# key: ds.${{ matrix.platform }}-${{ matrix.version }}

- name: Get EnvDeploy
# if: ${{ steps.cache-env.outputs.cache-hit != 'true' }}
run: |
ROOT_PATH=${{ github.workspace }}
git clone https://github.com/SynologyOpenSource/pkgscripts-ng.git ${ROOT_PATH}/pkgscripts-ng
cd ${ROOT_PATH}/pkgscripts-ng
git checkout DSM${{ matrix.version }}
sudo ./EnvDeploy -v ${{ matrix.version }} -l # Get Available platforms
sudo ./EnvDeploy -q -v ${{ matrix.version }} -p ${{ matrix.platform }}
#ENV
mkdir -p ${ROOT_PATH}/source
ENV_PATH=${ROOT_PATH}/build_env/ds.${{ matrix.platform }}-${{ matrix.version }}
sudo cp -al ${ROOT_PATH}/pkgscripts-ng ${ENV_PATH}/
sudo chroot ${ENV_PATH} << "EOF"
cd pkgscripts
version=${{ matrix.version }}; [ ${version:0:1} -gt 6 ] && sed -i 's/print(" ".join(kernels))/pass #&/' ProjectDepends.py
sed -i '/PLATFORM_FAMILY/a\\techo "PRODUCT=$PRODUCT" >> $file\n\techo "KSRC=$KERNEL_SEARCH_PATH" >> $file\n\techo "LINUX_SRC=$KERNEL_SEARCH_PATH" >> $file' include/build
./SynoBuild -c -p ${{ matrix.platform }}
while read line; do if [ ${line:0:1} != "#" ]; then export ${line%%=*}="${line#*=}"; fi; done < /env${BUILD_ARCH}.mak
if [ -f "${KSRC}/Makefile" ]; then
# gcc issue "unrecognized command-line option '--param=allow-store-data-races=0'".
[ "${{ matrix.version }}" == "7.2" ] && sed -i 's/--param=allow-store-data-races=0/--allow-store-data-races/g' ${KSRC}/Makefile
VERSION=`cat ${KSRC}/Makefile | grep ^VERSION | awk -F' ' '{print $3}'`
PATCHLEVEL=`cat ${KSRC}/Makefile | grep ^PATCHLEVEL | awk -F' ' '{print $3}'`
SUBLEVEL=`cat ${KSRC}/Makefile | grep ^SUBLEVEL | awk -F' ' '{print $3}'`
[ -f "/env32.mak" ] && echo "KVER=${VERSION}.${PATCHLEVEL}.${SUBLEVEL}" >> /env32.mak
[ -f "/env64.mak" ] && echo "KVER=${VERSION}.${PATCHLEVEL}.${SUBLEVEL}" >> /env64.mak
CCVER=`$CC --version | head -n 1 | awk -F' ' '{print $3}'`
[ -f "/env32.mak" ] && echo "CCVER=${CCVER}" >> /env32.mak
[ -f "/env64.mak" ] && echo "CCVER=${CCVER}" >> /env64.mak
fi
EOF
[ -f ${ENV_PATH}/env64.mak ] && ENV_FILE=${ENV_PATH}/env64.mak || ([ -f ${ENV_PATH}/env32.mak ] && ENV_FILE=${ENV_PATH}/env32.mak)
if [ -n "${ENV_FILE}" ]; then
KVER=`grep 'KVER=' ${ENV_FILE} | awk -F'=' '{print $2}'`
CCVER=`grep 'CCVER=' ${ENV_FILE} | awk -F'=' '{print $2}'`
[ -n "${KVER}" ] && echo "KVER=${KVER}" >> $GITHUB_ENV
[ -n "${CCVER}" ] && echo "CCVER=${CCVER}" >> $GITHUB_ENV
fi
- name: Get Src
run: |
ROOT_PATH=${{ github.workspace }}
mkdir -p ${ROOT_PATH}/source/output
repo=${{ github.server_url }}/${{ github.repository }}
git clone ${repo} ${ROOT_PATH}/source/input
# Runs a set of commands using the runners shell
- name: Build lkms
id: build
sudo cp -a ${ROOT_PATH}/source ${ROOT_PATH}/build_env/ds.${{ matrix.platform }}-${{ matrix.version }}/
- name: Make lkms
run: |
./compile-lkms.sh
zip -9 rp-lkms.zip -j output/*
ROOT_PATH=${{ github.workspace }}
sudo chroot build_env/ds.${{ matrix.platform }}-${{ matrix.version }} << "EOF"
sed -i 's/^CFLAGS=/#CFLAGS=/g; s/^CXXFLAGS=/#CXXFLAGS=/g' /env${BUILD_ARCH}.mak
while read line; do if [ ${line:0:1} != "#" ]; then export ${line%%=*}="${line#*=}"; fi; done < /env${BUILD_ARCH}.mak
cd /source/input
[ -z "`grep 'env.mak' Makefile`" ] && sed -i '1 i include /env.mak' Makefile
array=(${{ matrix.parm }})
for a in ${array[@]}
do
make ${a}
if [ -f redpill.ko ]; then
strip -g redpill.ko # Discard symbols from object files.
RPKOVER=$(modinfo --field=vermagic redpill.ko | awk '{print $1}')
gzip redpill.ko
mv -f ./redpill.ko.gz /source/output/rp-${{ matrix.platform }}-${RPKOVER/+/}-`echo ${a} | awk -F'-' '{print $1}'`.ko.gz
else
echo "error"
fi
make clean
done
ls -al /source/output
EOF
sudo cp -a ${ROOT_PATH}/build_env/ds.${{ matrix.platform }}-${{ matrix.version }}/source/output ${ROOT_PATH}/source/
# Upload img
- name: Upload lkms
- name: Upload to Artifacts
uses: actions/upload-artifact@v3
with:
name: Redpill LKM for all platforms
path: output
retention-days: 1
name: rp-lkms
path: |
${{ github.workspace }}/source/output/*
- name: clean
# if: ${{ steps.cache-env.outputs.cache-hit == 'true' }}
run: |
sudo rm -rf ${{ github.workspace }}/build_env/ds.${{ matrix.platform }}-${{ matrix.version }}/source/*
release:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@main

- name: Calculate version
run: |
# Calculate version
VERSION=""
if [ ${{ github.event_name }} == 'release' -a ${{ github.ref_type }} == 'tag' ]; then
VERSION="${{ github.ref_name }}"
elif [ -n "${{ inputs.version }}" ]; then
if [ "`echo ${{ inputs.version }} | cut -d '.' -f 1,2`" = "`date +'%y.%-m'`" ]; then
VERSION="${{ inputs.version }}"
else
LATEST_TAG="`curl -skL "https://api.github.com/repos/${{ github.repository }}/releases/latest" | jq -r ".[0].tag_name" 2>/dev/null`"
if [ -n "${LATEST_TAG}" -a "`echo ${LATEST_TAG} | cut -d '.' -f 1,2`" = "`date +'%y.%-m'`" ]; then # format %y.%-m.$i
VERSION="`echo ${LATEST_TAG} | awk -F '.' '{$3=$3+1}1' OFS='.'`"
else
VERSION="`date +'%y.%-m'`.0"
fi
fi
else
VERSION=""
fi
echo "VERSION: ${VERSION}"
echo "VERSION=${VERSION}" >> $GITHUB_ENV
- name: download to artifacts
if: env.VERSION != ''
uses: actions/download-artifact@v3
with:
name: rp-lkms
path: ./rp-lkms

- name: Zip lkms
if: env.VERSION != ''
run: |
echo "${{ env.VERSION }}" > "rp-lkms/VERSION"
zip -9 rp-lkms.zip -j rp-lkms/*
# Publish a release if is a tag
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
if: env.VERSION != ''
with:
tag_name: ${{ env.VERSION }}
files: rp-lkms.zip


3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/output
test*.sh

# Prerequisites
Expand Down Expand Up @@ -56,3 +57,5 @@ dkms.conf
email.patch
linux-*/
.idea/
.vscode/
_compile.sh
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ SRCS-y += compat/string_compat.c \
\
shim/storage/smart_shim.c shim/storage/sata_port_shim.c \
shim/bios/bios_hwcap_shim.c shim/bios/bios_hwmon_shim.c shim/bios/rtc_proxy.c \
shim/bios/bios_shims_collection.c ./shim/bios/bios_psu_status_shim.c shim/bios_shim.c \
shim/bios/bios_shims_collection.c shim/bios/bios_psu_status_shim.c shim/bios_shim.c \
shim/block_fw_update_shim.c shim/disable_exectutables.c shim/pci_shim.c shim/pmu_shim.c shim/uart_fixer.c \
\
redpill_main.c
Expand Down
1 change: 1 addition & 0 deletions PLATFORMS
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ denverton 4.4.180
geminilake 4.4.180
v1000 4.4.180
r1000 4.4.180
epyc7002 5.10.55
21 changes: 12 additions & 9 deletions compile-lkms.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,25 @@ set -e

TMP_PATH="/tmp"
DEST_PATH="output"
TOOLKIT_VER="7.1"
TOOLKIT_VER="latest"

mkdir -p "${DEST_PATH}"

if [ -f ../arpl/PLATFORMS ]; then
cp ../arpl/PLATFORMS PLATFORMS
else
curl -sLO "https://github.com/fbelavenuto/arpl/raw/main/PLATFORMS"
if [ ! -f PLATFORMS ]; then
curl -sLO "https://github.com/fbelavenuto/arpl/raw/main/docker/syno-compiler/PLATFORMS"
fi

function compileLkm() {
PLATFORM=$1
KVER=$2
OUT_PATH="${TMP_PATH}/${PLATFORM}"
mkdir -p "${OUT_PATH}"
sudo chmod 1777 "${OUT_PATH}"
# Compile using docker
docker run --rm -t -v "${OUT_PATH}":/output -v "${PWD}":/input \
fbelavenuto/syno-toolkit:${PLATFORM}-${TOOLKIT_VER} compile-lkm
# docker run --rm -t -v "${OUT_PATH}":/output -v "${PWD}":/input \
# fbelavenuto/syno-toolkit:${PLATFORM}-${TOOLKIT_VER} compile-lkm
docker run -u 1000 --rm -t -v "${OUT_PATH}":/output -v "${PWD}":/input \
fbelavenuto/syno-compiler:${TOOLKIT_VER} compile-lkm ${PLATFORM}
mv "${OUT_PATH}/redpill-dev.ko" "${DEST_PATH}/rp-${PLATFORM}-${KVER}-dev.ko"
rm -f "${DEST_PATH}/rp-${PLATFORM}-${KVER}-dev.ko.gz"
gzip "${DEST_PATH}/rp-${PLATFORM}-${KVER}-dev.ko"
Expand All @@ -32,8 +33,10 @@ function compileLkm() {
}

# Main
cat PLATFORMS
docker pull fbelavenuto/syno-compiler:${TOOLKIT_VER}
while read PLATFORM KVER; do
docker pull fbelavenuto/syno-toolkit:${PLATFORM}-${TOOLKIT_VER}
# docker pull fbelavenuto/syno-toolkit:${PLATFORM}-${TOOLKIT_VER}
compileLkm "${PLATFORM}" "${KVER}" &
done < PLATFORMS
wait
wait
Loading

0 comments on commit 5231b9c

Please sign in to comment.