#!/bin/sh set -x PRGNAM=laptop-mode-tools VERSION=1.55 BUILD=1 PACKAGER=cyco ARCH=$(uname -m) CWD=$(pwd) TMP=/tmp PKG=$TMP/$PACKAGER/pkg-$PRGNAM PREFIX=/usr # Cleaning ( cd $TMP rm -fr $PRGNAM-$VERSION rm -fr $PKG ) # Fetching sources ( cd $TMP [ -e $CWD/${PRGNAM}_$VERSION.tar.?z* ] \ && tar xvf $CWD/${PRGNAM}_$VERSION.tar.?z* \ && mv ${PRGNAM}_$VERSION ${PRGNAM}-$VERSION [ ! -e $PRGNAM-$VERSION ] \ && wget -c http://samwel.tk/laptop_mode/tools/downloads/${PRGNAM}_$VERSION.tar.gz \ && tar xvf ${PRGNAM}_$VERSION.tar.?z* \ && mv ${PRGNAM}_$VERSION ${PRGNAM}-$VERSION ) # Preparation ( cd $TMP/$PRGNAM-$VERSION chown -R root:root . find . \ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ -exec chmod 755 {} \; -o \ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ -exec chmod 644 {} \; ) # Installation mkdir -p $PKG$PREFIX/{bin,lib$LIBSUFFIX/$PRGNAM,man/man1} ( cd $TMP/$PRGNAM-$VERSION make install DESTDIR=$PKG echo "$ARCH" | grep -q "64" && mv $PKG$PREFIX/lib $PKG$PREFIX/lib64 mkdir -p $PKG/etc/rc.d/ mv $PKG/etc/init.d/laptop-mode $PKG/etc/rc.d/rc.laptop-mode.new rm -fr $PKG/etc/init.d/ ) # Cleaning ( cd $PKG find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null find $PKG$PREFIX/man -type f -name "*.?" -exec gzip -9 {} \; chown -R root:root . find . \ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ -exec chmod 755 {} \; -o \ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ -exec chmod 644 {} \; ) # Packaging ( cd $PKG mkdir install cat < install/doinst.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... } config etc/rc.d/rc.laptop-mode.new grep -q "rc\.laptop-mode" /etc/rc.d/rc.local || cat <> /etc/rc.d/rc.local [ -x /etc/rc.d/rc.laptop-mode ] && /etc/rc.d/rc.laptop-mode start EORCLOCAL EOF cat < install/slack-desc $PRGNAM: $PRGNAM (all you need to use laptop mode) $PRGNAM: $PRGNAM: Laptop Mode Tools is a laptop power saving package for Linux systems. It allows $PRGNAM: you to extend the battery life of your laptop, in several ways. It is the $PRGNAM: primary way to enable the Laptop Mode feature of the Linux kernel, which lets $PRGNAM: your hard drive spin down. In addition, it allows you to tweak a number of $PRGNAM: other power-related settings using a simple configuration file. $PRGNAM: $PRGNAM: $PRGNAM: http://samwel.tk/laptop_mode/ $PRGNAM: EOF makepkg -l y -c n $TMP/$PRGNAM-$(echo $VERSION | tr -d '-')-$ARCH-$BUILD$PACKAGER.txz )