commit:     d3a6267c6ff1b476669761af0f94f93c4737ecd4
Author:     Gonçalo Negrier Duarte <gonegrier.duarte <AT> gmail <DOT> com>
AuthorDate: Wed Jul  5 07:37:51 2023 +0000
Commit:     Gonçalo Negrier Duarte <gonegrier.duarte <AT> gmail <DOT> com>
CommitDate: Wed Jul  5 07:39:05 2023 +0000
URL:        https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=d3a6267c

sys-firmware/lenovolegionlinux: new package, add 9999

* add keyword for ~amd64 ~x86

Signed-off-by: Gonçalo Negrier Duarte <gonegrier.duarte <AT> gmail.com>

 sys-firmware/lenovolegionlinux/files/cpu           |  12 +++
 .../lenovolegionlinux/files/legion_cli.policy      |  19 ++++
 .../lenovolegionlinux/files/legion_gui.desktop     |   9 ++
 sys-firmware/lenovolegionlinux/files/nvidia        |  12 +++
 sys-firmware/lenovolegionlinux/files/radeon        |  12 +++
 .../lenovolegionlinux-9999.ebuild                  | 100 +++++++++++++++++++++
 sys-firmware/lenovolegionlinux/metadata.xml        |  17 ++++
 7 files changed, 181 insertions(+)

diff --git a/sys-firmware/lenovolegionlinux/files/cpu 
b/sys-firmware/lenovolegionlinux/files/cpu
new file mode 100644
index 000000000..76224d3fa
--- /dev/null
+++ b/sys-firmware/lenovolegionlinux/files/cpu
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+# Remove the comment for your configuration
+
+#RYZEN (Cpu TDP control using RyzenADJ)
+#INTEL (Cpu control using undervolt) 
[https://github.com/georgewhewell/undervolt]
+#Disable by default see the github from both project
+CPU_Control=0
+#NVIDIA (nvidia-smi)
+#TEAM_GREEN=1
+#AMD (rocm-smi)
+#TEAM_RED=1
\ No newline at end of file

diff --git a/sys-firmware/lenovolegionlinux/files/legion_cli.policy 
b/sys-firmware/lenovolegionlinux/files/legion_cli.policy
new file mode 100644
index 000000000..c19c64c55
--- /dev/null
+++ b/sys-firmware/lenovolegionlinux/files/legion_cli.policy
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE policyconfig PUBLIC
+  "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
+  "http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd";>
+<policyconfig>
+
+  <action id="legion_cli">
+    <message gettext-domain="legion_cli">Authentication is required to run 
legion_cli</message>
+    <icon_name>legion_cli</icon_name>
+    <defaults>
+      <allow_any>auth_admin_keep</allow_any>
+      <allow_inactive>auth_admin_keep</allow_inactive>
+      <allow_active>auth_admin_keep</allow_active>
+    </defaults>
+    <annotate 
key="org.freedesktop.policykit.exec.path">/usr/bin/legion_cli</annotate>
+    <annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
+  </action>
+
+</policyconfig>

diff --git a/sys-firmware/lenovolegionlinux/files/legion_gui.desktop 
b/sys-firmware/lenovolegionlinux/files/legion_gui.desktop
new file mode 100644
index 000000000..48b17927d
--- /dev/null
+++ b/sys-firmware/lenovolegionlinux/files/legion_gui.desktop
@@ -0,0 +1,9 @@
+[Desktop Entry]
+Version=1.0
+Type=Application
+Name=LenovoLegionLinux
+Icon=/usr/share/pixmaps/legion_logo.png
+Exec=legion_gui --use_legion_cli_to_write
+Comment=Control Lenovo Legion Laptops
+Categories=System
+Terminal=false

diff --git a/sys-firmware/lenovolegionlinux/files/nvidia 
b/sys-firmware/lenovolegionlinux/files/nvidia
new file mode 100644
index 000000000..93d3f0824
--- /dev/null
+++ b/sys-firmware/lenovolegionlinux/files/nvidia
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+# Remove the comment for your configuration
+
+#RYZEN (Cpu TDP control using RyzenADJ)
+#INTEL (Cpu control using undervolt) 
[https://github.com/georgewhewell/undervolt]
+#Disable by default see the github from both project
+#CPU_Control=0
+#NVIDIA (nvidia-smi)
+TEAM_GREEN=1
+#AMD (rocm-smi)
+#TEAM_RED=1
\ No newline at end of file

diff --git a/sys-firmware/lenovolegionlinux/files/radeon 
b/sys-firmware/lenovolegionlinux/files/radeon
new file mode 100644
index 000000000..660f9f881
--- /dev/null
+++ b/sys-firmware/lenovolegionlinux/files/radeon
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+# Remove the comment for your configuration
+
+#RYZEN (Cpu TDP control using RyzenADJ)
+#INTEL (Cpu control using undervolt) 
[https://github.com/georgewhewell/undervolt]
+#Disable by default see the github from both project
+#CPU_Control=0
+#NVIDIA (nvidia-smi)
+#TEAM_GREEN=1
+#AMD (rocm-smi)
+TEAM_RED=1
\ No newline at end of file

diff --git a/sys-firmware/lenovolegionlinux/lenovolegionlinux-9999.ebuild 
b/sys-firmware/lenovolegionlinux/lenovolegionlinux-9999.ebuild
new file mode 100644
index 000000000..9160a2f76
--- /dev/null
+++ b/sys-firmware/lenovolegionlinux/lenovolegionlinux-9999.ebuild
@@ -0,0 +1,100 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DISTUTILS_USE_PEP517=setuptools
+PYTHON_COMPAT=( python3_{9..11} )
+
+EPYTHON=python3
+
+inherit linux-mod-r1 toolchain-funcs git-r3 distutils-r1 desktop systemd
+
+EGIT_REPO_URI="https://github.com/johnfanv2/LenovoLegionLinux.git";
+
+DESCRIPTION="Lenovo Legion Linux kernel module"
+HOMEPAGE="https://github.com/johnfanv2/LenovoLegionLinux";
+
+DEPEND="sys-kernel/linux-headers
+        sys-apps/lm-sensors
+        sys-apps/dmidecode
+        legion-tools? ( dev-python/PyQt5 )
+        legion-tools? ( dev-python/pyyaml )
+        legion-tools? ( dev-python/argcomplete )
+               app-portage/smart-live-rebuild
+               legion-acpi? ( sys-power/acpid )
+               radeon-dgpu? ( dev-util/rocm-smi )
+        downgrade-nvidia? ( <=x11-drivers/nvidia-drivers-525 )
+        ryzenadj? ( sys-power/RyzenAdj )"
+LICENSE="GPL-2"
+SLOT="0"
+IUSE="legion-tools legion-acpi systemd radeon-dgpu downgrade-nvidia ryzenadj"
+REQUIRED_USE="|| ( systemd legion-acpi radeon-dgpu downgrade-nvidia ryzenadj 
legion-tools ) legion-acpi? ( legion-tools ) radeon-dgpu? ( !downgrade-nvidia 
legion-tools ) downgrade-nvidia? ( !radeon-dgpu legion-tools )"
+
+KEYWORDS="~amd64~x86"
+
+MODULES_KERNEL_MIN=5.10
+
+src_compile() {
+       local modlist=(
+               
legion-laptop=kernel/drivers/platform/x86:kernel_module:kernel_module:all
+       )
+    KERNELVERSION=${KV_FULL} linux-mod-r1_src_compile
+       if use legion-tools; then
+               #Define build dir (fix sandboxed)
+               cd "${WORKDIR}/${P}/python/legion_linux"
+               distutils-r1_src_compile --build-dir 
"${WORKDIR}/${P}/python/legion_linux/build"
+       fi
+}
+
+src_install() {
+       linux-mod-r1_src_install
+       #Load the module without reboot
+       cd "${WORKDIR}/${P}/python/legion_linux/"
+       make forcereloadmodule
+       if use legion-tools; then
+               #Define build dir (fix sandboxed)
+               cd "${WORKDIR}/${P}/python/legion_linux/"
+               distutils-r1_src_install --build-dir 
"${WORKDIR}/${P}/python/legion_linux/build"
+
+               cd "${WORKDIR}/${P}/extra"
+
+               if use legion-acpi; then
+            insinto /etc/acpi/events/ && doins 
acpi/events/{ac_adapter_legion-fancurve,novo-button,PrtSc-button,fn-r-refrate}
+                       insinto /etc/acpi/actions/ && doins 
acpi/actions/{battery-legion-quiet.sh,snipping-tool.sh,fn-r-refresh-rate.sh}
+        fi
+
+               if use systemd; then
+               systemd_dounit service/legion-linux.service 
service/legion-linux.path
+                       dobin service/fancurve-set
+                       insinto /usr/share/legion_linux && doins 
service/profiles/*
+                       insinto /etc/legion_linux && doins service/profiles/*
+
+                       #AMD
+               if use radeon-dgpu; then
+                       insinto /usr/share/legion_linux && newins 
"${FILESDIR}/radeon" .env
+                               insinto /etc/legion_linux && newins 
"${FILESDIR}/radeon" .env
+               fi
+               #NVIDIA (need dowgrade because nvidia-smi -pl was removed)
+                        if use downgrade-nvidia; then 
+                       insinto /usr/share/legion_linux && newins 
"${FILESDIR}/nvidia" .env
+                               insinto /etc/legion_linux && newins 
"${FILESDIR}/nvidia" .env
+               fi
+
+                       if use ryzenadj; then 
+                       insinto /usr/share/legion_linux && newins 
"${FILESDIR}/cpu" .env
+                               insinto /etc/legion_linux && newins 
"${FILESDIR}/cpu" .env
+               fi
+
+                       elog  "IMPORTANT!!!!\nPls copy /usr/share/legion_linux 
folder to .config in your Home folder\n Dont forget to edit 
.config/legion_linux/.env"
+               fi
+
+               # Desktop Files and Polkit
+               domenu "${FILESDIR}/legion_gui.desktop"
+               doicon 
"${WORKDIR}/${P}/python/legion_linux/legion_linux/legion_logo.png"
+               insinto "/usr/share/polkit-1/actions/" && doins 
"${FILESDIR}/legion_cli.policy"
+
+       fi
+
+       elog "INTEL USERS!!!!\nCPU Control Feature: On intel cpu install 
undervolt https://github.com/georgewhewell/undervolt (or other tool you like to 
use). More information read the readme 
https://github.com/Petingoso/legion-fan-utils-linux/blob/main/README.md";
+}

diff --git a/sys-firmware/lenovolegionlinux/metadata.xml 
b/sys-firmware/lenovolegionlinux/metadata.xml
new file mode 100644
index 000000000..479623d1d
--- /dev/null
+++ b/sys-firmware/lenovolegionlinux/metadata.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd";>
+<pkgmetadata>
+       <use>
+               <flag name="legion-tools">Build and install legion_gui and 
legion_cli</flag>
+               <flag name="legion-acpi">Install acpi script (experimental 
feature)</flag>
+               <flag name="radeon-dgpu">Enable AMD GPU TDP control 
(systemd-service)</flag>
+               <flag name="downgrade-nvidia">Downgrade nvidia for 525 to 
enable TDP control (systemd-service)</flag>
+               <flag name="ryzenadj">CPU and APU control using ryzenadj 
(systemd-service)</flag>
+       </use>
+       <upstream>
+               <remote-id type="github">johnfanv2/LenovoLegionLinux</remote-id>
+               
<bugs-to>https://github.com/johnfanv2/LenovoLegionLinux/issues</bugs-to>
+               
<changelog>https://github.com/johnfanv2/LenovoLegionLinux/blob/main/README.md</changelog>
+       </upstream>
+</pkgmetadata>
+

Reply via email to