summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 62ee9ac0b67598855e045ef1af1d544cabfeadd9 (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
# Maintainer: Caleb Maclennan <caleb@alerque.com>

pkgname=mastodon-git
pkgver=1.2.2_22_ga0ed88a9
_branch=master
pkgrel=0.2
pkgdesc="A GNU Social-compatible microblogging server"
arch=('i686' 'x86_64')
url="https://mastodon.social"
license=('AGPL-3.0')
provides=("${pkgname%-git}")
conflicts=("${pkgname%-git}" "${pkgname%-git}-docker" "${pkgname%-git}-docker-git")
makedepends=(
    'yarn'
    'ruby-bundler>=1.14.6'
    )
depends=(
    'ffmpeg'
    'imagemagick'
    'libpqxx'
    'libxml2'
    'libxslt'
    'nodejs'
    'postgresql'
    'redis'
    'ruby>=2.4.0'
    )
source=(
    "git://github.com/tootsuite/${pkgname%-git}.git#branch=$_branch"
    "mastodon-web.service"
    "mastodon-sidekiq.service"
    "mastodon-streaming.service"
    "mastodon.target"
    )
backup=("etc/mastodon/env.production")
sha256sums=('SKIP'
            '2b3a22149ee88c4bacf83aa1958b06fc791057089737596b35b6e1968b1443aa'
            '5f72e3ee2921f8b760bac614d910a3c36334ebfefdfd4ba0c9058e21d8537c73'
            '5a7bd6a66b93480468483205a12640317f5df5de3b4b4b6fcee38976bff606e4'
            '0920e862a1ad598022743381f2b0a38c3c745c7e1a6566c3fe51275bbef82e72')
install=mastodon.install
_user=mastodon
_homedir=/var/lib/mastodon
_shell=/bin/false

pkgver() {
  cd "${pkgname%-git}"
  git describe --long --tags | sed 's/^v//;s/-/_/g'
}

prepare() {
  bundle install --deployment --without development test
  yarn install
}

build() {
  cd "${pkgname%-git}"
  RAILS_ENV=production bundle exec rails assets:precompile
}

post_install() {
  sed -i -e "/^PAPERCLIP_SECRET=\$/s/\$/$(rake secret)/" \
         -e "/^SECRET_KEY_BASE=\$/s/\$/$(rake secret)/" \
         -e "/^OTP_SECRET=\$/s/\$/$(rake secret)/" \
         -e "/^REDIS_HOST=redis\$/s/redis\$/localhost/" \
         -e "/^DB_HOST=db\$/s/redis\$/localhost/" \
      /etc/mastodon/env.production

  echo "1. Configure your instance:"
  echo "    $ vim /etc/mastodon/env.production"
  echo ""
  echo "2. Create a postgres user for mastodon:"
  echo "    $ sudo -u postgres psql"
  echo "    > CREATE USER mastodon CREATEDB;"
  echo ""
  echo "3. Then setup the database for the first time:"
  echo "    $ cd ~mastodon && sudo -u mastodon RAILS_ENV=production bundle exec rails db:setup"
  echo ""
  echo "4. Create an administrator account:"
  echo "    $ cd ~mastodon && sudo -u mastodon RAILS_ENV=production bundle exec rails mastodon:make_admin USERNAME=<username>"
  echo ""
  echo "5. Enable and start instance:"
}

post_upgrade() {
  cd ~mastodon && sudo -u mastodon RAILS_ENV=production bundle exec rails db:migrate
}

package() {
  cd "${pkgname%-git}"

  install -Dm 644 .env.production.sample ${pkgdir}/etc/mastodon/env.production

  for service in mastodon-{web,sidekiq,streaming}.service mastodon.target; do
    install -Dm644 "${srcdir}/${service}" "${pkgdir}/usr/lib/systemd/system/${service}"
  done
}