From 529fd3d4ce62d2a672f7d02a6b9314694470a632 Mon Sep 17 00:00:00 2001 From: mcgillij Date: Sun, 7 Jul 2024 04:00:38 -0300 Subject: [PATCH] update to get autoconf to work - moved the configure.ac to the root - re-removed the PKGBUILD that was added to get the build passing - updated the readme/installs to have the right commands and fix a couple typo's - updated the templates used for autoconf to use the correct paths/vars - added cleanup/build script to use for cutting new release - updated pyproject.toml to include the service file once it's generated - fixed some default values and updated the .gitignore --- .gitignore | 4 ++++ INSTALL.md | 12 ++++++------ PKGBUILD | 27 --------------------------- README.md | 4 ++-- amdfan/commands.py | 3 +-- amdfan/defaults.py | 3 ++- clean_build | 15 +++++++++++++++ dist/configure.ac => configure.ac | 2 +- dist/pacman/PKGBUILD.in | 14 +++++++------- dist/systemd/amdfan.service.in | 2 +- pyproject.toml | 4 ++-- 11 files changed, 41 insertions(+), 49 deletions(-) delete mode 100644 PKGBUILD create mode 100755 clean_build rename dist/configure.ac => configure.ac (80%) diff --git a/.gitignore b/.gitignore index 95c7489..66dfaa0 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,10 @@ __pycache__/ *.py[cod] *$py.class +# PKGBUILD in the root that I use to build the package and the tarball/package +PKGBUILD +*.gz +*.zst # C extensions *.so diff --git a/INSTALL.md b/INSTALL.md index bed952f..1c4b933 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -6,14 +6,14 @@ At runtime: `python`, `numpy`, `click`, `rich` and `pyyaml` Our standard builds use pyproject, mainly with poetry. # Preparing the sources -The dist files are template files, which means you must first `autoconf` them. You could also just `sed` all the `.in` files if you don't want to use autotools. +The dist files are template files, which means you must first `autoconf` them. You could also just `sed` all the `.in` files if you don't want to use `autotools`. ``` sh git clone https://github.com/mcgillij/amdfan.git cd amdfan autoconf -./configure --prefix=/usr --libdir=/usr/lib +./configure --prefix=/usr --libdir=/usr/lib --bindir=/usr/bin ``` # Service files @@ -23,11 +23,11 @@ There are two ways to obtain the systemd service file. One is available during r amdfan print-default --service | sudo tee /usr/lib/systemd/system/amdfan.service ``` -If you ran `./configure` succesfully, you'll also find the service files for OpenRC and systemd under `dist/${init}/`. +If you ran `./configure` successfully, you'll also find the service files for OpenRC and systemd under `dist/${init}/`. # Configuration files -Similiar to above, you can obtain the sources from the runtime. This is not necessary, as this file is generated automatically after the daemon runs for the first time. +Similarly as above, you can obtain the sources from the runtime. This is not necessary, as this file is generated automatically after the daemon runs for the first time. ``` bash amdfan print-default --configuration | sudo tee /etc/amdfan.yml @@ -35,7 +35,7 @@ amdfan print-default --configuration | sudo tee /etc/amdfan.yml # Executable files -The executable files are contained within amdfan. This directory is a python module, and can either be loaded as `python -m amdgpu`. If you want to import the module, you may be interested in checking out `amdfan.commands`, which contains most of the subcommands. +The executable files are contained within amdfan. This directory is a python module, and can either be loaded as `python -m amdfan`. If you want to import the module, you may be interested in checking out `amdfan.commands`, which contains most of the subcommands. Otherwise, just use python-exec with something like @@ -50,7 +50,7 @@ if __name__ == '__main__': # Installing from PyPi -You can also install amdfan from pypi using something like poetry. +You can also install amdfan from PyPi using something like poetry. ``` bash poetry init diff --git a/PKGBUILD b/PKGBUILD deleted file mode 100644 index 68f3b6e..0000000 --- a/PKGBUILD +++ /dev/null @@ -1,27 +0,0 @@ -# Maintainer: Jason McGillivray < mcgillivray dot jason at gmail dot com> - - -pkgname=amdfan -pkgdesc="Python daemon for controlling the fans on amdgpu cards" -pkgver=0.2.0 -pkgrel=1 -arch=('any') -license=('GPL2') -depends=('python' 'python-yaml' 'python-numpy' 'python-rich' 'python-click') -makedepends=('python-poetry-core' 'python-build' 'python-installer') -url="https://github.com/mcgillij/amdfan" -source=("https://github.com/mcgillij/amdfan/releases/download/$pkgver/amdfan-$pkgver.tar.gz") -#source=("amdfan-$pkgver.tar.gz") -md5sums=('58db7ccf6255d4866efc75cc9c89a66a') - -build() { - cd "$srcdir/$pkgname-$pkgver" - python -m build --wheel --no-isolation -} - -package() { - cd "$srcdir/$pkgname-$pkgver" - python -m installer --destdir="$pkgdir" dist/*.whl - mkdir -p "$pkgdir/usr/lib/systemd/system" - install -Dm644 src/amdfan/amdfan.service "$pkgdir/usr/lib/systemd/system/" -} diff --git a/README.md b/README.md index f236b3a..1cba114 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ There are two ways to control your fans with Amdfan. Note that in order to contr The recommended way is through a system service started at boot. This will control the fans based on the detected temperature at a given interval. -In case you don't want to use a service, you may also control the fans manually. While this is only adviced to do when first setting up your configuration, keep in mind you can also use it to temporarily take control away from the daemon until you revert the fan speed back to `auto`. +In case you don't want to use a service, you may also control the fans manually. While this is only advised to do when first setting up your configuration, keep in mind you can also use it to temporarily take control away from the daemon until you revert the fan speed back to `auto`. ![screenshot](https://raw.githubusercontent.com/mcgillij/amdfan/main/images/manual.png) @@ -98,7 +98,7 @@ If a configuration file is not found, a default one will be generated. If you wa - `frequency` (default `5`): how often (in seconds) we wait between updates - `cards` (required): a list of card names (from `/sys/class/drm`) which we want to control. -Note! You can send a SIGHUP signal to the daemon to request a reload of the config without restarting the whole service. +Note! You can send a **SIGHUP** signal to the daemon to request a reload of the config without restarting the whole service. # Install diff --git a/amdfan/commands.py b/amdfan/commands.py index e6259e9..b8e0900 100644 --- a/amdfan/commands.py +++ b/amdfan/commands.py @@ -54,7 +54,6 @@ def cli( help="Run the controller", ) @click.option("--notification-fd", type=int) -# @click.option("--background", is_flag=True, default=True) def run_daemon(notification_fd): FanController.start_daemon( notification_fd=notification_fd, pidfile=os.path.join(PIDFILE_DIR, "amdfan.pid") @@ -77,7 +76,7 @@ def show_table(cards: Dict) -> Table: def monitor_cards(fps, single_run) -> None: scanner = Scanner() if not single_run: - c.print("AMD Fan Control - ctrl-c to quit") + c.print("AMD Fan Control - Ctrl-c to quit") with Live(refresh_per_second=fps) as live: while 1: diff --git a/amdfan/defaults.py b/amdfan/defaults.py index a76f8a9..21b42b7 100644 --- a/amdfan/defaults.py +++ b/amdfan/defaults.py @@ -39,7 +39,8 @@ Description=amdfan controller [Service] -ExecStart=/usr/bin/amdfan --daemon +ExecStart=/usr/bin/amdfan daemon +ExecReload=kill -HUP $MAINPID Restart=always [Install] diff --git a/clean_build b/clean_build new file mode 100755 index 0000000..c33e6e4 --- /dev/null +++ b/clean_build @@ -0,0 +1,15 @@ +#####!/bin/bash +echo "cleaning up previous run" +rm -rf dist/*.whl dist/*.gz configure config.status autom4te.cache config.log *.gz *.zst *.log +echo "autoconf" +autoconf +echo "./configure" +./configure --prefix=/usr --libdir=/usr/lib --bindir=/usr/bin +echo "Copy the PKGBUILD to the root dir for running makepkg" +cp dist/pacman/PKGBUILD . +echo "running poetry build" +poetry build +echo "getting the md5sum of the tarball" +md5sum dist/*.gz +echo "Copying the tarball to the root dir" +cp dist/*.gz . diff --git a/dist/configure.ac b/configure.ac similarity index 80% rename from dist/configure.ac rename to configure.ac index 94bcfb4..0e9fa69 100644 --- a/dist/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ -AC_INIT([amdfan], [0.1.28]) +AC_INIT([amdfan], [0.2.1]) AC_CONFIG_FILES([dist/pacman/PKGBUILD]) AC_CONFIG_FILES([dist/openrc/amdfan dist/systemd/amdfan.service]) AC_OUTPUT diff --git a/dist/pacman/PKGBUILD.in b/dist/pacman/PKGBUILD.in index f7b507b..4f7bcf4 100644 --- a/dist/pacman/PKGBUILD.in +++ b/dist/pacman/PKGBUILD.in @@ -3,16 +3,16 @@ pkgname=amdfan pkgdesc="Python daemon for controlling the fans on amdgpu cards" -pkgver=0.1.28 +pkgver=0.2.1 pkgrel=1 arch=('any') license=('GPL2') depends=('python' 'python-yaml' 'python-numpy' 'python-rich' 'python-click') -makedepends=('python-setuptools' 'python-poetry' 'python-build' 'python-installer') +makedepends=('python-poetry' 'python-build' 'python-installer') url="https://github.com/mcgillij/amdfan" -source=("https://github.com/mcgillij/amdfan/releases/download/$pkgver/amdfan-$pkgver.tar.gz") -#source=("amdfan-$pkgver.tar.gz") -md5sums=('7fe30661ba0d5117f32e4bab1db76888') +#source=("https://github.com/mcgillij/amdfan/releases/download/$pkgver/amdfan-$pkgver.tar.gz") +source=("dist/amdfan-$pkgver.tar.gz") +md5sums=('6e4418082f1cf765d10552117c0895fe') build() { cd "$srcdir/$pkgname-$pkgver" @@ -22,6 +22,6 @@ build() { package() { cd "$srcdir/$pkgname-$pkgver" python -m installer --destdir="$pkgdir" dist/*.whl - mkdir -p "$pkgdir/@libdir@/systemd/system" - install -Dm644 amdfan/packaging/pacman/amdfan.service "$pkgdir/@libdir@/systemd/system/" + mkdir -p "$pkgdir@libdir@/systemd/system" + install -Dm644 dist/systemd/amdfan.service "$pkgdir@libdir@/systemd/system/" } diff --git a/dist/systemd/amdfan.service.in b/dist/systemd/amdfan.service.in index 9fb87a4..02dbd40 100644 --- a/dist/systemd/amdfan.service.in +++ b/dist/systemd/amdfan.service.in @@ -4,7 +4,7 @@ After=multi-user.target Requires=multi-user.target [Service] -ExecStart=@bindir@/amdfan --daemon +ExecStart=@bindir@/amdfan daemon ExecReload=kill -HUP $MAINPID Restart=always diff --git a/pyproject.toml b/pyproject.toml index d1b0e1b..44105d6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "amdfan" -version = "0.2.0" +version = "0.2.1" description = "Fan monitor and controller for AMD gpus in Linux" authors = ["mcgillij "] license = "GPL-2.0-only" @@ -9,6 +9,7 @@ homepage = "https://mcgillij.dev/pages/amdfan.html" repository = "https://github.com/mcgillij/amdfan" documentation = "https://mcgillij.dev/pages/amdfan.html" keywords = ["fan", "gpu", "temp", "monitor", "amd"] +include = ["dist/systemd/amdfan.service"] classifiers = [ "Environment :: Console", "Environment :: GPU", @@ -29,7 +30,6 @@ pyyaml = "^6.0" click = "^8.1.3" rich = "^13.0.0" - [tool.poetry.group.dev.dependencies] pylint = "*" flake8 = "*"