-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild-batctl
executable file
·95 lines (83 loc) · 2.2 KB
/
build-batctl
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
#!/bin/bash
PACKAGE="batctl"
REMOTE="git://git.open-mesh.org/batctl.git"
TAG="v2024.0"
TARGET_VERSION="2024.0"
PKG_RELEASE_PREFIX="0~tecff"
PKG_RELEASE="1"
MAINTAINER="rotanid"
PKGLICENSE="GPL2"
PKGGROUP="net"
PKGALTSRC="https://git.open-mesh.org/batctl.git"
PKGDESC="B.A.T.M.A.N. advanced control and management tool"
REQUIRES="libc6 \(\>= 2.15\),libnl-genl-3-200 \(\>= 3.2.7\)"
BUILD_ROOT="/tmp/batctl-source"
INSTALL_PREFIX="/usr"
RUNNING_DISTRO="$(lsb_release -s -i)"
RUNNING_DISTRO_VERSION="$(lsb_release -r -s)"
if [[ "$RUNNING_DISTRO_VERSION" = "10"* ]]; then
# Debian Buster
PKG_RELEASE="${PKG_RELEASE_PREFIX}~deb10u${PKG_RELEASE}"
elif [[ "$RUNNING_DISTRO_VERSION" = "11"* ]]; then
# Debian Bullseye
PKG_RELEASE="${PKG_RELEASE_PREFIX}~deb11u${PKG_RELEASE}"
elif [[ "$RUNNING_DISTRO_VERSION" = "12"* ]]; then
# Debian Bookworm
PKG_RELEASE="${PKG_RELEASE_PREFIX}~deb12u${PKG_RELEASE}"
else
echo "the currently running $RUNNING_DISTRO version ( $RUNNING_DISTRO_VERSION ) of your distro is not supported yet by this build script."
exit 1
fi
check() {
REQUIRED=0
local CURRENT_VERSION=$(batctl -v | awk '{ print $2 }')
/usr/bin/dpkg --compare-versions "$CURRENT_VERSION" "eq" "$TARGET_VERSION"
local CODE=$?
if [ $CODE -ne 0 ]; then
echo "[-] batctl version changed (${CURRENT_VERSION} to ${TARGET_VERSION})."
REQUIRED=1
fi
exit $REQUIRED
}
prepare() {
rm -rf $BUILD_ROOT
git clone "$REMOTE" "$BUILD_ROOT"
cd $BUILD_ROOT
git checkout "$TAG"
# apply patches if they exist
if [ "$(ls -A /usr/src/${PACKAGE}_patches/)" ]; then
git am /usr/src/${PACKAGE}_patches/*
fi
}
build() {
cd $BUILD_ROOT
make -j$(nproc)
}
install() {
cd $BUILD_ROOT
echo ${PKGDESC} > description-pak
fakeroot checkinstall -y --nodoc \
--pkgname "${PACKAGE}" \
--pkgversion "${TARGET_VERSION}" \
--pkgrelease "${PKG_RELEASE}" \
--pkgsource "${REMOTE}" \
--pkgaltsource "${PKGALTSRC}" \
--pkglicense "${PKGLICENSE}" \
--pkggroup "${PKGGROUP}" \
--maintainer "${MAINTAINER}" \
--requires "${REQUIRES}" \
--fstrans=yes \
--install=no \
make install PREFIX="${INSTALL_PREFIX}"
}
if [ "$1" = "check" ]; then
check
else
prepare
build
if [ "$?" != "0" ]; then
echo "build may have failed."
exit 1
fi
install
fi