Skip to content

Instantly share code, notes, and snippets.

@icedream
Last active June 3, 2024 11:52
Show Gist options
  • Save icedream/ee7780b87706f2693c75a116759f0fbb to your computer and use it in GitHub Desktop.
Save icedream/ee7780b87706f2693c75a116759f0fbb to your computer and use it in GitHub Desktop.
PowerTOP 2.14 Ryzen patches for Debian 12

Ryzen patches for PowerTOP on Debian 12

Quick and dirty Dockerfile that will build a patched binary and source package for PowerTOP on Debian 12. They still ship 2.14 on this Debian version which does not include the necessary fixes.

You only need Docker and this command:

docker run --rm --output type=local,dest=output/ https://gist.github.com/icedream/ee7780b87706f2693c75a116759f0fbb/raw/Dockerfile

This will automatically fetch the Dockerfile, run it, and output the files to a output/ subdirectory. You can install the packages from there with dpkg -i <path-to-deb>.

image

If you are on Debian 13 or newer, the fixes are already included with the updated 2.15 they ship, so you won't need this.

# Dockerfile to build a patched powertop package for Debian 12 with the AMD
# Ryzen fixes.
#
# Debian 12 does not have these patches yet, however Debian 13 will include
# PowerTOP 2.15 which contains these changes already.
#
# Run this directly with this command, you don't need anything else than
# Docker:
#
# docker run --rm --output type=local,dest=output/ https://gist.github.com/icedream/ee7780b87706f2693c75a116759f0fbb/raw/Dockerfile
#
# This will give you an output/ directory with source and binary packages
# for a version suffixed +icedream.1 containing the patches.
#
# Author: Carl Kittelberger <icedream@icedream.pw>
FROM debian:12
# TODO - deal with sources.list* files, not just *.sources
RUN find /etc/apt -name '*.sources' -exec sed -i 's,Types: deb$,Types: deb deb-src,g' {} \;
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update
RUN apt-get install -y --no-install-recommends dpkg-dev devscripts build-essential
WORKDIR /usr/src/
ARG PKG=powertop
# install dependencies
RUN apt-get build-dep -y $PKG
# download source code and unpack, removing archives
RUN apt-get source $PKG
# apply patches
ARG MODIFIER=icedream
ARG DEBEMAIL=icedream@icedream.pw
ARG DEBFULLNAME="Carl Kittelberger"
ARG EMAIL=icedream@icedream.pw
ADD https://github.com/fenrus75/powertop/commit/798eb463d419941fa014ada1f863d769650351c7.patch /var/tmp/0001-Patch-compatibility-for-Ryzen-processors.patch
ADD https://github.com/fenrus75/powertop/commit/5b5212d7d6e8e00925a18dc92adf0ee95249143a.patch /var/tmp/0002-Patch-for-compatibility-with-Ryzen-processors-v2.patch
RUN cd powertop-*/ && for patch in /var/tmp/*.patch; do patch -p1 -i "$patch" && rm "$patch"; done
RUN cd powertop-*/ && debchange -l "+$MODIFIER." "Fix incompatibility with Ryzen processors" </dev/null
RUN cd powertop-*/ && EDITOR=/bin/true dpkg-source -q --commit . "1000-Fix-incompatibility-with-Ryzen-processors.patch"
# compile patched package
RUN cd powertop-*/ && dpkg-buildpackage -us -uc -F </dev/null
# clean up source code tree
RUN rm -rf powertop-*/
###
# Copy build output to its own files only layer
FROM scratch
ARG MODIFIER=icedream
COPY --from=0 /usr/src/*+$MODIFIER.* /
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment