summaryrefslogtreecommitdiffstats
path: root/system/mdcat-bin/mdcat-bin.SlackBuild
blob: 713d56a384dd47834b3c85834a73e0625691c426 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/bash

# Slackware build script for mdcat-bin

# Written by B. Watson (urchlay@slackware.uk)

# Licensed under the WTFPL. See http://www.wtfpl.net/txt/copying/ for details.

# This is a binary repack because the source is in Rust, and won't
# build with the Rust that ships with Slackware 15.0. It would be
# possible for someone to use rustup and deal with "cargo vendor"
# stuff to create build-from-source mdcat SlackBuild, but that
# someone will not be me. If you are that someone, I've named this one
# "mdcat-bin" so you can name yours "mdcat".

# Despite the "musl" in the tarball filename, this works fine on
# Slackware, since it's 100% statically linked. Upstream probably used
# musl because glibc's not capable of creating a truly static binary
# that uses DNS...

# Many thanks to chrisdent and pwshdooduk of libera.chat's #powershell,
# for making sense of the powershell completions and just generally
# being friendly folks.

cd $(dirname $0) ; CWD=$(pwd)

PRGNAM=mdcat-bin
SRCNAM=mdcat
VERSION=${VERSION:-2.0.3}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}
PKGTYPE=${PKGTYPE:-tgz}

if [ -z "$ARCH" ]; then
  case "$( uname -m )" in
    i?86) ARCH=i586 ;;
    arm*) ARCH=arm ;;
       *) ARCH=$( uname -m ) ;;
  esac
fi

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}

if [ "$ARCH" = "x86_64" ]; then
  SRCDIR="$SRCNAM-$VERSION-$ARCH-unknown-linux-musl"
  TARBALL="$SRCDIR.tar.gz"
else
  cat <<EOF

*** ARCH "$ARCH" is not supported (only x86_64 is supported, sorry).

EOF
  exit 1
fi

set -e

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
# use e.g. /tmp/SBo/mdcat-bin/<blah>/, for easy cleanup.
rm -rf $PRGNAM
mkdir -p $PRGNAM
cd $PRGNAM
tar xvf $CWD/$TARBALL
cd $SRCDIR
chown -R root:root .
# no find|chmod, but we install everything with explicit permissions
# or redirection, below.

PKGBIN=$PKG/usr/bin
PKGDOC=$PKG/usr/doc/$PRGNAM-$VERSION
PKGMAN1=$PKG/usr/man/man1
PKGBASHC=$PKG/usr/share/bash-completion/completions
PKGZSHC=$PKG/usr/share/zsh/site-functions
PKGFISHC=$PKG/usr/share/fish/completions

# powershell doesn't really have a completions directory, so I picked
# something plausible-looking. The README tells how to edit your
# profile to add these.
PKGPSHC="$PKG/usr/share/$PRGNAM/powershell-completions"

mkdir -p $PKGBIN $PKGDOC $PKGMAN1 $PKGBASHC $PKGZSHC $PKGFISHC $PKGPSHC

install -m0755 $SRCNAM $PKGBIN
ln -s $SRCNAM $PKGBIN/mdless

INST="install -m0644"
$INST LICENSE *.md $PKGDOC
gzip -9c < $SRCNAM.1 > $PKGMAN1/$SRCNAM.1.gz
ln -s $SRCNAM.1.gz $PKGMAN1/mdless.1.gz

cd completions
$INST mdcat.bash $PKGBASHC/mdcat
$INST mdless.bash $PKGBASHC/mdless
$INST _mdcat _mdless $PKGZSHC
$INST *.fish $PKGFISHC
$INST *.ps1 $PKGPSHC

cat $CWD/$PRGNAM.SlackBuild > $PKGDOC/$PRGNAM.SlackBuild

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc

cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE