forked from RedPill-TTG/redpill-load
156 lines (142 loc) · 6.75 KB
/
make_71_kver4.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
name: Make kernel bs patch for 7.1 Linux 4 using fabio kpatch
on:
workflow_dispatch:
inputs:
pat-address:
description: 'Pat file URL'
required: true
default: 'https://global.download.synology.com/download/DSM/release/7.1.1/42962/DSM_SA6400_42962.pat'
toolchain:
description: 'DSM toolchain URL for repack zImage'
required: true
default: 'https://downloads.sourceforge.net/project/dsgpl/Tool%20Chain/DSM%207.0.0%20Tool%20Chains/Intel%20x86%20Linux%204.4.180%20%28Broadwellnk%29/broadwellnk-gcc750_glibc226_x86_64-GPL.txz'
linux-src:
description: 'Linux kernel source URL for repack zImage'
required: true
default: 'https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.4.180.tar.xz'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Bulid
id: bulid-bsp
env:
ACTIONS_STEP_DEBUG: true
run: |
patfile=$(basename ${{ inputs.pat-address }} | while read; do echo -e ${REPLY//%/\\x}; done)
echo "::set-output name=patfile::$patfile"
# install bsdiff
sudo apt-get install -y bsdiff cpio xz-utils
pwd
#tree
#ls -al $GITHUB_WORKSPACE/
mkdir /opt/build
mkdir /opt/dist
cd /opt/build
curl --insecure -L ${{ inputs.pat-address }} -o ds.pat
curl --insecure -L ${{ inputs.toolchain }} -o toolchain.txz
curl --insecure -L ${{ inputs.linux-src }} -o linux.tar.xz
pwd
# download old pat for syno_extract_system_patch # thanks for jumkey's idea.
mkdir synoesp
curl --insecure --location https://global.download.synology.com/download/DSM/release/7.0.1/42218/DSM_DS3622xs%2B_42218.pat --output oldpat.tar.gz
tar -C./synoesp/ -xf oldpat.tar.gz rd.gz
cd synoesp
xz -dc < rd.gz >rd 2>/dev/null || echo "extract rd.gz"
echo "finish"
cpio -idm <rd 2>&1 || echo "extract rd"
mkdir extract
#curl --insecure --location https://raw.githubusercontent.com/PeterSuh-Q3/tinycore-redpill/master/extractor.gz --output ./extractor.gz
#tar -zxvf ./extractor.gz -C ./extract
cd extract
cp ../usr/lib/libcurl.so.4 ../usr/lib/libmbedcrypto.so.5 ../usr/lib/libmbedtls.so.13 ../usr/lib/libmbedx509.so.1 ../usr/lib/libmsgpackc.so.2 ../usr/lib/libsodium.so ../usr/lib/libsynocodesign-ng-virtual-junior-wins.so.7 ../usr/syno/bin/scemd ./
#ln -s libcurl.so.4.7.0 libcurl.so.4
ln -s scemd syno_extract_system_patch
cd ../..
mkdir pat
#tar xf ds.pat -C pat
ls -lh ./
sudo LD_LIBRARY_PATH=synoesp/extract synoesp/extract/syno_extract_system_patch ds.pat pat || echo "extract latest pat"
echo "test4"
# is update_pack
if [ ! -f "pat/zImage" ]; then
cd pat
ar x $(ls flashupdate*)
tar xf data.tar.xz
cd ..
fi
echo "test5"
mkdir toolchain
tar xf toolchain.txz -C toolchain
mkdir linux-src
tar xf linux.tar.xz --strip-components 1 -C linux-src
# extract vmlinux
./linux-src/scripts/extract-vmlinux pat/zImage > vmlinux
# sha256
sha256sum ds.pat >> checksum.sha256
sha256sum pat/zImage >> checksum.sha256
sha256sum pat/rd.gz >> checksum.sha256
sha256sum vmlinux >> checksum.sha256
# md5
md5sum ds.pat >> checksum.sha256
md5sum ds.pat
# patch vmlinux
# New fabio patching method
echo "Patching Kernel"
curl --insecure -L https://github.com/pocopico/tinycore-redpill/raw/main/tools/bzImage-to-vmlinux.sh -o bzImage-to-vmlinux.sh
curl --insecure -L https://github.com/pocopico/tinycore-redpill/raw/main/tools/kpatch -o kpatch
#curl --insecure -L https://github.com/pocopico/tinycore-redpill/raw/main/tools/vmlinux-to-bzImage.sh -o vmlinux-to-bzImage.sh
chmod +x kpatch
./kpatch vmlinux vmlinux_mod.bin
#vmlinux-to-bzImage.sh vmlinux-mod bzImage
git clone https://github.com/kiler129/recreate-zImage.git
chmod +x recreate-zImage/rebuild_kernel.sh
cd linux-src
# ---------- make zImage_mod
# Make file more anonymous
export KBUILD_BUILD_TIMESTAMP="1970/1/1 00:00:00"
export KBUILD_BUILD_USER="root"
export KBUILD_BUILD_HOST="localhost"
export KBUILD_BUILD_VERSION=0
export ARCH=x86_64
export CROSS_COMPILE=/opt/build/toolchain/x86_64-pc-linux-gnu/bin/x86_64-pc-linux-gnu-
#make olddefconfig
make defconfig
# change to lzma
sed -i 's/CONFIG_KERNEL_GZIP=y/# CONFIG_KERNEL_GZIP is not set/' .config
sed -i 's/# CONFIG_KERNEL_LZMA is not set/CONFIG_KERNEL_LZMA=y/' .config
<< see_below
make clean
sed -i 's/bzImage: vmlinux/bzImage: /' arch/x86/Makefile
make vmlinux -j4 || true # make some *.o inspire by UnknowO
cp ../vmlinux_mod.bin vmlinux # vmlinux_mod.bin is already stripped of debugging and comments, strippe again should be ok
make bzImage
sed -i 's/bzImage: /bzImage: vmlinux/' arch/x86/Makefile
cp arch/x86/boot/bzImage ../zImage_mod
make clean
see_below
# for DS3615xs
#sed -i 's/ -std=gnu89$/ -std=gnu89 $(call cc-option,-fno-PIE)/' Makefile
sed -i 's/ ld -/ ${CROSS_COMPILE}ld -/' ../recreate-zImage/rebuild_kernel.sh
sed -i 's/(ld -/(${CROSS_COMPILE}ld -/' ../recreate-zImage/rebuild_kernel.sh
sed -i 's/ gcc / ${CROSS_COMPILE}gcc /' ../recreate-zImage/rebuild_kernel.sh
sed -i 's/ nm / ${CROSS_COMPILE}nm /' ../recreate-zImage/rebuild_kernel.sh
sed -i 's/ objcopy / ${CROSS_COMPILE}objcopy /' ../recreate-zImage/rebuild_kernel.sh
sed -i 's/(objdump /(${CROSS_COMPILE}objdump /' ../recreate-zImage/rebuild_kernel.sh
sed -i 's/ readelf / ${CROSS_COMPILE}readelf /' ../recreate-zImage/rebuild_kernel.sh
../recreate-zImage/rebuild_kernel.sh $PWD/../linux-src ../vmlinux_mod.bin ../zImage_mod
# ----------
cd ..
bsdiff pat/zImage zImage_mod diff.bsp
sha256sum /opt/build/diff.bsp >> checksum.sha256
echo '---copy file---'
cp vmlinux /opt/dist
cp vmlinux_mod.bin /opt/dist
cp diff.bsp /opt/dist
cp checksum.sha256 /opt/dist
echo '---END---'
- name: Upload
uses: actions/upload-artifact@v2
with:
name: kernel bs patch for ${{ steps.bulid-bsp.outputs.patfile }}
path: /opt/dist