-
Notifications
You must be signed in to change notification settings - Fork 1
/
trid-package
executable file
·68 lines (49 loc) · 1.89 KB
/
trid-package
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
#!/bin/bash
# Define script version
VERSION=0.2.1
CURDIR="$(pwd)"
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
cd "$SCRIPT_DIR"
for PROGRAM in "unzip" "wget" "gpg" "dpkg-buildpackage" "dch"; do
echo -n "Checking for $PROGRAM: "
command -v "$PROGRAM" || { echo "$PROGRAM is required but was not found, aborting."; exit 1; }
done
ARCH="$(uname -m)"
if [[ "$ARCH" == "x86_64" ]]; then
URL="http://mark0.net/download/trid_linux_64.zip"
elif [[ "$ARCH" =~ i?86 ]]; then
URL="http://mark0.net/download/trid_linux.zip"
fi
ASCURL="$URL.asc"
DEFSURL="http://mark0.net/download/triddefs.zip"
TEMPDIR="$(mktemp -d)"
cd "$TEMPDIR"
echo "Downloading $URL to $TEMPDIR ..."
wget "$URL" -O trid_linux.zip
wget "$ASCURL" -O trid_linux.zip.asc
echo "Verifying PGP signature..."
gpg --no-default-keyring --keyring "$TEMPDIR/trid-package.gpg" --import "$SCRIPT_DIR/upstream-signing-key.asc"
gpg --no-default-keyring --keyring "$TEMPDIR/trid-package.gpg" --verify trid_linux.zip.asc trid_linux.zip
wget "$DEFSURL"
mkdir "$TEMPDIR/trid-autobuilt"
cd "$TEMPDIR/trid-autobuilt"
echo "Extracting trid binary package."
unzip ../trid_linux.zip -d .
chmod +x ./trid
TRID_VERSION="$(LANG=C ./trid -? 2>&1 | grep -Eo 'v[0-9]+\.[0-9]+' | cut -c 2-)"
retval=$?
if [[ $retval -eq 1 || -z "$TRID_VERSION" ]]; then
echo "Failed to obtain trid version."
exit $retval
fi
echo "Got $TRID_VERSION as trid version"
echo "Extracting trid definitions package."
unzip ../triddefs.zip -d .
DEBVERSIONSTRING="${TRID_VERSION}~$(date "+%Y%m%d")+auto$VERSION"
echo "Preparing Debian package in $TEMPDIR/trid-autobuilt/ (version: $DEBVERSIONSTRING)"
cp -R "$SCRIPT_DIR/debian-autogen/" "./debian"
dch --create --package "trid-autobuilt" --newversion "$DEBVERSIONSTRING" "Automatically generated by trid-package $VERSION."
dpkg-buildpackage -us -uc
cd ..
echo "Packages built successfully."
cp *.deb *.tar.* *.dsc *.changes "$CURDIR"