summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: c62377fa69375941bc85f964e59176a814eb5c86 (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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# Maintainer: Edward Pacman <edward@edward-p.xyz>

_pkgbase=iptables
pkgbase=iptables-fullconenat
pkgname=(iptables-fullconenat iptables-fullconenat-nft)
pkgver=1.8.9
pkgrel=2
epoch=1
pkgdesc='Linux kernel packet control tool with FULLCONENAT support.'
arch=(x86_64)
license=(GPL2)
url='https://www.netfilter.org/projects/iptables/index.html'
depends=(libnftnl libpcap libnfnetlink libnetfilter_conntrack bash)
makedepends=(linux-api-headers)
optdepends=("netfilter-fullconenat: kernel module for fullconenat")
provides=('iptables')
conflicts=(iptables)
install=${pkgbase}.install
backup=(etc/ethertypes etc/iptables/{ip,ip6}tables.rules)
source=(https://www.netfilter.org/projects/iptables/files/$_pkgbase-$pkgver.tar.xz{,.sig}
        empty.rules simple_firewall.rules empty-{filter,mangle,nat,raw,security}.rules
        {arp,eb,ip,ip6}tables.service iptables-{legacy,nft}-flush
        iptables-format-security-libxt_NAT.patch::https://git.netfilter.org/iptables/patch/?id=ed4082a7405a5838c205a34c1559e289949200cc
        iptables-apply-default-path.patch
        "libipt_FULLCONENAT.c::https://raw.githubusercontent.com/llccd/netfilter-full-cone-nat/dev/libipt_FULLCONENAT.c"
        "libip6t_FULLCONENAT.c::https://raw.githubusercontent.com/llccd/netfilter-full-cone-nat/dev/libip6t_FULLCONENAT.c")
sha1sums=('f47bc1026858d7078c8d0544bbb9bea5c08fd9ad'
          'SKIP'
          '83b3363878e3660ce23b2ad325b53cbd6c796ecf'
          'f085a71f467e4d7cb2cf094d9369b0bcc4bab6ec'
          'd9f9f06b46b4187648e860afa0552335aafe3ce4'
          'c45b738b5ec4cfb11611b984c21a83b91a2d58f3'
          '1694d79b3e6e9d9d543f6a6e75fed06066c9a6c6'
          '7db53bb882f62f6c677cc8559cff83d8bae2ef73'
          'ebbd1424a1564fd45f455a81c61ce348f0a14c2e'
          '95b0ee26f03132a948fea9f2136b2e2e6a4b40fe'
          'b668ba50d55030c68431a95756bc1f291d74b2b2'
          '8d66d21fa4cbfe2a80478301af94ba54f65e4ea0'
          '9cec592787e32451f58fa608ea057870e07aa704'
          'd10af7780d1634778d898c709e2d950aa1561856'
          '15c1684f3e671f4d0ede639a7c9c08e1a841511c'
          '24bd426b56c8fbc8df51a5666d2bff7db8314c6f'
          '454d0a6d3bca14b8702e7c5e2672f5bc0c832b85'
          '1d320a1193a754d5cb4afa7c4b8bb27316c7dd95'
          'abec6a9a953101c0345d60e5812393243cc7bb7b')
validpgpkeys=('C09DB2063F1D7034BA6152ADAB4655A126D292E4'
              '37D964ACC04981C75500FB9BD55D978A8A1420E4') # Netfilter Core Team

prepare() {
  mkdir build
  cd $_pkgbase-$pkgver

  cp ../libip{,6}t_FULLCONENAT.c extensions/
  # use system one
  rm include/linux/types.h

  ln -rs libiptc/linux_list.h include/libiptc
  patch -p1 -i ../iptables-format-security-libxt_NAT.patch # Fix build with -Werror=format-security

  # use Arch path
  patch -p0 -i ../iptables-apply-default-path.patch
}

build() {
  cd build
  ../$_pkgbase-$pkgver/configure \
    --prefix=/usr \
    --sysconfdir=/etc \
    --sbindir=/usr/bin \
    --libexecdir=/usr/lib \
    --enable-bpf-compiler \
    --enable-devel \
    --enable-libipq \
    --enable-shared
  sed -e 's/ -shared / -Wl,-O1,--as-needed\0/g' -i libtool
  make
}

package_iptables-fullconenat() {
  pkgdesc+=' (using legacy interface)'
  _package legacy
}

package_iptables-fullconenat-nft() {
  pkgdesc+=' (using nft interface)'
  depends+=(nftables)
  provides=(iptables iptables-fullconenat arptables ebtables)
  conflicts=(iptables iptables-fullconenat arptables ebtables)
  backup+=(etc/{arp,eb}tables.conf)

  _package nft

  install -Dt "$pkgdir/usr/lib/systemd/system" -m644 {arp,eb}tables.service
  touch "$pkgdir"/etc/{arp,eb}tables.conf
}

_package() {
  DESTDIR="$pkgdir" make -C build install

  for _x in {arp,eb,ip,ip6}tables{,-restore,-save} iptables-xml; do
    if [[ $1 = nft || $_x = ip* ]]; then
      ln -sf xtables-$1-multi "$pkgdir/usr/bin/$_x"
    else
      rm "$pkgdir/usr/bin/$_x"
    fi
  done

  install -Dt "$pkgdir/usr/lib/systemd/system" -m644 {ip,ip6}tables.service
  install -D iptables-$1-flush "$pkgdir/usr/lib/systemd/scripts/iptables-flush"

  install -Dm644 empty.rules "$pkgdir/etc/iptables/iptables.rules"
  install -Dm644 empty.rules "$pkgdir/etc/iptables/ip6tables.rules"
  install -Dt "$pkgdir/usr/share/iptables" -m644 *.rules
  ln -srt "$pkgdir/etc/iptables" "$pkgdir"/usr/share/iptables/{empty,simple_firewall}.rules
}

# vim:set sw=2 et: