Skip to content

Commit

Permalink
workflows: download linux source from https://cdn.kernel.org/pub/lin…
Browse files Browse the repository at this point in the history
…ux/kernel/`

Signed-off-by: CFC4N <cfc4n.cs@gmail.com>
  • Loading branch information
cfc4n committed Oct 6, 2024
1 parent 68af013 commit 1300f5f
Showing 1 changed file with 42 additions and 22 deletions.
64 changes: 42 additions & 22 deletions .github/workflows/go-c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,27 @@ jobs:
- name: Install Compilers
run: |
sudo apt-get update
sudo apt-get install --yes build-essential pkgconf libelf-dev llvm-14 clang-14 flex bison linux-tools-common linux-tools-generic gcc gcc-aarch64-linux-gnu libssl-dev linux-source
sudo apt-get install --yes build-essential pkgconf libelf-dev llvm-14 clang-14 flex bison linux-tools-common linux-tools-generic gcc gcc-aarch64-linux-gnu libssl-dev
for tool in "clang" "llc" "llvm-strip"
do
sudo rm -f /usr/bin/$tool
sudo ln -s /usr/bin/$tool-14 /usr/bin/$tool
done
cd /usr/src
source_file=$(find . -maxdepth 1 -name "*linux-source*.tar.bz2")
source_dir=$(echo "$source_file" | sed 's/\.tar\.bz2//g')
sudo tar -xf $source_file
cd $source_dir
kernel_version=$(uname -r | cut -d '-' -f 1)
echo "$kernel_version" | IFS='.' read -r major minor patch
patch_ver=""
if [ $patch -ne 0 ]; then
patch_ver=".$patch"
fi
source_name=linux-${major}.${minor}${patch_ver}
echo "major: $major , minor: $minor , patch: $patch , source_name : $source_name"
now_path=`pwd`
wget https://cdn.kernel.org/pub/linux/kernel/v${major}.x/${source_name}.tar.gz
tar -zxvf ${source_name}.tar.gz
cd ${source_name}
test -f .config || sudo make oldconfig
sudo make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- prepare V=0
ls -al /usr/src/$source_dir
ls -al ${now_path}/$source_name
shell: bash
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -160,7 +167,7 @@ jobs:
artifact_name: ecapture-${{ github.ref_name }}
# The shell to run commands with in the container
shell: /bin/sh
shell: /bin/bash

# Install some dependencies in the container. This speeds up builds if
# you are also using githubToken. Any dependencies installed here will
Expand All @@ -171,7 +178,7 @@ jobs:
install: |
uname -a
apt-get update
apt-get install --yes wget git build-essential pkgconf libelf-dev llvm-12 clang-12 linux-tools-generic linux-tools-common flex bison file gcc-x86-64-linux-gnu libssl-dev bc linux-source
apt-get install --yes wget git build-essential pkgconf libelf-dev llvm-12 clang-12 linux-tools-generic linux-tools-common flex bison file gcc-x86-64-linux-gnu libssl-dev bc
wget https://go.dev/dl/go1.21.0.linux-arm64.tar.gz
rm -rf /usr/local/go
tar -C /usr/local -xzf go1.21.0.linux-arm64.tar.gz
Expand All @@ -182,15 +189,22 @@ jobs:
done
clang --version
which bpftool
cd /usr/src
source_file=$(find . -maxdepth 1 -name "*linux-source*.tar.bz2")
source_dir=$(echo "$source_file" | sed 's/\.tar\.bz2//g')
tar -xf $source_file
cd $source_dir
kernel_version=$(uname -r | cut -d '-' -f 1)
echo "$kernel_version" | IFS='.' read -r major minor patch
patch_ver=""
if [ $patch -ne 0 ]; then
patch_ver=".$patch"
fi
source_name=linux-${major}.${minor}${patch_ver}
echo "major: $major , minor: $minor , patch: $patch , source_name : $source_name"
now_path=`pwd`
wget https://cdn.kernel.org/pub/linux/kernel/v${major}.x/${source_name}.tar.gz
tar -zxvf ${source_name}.tar.gz
cd ${source_name}
test -f .config || make oldconfig > /dev/null
make ARCH=x86 CROSS_COMPILE=x86_64-linux-gnu- prepare V=0 > /dev/null
make prepare V=0 > /dev/null
ls -al /usr/src/$source_dir
ls -al ${now_path}/$source_name
# Produce a binary artifact and place it in the mounted volume
run: |
uname -a
Expand All @@ -201,20 +215,26 @@ jobs:
cat /proc/1/cgroup
echo "cat /proc/1/sched:"
cat /proc/1/sched
cd /usr/src
source_file=$(find . -maxdepth 1 -name "*linux-source*.tar.bz2")
source_dir=$(echo "$source_file" | sed 's/\.tar\.bz2//g')
now_path=`pwd`
kernel_version=$(uname -r | cut -d '-' -f 1)
IFS='.' read -r major minor patch <<< "$kernel_version"
patch_ver=""
if [ $patch -ne 0 ]; then
patch_ver=".$patch"
fi
source_name=linux-${major}.${minor}${patch_ver}
echo "major: $major , minor: $minor , patch: $patch , source_name : $source_name"
git config --global --add safe.directory /source_code
cd /source_code
echo "-------------------start: Build CO-RE Linux (include non-CO-RE)-------------------"
KERN_HEADERS=/usr/src/$source_dir make env
KERN_HEADERS=${now_path}/$source_name make env
make clean
KERN_HEADERS=/usr/src/$source_dir make
KERN_HEADERS=${now_path}/$source_name make
bin/ecapture -v
echo "-------------------start: Build non-CO-RE (Cross-Compilation) Linux -------------------"
make clean
KERN_HEADERS=/usr/src/$source_dir CROSS_ARCH=amd64 make env
KERN_HEADERS=/usr/src/$source_dir CROSS_ARCH=amd64 make nocore -j8
KERN_HEADERS=${now_path}/$source_name CROSS_ARCH=amd64 make env
KERN_HEADERS=${now_path}/$source_name CROSS_ARCH=amd64 make nocore -j8
file bin/ecapture
- name: Show the artifact
# Items placed in /artifacts in the container will be in
Expand Down

0 comments on commit 1300f5f

Please sign in to comment.