Skip to content

Commit

Permalink
update dkms rpm build
Browse files Browse the repository at this point in the history
  • Loading branch information
MrDuartePT committed Aug 27, 2023
1 parent c4c01b5 commit e1bba4b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 39 deletions.
17 changes: 8 additions & 9 deletions deploy/build_deb_rpm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
REPODIR="${DIR}/.."
DKMSDIR=/usr/src/lenovolegionlinux-1.0.0
BUILD_DIR=/tmp/pkg
BUILD_DIR_RPM_DKMS=/tmp/rpm_dkms

set -ex
#Intsall debian packages
Expand Down Expand Up @@ -38,15 +39,13 @@ echo "Dkms deb located at ${BUILD_DIR}/lenovolegionlinux-dkms_1.0.0_amd64.deb"

#BUILD DKMS RPM

#Clean DKSM tree
sudo dkms remove -m lenovolegionlinux -v 1.0.0

#Build rpm file
sudo dkms mkkmp -m lenovolegionlinux -v 1.0.0 --spec lenovolegionlinux.spec
cd ${BUILD_DIR_RPM_DKMS}
mkdir -p rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
cp -r ${REPODIR}/kernel_module ./lenovolegionlinux-kmod-1.0.0-x86_64
tar --create --file lenovolegionlinux-kmod-1.0.0-x86_64.tar.gz lenovolegionlinux-kmod-1.0.0-x86_64 && rm --recursive lenovolegionlinux-kmod-1.0.0-x86_64
mv lenovolegionlinux-kmod-1.0.0-x86_64.tar.gz rpmbuild/SOURCES
rpmbuild --define "_topdir `pwd`" -bs SPECS/lenovolegionlinux.spec

#Copy rpm to deploy folder
sudo cp /var/lib/dkms/lenovolegionlinux/1.0.0/rpm/lenovolegionlinux-1.0-0.src.rpm ${BUILD_DIR}/lenovolegionlinux-1.0-0.src.rpm
##

##BUILD PYTHON DEB
cd ${REPODIR}/python/legion_linux
Expand All @@ -69,8 +68,8 @@ sudo mv ../python3-legion-linux_1.0.0-1_all.deb ${BUILD_DIR}
#Build to RPM
cd ${BUILD_DIR}
mkdir -p rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
cp ${REPODIR}/deploy/lenovolegionlinux.spec rpmbuild/SPECS
cp -r ${REPODIR}/python/legion_linux python-lenovolegionlinux-1.0.0
mv python-lenovolegionlinux-1.0.0/lenovolegionlinux.spec rpmbuild/SPECS
rm -r python-lenovolegionlinux-1.0.0/legion_linux/extra && cp -r ${REPODIR}/extra python-lenovolegionlinux-1.0.0/legion_linux/extra
tar --create --file python-lenovolegionlinux-1.0.0.tar.gz python-lenovolegionlinux-1.0.0 && rm --recursive python-lenovolegionlinux-1.0.0
mv python-lenovolegionlinux-1.0.0.tar.gz rpmbuild/SOURCES
Expand Down
56 changes: 26 additions & 30 deletions kernel_module/lenovolegionlinux.spec
Original file line number Diff line number Diff line change
@@ -1,45 +1,41 @@
# norootforbuild
%global dkms_name lenovolegionlinux

Name: lenovolegionlinux
Name: dkms-lenovolegionlinux
License: GPL
Group: System/Kernel
Summary: LenovoLegionLinux Kernel Module Package
Version: 1.0
Version: 1.0.0
Release: 0
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Source0: %{dkms_name}-kmod-%{version}-x86_64.tar.gz

%description
Driver for controlling Lenovo Legion laptops including fan control and power mode.

%package KMP
Summary: LenovoLegionLinux Kernel Module
Group: System/Kernel
Provides: %{dkms_name}-kmod = %{?epoch:%{epoch}:}%{version}
Requires: %{dkms_name}-kmod-common = %{?epoch:%{epoch}:}%{version}
Requires: dkms

%description KMP
This is one of the subpackages require for LenovoLegionLinux [kernel module/driver]
%description
Driver for controlling Lenovo Legion laptops including fan control and power mode.

%prep
set -- *
mkdir source
mv "$@" source/
mkdir obj

%build
for flavor in %flavors_to_build; do
rm -rf obj/$flavor
cp -r source obj/$flavor
make -C /usr/src/linux/%_target_cpu/$flavor M=$PWD/obj/$flavor
done
%autosetup -p0 -n %{dkms_name}-kmod-%{version}-x86_64

%install
export INSTALL_MOD_PATH=$RPM_BUILD_ROOT
export INSTALL_MOD_DIR=updates
for flavor in %flavors_to_build; do
make -C /usr/src/linux/%_target_cpu/$flavor install M=$PWD/obj/$flavor
done
mkdir -p %{buildroot}%{_usrsrc}/%{dkms_name}-%{version}/
cp -fr * %{buildroot}%{_usrsrc}/%{dkms_name}-%{version}/

%post
dkms add -m %{dkms_name} -v %{version} -q || :
# Rebuild and make available for the currently running kernel:
dkms build -m %{dkms_name} -v %{version} -q || :
dkms install -m %{dkms_name} -v %{version} -q --force || :

%preun
# Remove all versions from DKMS registry:
dkms remove -m %{dkms_name} -v %{version} -q --all || :

%clean
rm -rf %{buildroot}
%files
%{_usrsrc}/%{dkms_name}-%{version}

%changelog
Intial Release
* Sat Aug 25 2023 Gonçalo Negrier Duarte <gonegrier.duarte@gmail.com> - 1.0.0
- Intial Release 1.0.0.
File renamed without changes.

0 comments on commit e1bba4b

Please sign in to comment.