add xnedit
[slackbuilds.git] / slock / slock.SlackBuild
blob835fcb81396f23e362e294a139477b3a20f42370
1 #!/bin/bash
3 # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
4 # Version 2, December 2004
6 # Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
8 # Everyone is permitted to copy and distribute verbatim or modified
9 # copies of this license document, and changing it is allowed as long
10 # as the name is changed.
12 # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
13 # TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
16 # 0. You just DO WHAT THE FUCK YOU WANT TO.
18 # SlackBuild script for slock
19 # ===========================
20 # By: r1w1s1 (https://fosstodon.org/@r1w1s1)
21 # For: slock
22 # Descr: slock is a simple X display locker.
23 # URL: https://www.suckless.org/programs/slock.html
24 # Changelog:
25 # v1.4: Grabbed from slackbuilds.org
26 # v1.5: 17/july/2024 by r1w1s1 - update build and clean-up the slackbuild script
28 cd $(dirname $0) ; CWD=$(pwd)
30 PRGNAM=slock
31 VERSION=${VERSION:-1.5}
32 BUILD=${BUILD:-2}
33 TAG=${TAG:-_SBo}
34 PKGTYPE=${PKGTYPE:-tgz}
36 if [ -z "$ARCH" ]; then
37 case "$( uname -m )" in
38 i?86) ARCH=i586 ;;
39 arm*) ARCH=arm ;;
40 *) ARCH=$( uname -m ) ;;
41 esac
44 # If the variable PRINT_PACKAGE_NAME is set, then this script will report what
45 # the name of the created package would be, and then exit. This information
46 # could be useful to other scripts.
47 if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
48 echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
49 exit 0
52 TMP=${TMP:-/tmp/SBo}
53 PKG=$TMP/package-$PRGNAM
54 OUTPUT=${OUTPUT:-/tmp}
56 if [ "$ARCH" = "i586" ]; then
57 SLKCFLAGS="-O2 -march=i586 -mtune=i686"
58 LIBDIRSUFFIX=""
59 elif [ "$ARCH" = "x86_64" ]; then
60 SLKCFLAGS="-O2 -fPIC"
61 LIBDIRSUFFIX="64"
62 else
63 SLKCFLAGS="-O2"
64 LIBDIRSUFFIX=""
67 DOCS="LICENSE README"
69 set -e
71 rm -rf $PKG
72 mkdir -p $TMP $PKG $OUTPUT
73 cd $TMP
75 # Download and extract the source code
76 rm -rf "${PRGNAM}-${VERSION}"
77 wget -O "${PRGNAM}-${VERSION}.tar.gz" "https://dl.suckless.org/tools/${PRGNAM}-${VERSION}.tar.gz"
78 tar xvf "${PRGNAM}-${VERSION}.tar.gz"
79 cd "${PRGNAM}-${VERSION}"
81 chown -R root:root .
82 find -L . \
83 \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 -o -perm 511 \) \
84 -exec chmod 755 {} \; -o \
85 \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
86 -exec chmod 644 {} \;
88 make \
89 OPTS="$SLKCFLAGS" \
90 PREFIX=/usr \
91 MANPREFIX=/usr/man \
92 X11INC=/usr/include/X11 \
93 X11LIB=/usr/lib${LIBDIRSUFFIX}/X11
94 make install \
95 OPTS="$SLKCFLAGS" \
96 PREFIX=/usr \
97 MANPREFIX=/usr/man \
98 X11INC=/usr/include/X11 \
99 X11LIB=/usr/lib${LIBDIRSUFFIX}/X11 \
100 DESTDIR=$PKG
102 # This approach was preferable, but since slock must have root privs to
103 # adjust its OOM score, oh well...
104 #chown root:shadow $PKG/usr/bin/slock
105 #chmod 2755 $PKG/usr/bin/slock
106 chmod 4755 $PKG/usr/bin/slock
108 find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
109 | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
111 gzip -9 $PKG/usr/man/man?/*.?
113 mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
114 cp -a $DOCS $PKG/usr/doc/$PRGNAM-$VERSION
115 cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
117 mkdir -p $PKG/install
118 cat $CWD/slack-desc > $PKG/install/slack-desc
120 cd $PKG
121 /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE