Skip to content

Commit

Permalink
acpitool: rebuilt. Added a patch
Browse files Browse the repository at this point in the history
  • Loading branch information
conraid committed May 7, 2016
1 parent 320ba70 commit e18e647
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 103 deletions.
4 changes: 1 addition & 3 deletions acpitool/README
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

Slackware Current Repository by Conraid
Slackware Current Repository by Conraid

======================================================================

Expand All @@ -11,8 +11,6 @@ Even though APM works fine on a lot of laptops, it is deprecated and
will be replaced by ACPI. Most newer laptops even require ACPI to
boot properly. As such, it will be nice to have an ACPI client.



HOME: http://sourceforge.net/projects/acpitool

======================================================================
165 changes: 66 additions & 99 deletions acpitool/acpitool.SlackBuild
Original file line number Diff line number Diff line change
@@ -1,96 +1,81 @@
#!/bin/sh
# Slackware build script for acpitool
#
# Copyright 2008-2015 Corrado Franco (http://conraid.net)
# Copyright 2008-2016 Corrado Franco (http://conraid.net)
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# Exit on most errors
set -e

# Set variables:
# 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 2 of the License, or
# (at your option) any later version, with the following exception:
# the text of the GPL license may be omitted.

# This program 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. Compiling,
# interpreting, executing or merely reading the text of the program
# may result in lapses of consciousness and/or very being, up to and
# including the end of all existence and the Universe as we know it.
# See the GNU General Public License for more details.

# You may have received a copy of the GNU General Public License along
# with this program (most likely, a file named COPYING). If not, see
# <http://www.gnu.org/licenses/>.

set -eu

CWD=$(pwd)

PRGNAME=${PRGNAME:-acpitool}
PKGNAME=${PKGNAME:-$PRGNAME}
VERSION=${VERSION:-0.5.1}
BUILD=${BUILD:-3}
PKGNAM=acpitool
VERSION=0.5.1
BUILD=${BUILD:-4}
TAG=${TAG:-cf}
TMP=${TMP:-/tmp/pkg}
PKG=$TMP/package-$PKGNAME
DOCS="$PKG/usr/doc/$PKGNAME-$VERSION"
PKG=$TMP/package-$PKGNAM
OUTPUT=${OUTPUT:-/tmp}

# Insert document files in this variable
DOCFILES="AUTHORS COPYING ChangeLog INSTALL NEWS README TODO"

# Automatically determine the architecture we're building on:
if [ -z "$ARCH" ]; then
case "$( uname -m )" in
i?86) ARCH=i686 ;;
arm*) ARCH=arm ;;
# Unless $ARCH is already set, use uname -m for all other archs:
*) ARCH=$( uname -m ) ;;
esac
if [ -z ${ARCH:=""} ]; then
case "$( uname -m )" in
i?86) ARCH=i686 ;;
arm*) ARCH=arm ;;
*) ARCH=$( uname -m ) ;;
esac
fi

if [ "$ARCH" = "i586" ]; then
SLKCFLAGS="-O2 -march=i586 -mtune=i686"
LIBDIRSUFFIX=""
elif [ "$ARCH" = "i686" ]; then
SLKCFLAGS="-O2 -march=i686 -mtune=i686"
LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" ]; then
SLKCFLAGS="-O2 -fPIC -pipe -fomit-frame-pointer"
LIBDIRSUFFIX="64"
else
SLKCFLAGS="-O2"
LIBDIRSUFFIX=""
fi

# Set compiling FLAGS
case "$ARCH" in
i486)
SLKCFLAGS="-O2 -march=i486 -mtune=i686"; CHOST="i486"
SLKLDFLAGS=""; LIBDIRSUFFIX=""
;;
i686)
SLKCFLAGS="-O2 -march=i686 -pipe -fomit-frame-pointer"; CHOST="i486"
SLKLDFLAGS=""; LIBDIRSUFFIX=""
;;
x86_64)
SLKCFLAGS="-O2 -fPIC -pipe -fomit-frame-pointer"; CHOST="x86_64"
SLKLDFLAGS="-L/lib64 -L/usr/lib64"; LIBDIRSUFFIX="64"
;;
*)
SLKCFLAGS="-O2"; CHOST=$ARCH
SLKLDFLAGS=""; LIBDIRSUFFIX=""
;;
esac

# Extract source and prepare:
rm -rf $PKG
mkdir -p $TMP $PKG
cd $TMP
rm -rf $PRGNAME-$VERSION
tar xvf $CWD/$PRGNAME-$VERSION.tar.bz2
cd $PRGNAME-$VERSION

# Add the string.h include in toshiba.cpp and freq.cpp
# From SBo
patch -p1 < $CWD/acpitool-0.5-add_string.h.patch
rm -rf $PKGNAM-$VERSION
tar xvf $CWD/$PKGNAM-$VERSION.tar.bz2
cd $PKGNAM-$VERSION

# From archlinux
patch -p1 < $CWD/linux-3.0.patch
patch -p1 < $CWD/sysfs-battery.patch

# Make sure ownerships and permissions are sane:
chown -R root:root .
chmod -R u+w,go+r-w,a-s .

# Configure
LDFLAGS="$SLKLDFLAGS" \
# Apply patches from SBo and Archlinux
if [ -e $CWD/patches ]; then
for PATCH in $CWD/patches/*.patch; do
patch -p1 -i $PATCH
done
fi

LDFLAGS="-L/usr/lib${LIBDIRSUFFIX}" \
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
./configure \
Expand All @@ -100,42 +85,24 @@ CXXFLAGS="$SLKCFLAGS" \
--localstatedir=/var \
--mandir=/usr/man \
--infodir=/usr/info \
--docdir=/usr/doc/${PKGNAME}-${VERSION} \
--host=$CHOST-slackware-linux \
--build=$CHOST-slackware-linux
--docdir=/usr/doc/$PKGNAM-$VERSION \
--host=$ARCH-slackware-linux \
--build=$ARCH-slackware-linux

# Build and install:
make
make DESTDIR=$PKG install-strip

# Compress and link manpages, if any:
if [ -d $PKG/usr/man ]; then
( cd $PKG/usr/man
find . -type f -exec gzip -9 {} \;
for i in $( find . -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
)
find $PKG/usr/man -type f -exec chmod 644 {} \; -exec gzip -9 {} \;
for i in $( find $PKG/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
fi

# Add a documentation directory:
mkdir -p ${DOCS}
for i in ${DOCFILES}; do
if [ -e ${i} ]; then
if ! [ -L ${i} ]; then
cp -a ${i} ${DOCS}
else
cp -LRp ${i} ${DOCS}
fi
fi;
done


# Add a slackbuild script:
cat $CWD/$PKGNAME.SlackBuild > $DOCS/$PKGNAME.SlackBuild
mkdir -p $PKG/usr/doc/$PKGNAM-$VERSION
cp -a $DOCFILES $PKG/usr/doc/$PKGNAM-$VERSION || true
cat $CWD/$PKGNAM.SlackBuild > $PKG/usr/doc/$PKGNAM-$VERSION/$PKGNAM.SlackBuild

# Add slack-desc
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc

# Create package:
cd $PKG
/sbin/makepkg -l y -c n $CWD/$PKGNAME-$VERSION-$ARCH-${BUILD}${TAG}.txz
/sbin/makepkg -l y -c n $OUTPUT/$PKGNAM-$VERSION-$ARCH-$BUILD${TAG}.txz
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
From 3a87a4132667f78fc85c54ad89992bbdd02d1e55 Mon Sep 17 00:00:00 2001
From: Carlos Alberto Lopez Perez <clopez@igalia.com>
Date: Thu, 6 Oct 2011 03:12:55 +0200
Subject: [PATCH] Use dynamic structures instead of predefined ones

* The file /proc/acpi/wakeup can have much more than 25 entries.
In my computer (Dell E6420) I have 27 entries.
So instead of using an array of [x] entries better use dynamic
vectors and push the new entries when a new line from the file
is read.

* The name of the device is not ever 4 characters. For example I
have a device called "LID" which is 3 characters long.
Instead of using a fixed size for the device we split the line
on the first tab (\t) and use the first part.
---
src/acpitool.cpp | 23 +++++++++++------------
1 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/src/acpitool.cpp b/src/acpitool.cpp
index 2a610a5..71e01d7 100644
--- a/src/acpitool.cpp
+++ b/src/acpitool.cpp
@@ -460,16 +460,14 @@ int Show_WakeUp_Devices(int verbose)

int Toggle_WakeUp_Device(const int Device, int verbose)
{
- ifstream file_in;
ofstream file_out;
- char *filename, str[50];
- int index = 1;
- char Name[25][5]; // 25 should be enough I guess, I have only 9 so far //
-
+ char *filename; string str;
+ int index = 1; int charindex = 0;
+ std::vector <std::string> Name(index); // Never is enough, use dynamic structures //
filename = "/proc/acpi/wakeup";

- file_in.open(filename);
- if (!file_in)
+ ifstream file_in(filename, ifstream::in);
+ if (!file_in.good()) // if opening is not successful
{
if(!verbose)
{
@@ -484,14 +482,15 @@ int Toggle_WakeUp_Device(const int Device, int verbose)
}
}

- file_in.getline(str, 50); // first line are just headers //
+ getline(file_in, str); // first line are just headers //
while(!file_in.eof()) // count all devices and store their names//
{
- file_in.getline(str, 50);
- if(strlen(str)!=0) // avoid empty last line //
+ getline(file_in, str);
+ if( str.length() != 0 ) // avoid empty last line //
{
- memset(Name[index], '\0', 5);
- strncpy(Name[index], str, 4);
+ charindex = 0; // reset to zero
+ while ( (str[++charindex]!='\t') ); // stop on first tab and get the array index
+ Name.push_back(str.substr(0,charindex)); // Push the name into the vector
index++;
}
}
--
1.7.5.4


File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion acpitool/slack-desc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ acpitool: Even though APM works fine on a lot of laptops, it is deprecated and
acpitool: will be replaced by ACPI. Most newer laptops even require ACPI to
acpitool: boot properly. As such, it will be nice to have an ACPI client.
acpitool:
acpitool: Home: http://freeunix.dyndns.org:8000/site2/acpitool.shtml
acpitool:
acpitool:
acpitool:

0 comments on commit e18e647

Please sign in to comment.