summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: a1d36223565706e55ec4d4db76ca53912641243b (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
# Maintainer: yjun <jerrysteve1101 at gmail dot com>

pkgbase=ddns-watchdog
pkgname=("${pkgbase}-server" "${pkgbase}-client")
pkgver=1.5.10
pkgrel=1
pkgdesc='简单快速的可常驻的 Dynamic DNS 客户端,自动更新域名解析记录值'
arch=('x86_64' 'armv7h' 'aarch64')
url="https://github.com/yzy613/ddns-watchdog"
license=('Apache')
makedepends=('go')
replaces=('watchdog-ddns')
source=("${pkgbase}-${pkgver}.tar.gz::${url}/archive/v${pkgver}.tar.gz"
        "${pkgname[0]}.service"
        "${pkgname[1]}.service")
sha256sums=('a1971259380398726cd16ed1f1d74e00018b9806811eb7f3d02680c0727c916e'
            '61a4ffbfa76731c06b4c1744f3b5eb00f39009af0913f135670e1f7cc05aa9fe'
            '2ba36324b6b433d0256e097f990386d43b638358835d7cbbcca5e00cb890b1dc')

prepare(){
  cd "$pkgbase-$pkgver"

  mkdir -p build/
}

build() {
  cd "$pkgbase-$pkgver"

  export CGO_CPPFLAGS="${CPPFLAGS}"
  export CGO_CFLAGS="${CFLAGS}"
  export CGO_CXXFLAGS="${CXXFLAGS}"
  export CGO_LDFLAGS="${LDFLAGS}"
  export GOFLAGS="-buildmode=pie -trimpath -mod=readonly -modcacherw"

  # server
  go build \
    -ldflags "-w -s" \
    -o build/${pkgname[1]}  \
    ./cmd/${pkgname[1]}/main.go

  # client
  go build \
    -ldflags "-w -s" \
    -o  build/${pkgname[0]}  \
    ./cmd/${pkgname[0]}/main.go
}

packaging() {
  # binary
  install -Dm755 build/${1} ${pkgdir}/usr/bin/${1}

  # config 
  install -dm 755 ${pkgdir}/etc/${pkgbase}
  ${pkgdir}/usr/bin/${pkgname} -i ${2} -c ${pkgdir}/etc/${pkgbase}/
  
  # systemd service
  install -Dm644 ${srcdir}/${1}.service ${pkgdir}/usr/lib/systemd/system/${1}.service
}

package_ddns-watchdog-server() {
  cd "$pkgbase-$pkgver"
  
  backup=("etc/${pkgbase}/server.json")
  
  packaging $pkgname
}

package_ddns-watchdog-client() {
  cd "$pkgbase-$pkgver"

  backup=("etc/${pkgbase}/client.json"
          "etc/${pkgbase}/alidns.json"
          "etc/${pkgbase}/cloudflare.json"
          "etc/${pkgbase}/dnspod.json")

  packaging $pkgname 0123
}

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