add brightnessctl
[slackbuilds.git] / st / st.SlackBuild
blob4f4d8f628d36345467e75ded9e036ab2f2590cb5
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.
19 # 20221228 bkw: updated for v0.9.
21 # # 20211119 bkw: BUILD=2
22 # new maintainer.
23 # don't overwrite ncurses' st and st-256color terminfo entries.
24 # thanks to Eric Lindblad for pointing this out.
25 # install the rest of the docs (FAQ, LEGACY, TODO).
26 # include config.h in the doc dir.
27 # include patches.txt in the doc dir, if patches are used.
28 # add .desktop and icon.
31 # SlackBuild script for st
32 # ===========================
33 # By: r1w1s1 (https://fosstodon.org/@r1w1s1)
34 # For: st
35 # Descr: st is a simple terminal implementation for X.
36 # URL: https://st.suckless.org/
37 # Changelog:
38 # v0.9.2: 07/july/2024 by r1w1s1 - Update Version
39 # Add patches:
40 # st-blinking_cursor-20230819-3a6d6d7.diff
41 # st-defaultfontsize-20210225-4ef0cbd.diff
42 # Update .desktop file to start st with tmux
45 cd "$(dirname "$0")" || exit 1
46 CWD=$(pwd)
48 PRGNAM=st
49 VERSION=${VERSION:-0.9.2}
50 BUILD=${BUILD:-3}
51 TAG=${TAG:-_SBo}
52 PKGTYPE=${PKGTYPE:-tgz}
54 # Determine architecture
55 ARCH=${ARCH:-$(uname -m)}
56 case "$ARCH" in
57 i?86) ARCH=i586 ;;
58 arm*) ARCH=arm ;;
59 *) ARCH=$(uname -m) ;;
60 esac
62 # Output package name and exit if requested
63 if [ -n "${PRINT_PACKAGE_NAME}" ]; then
64 echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
65 exit 0
68 TMP=${TMP:-/tmp/SBo}
69 PKG=$TMP/package-$PRGNAM
70 OUTPUT=${OUTPUT:-/tmp}
72 # Set compiler flags
73 case "$ARCH" in
74 i586) SLKCFLAGS="-O2 -march=i586 -mtune=i686" ; LIBDIRSUFFIX="" ;;
75 i686) SLKCFLAGS="-O2 -march=i686 -mtune=i686" ; LIBDIRSUFFIX="" ;;
76 x86_64) SLKCFLAGS="-O2 -fPIC" ; LIBDIRSUFFIX="64" ;;
77 *) SLKCFLAGS="-O2" ; LIBDIRSUFFIX="" ;;
78 esac
80 # Clean up previous build
81 rm -rf "$PKG"
82 mkdir -p "$TMP" "$PKG" "$OUTPUT"
83 cd "$TMP" || exit 1
84 rm -rf "$PRGNAM-$VERSION"
85 tar xvf "$CWD/$PRGNAM-$VERSION.tar.gz"
86 cd "$PRGNAM-$VERSION" || exit 1
87 chown -R root:root .
88 find . -type f -exec chmod 644 {} \;
89 find . -type d -exec chmod 755 {} \;
90 find . -type f -perm /111 -exec chmod 755 {} \;
92 # Apply custom config.h if exists
93 [ -e "$CWD/config.h" ] && cp -f "$CWD/config.h" config.h
95 # Apply patches if available
96 for patch in "$CWD"/patches/*; do
97 [ -e "$patch" ] || break
98 patch -p1 < "$patch"
99 done
101 # Compile and install
102 make CFLAGS="$SLKCFLAGS"
103 make PREFIX=/usr DESTDIR="$PKG" install
105 # Strip binaries and compress man pages
106 strip "$PKG"/usr/bin/$PRGNAM
107 gzip -9 "$PKG"/usr/man/man?/*
109 # Exclude redundant terminfo entries from ncurses package
110 #pkgfile=$(ls /var/lib/pkgtools/packages/ncurses-* | grep '/ncurses-[^-]\+-[^-]\+-[^-]\+$' || echo /dev/null)
111 pkgfile="/dev/null"
112 for file in /var/lib/pkgtools/packages/ncurses-*; do
113 if [[ $file =~ /ncurses-[^-]+-[^-]+-[^-]+$ ]]; then
114 pkgfile=$file
115 break
117 done
119 for file in "$PKG"/usr/share/terminfo/s/*; do
120 name=$(basename "$file")
121 if grep -q "^usr/share/terminfo/s/$name$" "$pkgfile"; then
122 echo "=== excluding terminfo entry: $name"
123 rm "$file"
125 done
127 # Create .desktop file and icons
128 mkdir -p "$PKG"/usr/share/applications
129 cat "$CWD/$PRGNAM.desktop" > "$PKG"/usr/share/applications/"$PRGNAM.desktop"
131 for px in 16 32 48 64 128; do
132 size="${px}x${px}"
133 dir="$PKG/usr/share/icons/hicolor/$size/apps"
134 mkdir -p "$dir"
135 convert -resize "$size" "$CWD/$PRGNAM.png" "$dir/$PRGNAM.png"
136 done
138 mkdir -p "$PKG/usr/share/pixmaps"
139 ln -s ../icons/hicolor/48x48/apps/$PRGNAM.png "$PKG/usr/share/pixmaps/$PRGNAM.png"
141 # Documentation
142 PKGDOC="$PKG/usr/doc/$PRGNAM-$VERSION"
143 mkdir -p "$PKGDOC"
144 cp -a config.h FAQ LEGACY LICENSE README TODO "$PKGDOC"
145 cat "$CWD/$PRGNAM.SlackBuild" > "$PKGDOC/$PRGNAM.SlackBuild"
147 # Slackware install scripts
148 mkdir -p "$PKG/install"
149 cat "$CWD/slack-desc" > "$PKG/install/slack-desc"
150 cat "$CWD/doinst.sh" > "$PKG/install/doinst.sh"
152 # Create the package
153 cd "$PKG" || exit 1
154 /sbin/makepkg -l y -c n "$OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"