summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 98120e85478cd90e6287026d2a13744cf66175dc (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
# Maintainer: Kuan-Yen Chou <kuanyenchou at gmail dot com>
# Contributor: Johannes Kampmeyer <aur@kajoh.de>
# Contributor: Pedro Martinez-Julia <pedromj@gmail.com>
# Contributor: Walter Dworak <preparationh67@gmail.com>

pkgname=containernet-git
pkgver=3.1.r446.gc068942
pkgrel=2
pkgdesc="Mininet fork adding support for container-based emulated hosts"
_mn_deps=('python' 'iproute2' 'net-tools' 'iputils' 'inetutils' 'iperf'
          'ethtool' 'libcgroup' 'openvswitch' 'psmisc')
depends=("${_mn_deps[@]}"
         'docker' 'python-docker' 'python-pytest' 'python-iptables-git'
         'python-pexpect' 'python-urllib3' 'python-networkx')
optdepends=('xorg-xhost: for X11 forwarding'
            'socat: for X11 forwarding'
            'xterm: required for MiniEdit'
            'tk: required for MiniEdit')
makedepends=('git' 'help2man' 'python-setuptools' 'python-build'
             'python-installer' 'python-wheel')
arch=('x86_64')
url="https://github.com/containernet/containernet"
license=('custom')
provides=('mininet' 'containernet')
conflicts=('mininet' 'containernet')
install="${pkgname%-git}.install"
source=("$pkgname"::'git+https://github.com/containernet/containernet'
        'git+https://github.com/mininet/openflow'
        'fix-openflow-strlcpy.patch'
        'fix-openflow-w-gcc-14-clang-17.patch'
        'fix-mininet-version.patch')
sha256sums=('SKIP'
            'SKIP'
            '0a85f8a5ce2dd900d4f874849b28301aa47d7b9d7b03ed405c973d917d98383a'
            '7258329a8df02c2b4bc87697daff12bc45ce8b2fc3145d2b6c520a8dd7ad8986'
            'dedc06db994a38b19a5641665dffeb6f5729efd25728e04edb9a71f65744df2c')

pkgver() {
    cd "$srcdir/$pkgname"
    if git describe --long --tags >/dev/null 2>&1; then
        git describe --long --tags | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
    else
        printf 'r%s.%s' "$(git rev-list --count HEAD)" "$(git describe --always)"
    fi
}

prepare() {
    cd "$srcdir/openflow"
    sed '/^include debian\/automake.mk/d' -i Makefile.am
    # Patch controller to handle more than 16 switches
    patch -Np1 -i "$srcdir/$pkgname/util/openflow-patches/controller.patch"
    patch -Np1 -i "$srcdir/fix-openflow-strlcpy.patch"
    patch -Np1 -i "$srcdir/fix-openflow-w-gcc-14-clang-17.patch"

    cd "$srcdir/$pkgname"
    # shellcheck disable=SC2016
    sed -i Makefile \
        -e 's:PREFIX ?= /usr:PREFIX ?= "$(DESTDIR)"/usr:' \
        -e '/^[[:space:]]*$(PYTHON) /d'
    patch -Np1 -i "$srcdir/fix-mininet-version.patch"
}

build() {
    cd "$srcdir/openflow"
    autoreconf --install --force
    ./configure --prefix=/usr --sbindir=/usr/bin
    make

    cd "$srcdir/$pkgname"
    make mnexec man
    python -m build --wheel --no-isolation
}

package() {
    cd "$srcdir/openflow"
    make DESTDIR="${pkgdir}" install

    cd "$srcdir/$pkgname"
    make DESTDIR="${pkgdir}" install
    python -m installer \
        --prefix=/usr \
        --destdir="$pkgdir" \
        --compile-bytecode=1 \
        dist/*.whl
    install -Dm 644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname%-git}/LICENSE"
}

# vim: set sw=4 ts=4 et: