summaryrefslogtreecommitdiff
path: root/pcr/acmetool/PKGBUILD
blob: 0e7348e05dfbb2afd1409ae5e12cc09130803c28 (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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# Maintainer: Luke Shumaker <lukeshu@parabola.nu>

pkgname=acmetool
pkgver=0.0.24
url=https://github.com/hlandau/acme
pkgdesc="Automatic certificate acquisition tool for ACME (Let's Encrypt)"

pkgrel=1
arch=(x86_64 i686)
depends=(libcap)
makedepends=(go)

_source=(
  #import-path                      license    version download-spec
  "github.com/hlandau/acme          MIT        $pkgver %n-%v.tar.gz::https://github.com/hlandau/%n/archive/v%v.tar.gz"

  'github.com/coreos/go-systemd     Apache     4       %n-%v.tar.gz::https://github.com/coreos/%n/archive/v%v.tar.gz'
  'github.com/godbus/dbus           BSD2       3       %n-%v.tar.gz::https://github.com/godbus/%n/archive/v%v.tar.gz'
  'gopkg.in/alecthomas/kingpin.v2   MIT        2.1.8   %n-%v.tar.gz::https://github.com/alecthomas/%n/archive/v%v.tar.gz'
  'gopkg.in/hlandau/configurable.v1 MIT        1.0.1   %n-%v.tar.gz::https://github.com/hlandau/%n/archive/v%v.tar.gz'
  'gopkg.in/hlandau/easyconfig.v1   MIT        1.0.12  %n-%v.tar.gz::https://github.com/hlandau/%n/archive/v%v.tar.gz'
  'gopkg.in/hlandau/service.v2      ISC        2.0.12  %n-%v.tar.gz::https://github.com/hlandau/%n/archive/v%v.tar.gz'
  'gopkg.in/hlandau/svcutils.v1     MIT,Apache 1.0.3   %n-%v.tar.gz::https://github.com/hlandau/%n/archive/v%v.tar.gz'
  'gopkg.in/tylerb/graceful.v1      MIT        1.2.3   %n-%v.tar.gz::https://github.com/tylerb/%n/archive/v%v.tar.gz'

  'github.com/alecthomas/template   BSD3      14fd436dd20c3cc65242a9f396b61bfc8a3926fc %n-%v.tar.gz::https://github.com/alecthomas/%n/archive/%v.tar.gz'
  'github.com/alecthomas/units      MIT       2efee857e7cfd4f3d0138cc3cbb1b4966962b93a %n-%v.tar.gz::https://github.com/alecthomas/%n/archive/%v.tar.gz'
  'github.com/hlandau/degoutils     MIT       84ffe62d5c43845c9cf4de43a94dd1c0ad102eb4 %n-%v.tar.gz::https://github.com/hlandau/%n/archive/%v.tar.gz'
  'github.com/hlandau/xlog          MIT       c37f75515760879c01260fdb842000f8af5c665c %n-%v.tar.gz::https://github.com/hlandau/%n/archive/%v.tar.gz'
  'github.com/hlandauf/gspt         MIT       25f3bd3f5948489aa5f31c949310ae9f2b0e956c %n-%v.tar.gz::https://github.com/hlandauf/%n/archive/%v.tar.gz'
  'github.com/hlandauf/pb           BSD3      0c1cdefd84b3b1937c4e54309f3a817d9c683bab %n-%v.tar.gz::https://github.com/hlandauf/%n/archive/%v.tar.gz'
  'github.com/mattn/go-isatty       MIT       56b76bdf51f7708750eac80fa38b952bb9f32639 %n-%v.tar.gz::https://github.com/mattn/%n/archive/%v.tar.gz'
  'github.com/ogier/pflag           BSD3      6f7159c3154e7cd4ab30f6cc9c58fa3fd0f22325 %n-%v.tar.gz::https://github.com/ogier/%n/archive/%v.tar.gz'
  'github.com/peterhellberg/link    MIT       1053d3b2893eeebd482fce32550ec24bebed308c %n-%v.tar.gz::https://github.com/peterhellberg/%n/archive/%v.tar.gz'
  'github.com/satori/go.uuid        MIT       d41af8bb6a7704f00bc3b7cba9355ae6a5a80048 %n-%v.tar.gz::https://github.com/satori/%n/archive/%v.tar.gz'
  'github.com/shiena/ansicolor      MIT       a422bbe96644373c5753384a59d678f7d261ff10 %n-%v.tar.gz::https://github.com/shiena/%n/archive/%v.tar.gz'
  'github.com/square/go-jose        MIT       37934a899dd03635373fd1e143936d32cfe48d31 %n-%v.tar.gz::https://github.com/square/%n/archive/%v.tar.gz'
  'golang.org/x/crypto              BSD3      287a1d87db5d649b01d6193bd9d07e909f08094c %n-%v.tar.gz::https://github.com/golang/%n/archive/%v.tar.gz'
  'golang.org/x/net                 BSD3      0cb26f788dd4625d1956c6fd97ffc4c90669d129 %n-%v.tar.gz::https://github.com/golang/%n/archive/%v.tar.gz'
  'gopkg.in/yaml.v2                 MIT,LGPL3 f7716cbe52baa25d2e9b0d0da546fcf909fc16b4 %n-%v.tar.gz::https://github.com/go-yaml/%n/archive/%v.tar.gz'
)
license=($(
  for spec in "${_source[@]}"; do
    read import lic ver dlspec <<<"$spec"
    printf '%s\n' ${lic//,/ }
  done | sort -u
))
source=($(
  for spec in "${_source[@]}"; do
    read import lic ver dlspec <<<"$spec"
    name=${import##*/}
    name=${name%%.v*}
    dlspec=${dlspec//%v/$ver}
    dlspec=${dlspec//%n/$name}
    echo "${dlspec}"
  done
))
md5sums=('1665cccb5620e3c277f870d353a838ec'
         '53a269ddb176ecfcbe39fd93ab6b8cf9'
         '65437268cb4303ecf75632a8947456a1'
         '46b75c8abf30235d5e2b464b5a6a5ec8'
         'b08b85ab86aa2bc685b0345f60709db3'
         'dba8984bc7c215de505f71a02577090d'
         'aa5b19990a6779f84975d9209b9a1c56'
         '18c01ebf2e94c3690551408ed090eccb'
         'df74248ea9f7194e01807d01b7f7017f'
         '864d73ecd1ae680ad5ba91ccfb159768'
         'fef2a852aab48bbfd89cd872b315ce11'
         '8575e4bedf95d9d37c206a7227d54381'
         'bf8eacbb1da5e8b905b01ee5885e108e'
         '5112b44c1dce49d44059c5fd20689aa6'
         'ba34f661954c087d252c58e3f1be2b92'
         'eaed246cf927a4aa2cd2c01959ccd632'
         'd42c2a7d949727be216d9a24c6b23475'
         'e8d4098ecc2e61be5bbaa18d788fecfa'
         '2d3ca6484a442dd89d7e11a8b4f8f8a2'
         '4f1ce87e11abc3da157a380bce08a256'
         '6f42205b50935e199317fd7d59539e04'
         '4f25ea0cac57961549fbdf9dd7744557'
         'f972181d55531f81b9c581655e25f188'
         'c5df18d531e894a7c231ef19a7332345')

prepare() {
  cd "$srcdir"
  local spec import ver dlspec name tarname
  for spec in "${_source[@]}"; do
    read import lic ver dlspec <<<"$spec"
    name=${import##*/}
    name=${name%%.v*}
    dlspec=${dlspec//%v/$ver}
    dlspec=${dlspec//%n/$name}
    tarname="$(get_filename "${dlspec}")"
    mkdir -p "$(dirname "gopath/src/$import")"
    ln -srTf "${tarname%.tar.gz}" "gopath/src/$import"
  done
}

build() {
  cd "$srcdir/gopath"
  GOPATH=$PWD go install github.com/hlandau/acme/cmd/acmetool
}

package() {
  cd "$srcdir"
  install -Dm755 gopath/bin/acmetool "$pkgdir"/usr/bin/acmetool
  install -d "$pkgdir"/usr/share/doc/$pkgname
  install -Dm644 acme-$pkgver/README.md acme-$pkgver/_doc/* -t "$pkgdir"/usr/share/doc/$pkgname

  install -d "$pkgdir"/usr/share/licenses/$pkgname
  local spec import lic ver dlspec name base found
  for spec in "${_source[@]}"; do
    read import lic ver dlspec <<<"$spec"
    name=${import##*/}
    name=${name%%.v*}

    base=$name
    if [[ $name != acme ]]; then
      base=lib-$base
    fi
    base="$pkgdir"/usr/share/licenses/$pkgname/$base
    case $name in
      svcutils)
        grep -h © $name-$ver/systemd/*|sort -u > $base-systemd.txt
        {
          echo 'The license of gopkg.in/hlandau/svcutils.v1/exepath is unspecified,'
          echo 'but based on the authorship, it can safely be assumed to be MIT-license'
        } > $base-exepath.txt
        ;;
      xlog)
        {
          echo 'The license of github.com/hlandau/xlog is unspecified,'
          echo 'but based on the authorship, it can safely be assumed to be MIT-license'
        } > $base.txt
        ;;
      service)
        sed -n '/ISC License/,${s/^\s*//p}' $name-$ver/README.md > $base.txt
        ;;
      link)
        sed -n '/# License/,$p' $name-$ver/README.md > $base.txt
        ;;
      template)
        install -m644 /usr/share/licenses/go/LICENSE $base.txt
        ;;
      yaml)
        install -m644 $name-$ver/LICENSE         $base-primary.LICENSE.txt
        install -m644 $name-$ver/LICENSE.libyaml $base-libyaml.LICENSE.txt
        ;;
      *)
        found=false
        for file in $name-$ver/LICENSE $name-$ver/COPYING $name-$ver/PATENTS; do
          if test -f "$file"; then
            install -m644 "$file" $base.${file##*/}.txt
            found=true
          fi
        done
        if ! $found; then
          grep © $name-$ver/README.md > $base.txt
        fi
        ;;
    esac
  done
}