diff options
Diffstat (limited to 'system/system76-power/system76-power.SlackBuild')
-rw-r--r-- | system/system76-power/system76-power.SlackBuild | 162 |
1 files changed, 75 insertions, 87 deletions
diff --git a/system/system76-power/system76-power.SlackBuild b/system/system76-power/system76-power.SlackBuild index ad711aac15..ba3303aa2f 100644 --- a/system/system76-power/system76-power.SlackBuild +++ b/system/system76-power/system76-power.SlackBuild @@ -1,8 +1,8 @@ -#!/bin/sh +#!/bin/bash # Slackware build script for system76-power -# Copyright 2019 Erich Ritz, Scottsdale, Arizona, USA +# Copyright 2019-2024 Erich Ritz, Jenks, Oklahoma, USA # All rights reserved. # # Redistribution and use of this script, with or without modification, is @@ -22,10 +22,22 @@ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# 20220210 bkw: Warning from SlackBuilds.org: the download URLs are +# incorrect. They work OK when using a client that doesn't respect the +# Content-disposition header (e.g. wget in its default config), but +# they'll break with clients that do respect it. +# +# 20220301 etr: Fix script to work with Content-disposition-safe download URL. +# Bit hackish, but it works. + +cd $(dirname $0) ; CWD=$(pwd) + PRGNAM=system76-power -VERSION=${VERSION:-1.0.1} -BUILD=${BUILD:-1} +VERSION=${VERSION:-1.1.25_fc8eb49} +SRCVER=${SRCVER:-fc8eb49fae5222da56dcfa414ef2b190e9f870c7} +BUILD=${BUILD:-2} TAG=${TAG:-_SBo} +PKGTYPE=${PKGTYPE:-tgz} if [ -z "$ARCH" ]; then case "$( uname -m )" in @@ -33,15 +45,19 @@ if [ -z "$ARCH" ]; then arm*) ARCH=arm ;; *) ARCH=$( uname -m ) ;; esac +fi - if [ "$ARCH" = "i586" ]; then - if rustc -Vv | grep host | grep i686 > /dev/null ; then - ARCH=i686 - fi - fi +case "$ARCH" in + x86_64) ;; + arm*) ;; + *) echo "Unsupported ARCH '$ARCH'"; exit 1 ;; +esac + +if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then + echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE" + exit 0 fi -CWD=$(pwd) TMP=${TMP:-/tmp/SBo} PKG=$TMP/package-$PRGNAM OUTPUT=${OUTPUT:-/tmp} @@ -65,89 +81,63 @@ set -e rm -rf $PKG mkdir -p $TMP $PKG $OUTPUT cd $TMP -rm -rf $PRGNAM-$VERSION -if [ -e $CWD/$VERSION.tar.gz ]; then - tar xvf $CWD/$VERSION.tar.gz -else - tar xvf $CWD/$PRGNAM-$VERSION.tar.gz -fi -cd $PRGNAM-$VERSION +rm -rf $PRGNAM-$SRCVER +tar xvf $CWD/$PRGNAM-$SRCVER.tar.gz +cd $PRGNAM-$SRCVER # build offline # configuration tells cargo to use the configured directory # for dependencies intead of downloading from crates.io mkdir .cargo -cat << EOF >> .cargo/config +cat << EOF >> .cargo/config.toml +[source] [source.crates-io] replace-with = "vendored-sources" [source."https://github.com/pop-os/sysfs-class"] git = "https://github.com/pop-os/sysfs-class" -branch = "master" replace-with = "vendored-sources" [source.vendored-sources] -directory = "$(pwd)/vendor" +directory = "vendor" EOF -mkdir vendor # deps and versions come from Cargo.lock +mkdir vendor ( cd vendor - for dependency in ansi_term=0.11.0 \ - atty=0.2.11 \ - bitflags=0.7.0 \ - bitflags=1.0.4 \ - cfg-if=0.1.7 \ - clap=2.33.0 \ - dbus=0.6.2 \ - err-derive=0.1.5 \ - fern=0.5.8 \ - intel-pstate=0.2.0 \ - libc=0.2.54 \ - libdbus-sys=0.1.5 \ - log=0.4.6 \ - numtoa=0.1.0 \ - numtoa=0.2.3 \ - pkg-config=0.3.14 \ - proc-macro2=0.4.30 \ - quote=0.6.12 \ - redox_syscall=0.1.54 \ - redox_termios=0.1.1 \ - rustc_version=0.2.3 \ - semver=0.9.0 \ - semver-parser=0.7.0 \ - smart-default=0.5.2 \ - strsim=0.8.0 \ - syn=0.15.34 \ - synstructure=0.10.1 \ - sysfs-class=0.1.1=7bc914e0ac41df18a671ede0691fcd7d1f7e8add \ - termion=1.5.2 \ - textwrap=0.11.0 \ - time=0.1.42 \ - unicode-width=0.1.5 \ - unicode-xid=0.1.0 \ - vec_map=0.8.1 \ - vergen=0.1.1 \ - winapi=0.3.7 \ - winapi-i686-pc-windows-gnu=0.4.0 \ - winapi-x86_64-pc-windows-gnu=0.4.0; do - dep="$(echo "$dependency" | cut -d= -f1)" - ver="$(echo "$dependency" | cut -d= -f2)" - - if [ -e $CWD/$dep-$ver.crate ]; then - CRATE_FILE=$CWD/$dep-$ver.crate + grep -h -A 4 "\[\[package\]\]" \ + $(find "../" -maxdepth 1 -mindepth 1 -name Cargo.lock | tr '\n' ' ') | \ + sed 's/[[:space:]]*=[[:space:]]*/=/g;s/^--//;s/^\[\[/--\n[[/' | \ + awk 'BEGIN { RS = "--\n" ; FS="\n" } { print $2, $3, $4, $5 }' | \ + sed 's/"//g;s/name=//;s/ version=/=/' | \ + grep " source=" | \ + sed 's/ dependencies=.*$//' | \ + sed 's/ source=[^ ]*//' | \ + sed 's/ checksum=/=/' | \ + sort -u | \ + while read -r dep ; do + + cksum="$(printf "%s\n" "$dep" | cut -d= -f3)" + ver="$(printf "%s\n" "$dep" | cut -d= -f2)" + dep="$(printf "%s\n" "$dep" | cut -d= -f1)" + + CRATE_FILE=$CWD/$dep-$ver.crate + + if [ -z "$cksum" ] ; then + if [ "$dep" = "sysfs-class" ] ; then + CRATE_FILE=$CWD/pop-os-sysfs-class-0.1.3-1-gab63e7f.tar.gz + fi + mkdir $dep-$ver + if [ "$dep" = "sysfs-class" ] ; then + CRATE_FILE=$CWD/pop-os-$dep-$ver-1-gab63e7f.tar.gz + fi + tar xvf $CRATE_FILE -C $dep-$ver --strip-components=1 + cksum="null" else - id="$(echo "$dependency" | cut -d= -f3)" - if [ -e $CWD/$id.tar.gz ]; then - CRATE_FILE=$CWD/$id.tar.gz - else - CRATE_FILE=$CWD/sysfs-class-$id.tar.gz - fi - ver=$id + tar xvf $CRATE_FILE fi - tar xvf $CRATE_FILE touch $dep-$ver/.cargo-ok @@ -162,16 +152,10 @@ mkdir vendor ) | sed '$ s/,$//' printf " },\n" - printf ' "package": "' - - sha256sum "$CRATE_FILE" | cut -f1 -d' ' | sed 's/$/"/' + printf ' "package": "%s"' "$cksum" printf "}\n" - } | python -c "import sys, json; data = sys.stdin.read(); print json.dumps(json.loads(data), sort_keys=True, indent=4, separators=(',', ' : '))" > $dep-$ver/.cargo-checksum.json - # Change selected package checksums to null - if [ "$dep" == "sysfs-class" ] ; then - sed -i 's/"package" : ".\{64\}"/"package" : null/' $dep-$ver/.cargo-checksum.json - fi + } | python3 -c "import sys, json; data = sys.stdin.read(); print (json.dumps(json.loads(data), sort_keys=True, indent=4, separators=(',', ' : ')))" > $dep-$ver/.cargo-checksum.json done ) @@ -182,20 +166,24 @@ find -L . \ \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \ -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \; +# Prevent syslog messasge 'Unknown group "sudo" in message bus configuration file'. +patch -p1 < $CWD/fix_groups.patch +# Prevent CPU from overheating +patch -p1 < $CWD/xeon_fan_curve.patch +# Prevent NVMe U.2 SSD from overheating +patch -p1 < $CWD/nvme_temp.patch + +export CARGO_HOME=.cargo + CFLAGS="$SLKCFLAGS" \ CXXFLAGS="$SLKCFLAGS" \ -libdir=/usr/lib${LIBDIRSUFFIX} \ make make install DESTDIR=$PKG -# Remove suid bit on system76-power executable -# Despite being installed SUID by the Makefile, the Debian package installed -# on Pop!_OS has 0755 permissions for this file, so follow that convention. -chmod u-s $PKG/usr/bin/system76-power - find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \ | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true +rm -rf $PKG/usr/lib mkdir -p $PKG/etc/logrotate.d $PKG/etc/rc.d install -m 0644 $CWD/config/system76-power.logrotate $PKG/etc/logrotate.d/system76-power.new install -m 0644 $CWD/config/rc.system76-power $PKG/etc/rc.d/rc.system76-power.new @@ -209,4 +197,4 @@ cat $CWD/slack-desc > $PKG/install/slack-desc cat $CWD/doinst.sh > $PKG/install/doinst.sh cd $PKG -/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz} +/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE |