Skip to content

Commit 4731868

Browse files
committed
first commit
0 parents  commit 4731868

File tree

20 files changed

+1157
-0
lines changed

20 files changed

+1157
-0
lines changed

.github/workflows/release.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
7+
jobs:
8+
packaging-debian:
9+
runs-on: ubuntu-24.04
10+
steps:
11+
- name: Install Dependencies
12+
run: |
13+
sudo apt-get update
14+
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential devscripts dh-make dh-dkms dkms tree
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
path: usb_oc-dkms
19+
- name: Packaging
20+
working-directory: usb_oc-dkms
21+
run: |
22+
LATEST_VERSION=$(grep "^PACKAGE_VERSION" "dkms.conf" | sed 's/.*\?"\([^"]*\)".*/\1/')
23+
ln -s packaging/debian debian
24+
sed -i "s/###LATEST_VERSION###/$LATEST_VERSION/g" debian/control debian/changelog
25+
dpkg-buildpackage --build=binary --post-clean --unsigned-source --unsigned-changes
26+
- name: Upload artifact
27+
uses: actions/upload-artifact@v4
28+
with:
29+
name: debian-package
30+
path: "*.deb"
31+
32+
packaging-archlinux:
33+
runs-on: ubuntu-24.04
34+
container:
35+
image: archlinux:base-devel
36+
steps:
37+
- name: Install Dependencies
38+
run: |
39+
pacman-key --init
40+
pacman -Syu --noconfirm git dkms
41+
useradd -m user
42+
sed -i 's/COMPRESSZST=.*/COMPRESSZST=(zstd -c -T0 --ultra -22 -)/' /etc/makepkg.conf
43+
echo "user ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers
44+
- name: Checkout
45+
uses: actions/checkout@v4
46+
with:
47+
path: usb_oc-dkms
48+
- name: Packaging
49+
working-directory: usb_oc-dkms/packaging/arch
50+
run: |
51+
chown -R user: .
52+
sudo -u user makepkg -s --noconfirm
53+
- name: Upload artifact
54+
uses: actions/upload-artifact@v4
55+
with:
56+
name: arch-package
57+
path: "usb_oc-dkms/packaging/arch/*.pkg*"
58+
59+
packaging-fedora:
60+
runs-on: ubuntu-24.04
61+
container:
62+
image: fedora:rawhide
63+
steps:
64+
- name: Install Dependencies
65+
run: |
66+
dnf install -y fedpkg fedora-packager rpmdevtools \
67+
perl-generators tree
68+
rpmdev-setuptree
69+
- name: Checkout
70+
uses: actions/checkout@v4
71+
with:
72+
path: usb_oc-dkms
73+
- name: Pack a tar with needed files for rpmbuild
74+
run: |
75+
tar cf packaging/rpm/files.tar dkms.conf Makefile src LICENSE README.md
76+
- name: Packaging
77+
working-directory: usb_oc-dkms/packaging/rpm
78+
run: |
79+
rpmbuild --define "_sourcedir `pwd`" --define "_topdir `pwd`" -ba usb_oc-dkms.spec
80+
- name: Upload artifact
81+
uses: actions/upload-artifact@v4
82+
with:
83+
name: arch-package
84+
path: "usb_oc-dkms/packaging/rpm/RPMS/noarch/*.rpm*"
85+
86+
release:
87+
runs-on: ubuntu-24.04
88+
needs: [packaging-debian, packaging-archlinux]
89+
if: github.ref_type == 'tag'
90+
permissions:
91+
contents: write
92+
steps:
93+
- name: Download artifacts
94+
uses: actions/download-artifact@v4
95+
with:
96+
merge-multiple: true
97+
- name: Create Release
98+
uses: softprops/action-gh-release@v2
99+
with:
100+
files: |
101+
*.pkg*
102+
*.deb

.github/workflows/test.yml

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
name: Test
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- "**"
8+
tags-ignore:
9+
- "v[0-9]+.[0-9]+.[0-9]+"
10+
11+
jobs:
12+
test-proxmox-trixie:
13+
runs-on: ubuntu-24.04
14+
container:
15+
image: debian:trixie
16+
steps:
17+
- name: Install Dependencies
18+
run: |
19+
export DEBIAN_FRONTEND=noninteractive
20+
apt-get update
21+
apt-get install -y curl
22+
sh -c "echo deb http://download.proxmox.com/debian/pve trixie pve-no-subscription >> /etc/apt/sources.list"
23+
curl -o /etc/apt/trusted.gpg.d/proxmox-release-trixie.gpg https://enterprise.proxmox.com/debian/proxmox-release-trixie.gpg
24+
apt-get update
25+
apt-get install -y proxmox-archive-keyring
26+
apt-get upgrade -y
27+
apt-get install -y build-essential elfutils libelf-dev proxmox-default-kernel proxmox-default-headers
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
with:
31+
path: usb_oc-dkms
32+
- name: Build Module
33+
working-directory: usb_oc-dkms
34+
run: |
35+
KERNEL_SOURCE_DIR=$(dpkg -L $(dpkg -s $(dpkg -s proxmox-default-headers | grep "Depends: " | cut -d " " -f2) | grep "Depends: " | cut -d " " -f2) | grep -m 1 -Eo ".*/lib/modules/[^/]+/build")
36+
KERNELRELEASE=$(echo -n "$KERNEL_SOURCE_DIR" | sed 's/.*\/lib\/modules\///g;s/\/build//')
37+
make -j$(nproc) KERNELRELEASE=$KERNELRELEASE -C $KERNEL_SOURCE_DIR M=$(pwd)
38+
39+
test-archlinux:
40+
runs-on: ubuntu-24.04
41+
container:
42+
image: archlinux:base-devel
43+
steps:
44+
- name: Install Dependencies
45+
run: |
46+
pacman-key --init
47+
pacman -Syu --noconfirm git linux linux-headers
48+
- name: Checkout
49+
uses: actions/checkout@v4
50+
with:
51+
path: usb_oc-dkms
52+
- name: Check Kernel Compatibility
53+
if: github.event_name != 'workflow_dispatch'
54+
id: check_kernel
55+
working-directory: usb_oc-dkms
56+
run: |
57+
KERNEL_SOURCE_DIR=$(pacman -Qql linux-headers | grep -m 1 -Eo ".*/lib/modules/[^/]+/build")
58+
KERNELRELEASE=$(echo -n "$KERNEL_SOURCE_DIR" | sed 's/.*\/lib\/modules\///g;s/\/build//')
59+
echo "Detected kernel: $KERNELRELEASE"
60+
61+
REGEX=$(grep '^BUILD_EXCLUSIVE_KERNEL=' dkms.conf | cut -d'"' -f2)
62+
63+
if [[ ! "$KERNELRELEASE" =~ $REGEX ]]; then
64+
echo "Kernel $KERNELRELEASE not supported yet."
65+
echo "skip_build=true" >> $GITHUB_OUTPUT
66+
else
67+
echo "Kernel $KERNELRELEASE is supported."
68+
echo "skip_build=false" >> $GITHUB_OUTPUT
69+
fi
70+
- name: Build Module
71+
if: github.event_name == 'workflow_dispatch' || steps.check_kernel.outputs.skip_build == 'false'
72+
working-directory: usb_oc-dkms
73+
run: |
74+
KERNEL_SOURCE_DIR=$(pacman -Qql linux-headers | grep -m 1 -Eo ".*/lib/modules/[^/]+/build")
75+
KERNELRELEASE=$(echo -n "$KERNEL_SOURCE_DIR" | sed 's/.*\/lib\/modules\///g;s/\/build//')
76+
sudo make -j$(nproc) KERNELRELEASE=$KERNELRELEASE -C $KERNEL_SOURCE_DIR M=$(pwd)
77+
78+
test-archlinux-lts:
79+
runs-on: ubuntu-24.04
80+
container:
81+
image: archlinux:base-devel
82+
steps:
83+
- name: Install Dependencies
84+
run: |
85+
pacman-key --init
86+
pacman -Syu --noconfirm git linux-lts linux-lts-headers
87+
- name: Checkout
88+
uses: actions/checkout@v4
89+
with:
90+
path: usb_oc-dkms
91+
- name: Build Module
92+
working-directory: usb_oc-dkms
93+
run: |
94+
KERNEL_SOURCE_DIR=$(pacman -Qql linux-lts-headers | grep -m 1 -Eo ".*/lib/modules/[^/]+/build")
95+
KERNELRELEASE=$(echo -n "$KERNEL_SOURCE_DIR" | sed 's/.*\/lib\/modules\///g;s/\/build//')
96+
sudo make -j$(nproc) KERNELRELEASE=$KERNELRELEASE -C $KERNEL_SOURCE_DIR M=$(pwd)
97+
98+
test-archlinux-mainline:
99+
runs-on: ubuntu-24.04
100+
container:
101+
image: archlinux:base-devel
102+
steps:
103+
- name: Install Dependencies
104+
run: |
105+
pacman-key --init
106+
cat <<EOF >> /etc/pacman.conf
107+
[archlinuxcn]
108+
Server = https://repo.archlinuxcn.org/\$arch
109+
SigLevel = Never
110+
EOF
111+
pacman -Syu --noconfirm git linux-mainline linux-mainline-headers
112+
- name: Checkout
113+
uses: actions/checkout@v4
114+
with:
115+
path: usb_oc-dkms
116+
- name: Check Kernel Compatibility
117+
if: github.event_name != 'workflow_dispatch'
118+
id: check_kernel
119+
working-directory: usb_oc-dkms
120+
run: |
121+
KERNEL_SOURCE_DIR=$(pacman -Qql linux-mainline-headers | grep -m 1 -Eo ".*/lib/modules/[^/]+/build")
122+
KERNELRELEASE=$(echo -n "$KERNEL_SOURCE_DIR" | sed 's/.*\/lib\/modules\///g;s/\/build//')
123+
echo "Detected kernel: $KERNELRELEASE"
124+
125+
REGEX=$(grep '^BUILD_EXCLUSIVE_KERNEL=' dkms.conf | cut -d'"' -f2)
126+
127+
if [[ ! "$KERNELRELEASE" =~ $REGEX ]]; then
128+
echo "Kernel $KERNELRELEASE not supported yet."
129+
echo "skip_build=true" >> $GITHUB_OUTPUT
130+
else
131+
echo "Kernel $KERNELRELEASE is supported."
132+
echo "skip_build=false" >> $GITHUB_OUTPUT
133+
fi
134+
- name: Build Module
135+
if: github.event_name == 'workflow_dispatch' || steps.check_kernel.outputs.skip_build == 'false'
136+
working-directory: usb_oc-dkms
137+
run: |
138+
KERNEL_SOURCE_DIR=$(pacman -Qql linux-mainline-headers | grep -m 1 -Eo ".*/lib/modules/[^/]+/build")
139+
KERNELRELEASE=$(echo -n "$KERNEL_SOURCE_DIR" | sed 's/.*\/lib\/modules\///g;s/\/build//')
140+
sudo make -j$(nproc) KERNELRELEASE=$KERNELRELEASE -C $KERNEL_SOURCE_DIR M=$(pwd)
141+
142+
# test-nixos:
143+
# runs-on: ubuntu-24.04
144+
# steps:
145+
# - name: "Install Nix"
146+
# uses: cachix/install-nix-action@v31.5.1
147+
# - name: Checkout
148+
# uses: actions/checkout@v4
149+
# with:
150+
# path: usb_oc-dkms
151+
# - name: Build i915-sriov kernel module for NixOS
152+
# working-directory: usb_oc-dkms
153+
# env:
154+
# GC_DONT_GC: "1"
155+
# run: |
156+
# nix --version
157+
# nix flake check

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Packages
2+
*.tar.zst
3+
*.deb
4+
/packaging/arch/source/
5+
/packaging/arch/src/
6+
/packaging/arch/pkg/
7+
/packaging/rpm/files.tar

0 commit comments

Comments
 (0)