commit 49a28ef28816a9a4b4319a52549a8042eb345baa Author: crt0mega Date: Mon May 24 00:21:33 2021 +0200 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d0a06c5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ +debian/debhelper* +debian/.debhelper +debian/*.log +debian/*.debhelper +debian/*.substvars +debian/debhelper-build-stamp +debian/asus-wmi-sensors-dkms +debian/asus-wmi-sensors-dkms* +debian/files +.pc +debian/*.ex +debian/*.EX \ No newline at end of file diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..ec5c298 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "src"] + path = src + url = https://gitlab.com/torkel104/libstrangle.git diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..1edf581 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +libstrangle (0.1.1-1) unstable; urgency=medium + + * Initial release + + -- crt0mega Sun, 23 May 2021 20:38:41 +0200 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..90bf8a6 --- /dev/null +++ b/debian/control @@ -0,0 +1,17 @@ +Source: libstrangle +Section: misc +Priority: optional +Maintainer: crt0mega +Build-Depends: debhelper-compat (= 13) +Standards-Version: 4.5.1 +Homepage: https://gitlab.com/torkel104/libstrangle +#Vcs-Browser: https://salsa.debian.org/debian/libstrangle +#Vcs-Git: https://salsa.debian.org/debian/libstrangle.git +Rules-Requires-Root: no + +Package: libstrangle +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Frame rate limiter for Linux. + Cap the FPS (frames per second) of a chosen game by using the included script strangle. + diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..dd51b27 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,39 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: libstrangle +Upstream-Contact: +Source: + +Files: * +Copyright: + +License: GPL-3.0+ + +Files: debian/* +Copyright: 2021 crt0mega +License: GPL-3.0+ + +License: GPL-3.0+ + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + . + This package is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + . + You should have received a copy of the GNU General Public License + along with this program. If not, see . + . + On Debian systems, the complete text of the GNU General + Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". + +# Please also look if there are files or directories which have a +# different copyright/license attached and list them here. +# Please avoid picking licenses with terms that are more restrictive than the +# packaged work, as it may make Debian's contributions unacceptable upstream. +# +# If you need, there are some extra license texts available in two places: +# /usr/share/debhelper/dh_make/licenses/ +# /usr/share/common-licenses/ diff --git a/debian/libstrangle-docs.docs b/debian/libstrangle-docs.docs new file mode 100644 index 0000000..efea0a6 --- /dev/null +++ b/debian/libstrangle-docs.docs @@ -0,0 +1,2 @@ +README.Debian +README.source diff --git a/debian/libstrangle/DEBIAN/conffiles b/debian/libstrangle/DEBIAN/conffiles new file mode 100644 index 0000000..cf67a06 --- /dev/null +++ b/debian/libstrangle/DEBIAN/conffiles @@ -0,0 +1 @@ +/etc/ld.so.conf.d/libstrangle.conf diff --git a/debian/libstrangle/DEBIAN/control b/debian/libstrangle/DEBIAN/control new file mode 100644 index 0000000..62ceda7 --- /dev/null +++ b/debian/libstrangle/DEBIAN/control @@ -0,0 +1,11 @@ +Package: libstrangle +Version: 0.1.1-1 +Architecture: amd64 +Maintainer: crt0mega +Installed-Size: 443 +Depends: libc6 (>> 2.31), libc6 (<< 2.32), libgcc-s1 (>= 4.2), libstdc++6 (>= 5) +Section: misc +Priority: optional +Homepage: https://gitlab.com/torkel104/libstrangle +Description: Frame rate limiter for Linux. + Cap the FPS (frames per second) of a chosen game by using the included script strangle. diff --git a/debian/libstrangle/DEBIAN/md5sums b/debian/libstrangle/DEBIAN/md5sums new file mode 100644 index 0000000..eae6a4c --- /dev/null +++ b/debian/libstrangle/DEBIAN/md5sums @@ -0,0 +1,11 @@ +35dbf6d202f84a15f8d000d7c623c62d usr/bin/strangle +39b053e5bd7cec95da60c75c688f862a usr/bin/stranglevk +abe5912ec1cb73983d325ee42b094650 usr/lib/libstrangle/lib32/libstrangle.so +c434950b4af80cd75efb2f4474e669a6 usr/lib/libstrangle/lib32/libstrangle_nodlsym.so +f940f90e16de2dc7ac49693754bfcc65 usr/lib/libstrangle/lib32/libstrangle_vk.so +ad4b13369f5eddf52ba8913e62dab6da usr/lib/libstrangle/lib64/libstrangle.so +ff49a204ba0497ef0a46f3ad66b97ed5 usr/lib/libstrangle/lib64/libstrangle_nodlsym.so +695049abfd0e2effb37230abab4fd67c usr/lib/libstrangle/lib64/libstrangle_vk.so +dc1b2e6fc57a67b68b5ae17bc1e37c31 usr/share/doc/libstrangle/changelog.Debian.gz +1080fc22867256e9238f95e7e82e534c usr/share/doc/libstrangle/copyright +f11c08ce53d1732355707d4cb07cd773 usr/share/vulkan/implicit_layer.d/libstrangle_vk.json diff --git a/debian/libstrangle/DEBIAN/postinst b/debian/libstrangle/DEBIAN/postinst new file mode 100755 index 0000000..4d56109 --- /dev/null +++ b/debian/libstrangle/DEBIAN/postinst @@ -0,0 +1,43 @@ +#!/bin/sh +# postinst script for libstrangle +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `configure' +# * `abort-upgrade' +# * `abort-remove' `in-favour' +# +# * `abort-remove' +# * `abort-deconfigure' `in-favour' +# `removing' +# +# for details, see https://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + configure) + ;; + + triggered) + ldconfig + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + + + +exit 0 diff --git a/debian/libstrangle/DEBIAN/triggers b/debian/libstrangle/DEBIAN/triggers new file mode 100644 index 0000000..dd86603 --- /dev/null +++ b/debian/libstrangle/DEBIAN/triggers @@ -0,0 +1 @@ +activate-noawait ldconfig diff --git a/debian/libstrangle/etc/ld.so.conf.d/libstrangle.conf b/debian/libstrangle/etc/ld.so.conf.d/libstrangle.conf new file mode 100644 index 0000000..b01988a --- /dev/null +++ b/debian/libstrangle/etc/ld.so.conf.d/libstrangle.conf @@ -0,0 +1,2 @@ +/usr/lib/libstrangle/lib32/ +/usr/lib/libstrangle/lib64/ diff --git a/debian/libstrangle/usr/bin/strangle b/debian/libstrangle/usr/bin/strangle new file mode 100755 index 0000000..a200ea7 --- /dev/null +++ b/debian/libstrangle/usr/bin/strangle @@ -0,0 +1,135 @@ +#!/bin/sh + +programName=$(basename "$0") +STRANGLE_LIB_NAME="libstrangle.so" +STRANGLE_LIB_NAME_NO_DLSYM="libstrangle_nodlsym.so" + +print_usage_info() { + echo "Usage: ${programName} [OPTION]... [FPS] PROGRAM" + echo " or: ${programName} [OPTION]... [FPS]:[BATTERY_FPS] PROGRAM" + echo "Limit the framerate of PROGRAM to FPS" + echo + echo "Mandatory arguments to long options are mandatory for short options too." + echo " -a, --aniso AF sets the anisotropic filtering level. Makes textures" + echo " sharper at an angle. Limited OpenGL support" + echo " -b, --battery-fps FPS alternative framerate cap for when running on" + echo " battery power. See --fps" + echo " -f, --fps FPS limit the framerate to FPS." + echo " A value of 0 will disable the limiter." + echo " -k, --vulkan-only prevent the OpenGL libs from loading" + echo " -n, --no-dlsym disable dlsym hijacking in the OpenGL library" + echo " -p, --picmip PICMIP set the mipmap LoD bias to PICMIP. A higher value" + echo " means blurrier textures. Can be negative" + echo " -t, --trilinear force trilinear filtering. Vulkan only" + echo " -v, --vsync VSYNC Force vertical synchronisation on or off." + echo " For OpenGL the following rules apply:" + echo " 0 - Force off" + echo " 1 - Force on" + echo " n - Sync to refresh rate / n" + echo " For Vulkan the following rules apply:" + echo " 0 - Force off" + echo " 1 - Mailbox mode. Uncapped framerate" + echo " 2 - Traditional vsync. Capped framerate" + echo " 3 - Adaptive vsync. tearing at low framerates" + echo + echo "Short options may not be combined into one string." + echo "Options will override environment variables." + echo + echo "Some programs will crash, freeze or behave unexpectedly when dlsym is hijacked" + echo "If a program is exhibiting these symptoms when run with strangle try using the" + echo "'--no-dlsym' option. Or if the program uses the Vulkan API you can disable" + echo "strangle's OpenGL libs altogether with the '--vulkan-only' option." + echo + echo "Strangle home page: " +} + +while [ $# -gt 0 ]; do + if echo $1 | grep -Pq '^\d+(\.\d+)?$'; then + export STRANGLE_FPS="$1" + shift + elif echo $1 | grep -Pq '^\d+(\.\d+)?:\d+(\.\d+)?$'; then + export STRANGLE_FPS="$(echo $1 | cut -d':' -f1)" + export STRANGLE_FPS_BATTERY="$(echo $1 | cut -d':' -f2)" + shift + else + case "$1" in + -a|--aniso) + export STRANGLE_AF="$2" + shift + shift + ;; + -b|--battery-fps) + export STRANGLE_FPS_BATTERY="$2" + shift + shift + ;; + -f|--fps) + export STRANGLE_FPS="$2" + shift + shift + ;; + -h|--help) + print_usage_info + exit 0 + ;; + -k|--vulkan-only) + STRANGLE_VKONLY="1" + shift + ;; + -n|--no-dlsym) + STRANGLE_NODLSYM="1" + shift + ;; + -p|--picmip) + export STRANGLE_PICMIP="$2" + shift + shift + ;; + -t|--trilinear) + STRANGLE_TRILINEAR="1" + shift + ;; + -v|--vsync) + export STRANGLE_VSYNC="$2" + shift + shift + ;; + --) + shift + break 2 + ;; + *) + break 2 + ;; + esac + fi +done + +if [ "$#" -eq 0 ]; then + echo "${programName}: no program supplied" + echo "Try '${programName} --help' for more information" + exit 1 +fi + +if [ -n "$STRANGLE_AF" ]; then + # AMD + export AMD_TEX_ANISO="$STRANGLE_AF" + export R600_TEX_ANISO="$STRANGLE_AF" + export RADV_TEX_ANISO="$STRANGLE_AF" + + # Nvidia + # http://us.download.nvidia.com/XFree86/Linux-x86_64/440.64/README/openglenvvariables.html + export __GL_LOG_MAX_ANISO=$(echo $STRANGLE_AF | awk '{printf "%d", log($1)/log(2)}') +fi + +if [ "$STRANGLE_VKONLY" != "1" ]; then + if [ "$STRANGLE_NODLSYM" = "1" ]; then + LD_PRELOAD="${LD_PRELOAD}:${STRANGLE_LIB_NAME_NO_DLSYM}" + else + LD_PRELOAD="${LD_PRELOAD}:${STRANGLE_LIB_NAME}" + fi +fi + +# Execute the strangled program under a clean environment +# pass through the FPS and overriden LD_PRELOAD environment variables +exec env ENABLE_VK_LAYER_TORKEL104_libstrangle=1 LD_PRELOAD="${LD_PRELOAD}" "$@" diff --git a/debian/libstrangle/usr/bin/stranglevk b/debian/libstrangle/usr/bin/stranglevk new file mode 100755 index 0000000..265b1b6 --- /dev/null +++ b/debian/libstrangle/usr/bin/stranglevk @@ -0,0 +1,3 @@ +#!/bin/sh + +ENABLE_VK_LAYER_TORKEL104_libstrangle=1 STRANGLE_VKONLY=1 strangle "$@" diff --git a/debian/libstrangle/usr/lib/libstrangle/lib32/libstrangle.so b/debian/libstrangle/usr/lib/libstrangle/lib32/libstrangle.so new file mode 100644 index 0000000..8094022 Binary files /dev/null and b/debian/libstrangle/usr/lib/libstrangle/lib32/libstrangle.so differ diff --git a/debian/libstrangle/usr/lib/libstrangle/lib32/libstrangle_nodlsym.so b/debian/libstrangle/usr/lib/libstrangle/lib32/libstrangle_nodlsym.so new file mode 100644 index 0000000..05dd3ba Binary files /dev/null and b/debian/libstrangle/usr/lib/libstrangle/lib32/libstrangle_nodlsym.so differ diff --git a/debian/libstrangle/usr/lib/libstrangle/lib32/libstrangle_vk.so b/debian/libstrangle/usr/lib/libstrangle/lib32/libstrangle_vk.so new file mode 100644 index 0000000..9215c8c Binary files /dev/null and b/debian/libstrangle/usr/lib/libstrangle/lib32/libstrangle_vk.so differ diff --git a/debian/libstrangle/usr/lib/libstrangle/lib64/libstrangle.so b/debian/libstrangle/usr/lib/libstrangle/lib64/libstrangle.so new file mode 100644 index 0000000..0c262e2 Binary files /dev/null and b/debian/libstrangle/usr/lib/libstrangle/lib64/libstrangle.so differ diff --git a/debian/libstrangle/usr/lib/libstrangle/lib64/libstrangle_nodlsym.so b/debian/libstrangle/usr/lib/libstrangle/lib64/libstrangle_nodlsym.so new file mode 100644 index 0000000..1cdd553 Binary files /dev/null and b/debian/libstrangle/usr/lib/libstrangle/lib64/libstrangle_nodlsym.so differ diff --git a/debian/libstrangle/usr/lib/libstrangle/lib64/libstrangle_vk.so b/debian/libstrangle/usr/lib/libstrangle/lib64/libstrangle_vk.so new file mode 100644 index 0000000..8d5789d Binary files /dev/null and b/debian/libstrangle/usr/lib/libstrangle/lib64/libstrangle_vk.so differ diff --git a/debian/libstrangle/usr/share/doc/libstrangle/changelog.Debian.gz b/debian/libstrangle/usr/share/doc/libstrangle/changelog.Debian.gz new file mode 100644 index 0000000..da90476 Binary files /dev/null and b/debian/libstrangle/usr/share/doc/libstrangle/changelog.Debian.gz differ diff --git a/debian/libstrangle/usr/share/doc/libstrangle/copyright b/debian/libstrangle/usr/share/doc/libstrangle/copyright new file mode 100644 index 0000000..dd51b27 --- /dev/null +++ b/debian/libstrangle/usr/share/doc/libstrangle/copyright @@ -0,0 +1,39 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: libstrangle +Upstream-Contact: +Source: + +Files: * +Copyright: + +License: GPL-3.0+ + +Files: debian/* +Copyright: 2021 crt0mega +License: GPL-3.0+ + +License: GPL-3.0+ + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + . + This package is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + . + You should have received a copy of the GNU General Public License + along with this program. If not, see . + . + On Debian systems, the complete text of the GNU General + Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". + +# Please also look if there are files or directories which have a +# different copyright/license attached and list them here. +# Please avoid picking licenses with terms that are more restrictive than the +# packaged work, as it may make Debian's contributions unacceptable upstream. +# +# If you need, there are some extra license texts available in two places: +# /usr/share/debhelper/dh_make/licenses/ +# /usr/share/common-licenses/ diff --git a/debian/libstrangle/usr/share/vulkan/implicit_layer.d/libstrangle_vk.json b/debian/libstrangle/usr/share/vulkan/implicit_layer.d/libstrangle_vk.json new file mode 100644 index 0000000..f7366ac --- /dev/null +++ b/debian/libstrangle/usr/share/vulkan/implicit_layer.d/libstrangle_vk.json @@ -0,0 +1,17 @@ +{ + "file_format_version" : "1.0.0", + "layer" : { + "name": "VK_LAYER_TORKEL104_libstrangle", + "type": "GLOBAL", + "api_version": "1.1.125", + "library_path": "libstrangle_vk.so", + "implementation_version": "1", + "description": "Libstrangle framerate limiter", + "enable_environment": { + "ENABLE_VK_LAYER_TORKEL104_libstrangle": "1" + }, + "disable_environment": { + "DISABLE_VK_LAYER_TORKEL104_libstrangle": "1" + } + } +} diff --git a/debian/patches/01_fix_makefile b/debian/patches/01_fix_makefile new file mode 100644 index 0000000..af4b380 --- /dev/null +++ b/debian/patches/01_fix_makefile @@ -0,0 +1,21 @@ +Fixes makefile by removing ldconfig and correcting installation prefix to /usr +--- a/src/makefile ++++ b/src/makefile +@@ -4,7 +4,7 @@ + LDFLAGS=-Wl,-z,relro,-z,now + LDLIBS=-ldl -lrt + +-prefix=/usr/local ++prefix=/usr + exec_prefix=$(prefix) + bindir=$(exec_prefix)/bin + libdir=$(exec_prefix)/lib +@@ -88,7 +88,7 @@ + + install-ld: ld + install -m 0644 -D -T $(BUILDDIR)/libstrangle.conf $(DESTDIR)/etc/ld.so.conf.d/libstrangle.conf +- ldconfig ++# ldconfig + + install-32: 32-bit + install -m 0755 -D -T $(BUILDDIR)/libstrangle32.so $(DESTDIR)$(LIB32_PATH)/libstrangle.so diff --git a/debian/patches/series b/debian/patches/series new file mode 100644 index 0000000..5be8640 --- /dev/null +++ b/debian/patches/series @@ -0,0 +1 @@ +01_fix_makefile diff --git a/debian/postinst b/debian/postinst new file mode 100644 index 0000000..af4d696 --- /dev/null +++ b/debian/postinst @@ -0,0 +1,43 @@ +#!/bin/sh +# postinst script for libstrangle +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `configure' +# * `abort-upgrade' +# * `abort-remove' `in-favour' +# +# * `abort-remove' +# * `abort-deconfigure' `in-favour' +# `removing' +# +# for details, see https://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + configure) + ;; + + triggered) + ldconfig + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..19078ec --- /dev/null +++ b/debian/rules @@ -0,0 +1,25 @@ +#!/usr/bin/make -f +# See debhelper(7) (uncomment to enable) +# output every command that modifies files on the build system. +#export DH_VERBOSE = 1 + + +# see FEATURE AREAS in dpkg-buildflags(1) +#export DEB_BUILD_MAINT_OPTIONS = hardening=+all + +# see ENVIRONMENT in dpkg-buildflags(1) +# package maintainers to append CFLAGS +#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic +# package maintainers to append LDFLAGS +#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed + + +%: + dh $@ -Dsrc + + +# dh_make generated override targets +# This is example for Cmake (See https://bugs.debian.org/641051 ) +#override_dh_auto_configure: +# dh_auto_configure -- \ +# -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH) diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..163aaf8 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/debian/triggers b/debian/triggers new file mode 100644 index 0000000..dd86603 --- /dev/null +++ b/debian/triggers @@ -0,0 +1 @@ +activate-noawait ldconfig diff --git a/src b/src new file mode 160000 index 0000000..36122df --- /dev/null +++ b/src @@ -0,0 +1 @@ +Subproject commit 36122dfa7e4faf0eaf70629b8305dd97b61b0ba5