summaryrefslogblamecommitdiffstats
path: root/source/n/bluez-utils/bluez-utils.SlackBuild
blob: 7f8b957463068cfee943ce942b079f7e07aab2df (plain) (tree)



























































































































































































                                                                                                                               
#!/bin/sh
#
# SlackBuild for bluez-utils
# http://www.bluez.org
# By SukkoPera <enjoy.the.silence@iol.it>
# Thanks a lot to CAT for his Slackware package cration
# guide (http://www.slacky.it/misto/tutorial/spunleashed.txt)
#
# Check out
# - http://www.sukkopera.tk
# - http://www.slacky.it
# - http://www.nyft.org
#
# Notes:
# - Many files and the whole PIN management system have been stolen from the
#   Debian package. Thanks.
#
# Rewritten for Slackware 2007-05  <pjv>

NAME=bluez-utils
VERSION=${VERSION:-3.36}
ARCH=${ARCH:-x86_64}
NUMJOBS=${NUMJOBS:-" -j7 "}
BUILD=${BUILD:-7}


if [ "$ARCH" = "i486" ]; then
  SLKCFLAGS="-O2 -march=i486 -mtune=i686"
  LIBDIRSUFFIX=""
elif [ "$ARCH" = "s390" ]; then
  SLKCFLAGS="-O2"
  LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" ]; then
  SLKCFLAGS="-O2 -fPIC"
  LIBDIRSUFFIX="64"
fi

CWD=$(pwd)
TMP=${TMP:-/tmp}
PKG=$TMP/package-$NAME

rm -rf $PKG
mkdir -p $TMP $PKG
mkdir -p $PKG/etc/rc.d \
  $PKG/etc/bluetooth/passkeys \
  $PKG/usr/lib${LIBDIRSUFFIX}/bluetooth
# Is there any reason for a non-root user to be able to see these?
chmod 700 $PKG/etc/bluetooth/passkeys
cd $TMP
rm -rf $NAME-$VERSION
tar xvf $CWD/${NAME}-${VERSION}.tar.bz2 || exit 1
cd $NAME-$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 {} \;

CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
./configure \
  --prefix=/usr \
  --libdir=/usr/lib${LIBDIRSUFFIX} \
  --sysconfdir=/etc \
  --mandir=/usr/man \
  --localstatedir=/var \
  --enable-tools\
  --enable-bccmd \
  --enable-hid2hci \
  --enable-dfutool \
  --enable-hidd \
  --enable-pand \
  --enable-dund \
  --enable-cups \
  --enable-manpages \
  --enable-configfiles \
  --build=$ARCH-slackware-linux

make $NUMJOBS || make || exit 1
make install DESTDIR=$PKG

mkdir -p $PKG/lib/udev
cp -a scripts/bluetooth_serial $PKG/lib/udev/bluetooth_serial || exit 1
chmod 755 $PKG/lib/udev/bluetooth_serial

mkdir -p $PKG/lib/udev/rules.d
cp -a scripts/bluetooth.rules $PKG/lib/udev/rules.d/60-bluetooth.rules || exit 1
chmod 644 $PKG/lib/udev/rules.d/60-bluetooth.rules

# This appears to be gone/obsolete:
#if [ ! -e $PKG/etc/bluetooth/transfer.service ]; then
#  cat transfer/transfer.service > $PKG/etc/bluetooth/transfer.service
#fi
#if [ ! -e $PKG/usr/lib${LIBDIRSUFFIX}/bluetooth/bluetoothd-service-transfer -a -e transfer/bluetoothd-service-transfer ]; then
#  cat transfer/bluetoothd-service-transfer > $PKG/usr/lib${LIBDIRSUFFIX}/bluetooth/bluetoothd-service-transfer
#  chmod 755 $PKG/usr/lib${LIBDIRSUFFIX}/bluetooth/bluetoothd-service-transfer
#fi

# Install Debian's add-passkey program:
DEBDEST=/usr/lib${LIBDIRSUFFIX}/bluetooth
gcc $(pkg-config --libs --cflags dbus-1) -DDBUS_API_SUBJECT_TO_CHANGE \
	$CWD/add-passkey.c -o $PKG/$DEBDEST/add-passkey || exit 1
cp $CWD/register-passkeys $PKG/$DEBDEST
if [ "$ARCH" = "x86_64" ]; then
  sed -i "s,/usr/lib/,/usr/lib${LIBDIRSUFFIX}/,g" $PKG/$DEBDEST/register-passkeys
fi
chmod a+x $PKG/$DEBDEST/*

# Default PIN (wow, does this seem insecure!)
#echo "1234" > $PKG/etc/bluetooth/passkeys/default
touch $PKG/etc/bluetooth/passkeys/default

mkdir -p $PKG/usr/doc/$NAME-$VERSION
cp -a \
  AUTHORS ChangeLog COPYING* INSTALL NEWS README $CWD/README.SLACKWARE \
  $PKG/usr/doc/$NAME-$VERSION
( cd $PKG/etc/bluetooth
  ln -sf /usr/doc/$NAME-$VERSION/README.SLACKWARE .
)

# Arrange init scripts and config files:
CONF=/etc/rc.d/rc.bluetooth.conf
mkdir -p $PKG/etc/rc.d
cp $CWD/rc.bluetooth $PKG/etc/rc.d/rc.bluetooth
if [ "$ARCH" = "x86_64" ]; then
  sed -i "s,/usr/lib/,/usr/lib${LIBDIRSUFFIX}/,g" $PKG/etc/rc.d/rc.bluetooth
fi
cp -a $CWD/rc.bluetooth.conf $PKG/etc/rc.d/rc.bluetooth.conf
sed -i "s:\(HIDD_ENABLE=\).*:\1false:" $PKG/$CONF || exit 1
sed -i "s:\(HID2HCI_ENABLE=\).*:\1false:" $PKG/$CONF || exit 1

mkdir -p $PKG/etc/bluetooth
cp -a audio/audio.conf $PKG/etc/bluetooth
cp -a audio/asound.conf $PKG/etc/bluetooth
cp -a input/input.conf $PKG/etc/bluetooth
cp -a hcid/hcid.conf $PKG/etc/bluetooth
cp -a network/network.conf $PKG/etc/bluetooth
cp -a rfcomm/rfcomm.conf $PKG/etc/bluetooth
chmod 644 $PKG/etc/bluetooth/*.conf

# Do not overwrite configuration
# Well, let the dbus file be overwritten, as it is not usually user-edited.
( cd $PKG
  for file in \
    etc/bluetooth/audio.conf \
    etc/asound.conf \
    etc/bluetooth/asound.conf \
    etc/bluetooth/input.conf \
    etc/bluetooth/hcid.conf \
    etc/bluetooth/network.conf \
    etc/bluetooth/rfcomm.conf \
    etc/bluetooth/passkeys/default \
    etc/rc.d/rc.bluetooth \
    etc/rc.d/rc.bluetooth.conf ; do
      mv ${file} ${file}.new
  done
)

# Replace the bluetooth.conf file with one from BlueZ4 that works with the newest dbus:
cat $CWD/bluetooth.conf > $PKG/etc/dbus-1/system.d/bluetooth.conf

# Compress and if needed symlink the man pages:
if [ -d $PKG/usr/man ]; then
  ( cd $PKG/usr/man
    for manpagedir in $(find . -type d -name "man*") ; do
      ( cd $manpagedir
        for eachpage in $( find . -type l -maxdepth 1) ; do
          ln -s $( readlink $eachpage ).gz $eachpage.gz
          rm $eachpage
        done
        gzip -9 *.?
      )
    done
  )
fi

find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \
  | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
zcat $CWD/doinst.sh.gz > $PKG/install/doinst.sh

cd $PKG
/sbin/makepkg -l y -c n $TMP/$NAME-$VERSION-$ARCH-$BUILD.txz