slackbuilds/system/gnsu/gnsu.SlackBuild

112 lines
3.7 KiB
Bash

#!/bin/bash
# Slackware build script for gnsu
# Written by B. Watson (urchlay@slackware.uk)
# Licensed under the WTFPL. See http://www.wtfpl.net/txt/copying/ for details.
# Didier Spaier suggested (on the mailing list) that someone should
# package this, as a replacement for gksu. Sure, why not?
# I'm not a gksu user. If I were, I might not consider this a proper
# replacement. The main feature it's missing is, it doesn't grab the
# keyboard & mouse when prompting for a password (to prevent the user
# accidentally typing the password into some other window). Also, gksu
# will prompt for a command to run, if you don't supply one; gnsu just
# prints the --help message (on stderr, not in a dialog) and exits.
# OTOH, this is written in python3 and is pretty self
# contained. There's no compiled code and no extra dependencies.
# I've added a .desktop and icon, so this can replace gksu's "root
# terminal" menu entry... not that that ever *worked* because
# gksu.desktop executes "gksu /usr/bin/terminal", and Slackware
# doesn't have any such binary. It's supposed to be xfce4-terminal,
# but nobody ever got around to updating the .desktop file when XFCE
# changed its terminal binary's name.
cd $(dirname $0) ; CWD=$(pwd)
PRGNAM=gnsu
VERSION=${VERSION:-0.3}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}
PKGTYPE=${PKGTYPE:-tgz}
ARCH=noarch
if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
exit 0
fi
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}
set -e
rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$VERSION
tar xvf $CWD/$PRGNAM-$VERSION.tar.gz
cd $PRGNAM-$VERSION
chown -R root:root .
find -L . -perm /111 -a \! -perm 755 -a -exec chmod -h 755 {} + -o \
\! -perm /111 -a \! -perm 644 -a -exec chmod -h 644 {} +
# SalixOS has a "gnsu-0.3.1" package. The only differences between
# upstream's 0.3 and salix's 0.3.1 are that salix added an Irish
# (Gaelic?) translation, and modified the Portuguese translations
# incorrectly (fixed the "a a", but got rid of the "Por favor"). This
# patch adds the Irish translation and fixes the Portuguese
# *correctly*.
patch -p1 < $CWD/translations.diff
# We ship our own man page. It was generated by running 'make man',
# but manually edited to set the date in the .TH line (txt2tags wasn't
# expanding the %%mtime macro). Doing it this way also means we don't
# have to have REQUIRES="txt2tags".
cat $CWD/$PRGNAM.man > man/$PRGNAM.man
# The make command doesn't include "all" because we don't want
# it regenerating the man page. The -j1 may not be necessary, but
# removing it won't speed things up anyway (since we're not compiling
# anything).
make -j1 mo install PREFIX=/usr DESTDIR=$PKG
gzip -9 $PKG/usr/man/man*/*
# .desktop is just a modified copy of the one from gksu, and the icons
# are unmodified from gksu.
APP=gnsu-root-terminal
mkdir -p $PKG/usr/share/applications
cat $CWD/$APP.desktop > $PKG/usr/share/applications/$APP.desktop
for i in $CWD/icons/*.png; do
px="$( basename $i | cut -d. -f1 )"
sz="${px}x${px}"
dir=$PKG/usr/share/icons/hicolor/$sz/apps
mkdir -p $dir
cat $i > $dir/$APP.png
done
mkdir -p $PKG/usr/share/pixmaps
ln -s ../icons/hicolor/48x48/apps/$APP.png $PKG/usr/share/pixmaps/$APP.png
PKGDOC=$PKG/usr/doc/$PRGNAM-$VERSION
mkdir -p $PKGDOC
cp -a COPYING README* $PKGDOC
cat $CWD/$PRGNAM.SlackBuild > $PKGDOC/$PRGNAM.SlackBuild
# The douninst.sh removes the gksu and gksudo symlinks on package
# removal, but only if they're actually symlinks to gnsu.
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cat $CWD/doinst.sh > $PKG/install/doinst.sh
cat $CWD/douninst.sh > $PKG/install/douninst.sh
cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE