summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 7234942ce86b2fa745cd556c698b469a26e563d5 (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
# Maintainer: Claudia Pellegrino <aur ät cpellegrino.de>
# Contributor: Jesse Spangenberger <azulephoenix@gmail.com>

pkgname=private-internet-access-vpn
pkgver=3.4
pkgrel=3
pkgdesc="Installs VPN profiles for Private Internet Access Service"
arch=("any")
url="https://www.privateinternetaccess.com/"
license=('GPL')
depends=('openvpn' 'python' 'python-docopt' 'python-setuptools')
makedepends=('git' 'python-build' 'python-installer' 'python-wheel')
optdepends=('networkmanager: Enables PIA for Network Manager (needs a openvpn plugin)'
            'connman: Enables PIA for Connman')
conflicts=('xawtv') # Both packages install a `pia` executable

sha256sums=('bc38427782aedc90cb65b322cd6f9d74af4e988cc5b3c884e43236ed7a5e4491'
            '38758f393590c51ec1566aba19beaed7c4fa8bd6f7c323f44ab00b9eb9fd7577'
            '4322a2a4bc3e206c6ab7e1df87a8805032b76c177c1ed9dd3501260ed32ccb30'
            '797dbdb6e3aadc86f97262e26d61cf4847caf85dda4b7a97cac59088cb912b27'
            '246fc4dc3218f56b4c70014df6801b10fc2a573d6545962b7fce05f16908c54e'
            '7f4a5ee1fb8ea4d0e69ed2a8217c575cf335f21e90082f6e423c769eca4a7a46'
            'dd15ff9d020d6779c51bff560c8571b462cc7ca3f4d2a92b8103056be4b2e0fd'
            'SKIP'
            'SKIP')

source=("default-$pkgver-$pkgrel.zip::https://www.privateinternetaccess.com/openvpn/openvpn.zip"
        "strong-$pkgver-$pkgrel.zip::https://www.privateinternetaccess.com/openvpn/openvpn-strong.zip"
        "login-example.conf"
        "pia-example.conf"
        "restart.conf"
        "vpn.sh"
        "pia.8.gz"
        "git+https://github.com/flamusdiu/python-pia.git#tag=v${pkgver}"
        "git+https://github.com/masterkorp/openvpn-update-resolv-conf.git")

noextract=("default-$pkgver-$pkgrel.zip"
           "strong-$pkgver-$pkgrel.zip"
           "pia.8.gz")

prepare() {
  cd "${srcdir}"

  echo >&2 "Extracting Certifications..."
  bsdtar -xf default-$pkgver-$pkgrel.zip "*.pem" "*.crt"
  bsdtar -xf strong-$pkgver-$pkgrel.zip "*.pem" "*.crt"

  echo >&2 "Extracting OpenVPN Configurations..."
  if [ -d "vpn-configs" ]; then
      rm -rf vpn-configs
  fi
  mkdir "vpn-configs"
  bsdtar -xf default-$pkgver-$pkgrel.zip -C vpn-configs *.ovpn

  cd "vpn-configs"
  echo >&2 "Creating Remote Host List..."
  touch ../vpn-hosts.txt

  grep -Eo "\s(.*\.privacy\.network)\s" *.ovpn | \
    sed 's/_/ /g;s/.ovpn//;s/: /,/;s/[^ ]\+/\L\u&/g;s/\b\([a-z]\{2\}\)\s/\U&/gi' \
    >> ../vpn-hosts.txt

  echo >&2 "Resetting python-pia repository..."
  git -C "${srcdir}/python-pia" clean -dfx

  echo >&2 "Done."
}

build() {
  cd "${srcdir}/python-pia"
  python -m build --wheel --no-isolation
}

package() {
  cd "${srcdir}"

  install -D -m 644 restart.conf "${pkgdir}/usr/lib/systemd/openvpn-client@.service.d/restart.conf"
  install -D -m 755 vpn.sh "${pkgdir}/usr/lib/systemd/system/system-sleep/vpn.sh"
  install -D -m 644 pia.8.gz "${pkgdir}/usr/share/man/man8/pia.8.gz"


  install -dm755 "${pkgdir}"/etc/{openvpn,private-internet-access}
  install -g network -dm750 "${pkgdir}"/etc/openvpn/client

  install -D -m 644 vpn-hosts.txt "${pkgdir}/etc/private-internet-access"
  install -D -g network -m 640 *.crt "${pkgdir}/etc/openvpn/client"
  install -D -g network -m 640 *.pem "${pkgdir}/etc/openvpn/client"
  install -D -m 644 {pia-example.conf,login-example.conf} "${pkgdir}/etc/private-internet-access/"

  install -D -m 755 openvpn-update-resolv-conf/update-resolv-conf.sh "${pkgdir}/etc/openvpn/update-resolv-conf.sh"

  cd "python-pia"
  python -I -m installer --destdir="${pkgdir}" dist/*.whl

}