forked from bytedance/Elkeid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbatch_compile.sh
38 lines (35 loc) · 1.44 KB
/
batch_compile.sh
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
#!/bin/bash
mkdir -p /ko_output
BUILD_VERSION=$(cat LKM/src/init.c | grep MODULE_VERSION | awk -F '"' '{print $2}')
KO_NAME=$(grep "MODULE_NAME" ./LKM/Makefile | grep -m 1 ":=" | awk '{print $3}')
UBUNTU_OR_DEBIAN_FLAG=$(cat /etc/*release | grep -iE "ubuntu|debian")
FLAG_SIZE=${#UBUNTU_OR_DEBIAN_FLAG}
if [ $FLAG_SIZE -ne 0 ]; then
echo "this is ubuntu or debian"
for f in /lib/modules/*
do
set -e
set -o xtrace
KV="$(basename -- $f)"
echo "Processing $KV file..."
KVERSION=$KV make -C ./LKM clean || true
BATCH=true KVERSION=$KV make -C ./LKM -j all || true
sha256sum ./LKM/${KO_NAME}.ko | awk '{print $1}' > /ko_output/${KO_NAME}_${BUILD_VERSION}_${KV}_amd64.sign || true
mv ./LKM/${KO_NAME}.ko /ko_output/${KO_NAME}_${BUILD_VERSION}_${KV}_amd64.ko || true
KVERSION=$KV make -C ./LKM clean || true
done
else
echo "this is centos"
for f in /usr/src/kernels/*
do
set -e
set -o xtrace
KV="$(basename -- $f)"
echo "Processing $KV file..."
KVERSION=$KV make -C ./LKM clean || true
BATCH=true KVERSION=$KV make -C ./LKM -j all || true
sha256sum ./LKM/${KO_NAME}.ko | awk '{print $1}' > /ko_output/${KO_NAME}_${BUILD_VERSION}_${KV}_amd64.sign || true
mv ./LKM/${KO_NAME}.ko /ko_output/${KO_NAME}_${BUILD_VERSION}_${KV}_amd64.ko || true
KVERSION=$KV make -C ./LKM clean || true
done
fi