summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Maisonnas2020-02-02 23:30:08 +0100
committerBenjamin Maisonnas2020-02-02 23:30:08 +0100
commit3c6cd8c2893357fdc5a3527a22acc9b08864397d (patch)
treefb92b97f32ccb016a7359f61b5b191cdad103d59
downloadaur-3c6cd8c2893357fdc5a3527a22acc9b08864397d.tar.gz
initial commit
-rw-r--r--.SRCINFO23
-rw-r--r--.gitignore7
-rw-r--r--Makefile105
-rw-r--r--PKGBUILD49
-rw-r--r--corsairpsu.conf5
-rw-r--r--dkms.conf7
6 files changed, 196 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 00000000000..0b1a711b5ad
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,23 @@
+pkgbase = corsairpsu-dkms-git
+ pkgdesc = Linux kernel driver for reading sensors for Corsair RMi/HXi Series PSUs
+ pkgver = 3.a6ccb44
+ pkgrel = 1
+ url = https://github.com/benzhaomin/corsairpsu
+ arch = x86_64
+ arch = i686
+ license = GPL2
+ makedepends = git
+ makedepends = linux-headers
+ depends = dkms
+ provides = corsairpsu
+ source = corsairpsu::git+https://github.com/benzhaomin/corsairpsu.git
+ source = Makefile
+ source = dkms.conf
+ source = corsairpsu.conf
+ sha256sums = SKIP
+ sha256sums = 46ab8a4d60a9db7a1957d199fc20da09d0195df80cd64ad6ffddea17b5fd75c8
+ sha256sums = 9eb35ca8dcff02744dd3256238f22bfe6ebaf1636867aabed4c40a31073c4e1e
+ sha256sums = 4fee830333d13c385e2c27bc74d3473304794d62a739fa614073f045e6039f58
+
+pkgname = corsairpsu-dkms-git
+
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 00000000000..c7dd7780892
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,7 @@
+*.[oa]
+*.zip
+*.gz
+*.pkg.*
+corsairpsu/
+pkg/
+src/
diff --git a/Makefile b/Makefile
new file mode 100644
index 00000000000..b52efb7f153
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,105 @@
+# For building for the current running version of Linux
+ifndef TARGET
+TARGET := $(shell uname -r)
+endif
+# Or specific version
+#TARGET := 2.6.33.5
+
+KERNEL_MODULES := /lib/modules/$(TARGET)
+
+ifneq ("","$(wildcard /usr/src/linux-headers-$(TARGET)/*)")
+# Ubuntu
+KERNEL_BUILD := /usr/src/linux-headers-$(TARGET)
+else
+ifneq ("","$(wildcard /usr/src/kernels/$(TARGET)/*)")
+# Fedora
+KERNEL_BUILD := /usr/src/kernels/$(TARGET)
+else
+KERNEL_BUILD := $(KERNEL_MODULES)/build
+endif
+endif
+
+#SYSTEM_MAP := $(KERNEL_BUILD)/System.map
+ifneq ("","$(wildcard /boot/System.map-$(TARGET))")
+SYSTEM_MAP := /boot/System.map-$(TARGET)
+else
+# Arch
+SYSTEM_MAP := /proc/kallsyms
+endif
+
+DRIVER := corsairpsu
+ifneq ("","$(wildcard .git/*)")
+DRIVER_VERSION := $(shell git describe --long)
+else
+ifneq ("", "$(wildcard VERSION)")
+DRIVER_VERSION := $(shell cat VERSION)
+else
+DRIVER_VERSION := unknown
+endif
+endif
+
+# DKMS
+DKMS_ROOT_PATH=/usr/src/$(DRIVER)-$(DRIVER_VERSION)
+MODPROBE_OUTPUT=$(shell lsmod | grep corsairpsu)
+
+# Directory below /lib/modules/$(TARGET)/kernel into which to install
+# the module:
+MOD_SUBDIR = drivers/hwmon
+MODDESTDIR=$(KERNEL_MODULES)/kernel/$(MOD_SUBDIR)
+
+obj-m := $(patsubst %,%.o,$(DRIVER))
+obj-ko := $(patsubst %,%.ko,$(DRIVER))
+
+MAKEFLAGS += --no-print-directory
+
+ifneq ("","$(wildcard $(MODDESTDIR)/*.ko.gz)")
+COMPRESS_GZIP := y
+endif
+ifneq ("","$(wildcard $(MODDESTDIR)/*.ko.xz)")
+COMPRESS_XZ := y
+endif
+
+.PHONY: all install modules modules_install clean dkms dkms_clean
+
+all: modules
+
+# Targets for running make directly in the external module directory:
+
+modules:
+ @$(MAKE) -C $(KERNEL_BUILD) M=$(CURDIR) $@
+
+clean:
+ @$(MAKE) -C $(KERNEL_BUILD) M=$(CURDIR) $@
+
+install: modules_install
+
+modules_install:
+ mkdir -p $(MODDESTDIR)
+ cp $(DRIVER).ko $(MODDESTDIR)/
+ifeq ($(COMPRESS_GZIP), y)
+ @gzip -f $(MODDESTDIR)/$(DRIVER).ko
+endif
+ifeq ($(COMPRESS_XZ), y)
+ @xz -f $(MODDESTDIR)/$(DRIVER).ko
+endif
+ depmod -a -F $(SYSTEM_MAP) $(TARGET)
+
+dkms:
+ @sed -i -e '/^PACKAGE_VERSION=/ s/=.*/=\"$(DRIVER_VERSION)\"/' dkms.conf
+ @echo "$(DRIVER_VERSION)" >VERSION
+ @mkdir $(DKMS_ROOT_PATH)
+ @cp `pwd`/dkms.conf $(DKMS_ROOT_PATH)
+ @cp `pwd`/VERSION $(DKMS_ROOT_PATH)
+ @cp `pwd`/Makefile $(DKMS_ROOT_PATH)
+ @cp `pwd`/corsairpsu.c $(DKMS_ROOT_PATH)
+ @dkms add -m $(DRIVER) -v $(DRIVER_VERSION)
+ @dkms build -m $(DRIVER) -v $(DRIVER_VERSION)
+ @dkms install --force -m $(DRIVER) -v $(DRIVER_VERSION)
+ @modprobe $(DRIVER)
+
+dkms_clean:
+ @if [ ! -z "$(MODPROBE_OUTPUT)" ]; then \
+ rmmod $(DRIVER);\
+ fi
+ @dkms remove -m $(DRIVER) -v $(DRIVER_VERSION) --all
+ @rm -rf $(DKMS_ROOT_PATH)
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 00000000000..1e120d2df68
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,49 @@
+# Maintainer: Benjamin Maisonnas <ben at wainei dot net>
+# Author: Benjamin Maisonnas <ben at wainei dot net>
+
+_pkgbase=corsairpsu
+pkgname=corsairpsu-dkms-git
+pkgver=3.a6ccb44
+pkgrel=1
+pkgdesc="Linux kernel driver for reading sensors for Corsair RMi/HXi Series PSUs"
+arch=('x86_64' 'i686')
+url="https://github.com/benzhaomin/corsairpsu"
+license=('GPL2')
+depends=('dkms')
+makedepends=('git' 'linux-headers')
+provides=('corsairpsu')
+
+source=("$_pkgbase::git+$url.git"
+ "Makefile"
+ "dkms.conf"
+ "$_pkgbase.conf")
+
+sha256sums=('SKIP'
+ '46ab8a4d60a9db7a1957d199fc20da09d0195df80cd64ad6ffddea17b5fd75c8'
+ '9eb35ca8dcff02744dd3256238f22bfe6ebaf1636867aabed4c40a31073c4e1e'
+ '4fee830333d13c385e2c27bc74d3473304794d62a739fa614073f045e6039f58')
+
+pkgver() {
+ cd "$srcdir/$_pkgbase"
+ printf "%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
+}
+
+prepare() {
+ cd "$srcdir/$_pkgbase"
+}
+
+package() {
+ cd "$srcdir/$_pkgbase"
+
+ install -d "${pkgdir}"/usr/src/${_pkgbase}-${pkgver}/
+ cp -r ${srcdir}/${_pkgbase}/* "${pkgdir}"/usr/src/${_pkgbase}-${pkgver}/
+
+ install -Dm644 ${srcdir}/Makefile "${pkgdir}"/usr/src/${_pkgbase}-${pkgver}/Makefile
+ install -Dm644 ${srcdir}/dkms.conf "${pkgdir}"/usr/src/${_pkgbase}-${pkgver}/dkms.conf
+
+ sed -e "s/@_PKGBASE@/${_pkgbase}/" \
+ -e "s/@PKGVER@/${pkgver}/" \
+ -i "${pkgdir}"/usr/src/${_pkgbase}-${pkgver}/dkms.conf
+
+ install -Dm644 ${srcdir}/${_pkgbase}.conf "${pkgdir}"/usr/lib/depmod.d/${_pkgbase}.conf
+}
diff --git a/corsairpsu.conf b/corsairpsu.conf
new file mode 100644
index 00000000000..0f5a03a317f
--- /dev/null
+++ b/corsairpsu.conf
@@ -0,0 +1,5 @@
+#
+# /usr/lib/depmod.d/corsairpsu.conf
+#
+
+search updates extramodules built-in
diff --git a/dkms.conf b/dkms.conf
new file mode 100644
index 00000000000..6200bb28dae
--- /dev/null
+++ b/dkms.conf
@@ -0,0 +1,7 @@
+PACKAGE_NAME="@_PKGBASE@"
+PACKAGE_VERSION="@PKGVER@"
+MAKE[0]="make -C $kernel_source_dir M=$dkms_tree/$PACKAGE_NAME/$PACKAGE_VERSION/build modules"
+CLEAN="make clean"
+BUILT_MODULE_NAME[0]="@_PKGBASE@"
+DEST_MODULE_LOCATION[0]="/extramodules/kernel/drivers/hwmon"
+AUTOINSTALL="yes"