summaryrefslogtreecommitdiffstats
path: root/network/mitmproxy-bin/mitmproxy-bin.SlackBuild
blob: ba326f9e52abd297292b7f11d59c75a6e9d0e3cb (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
#!/bin/bash

# Slackware build script for mitmproxy-bin

# Written by B. Watson (yalhcru@gmail.com)

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

# I was gonna package this up from source, but it just has too many
# dependencies, many of which aren't on SBo already. I'd have to add
# at least 15 or 20 python modules, and I just won't. The official
# binary release is "frozen" executables with no external Python
# dependencies (just shared libs that are part of Slackware already).

# This is mostly just a binary repack of the official build. Which
# is only for x86_64 Linux (sorry, 32-bit users).

# I named this with the -bin suffix so that someday someone (other
# than me!) can do a proper build-from-source mitmproxy SlackBuild,
# with tons of dependencies in REQUIRES...

# There's *nothing* in the Linux tarball besides the executables, so
# I've also included some docs from the source tarball, but not the
# complete API docs (again, to avoid a long dependency chain of the
# stuff needed to build them). Use https://docs.mitmproxy.org/stable/
# for that.

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

PRGNAM=mitmproxy-bin
SRCNAM=mitmproxy
VERSION=${VERSION:-7.0.4}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}

# Binary repack, only supports:
ARCH=x86_64

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 the user's trying to build this on a non-x86_64 box, it's
# almost certainly a mistake on the user's part... but maybe not,
# for smart users. So warn and pause, but allow it to happen.
M="$(uname -m)"
if [ "$M" != "x86_64" ]; then
  W="* WARNING: cross-building x86_64 package on $M host. *"
  H="$( echo "$W" | sed 's,.,*,g' )"
  echo -e "$H\\n$W\\n$H\\n"
  cat <<EOF
You're about to build a 64-bit (x86_64) package, which will work fine
if you install it on an x86_64 Slackware64 system... but not on *this*
system, because it's $M, not x86_64.

Press Enter or wait 5 seconds to continue. Or, press ^C to abort.
EOF
  read -p "> " -t 5
fi

set -e

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $SRCNAM-$VERSION
mkdir -p $SRCNAM-$VERSION
cd $SRCNAM-$VERSION
tar xvf $CWD/$SRCNAM-$VERSION-linux.tar.gz
tar xvf $CWD/$SRCNAM-$VERSION.tar.gz
chown -R root:root .
find -L .  -perm /111 -a \! -perm 755 -a -exec chmod 755 {} \+ -o \
        \! -perm /111 -a \! -perm 644 -a -exec chmod 644 {} \+

# Already stripped.
mkdir -p $PKG/usr/bin
install -m0755 $SRCNAM mitmdump mitmweb $PKG/usr/bin

# Stub man page. Just stuff copied from the README and a pointer to the
# actual docs on the web.
mkdir -p $PKG/usr/man/man1
gzip -9c < $CWD/$SRCNAM.1 > $PKG/usr/man/man1/$SRCNAM.1.gz
ln -s $SRCNAM.1.gz $PKG/usr/man/man1/mitmdump.1.gz
ln -s $SRCNAM.1.gz $PKG/usr/man/man1/mitmweb.1.gz

# Include README, etc from source tarball.
cd $SRCNAM-$VERSION
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a *.md LICENSE $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$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:-tgz}