Browse Source

ap/laptop-mode-tools: Added.

slackware-14.2
Damien Goutte-Gattat 12 years ago
parent
commit
acce27cec3
5 changed files with 268 additions and 0 deletions
  1. +56
    -0
      ap/laptop-mode-tools/doinst.sh
  2. +112
    -0
      ap/laptop-mode-tools/laptop-mode-tools.SlackBuild
  3. +1
    -0
      ap/laptop-mode-tools/laptop-mode-tools_1.45.tar.gz.sha1
  4. +80
    -0
      ap/laptop-mode-tools/rc.laptop-mode
  5. +19
    -0
      ap/laptop-mode-tools/slack-desc

+ 56
- 0
ap/laptop-mode-tools/doinst.sh View File

@ -0,0 +1,56 @@
#!/bin/sh
config() {
NEW="$1"
OLD="$(dirname $NEW)/$(basename $NEW .new)"
# If there's no config file by that name, mv it over:
if [ ! -r $OLD ]; then
mv $NEW $OLD
elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then # toss the redundant copy
rm $NEW
fi
# Otherwise, we leave the .new copy for the admin to consider...
}
for i in ac97-powersave.conf auto-hibernate.conf bluetooth.conf \
configuration-file-control.conf cpufreq.conf dpms-standby.conf \
ethernet.conf hal-polling.conf intel-sata-powermgmt.conf \
lcd-brightness.conf sched-mc-power-savings.conf \
start-stop-programs.conf terminal-blanking.conf video-out.conf \
wireless-ipw-power.conf wireless-iwl-power.conf ; \
do config etc/laptop-mode/conf.d/$i.new ; \
done
config etc/laptop-mode/laptop-mode.conf.new
config etc/laptop-mode/lm-profiler.conf.new
# We want to run laptop-mode-tools on boot
exist_local=$(grep "/etc/rc.d/rc.laptop-mode" etc/rc.d/rc.local)
if [[ "${exist_local}" == "" ]]; then
cat << EOF >> etc/rc.d/rc.local
# Run laptop-mode-tools:
if [ -x /etc/rc.d/rc.laptop-mode ]; then
/etc/rc.d/rc.laptop-mode start
fi
EOF
fi
# If rc.local_shutdown doesn't exist (like on a stock Slackware 12.1 install), create it
if [ ! -e etc/rc.d/rc.local_shutdown ]; then
echo "#!/bin/sh" > etc/rc.d/rc.local_shutdown
echo "" >> etc/rc.d/rc.local_shutdown
chmod 755 etc/rc.d/rc.local_shutdown
fi
# We want to stop laptop-mode-tools on shutdown
exist_local_shutdown=$(grep "/etc/rc.d/rc.laptop-mode" etc/rc.d/rc.local_shutdown)
if [[ "${exist_local_shutdown}" == "" ]]; then
cat << EOF >> etc/rc.d/rc.local_shutdown
# Stop laptop-mode-tools:
if [ -x /etc/rc.d/rc.laptop-mode ]; then
/etc/rc.d/rc.laptop-mode stop
fi
EOF
fi

+ 112
- 0
ap/laptop-mode-tools/laptop-mode-tools.SlackBuild View File

@ -0,0 +1,112 @@
#!/bin/sh
# Build script for Slackware
# by: Parein Nicolas "_Hitek_" http://www.slackbuilds.net < hitek at slackbuilds dot net >
#
# Copyright: See COPYING file at http://www.slackbuilds.net/COPYING
#
# Latest laptop-mode-tools sourcecode is available at:
# http://samwel.tk/laptop_mode/
## Fill these variables to your needs ##
NAMESRC=${NAMESRC:-laptop-mode-tools}
VERSION=${VERSION:-1.45}
EXT=${EXT:-tar.gz}
NAMETGZ=${NAMETGZ:-laptop-mode-tools}
BUILD=${BUILD:-1_SBn}
TMP=${TMP:-/tmp}
OUT=${OUT:-$TMP/build}
ARCH=${ARCH:-i486}
TARGET=${TARGET:-i486}
WGET=${WGET:-http://samwel.tk/laptop_mode/tools/downloads/${NAMESRC}_${VERSION}.$EXT}
########################################
set -e
if [ ! -r ${NAMESRC}_${VERSION}.$EXT ]; then
rm -f ${NAMESRC}_${VERSION}.$EXT.part
wget -vc $WGET -O ${NAMESRC}_${VERSION}.$EXT.part
mv ${NAMESRC}_${VERSION}.$EXT.part ${NAMESRC}_${VERSION}.$EXT
fi
sha1sum -c ${NAMESRC}_${VERSION}.$EXT.sha1
CWD=$(pwd)
PKG=$TMP/build/$NAMETGZ
NAME=$(tar ft ${NAMESRC}_${VERSION}.$EXT | head -n 1 | awk -F/ '{ print $1 }')
if [ "$(id -u)" = "0" ]; then
echo "You shouldn't run this SlackBuild as ROOT !"
exit 1
fi
if [ ! -d $TMP ]; then
echo "$TMP doesn't exist or is not a directory !"
exit 1
fi
# Build the software
cd $TMP
echo "Building ${NAMESRC}_${VERSION}.$EXT..."
tar xf $CWD/${NAMESRC}_${VERSION}.$EXT
cd $NAME
mkdir -p $PKG/etc
mkdir -p $PKG/etc/rc.d
mkdir -p $PKG/usr/man/man8
cp -R etc/acpi $PKG/etc
#cp -R etc/apm $PKG/etc
cp -R etc/laptop-mode $PKG/etc
cp -R usr $PKG
cp -R man/* $PKG/usr/man/man8
cat $CWD/rc.laptop-mode > $PKG/etc/rc.d/rc.laptop-mode
for i in ac97-powersave.conf auto-hibernate.conf bluetooth.conf \
configuration-file-control.conf cpufreq.conf dpms-standby.conf \
ethernet.conf hal-polling.conf intel-sata-powermgmt.conf \
lcd-brightness.conf sched-mc-power-savings.conf \
start-stop-programs.conf terminal-blanking.conf video-out.conf \
wireless-ipw-power.conf wireless-iwl-power.conf ; \
do mv $PKG/etc/laptop-mode/conf.d/$i $PKG/etc/laptop-mode/conf.d/$i.new ; \
done
mv $PKG/etc/laptop-mode/laptop-mode.conf $PKG/etc/laptop-mode/laptop-mode.conf.new
mv $PKG/etc/laptop-mode/lm-profiler.conf $PKG/etc/laptop-mode/lm-profiler.conf.new
chmod 755 $PKG/etc/acpi/actions/*
chmod 755 $PKG/etc/rc.d/rc.laptop-mode
# Install a slack-desc
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
# Install a doinst.sh, if it exists
if [ -r $CWD/doinst.sh ]; then
cat $CWD/doinst.sh > $PKG/install/doinst.sh
fi
# Install the documentation
mkdir -p $PKG/usr/doc/$NAMETGZ-$VERSION
install -p -m 644 \
Documentation/* COPYING README \
$PKG/usr/doc/$NAMETGZ-$VERSION
# Compress the man pages
if [ -d $PKG/usr/man ]; then
find $PKG/usr/man -type f -name "*.?" -exec gzip -9 {} \;
for manpage in $(find $PKG/usr/man -type l) ; do
ln -s $(readlink $manpage).gz $manpage.gz
rm -f $manpage
done
fi
# Build the package
cd $PKG
mkdir -p $OUT
PACKAGING="
chown root:root . -R
/sbin/makepkg -l y -c n $OUT/$NAMETGZ-$VERSION-$ARCH-$BUILD.tgz
rm -rf $PKG
rm -rf $TMP/$NAME
"
if [ "$(which fakeroot 2> /dev/null)" ]; then
echo "$PACKAGING" | fakeroot
else
su -c "$PACKAGING"
fi

+ 1
- 0
ap/laptop-mode-tools/laptop-mode-tools_1.45.tar.gz.sha1 View File

@ -0,0 +1 @@
776537b8052086163961c2c831eddf9f3cc682ad ./laptop-mode-tools_1.45.tar.gz

+ 80
- 0
ap/laptop-mode-tools/rc.laptop-mode View File

@ -0,0 +1,80 @@
#! /bin/sh
#
# chkconfig: - 90 90
# description: Starts and stops "laptop-mode" - tweaks system behavior
# to extend battery life.
#
# config: /etc/laptop-mode/laptop-mode.conf
test -f /usr/sbin/laptop_mode || exit 0
if [ -f /lib/lsb/init-functions ] ; then
. /lib/lsb/init-functions
else
log_success_msg()
{
logger -t LAPTOP-MODE -p daemon.info -- $*
echo "$*"
}
log_failure_msg()
{
logger -t LAPTOP-MODE -p daemon.notice -- $*
echo "$*"
}
fi
# Enable laptop mode when the system is booted when running on battery.
case $1 in
start)
mkdir -p /var/run/laptop-mode-tools
touch /var/run/laptop-mode-tools/enabled
if RESULT=`/usr/sbin/laptop_mode auto` ; then
log_success_msg "$RESULT"
else
log_failure_msg "$RESULT"
fi
;;
restart|reload|force-reload)
# Full restart: first stop laptop mode completely (to restore default mount options etc.)
mkdir -p /var/run/laptop-mode-tools
rm -f /var/run/laptop-mode-tools/enabled
if RESULT=`/usr/sbin/laptop_mode stop` ; then
log_success_msg "$RESULT"
else
log_failure_msg "$RESULT"
fi
# Now remove files containing stored status, re-enable, and start it up again.
rm -f /var/run/laptop-mode-tools/*
touch /var/run/laptop-mode-tools/enabled
if RESULT=`/usr/sbin/laptop_mode auto force` ; then
log_success_msg "$RESULT"
else
log_failure_msg "$RESULT"
fi
;;
stop)
rm -f /var/run/laptop-mode-tools/enabled
if RESULT=`/usr/sbin/laptop_mode stop` ; then
log_success_msg "$RESULT"
else
log_failure_msg "$RESULT"
fi
;;
status)
echo "Laptop mode status:"
echo
/usr/sbin/laptop_mode status
;;
*)
echo "Usage: $0 {stop|start|restart|reload|force-reload|status}" >&2
exit 2
;;
esac
exit 0

+ 19
- 0
ap/laptop-mode-tools/slack-desc View File

@ -0,0 +1,19 @@
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description. Line
# up the first '|' above the ':' following the base package name, and the '|'
# on the right side marks the last column you can put a character in. You must
# make exactly 11 lines for the formatting to be correct. It's also
# customary to leave one space after the ':'.
|-----handy-ruler------------------------------------------------------|
laptop-mode-tools: laptop-mode-tools (Tools for power savings)
laptop-mode-tools:
laptop-mode-tools: Laptop mode is a Linux kernel feature that allows your laptop to save
laptop-mode-tools: considerable power, by allowing the hard drive to spin down for longer
laptop-mode-tools: periods of time. This package contains the userland scripts that are
laptop-mode-tools: needed to enable laptop mode. It includes support for automatically
laptop-mode-tools: enabling laptop mode when the computer is working on batteries.
laptop-mode-tools:
laptop-mode-tools:
laptop-mode-tools:
laptop-mode-tools:

Loading…
Cancel
Save