ayaports/user/mastodon/APKBUILD

203 lines
5.6 KiB
Text

# Maintainer: Antoine Martin (ayakael) <dev@ayakael.net>
# Contributor: Antoine Martin (ayakael) <dev@ayakael.net>
pkgname=mastodon
_pkgname=$pkgname
pkgver=4.2.4
_gittag=v$pkgver
pkgrel=0
pkgdesc="Self-hosted social media and network server based on ActivityPub and OStatus"
arch="x86_64"
url="https://github.com/mastodon/mastodon"
license="AGPL-3.0-only"
depends="
$pkgname-assets=$pkgver-r$pkgrel
ffmpeg
file
gcompat
imagemagick
nodejs
npm
protobuf
py3-elasticsearch
redis
ruby
ruby-bundler
yarn
"
makedepends="
gnu-libiconv-dev
icu-dev
libffi-dev
libidn-dev
libxml2-dev
libxslt-dev
openssl-dev
postgresql-dev
protobuf-dev
ruby-dev
yaml-dev
zlib-dev
"
install="
$pkgname.pre-install
$pkgname.post-upgrade
$pkgname.post-install
"
source="
mastodon-$_gittag.tar.gz::https://github.com/mastodon/mastodon/archive/$_gittag.tar.gz
mastodon.initd
mastodon.web.initd
mastodon.sidekiq.initd
mastodon.streaming.initd
mastodon.logrotate
bin-wrapper.in
"
subpackages="$pkgname-openrc $pkgname-assets::noarch"
options="!check" # No test suite
_prefix="usr/lib/bundles/$_pkgname"
export BUNDLE_DEPLOYMENT=true
export BUNDLE_FORCE_RUBY_PLATFORM=true
export BUNDLE_FROZEN=true
export BUNDLE_JOBS=${JOBS:-2}
prepare() {
default_prepare
# Allow use of any bundler
sed -i -e '/BUNDLED/,+1d' Gemfile.lock
# Allow use of higher Node versions
sed -i 's/"node": .*"/"node": ">=14.15"/' package.json
mkdir -p "$srcdir"/gem-cache
}
build() {
local bundle_without='exclude development'
msg "Installing Ruby gems..."
bundle config --local build.nokogiri --use-system-libraries \
--with-xml2-include=/usr/include/libxml2 \
--with-xslt-include=/usr/include/libxslt
bundle config --local build.ffi --enable-system-libffi
bundle config --local build.idn --enable-system-libidn
bundle config --local path "vendor/bundle"
bundle config --local set deployment 'false'
bundle config --local set without "$bundle_without"
bundle install --no-cache -j"$(getconf _NPROCESSORS_ONLN)"
msg "Installing npm modules..."
yarn install --production --frozen-lockfile
(
msg "Compiling assets..."
export NODE_ENV=production
export RAILS_ENV=production
export NODE_OPTIONS="--openssl-legacy-provider"
OTP_SECRET=precompile_placeholder SECRET_KEY_BASE=precompile_placeholder bundle exec rails assets:precompile
)
msg "Cleaning assets gems..."
bundle config --local without "$bundle_without"
bundle clean
# Create executables in bin/*.
# See also https://github.com/bundler/bundler/issues/6149.
bundle binstubs --force bundler puma sidekiq
}
package() {
local destdir="$pkgdir"/$_prefix
local datadir="$pkgdir/var/lib/gitlab"
# directory creation
install -dm 755 \
"$destdir" \
"$datadir" \
"$pkgdir"/etc/init.d
# Install application files.
rmdir "$destdir"
cp -a "$builddir" "$destdir"
install -m755 -t "$destdir"/bin/ \
bin/bundle \
bin/rails \
bin/rake \
bin/sidekiq \
bin/sidekiqmon \
bin/tootctl \
bin/puma
cd "$destdir"/vendor/bundle/ruby/*/
# Remove tests, documentations and other useless files.
find gems/ \( -name 'doc' \
-o -name 'spec' \
-o -name 'test' \) \
-type d -maxdepth 2 -exec rm -fr "{}" +
find gems/ \( -name 'README*' \
-o -name 'CHANGELOG*' \
-o -name 'CONTRIBUT*' \
-o -name '*LICENSE*' \
-o -name 'Rakefile' \
-o -name '.*' \) \
-type f -delete
# Remove assets, they are already compiled.
rm -r gems/doorkeeper-*/app/assets
rm -r gems/pghero-*/app/assets
# Remove build logs and cache.
rm -rf build_info/ cache/
find extensions/ \( -name gem_make.out -o -name mkmf.log \) -delete
cat > "$datadir"/.profile <<-EOF
export RAILS_ENV=production
export NODE_ENV=production
export EXECJS_RUNTIME=Disabled
EOF
# Install wrapper scripts to /usr/bin.
local name; for name in rake rails tootctl; do
sed "s/__COMMAND__/$name/g" "$srcdir"/bin-wrapper.in \
> "$builddir"/mastodon-$name
install -m755 -D "$builddir"/mastodon-$name "$pkgdir"/usr/bin/mastodon-$name
done
# Put the config file in /etc and link to it
touch "$pkgdir"/etc/mastodon.conf
ln -s /etc/mastodon.conf "$destdir"/.env.production
ln -s /usr/bin/node "$destdir"/node
for file in $_pkgname $_pkgname.sidekiq $_pkgname.web $_pkgname.streaming; do
install -m755 -D "$srcdir"/$file.initd "$pkgdir"/etc/init.d/$file
done
# Removing all prebuilt artifacts
rm -R "$destdir"/node_modules/*/prebuilds 2>&1 || true
install -m644 -D "$srcdir"/$_pkgname.logrotate \
"$pkgdir"/etc/logrotate.d/$_pkgname
}
assets() {
depends=""
amove $_prefix/public/assets
}
sha512sums="
9c52e0998947aaf4d1ccd70ffddee769bf1efec32a33225c602591b84940d0b478698309f385bf202e3feb62df183377c18007d01888ea882adfb2583b1820dc mastodon-v4.2.4.tar.gz
36604cd630f0f5b4d88b630b1512cd26e922f859e5d19cbb85106ff29fc9048d2349f926d5c4b6947c655f67e60ec33e2f524a8154405a4369f283e00be7cdce mastodon.initd
9e77061fbdebe90492398f8089a7d2612ff4b6e70b5462dd67330b66d9788cb0133eab38c372b1f27a7214aacdd9f7f70381d4ecc6e92c8c38d794404ae0f840 mastodon.web.initd
6dacafca86dd39f6a6efa773cfe35b4632098175605a7c64488027237b01028d9785e50a3a0532b88ebf8f857c9a594c7b68f9e577b46e95104e7cffde51ccf8 mastodon.sidekiq.initd
63b67ec16107e4d1747ae956cdd41edd03be71da1ed96d21a18710cbba69ce37c856f4abc080a61f172a10859d0b9a33ba9290fc69213e1bc15a1ce8f8d40108 mastodon.streaming.initd
83b3bae5b6fdb4d0dbc1cbe546c62c0aa77397b97d1a5d5377af032466677de188065b556710c0d96576bbae89cc76800f1ffb8cd718155eb2784da818f27619 mastodon.logrotate
dfd0e43ac6c28387bd4aa57fd98ae41aeb5a098b6deb3e44b89f07818e2470773b025364afee7ef6fd0f664cb86bbbbe8796c9f222f5436c256a787282fbe3e1 bin-wrapper.in
"