Add 'mastodon/' from commit 'a72bcf412ae60f27d34805b662973400606bbd56'

git-subtree-dir: mastodon
git-subtree-mainline: 794a9fac74
git-subtree-split: a72bcf412a
This commit is contained in:
Anthony Wang 2023-11-11 19:09:29 -05:00
commit 996cb8e076
7 changed files with 150 additions and 0 deletions

38
mastodon/.SRCINFO Normal file
View file

@ -0,0 +1,38 @@
pkgbase = mastodon
pkgdesc = Your self-hosted, globally interconnected microblogging community
pkgver = 4.2.1
pkgrel = 1
url = https://github.com/mastodon/mastodon
install = mastodon.install
arch = any
license = AGPL3
depends = ffmpeg
depends = gcc
depends = git
depends = imagemagick
depends = libidn
depends = libpqxx
depends = libxml2
depends = libxslt
depends = libyaml
depends = make
depends = nodejs
depends = postgresql
depends = protobuf
depends = redis
depends = ruby-bundler
depends = sudo
depends = yarn
depends = zlib
options = !strip
backup = etc/mastodon.conf
source = https://github.com/mastodon/mastodon/archive/v4.2.1.tar.gz
source = mastodon.target
source = mastodon.sysusers.d
source = mastodon.tmpfiles.d
sha512sums = 54e3e14abbe9ce6b4ec72586b00d0e7845b8e7b0f18ee608ab452a4b56df257657ffcd1f3a0b8de715dbaad3edacbf31a4e20cef5f5d82b6902837ee9a6ab900
sha512sums = c9820c2a83d08bd5d842a78e924682db97ebd5c7291b682603ad30dafcdcc5816c13e717ad39554f042b9d9ed71ab902ce3f604952264a900a72612ee8060acb
sha512sums = 4ee4210bde391e6dc782cb7c14f2cb968c95ad541aa0efcf843a811f8cc5f0d1067ee3c8346bb412aa9fd1dd5a8bd05a4524df7dc4a106957009853dd237074a
sha512sums = 27c4eb01d462c525b59e5808a3b2501b63a34425752128388fbde82f7eb5944b20d2f8d8b1be8ed8adb165cab4cfb8e13f90215f20989ca671a0422ffa37001f
pkgname = mastodon

3
mastodon/.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
pkg/
src/
*.tar.*

76
mastodon/PKGBUILD Normal file
View file

@ -0,0 +1,76 @@
# Maintainer: Anthony Wang <a at exozy dot me>
# Contributor: ny-a <nyaarch64 at gmail dot com>
# Contributor: Daniel Moch <daniel@danielmoch.com>
# Contributor: Jean Lucas <jean@4ray.co>
# Contributor: Fredrick Brennan <copypaste@kittens.ph>
pkgname=mastodon
pkgver=4.2.1
pkgrel=1
pkgdesc='Your self-hosted, globally interconnected microblogging community'
arch=(any)
url=https://github.com/mastodon/mastodon
license=(AGPL3)
depends=(ffmpeg
gcc
git
imagemagick
libidn
libpqxx
libxml2
libxslt
libyaml
make
nodejs
postgresql
protobuf
redis
ruby-bundler
sudo
yarn
zlib)
backup=(etc/mastodon.conf)
install=mastodon.install
options=(!strip)
source=(https://github.com/mastodon/mastodon/archive/v$pkgver.tar.gz
mastodon.target
mastodon.sysusers.d
mastodon.tmpfiles.d)
sha512sums=('54e3e14abbe9ce6b4ec72586b00d0e7845b8e7b0f18ee608ab452a4b56df257657ffcd1f3a0b8de715dbaad3edacbf31a4e20cef5f5d82b6902837ee9a6ab900'
'c9820c2a83d08bd5d842a78e924682db97ebd5c7291b682603ad30dafcdcc5816c13e717ad39554f042b9d9ed71ab902ce3f604952264a900a72612ee8060acb'
'4ee4210bde391e6dc782cb7c14f2cb968c95ad541aa0efcf843a811f8cc5f0d1067ee3c8346bb412aa9fd1dd5a8bd05a4524df7dc4a106957009853dd237074a'
'27c4eb01d462c525b59e5808a3b2501b63a34425752128388fbde82f7eb5944b20d2f8d8b1be8ed8adb165cab4cfb8e13f90215f20989ca671a0422ffa37001f')
build() {
cd mastodon-$pkgver
mkdir -p .git # Fix husky error
bundle config deployment 'true'
bundle config without 'development test'
bundle install -j$(getconf _NPROCESSORS_ONLN)
yarn install --pure-lockfile
}
package() {
install -d "$pkgdir"/{var/lib,etc}
cp -a mastodon-$pkgver "$pkgdir"/var/lib/mastodon
# Put the config file in /etc and link to it
touch "$pkgdir"/etc/mastodon.conf
ln -s /etc/mastodon.conf "$pkgdir"/var/lib/mastodon/.env.production
ln -s /usr/bin/node "$pkgdir"/var/lib/mastodon/node
install -Dm 644 mastodon.target -t "$pkgdir"/usr/lib/systemd/system
install -Dm 644 mastodon.sysusers.d "$pkgdir"/usr/lib/sysusers.d/mastodon.conf
install -Dm 644 mastodon.tmpfiles.d "$pkgdir"/usr/lib/tmpfiles.d/mastodon.conf
cd mastodon-$pkgver/dist
# Fix path discrepancies
sed -e 's/home\/mastodon\/live/var\/lib\/mastodon/g' \
-e 's/home\/mastodon\/.rbenv\/shims/usr\/bin/' \
-i mastodon-*.service
sed -e 's/home\/mastodon\/live/var\/lib\/mastodon/g' \
-i nginx.conf
install -Dm 644 mastodon-*.service -t "$pkgdir"/usr/lib/systemd/system
}

23
mastodon/mastodon.install Normal file
View file

@ -0,0 +1,23 @@
post_install() {
echo "To setup Mastodon, enable and start PostgreSQL and Redis:
# systemctl enable --now postgresql redis
Create the Mastodon PostgreSQL user and grant it the ability to create databases with:
# sudo -u postgres createuser -d mastodon
Then, run:
# cd /var/lib/mastodon
# sudo chown mastodon:mastodon -R .
# sudo -u mastodon RAILS_ENV=production NODE_OPTIONS=--openssl-legacy-provider bundle exec rails mastodon:setup
Finally, enable and start all the required services:
# systemctl enable --now mastodon.target"
}
post_upgrade() {
cd /var/lib/mastodon
echo "Setting ownership of mastodon files"
find -path ./public/system -prune -o -exec chown -h mastodon:mastodon {} +
echo "Upgrading database schema"
sudo -u mastodon RAILS_ENV=production bundle exec rails db:migrate
echo "Precompiling assets"
sudo -u mastodon RAILS_ENV=production NODE_OPTIONS=--openssl-legacy-provider bundle exec rails assets:precompile
}

View file

@ -0,0 +1 @@
u mastodon - "Mastodon user" /var/lib/mastodon

7
mastodon/mastodon.target Normal file
View file

@ -0,0 +1,7 @@
[Unit]
Description=Mastodon
Wants=mastodon-web.service mastodon-sidekiq.service mastodon-streaming.service
Wants=postgresql.service redis.service
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,2 @@
d /var/lib/mastodon - mastodon mastodon
z /etc/mastodon.conf 0600 mastodon mastodon