Create additional tool (arp-scan) for LibreELEC

I wanted my Rasperry Pi 2, which was running LibreELEC, to additionally scan for specific network devices. I didn’t want to change the LibreELEC, as I was very satisfied with it. So here’s how I managed to cross-compile on my linux box the tool `arp-scan`.

1.) Get the LibreELEC.tv-Source and compile an image.

Make sure that this works before continuing with anything else. I managed to compile the 9.0-devel version.

Instructions are given on the LibreELEC-Wiki

2.) Create the arp-scan directory and the package.mk

mkdir -p packages/tools/arp-scan
cat >packages/tools/arp-scan/package.mk <<EOF
################################################################################
#      This file is part of LibreELEC - https://libreelec.tv
#      Copyright (C) 2018-present Team LibreELEC
#
#  LibreELEC is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 2 of the License, or
#  (at your option) any later version.
#
#  LibreELEC is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with LibreELEC.  If not, see <http://www.gnu.org/licenses/>.
################################################################################
 
PKG_NAME="arp-scan"
PKG_VERSION="1.9"
PKG_ARCH="arm"
PKG_LICENSE="GPL"
PKG_SITE="http://www.nta-monitor.com/wiki/index.php/Arp-scan_Installation_Guide"
PKG_URL="https://github.com/royhills/arp-scan/releases/download/$PKG_VERSION/arp-scan-$PKG_VERSION.tar.gz"
PKG_DEPENDS_TARGET="toolchain zlib libpcap"
PKG_SECTION="tools"
PKG_SHORTDESC="arp-scan"
PKG_LONGDESC="The arp-scan utility"
PKG_TOOLCHAIN="auto"
 
post_patch() {
  rm $PKG_BUILD/configure
  cd $PKG_BUILD
  autoconf
}
EOF

3.) Add needed patches

To get a patch-File from a github-commit, you can just add `.patch` to the url and you’ll get a correct patchable diff.

mkdir -p packages/tools/arp-scan/patches

I needed the change for the cross compilation, but the author hadn’t released a new version yet, so I had to download and include the patch:

wget https://github.com/royhills/arp-scan/commit/f74edaf821f49652b7649ff6113fc6685d2c952a.patch -O packages/tools/arp-scan/patches/Assume-long-long-int-format-is-lld-if-cross-compiling.patch

Sadly this won’t help with the release file, as the configure script already exists. So we have to delete the configure-File to force the package-System to run „autoconf“. That’s the reason for the `post_patch()`-Section in the package.mk.

4.) Add ourself to the dependency tree

sed -i 's/PKG_DEPENDS_TARGET="toolchain connman netbase ethtool openssh"/PKG_DEPENDS_TARGET="toolchain connman netbase ethtool openssh arp-scan"/' ./packages/virtual/network/package.mk

5.) Copy resulting file to host
In this case, we have to copy the libpcap.a and the arp-scan binary, like this:

scp build.LibreELEC-RPi2.arm-9.0-devel/libpcap-1.7.4/.armv7ve-libreelec-linux-gnueabi/libpcap.a targethost:
scp build.LibreELEC-RPi2.arm-9.0-devel/arp-scan-1.9/.armv7ve-libreelec-linux-gnueabi/arp-scan targethost:

Schreibe einen Kommentar