diff --git a/.github/workflows/rtl88x2bu-dkms-mkrpm.spec b/.github/workflows/rtl88x2bu-dkms-mkrpm.spec new file mode 100644 index 0000000..378e29e --- /dev/null +++ b/.github/workflows/rtl88x2bu-dkms-mkrpm.spec @@ -0,0 +1,84 @@ +%{?!module_name: %{error: You did not specify a module name (%%module_name)}} +%{?!version: %{error: You did not specify a module version (%%version)}} +%{?!kernel_versions: %{error: You did not specify kernel versions (%%kernel_version)}} +%{?!packager: %define packager DKMS } +%{?!license: %define license Unknown} +%{?!_dkmsdir: %define _dkmsdir /var/lib/dkms} +%{?!_srcdir: %define _srcdir %_prefix/src} +%{?!_datarootdir: %define _datarootdir %{_datadir}} + +Summary: %{module_name} %{version} dkms package +Name: %{module_name} +Version: %{version} +License: %license +Release: 1dkms +BuildArch: noarch +Group: System/Kernel +Requires: dkms >= 1.95, kernel-devel +# -- Building dkms-rpm from ubuntu, turn off checking requirements (find-requires and find-provides), manually added in Requires +Autoprov: 0 +#BuildRequires: dkms +# -- +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root/ + +%description +Kernel modules for %{module_name} %{version} in a DKMS wrapper. + +%prep +if [ "%mktarball_line" != "none" ]; then + /usr/sbin/dkms mktarball -m %module_name -v %version %mktarball_line --archive `basename %{module_name}-%{version}.dkms.tar.gz` + cp -af %{_dkmsdir}/%{module_name}/%{version}/tarball/`basename %{module_name}-%{version}.dkms.tar.gz` %{module_name}-%{version}.dkms.tar.gz +fi + +%install +if [ "$RPM_BUILD_ROOT" != "/" ]; then + rm -rf $RPM_BUILD_ROOT +fi +mkdir -p $RPM_BUILD_ROOT/%{_srcdir} +mkdir -p $RPM_BUILD_ROOT/%{_datarootdir}/%{module_name} + +if [ -d %{_sourcedir}/%{module_name}-%{version} ]; then + cp -Lpr %{_sourcedir}/%{module_name}-%{version} $RPM_BUILD_ROOT/%{_srcdir} +fi + +if [ -f %{module_name}-%{version}.dkms.tar.gz ]; then + install -m 644 %{module_name}-%{version}.dkms.tar.gz $RPM_BUILD_ROOT/%{_datarootdir}/%{module_name} +fi + +if [ -f %{_sourcedir}/common.postinst ]; then + install -m 755 %{_sourcedir}/common.postinst $RPM_BUILD_ROOT/%{_datarootdir}/%{module_name}/postinst +fi + +%clean +if [ "$RPM_BUILD_ROOT" != "/" ]; then + rm -rf $RPM_BUILD_ROOT +fi + +%post +for POSTINST in %{_prefix}/lib/dkms/common.postinst %{_datarootdir}/%{module_name}/postinst; do + if [ -f $POSTINST ]; then + $POSTINST %{module_name} %{version} %{_datarootdir}/%{module_name} + exit $? + fi + echo "WARNING: $POSTINST does not exist." +done +echo -e "ERROR: DKMS version is too old and %{module_name} was not" +echo -e "built with legacy DKMS support." +echo -e "You must either rebuild %{module_name} with legacy postinst" +echo -e "support or upgrade DKMS to a more current version." +exit 1 + +%preun +echo -e +echo -e "Uninstall of %{module_name} module (version %{version}) beginning:" +dkms remove -m %{module_name} -v %{version} --all --rpm_safe_upgrade +exit 0 + +%files +%defattr(-,root,root) +%{_srcdir} +%{_datarootdir}/%{module_name}/ + +%changelog +* %(date "+%a %b %d %Y") %packager %{version}-%{release} +- Automatic build by DKMS diff --git a/.github/workflows/tag-and-release.yml b/.github/workflows/tag-and-release.yml new file mode 100644 index 0000000..5bc87f8 --- /dev/null +++ b/.github/workflows/tag-and-release.yml @@ -0,0 +1,56 @@ +# This is a basic workflow to help you get started with Actions + +name: CI + +# Controls when the action will run. +on: + # Triggers the workflow on push or pull request events but only for any tag + push: + tags: [ '**' ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# 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 + 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@v2 + + # Gets tags name + - name: Set env + run: echo "TAG_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + + # Installs dependencies to build the package + - name: Install dependencies + run: sudo apt install dkms debhelper rpm + + # Runs a set of commands using the runners shell + - name: Run a multi-line script + run: | + VER=$(sed -n 's/\PACKAGE_VERSION="\(.*\)"/\1/p' dkms.conf) + cp .github/workflows/rtl88x2bu-dkms-mkrpm.spec ./ + sudo rsync --exclude '.git' -rvhP ./ /usr/src/rtl88x2bu-${VER} + sudo dkms add -m rtl88x2bu -v ${VER} + sudo dkms build -m rtl88x2bu -v ${VER} + sudo dkms mkdeb -m rtl88x2bu -v ${VER} --source-only + sudo dkms mkrpm -m rtl88x2bu -v ${VER} --source-only + + # Creates a release draft with the attached package + - name: Create release draft + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ env.TAG_NAME }} + name: ${{ env.TAG_NAME }} + draft: true + files: | + /var/lib/dkms/rtl88x2bu/*/deb/rtl88x2bu-*.deb + /var/lib/dkms/rtl88x2bu/*/rpm/rtl88x2bu-*.rpm + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}