summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 22c05ceb789d8a49f416a701069e9a1b1aba262b (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
# Maintainer: lsf

pkgname='envizon-git'
_pkgname='envizon'
pkgver=38.810f89c
pkgrel=1
pkgdesc='network visualization tool with focus on red / blue team requirements'
url='https://evait-security.github.io/envizon/'
license=('MIT')
depends=('ruby' 'ruby-bundler' 'git' 'postgresql'
         'openssl' 'libxml2' 'libxslt' 'xz' 'x11-ssh-askpass')
makedepends=('git')
arch=('any')
source=("git+https://github.com/evait-security/${_pkgname}.git"
        "${_pkgname}.sysusers.conf"
        "db_setup.sh")
install="${_pkgname}.install"
sha1sums=('SKIP'
          '59f638f39ebf1f4e05928071e5dd0fbbb9bffc92'
          '53199f7d1210e1a85a7045426a8b7949c324a475')
options=('!strip')

pkgver() {
  cd "$srcdir/${_pkgname}"

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

build() {
  cd "$srcdir/${_pkgname}"
  bundle config --local build.nokogiri --use-system-libraries
  bundle install --path vendor/bundle --without development test -j"$(nproc)" --no-cache
  mkdir -p .ssl
}

package() {
  mkdir -p "$pkgdir/usr/lib/sysusers.d/" \
                   "$pkgdir/usr/bin" \
                   "$pkgdir/opt"

  install -m644 "${_pkgname}.sysusers.conf"\
    "$pkgdir/usr/lib/sysusers.d/${_pkgname}.conf"

  cp -ar "${_pkgname}" "$pkgdir/opt/${_pkgname}"
  cp db_setup.sh "$pkgdir/opt/${_pkgname}/"
  chmod +x "$pkgdir/opt/${_pkgname}/"

  rm -rf "$pkgdir/opt/${_pkgname}/docker"
  rm -rf "$pkgdir/opt/${_pkgname}/.github"

  chmod -R g+w "$pkgdir/opt/${_pkgname}"

  cat > "$pkgdir/usr/bin/${_pkgname}" << EOF
#!/bin/sh
cd /opt/${_pkgname}
export SECRET_KEY_BASE=\$(cat config/secret)
RAILS_ENV=production
export RAILS_ENV
bundle exec rails db:migrate
bundle exec rails db:seed
bundle exec rails assets:precompile
RAILS_FORCE_SSL=true RAILS_SERVE_STATIC_FILES=true exec bundle exec rails s
EOF

  chmod +x "$pkgdir/usr/bin/${_pkgname}"
}