#! /bin/sh # script written by Thomas Monjalon # Heavily based on the Slackware 12.1 SlackBuild NAME=beep URL=http://www.johnath.com/$NAME VERSION=${VERSION:-1.2.2} REQUIRED='' SUGGESTS='' CONFLICTS='' SRC_TAR=$NAME-$VERSION.tar.gz SRC_URL=$URL/$SRC_TAR ARCH=${ARCH:-i486} BUILD=${BUILD:-1} TAG=${TAG:-_tmonjalo} CWD=$(pwd) TMP=${TMP:-/tmp/$NAME} PKG=$TMP/package-$NAME-$VERSION PKG_TAR=$NAME-$VERSION-$ARCH-$BUILD$TAG.tgz OUT=${OUT:-$CWD} PREFIX_DIR=/usr CONF_DIR=/etc STATE_DIR=/var BIN_DIR=$PREFIX_DIR/bin SBIN_DIR=$PREFIX_DIR/sbin MAN_DIR=$PREFIX_DIR/man INFO_DIR=$PREFIX_DIR/info DOC_DIR=$PREFIX_DIR/doc/$NAME-$VERSION # See the manpage for more information on why, but you will need to install # beep with the suid bit set in order to have full functionality in all # instances. The default is NO, but it *should* be safe to change it to YES SET_SUID=NO set -e # get source if [ ! -r $CWD/$SRC_TAR ] ; then wget -P $CWD $SRC_URL fi mkdir -p $TMP SRC=$TMP/$(tar tf $CWD/$SRC_TAR | head -n1 | sed 's:/*$::') rm -rf $SRC tar x -C $TMP -f $CWD/$SRC_TAR # NO configure step for beep # build make -C $SRC # install rm -rf $PKG mkdir -p $PKG$BIN_DIR if [ "$SET_SUID" = "YES" ]; then install -m 4755 $SRC/beep $PKG$BIN_DIR else install -m 0755 $SRC/beep $PKG$BIN_DIR fi # strip binaries find $PKG -type f -exec file '{}' \; | grep 'ELF .* \(executable\|shared object\)' | cut -d':' -f1 | xargs strip --strip-unneeded 2>/dev/null || true # add man page mkdir -p $PKG$MAN_DIR/man1 install -m 0644 $SRC/beep.1.gz $PKG$MAN_DIR/man1 # gzip man pages if [ -d $PKG$MAN_DIR ] ; then for MAN_LINK in $(find $PKG$MAN_DIR -type l) ; do MAN_LINK_TARGET=$(readlink $MAN_LINK) if ! file $MAN_LINK_TARGET | fgrep -q gzip ; then ln -s $MAN_LINK_TARGET.gz $MAN_LINK.gz rm $MAN_LINK fi done find $PKG$MAN_DIR -type f -exec gzip -9 '{}' \; 2>/dev/null fi # gzip info pages and remove dir file if [ -d $PKG$INFO_DIR ] ; then rm -f $PKG$INFO_DIR/dir find $PKG$INFO_DIR -type f -exec gzip -9 '{}' \; 2>/dev/null fi # add docs mkdir -p $PKG$DOC_DIR cp -p \ $SRC/CREDITS \ $SRC/COPYING \ $SRC/README \ $SRC/INSTALL \ $SRC/CHANGELOG \ $PKG$DOC_DIR cat $0 > $PKG$DOC_DIR/$NAME.SlackBuild find $PKG$DOC_DIR -type f -exec chmod 0644 '{}' \; # add slack-desc mkdir -p $PKG/install cat > $PKG/install/slack-desc <<- EOF # 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------------------------------------------------------| $NAME: Beep (beep does exactly what you would expect: it beeps) $NAME: $NAME: Unlike printf("\a"), beep allows you to control pitch, duration, and $NAME: repetitions. Its job is to live inside shell/perl scripts and allow $NAME: more granularity than one would otherwise have. It is controlled $NAME: completely through command line options. It's not supposed to be $NAME: complex, and it isn't - but it makes system monitoring (or whatever $NAME: else it gets hacked onto) that much more informative. $NAME: $NAME: You may need to set beep executable suid. $NAME: $URL EOF # add slapt-get's style dependencies add_slaptget_dependency () { if [ -n "$1" ] ; then echo $1 | tr ',;:' '\n' | sed 's:\(^ *\| *$\)::' > $PKG/install/$2 fi } add_slaptget_dependency "$REQUIRED" slack-required add_slaptget_dependency "$SUGGESTS" slack-suggests add_slaptget_dependency "$CONFLICTS" slack-conflicts # package ( cd $PKG requiredbuilder -v -y -s $CWD $PKG mkdir -p $OUT PACKAGE_CMD=$(cat <<- EOF chown -R root:root . chmod -R u+w,go+r-w,a-s . /sbin/makepkg -c n -l y -p $OUT/$PKG_TAR chown -R $(id -u):$(id -g) . $OUT/$PKG_TAR EOF) if [ $(id -u) -eq 0 ] ; then eval "$PACKAGE_CMD" elif which fakeroot >/dev/null 2>&1 ; then echo ROOT by fakeroot... echo "$PACKAGE_CMD" | fakeroot else echo ROOT by su... su -c "$PACKAGE_CMD" fi ) # cleanup rm -rf $PKG rm -rf $SRC rm -rf $TMP