summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 35f3105caeb47d6cdab5bca200b2ea71a71ff43e (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
# Maintainer: somekool <somekool _ at _ gmail _ dot _com>

pkgname=netvfy-agent-git
srcgiturl=https://github.com/netvfy/netvfy-agent
pkgver=v1.0.0
pkgrel=1
pkgdesc="Netvfy - Connect to your secure virtual network."
arch=('i686' 'x86_64')
url="https://my.netvfy.org/"
license=('Unknown Free')
depends=('jansson' 'curl' 'libevent' 'openssl')
optdepends=()
makedepends=('git' 'scons' 'cmake')
# - libevent-dev
# - libssl-dev
# - libjansson-dev
# - libcurl4-openssl-dev)
source=("${pkgname}::git+${srcgiturl}.git")
md5sums=('SKIP')

pkgver() {
  gitinfo=`git ls-remote ${srcgiturl} | sort -Vk2`
  sha=`echo "$gitinfo" | head -n 1 | cut -c -7`
  tag=`echo "$gitinfo" | tail -n 1 | awk -F "/" {'print $3'}`
  commits=`curl -s ${srcgiturl}/releases/tag/${tag} | grep -o "[0-9]* commits" | awk {'print $1'}`
  if [ "$commit" = "" ]; then
    printf $tag
  else
    printf "%s.r%s.g%s" $tag $commits $sha
  fi

}

prepare() {
  cd ${srcdir}/${pkgname}
  set -e
  git submodule update --init --recursive

  pushd tapcfg
  ./buildall.sh linuxonly || true > /dev/null
  popd
  set +e
  echo ======================== prepare completed ========================
}

build() {
  [ -d ${srcdir}/${pkgname}/build ] && rm -fr ${srcdir}/${pkgname}/build
  mkdir ${srcdir}/${pkgname}/build
  cd ${srcdir}/${pkgname}/build
  cmake .. -DCMAKE_INSTALL_PREFIX:PATH=${pkgdir}/usr -DWITH_GUI=OFF
  make nvagent
  echo ======================== build completed ========================
}

package() {
  cd ${srcdir}/${pkgname}/build
  make install

  #TODO: this could/should become a post_install item
  echo "#!/bin/sh
  sudo chmod 666 /dev/net/tun
  sudo setcap cap_net_bind_service,cap_net_admin=ep /usr/bin/netvfy-agent
  " > ${pkgdir}/usr/bin/netvirt-allow_user

  mkdir -p ${pkgdir}/usr/lib/systemd/system

  # ArchLinux uses SystemD, Yeah
  cat << EOF > ${pkgdir}/usr/lib/systemd/system/netvfy-agent.service
[Unit]
Description=Netvfy Agent
After=network.target

[Service]
Environment="HOME=/root"
ExecStart=/usr/bin/netvfy-agent
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=always

[Install]
WantedBy=multi-user.target

EOF

}