From 28da784b288eaec090e13320d8cd46524c6ae962 Mon Sep 17 00:00:00 2001 From: tastytea Date: Tue, 24 May 2022 21:05:57 +0200 Subject: [PATCH] www-apps/misskey: add option to not install full source code --- www-apps/misskey/metadata.xml | 1 + www-apps/misskey/misskey-12.110.1-r5.ebuild | 134 ++++++++++++++++++++ 2 files changed, 135 insertions(+) create mode 100644 www-apps/misskey/misskey-12.110.1-r5.ebuild diff --git a/www-apps/misskey/metadata.xml b/www-apps/misskey/metadata.xml index 86801f0..d0f7e0a 100644 --- a/www-apps/misskey/metadata.xml +++ b/www-apps/misskey/metadata.xml @@ -22,5 +22,6 @@ Make init script depend on nginx + Install full source code diff --git a/www-apps/misskey/misskey-12.110.1-r5.ebuild b/www-apps/misskey/misskey-12.110.1-r5.ebuild new file mode 100644 index 0000000..9335e6e --- /dev/null +++ b/www-apps/misskey/misskey-12.110.1-r5.ebuild @@ -0,0 +1,134 @@ +# Copyright 2022 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +# TODO: systemd support, ffmpeg USE-flags, postgresql USE-flags, +# nginx USE-flags, bundle node_modules/cypress deps + +EAPI=7 + +inherit optfeature savedconfig + +# NOTE: update for each bump +MY_COMMIT_ASSETS="0179793ec891856d6f37a3be16ba4c22f67a81b5" + +DESCRIPTION="An interplanetary microblogging platform" +HOMEPAGE="https://misskey-hub.net/" +SRC_URI=" + https://github.com/misskey-dev/misskey/archive/refs/tags/${PV}.tar.gz -> ${P}.tar.gz + https://github.com/misskey-dev/assets/archive/${MY_COMMIT_ASSETS}.tar.gz -> ${PN}-assets-${PV}.tar.gz + https://tastytea.de/files/gentoo/${P}-deps.tar +" + +# NOTE: To generate the (incomplete) deps archive: +# echo 'yarn-offline-mirror "./npm-cache"' >> .yarnrc +# echo 'cache=./npm_cache' >> .npmrc +# yarn install +# tar -caf ${P}-deps.tar npm-cache + +LICENSE="GPL-3" +SLOT="0" +KEYWORDS="~amd64" +IUSE="nginx +source" + +REQUIRED_USE="savedconfig" + +RESTRICT="network-sandbox" + +COMMON_DEPEND=" + net-libs/nodejs:0/16 + sys-apps/yarn +" +BDEPEND=" + ${COMMON_DEPEND} + dev-lang/nasm + virtual/pkgconfig +" +RDEPEND=" + ${COMMON_DEPEND} + acct-user/misskey + dev-db/postgresql + dev-db/redis + nginx? ( www-servers/nginx ) +" + +src_unpack() { + default + mv --no-target-directory assets-${MY_COMMIT_ASSETS} ${P}/${PN}-assets \ + || die "Could not move assets" + mv npm-cache ${P}/ || die "Could not move npm cache" +} + +src_prepare() { + yarn config set yarn-offline-mirror $(realpath ./npm-cache) \ + || die "Setting up npm offline cache failed" + npm config set cache $(realpath ./npm-cache) \ + || die "Setting up npm offline cache failed" + + restore_config .config/default.yml + if [[ ! -f .config/default.yml ]]; then + eerror "Edit .config/example.yml and save it to the location mentioned above" + die "No config file found" + fi + + default +} + +src_compile() { + # this still downloads stuff 🙃 + yarn --offline install || die "dependency installation failed" + NODE_ENV=production yarn --offline build || die "build failed" +} + +src_install() { + rm -rf npm-cache || die "Deleting cache failed" + + insinto opt/misskey/misskey + insopts -o misskey -g misskey + if use source; then + doins -r . + else + doins -r package.json .node-version .config built packages + fi + + # insopts doesn't affect directories + chown --recursive misskey:misskey "${ED}"/opt/misskey/misskey + chmod o= "${ED}"/opt/misskey/misskey + + newinitd ${FILESDIR}/${PN}.initd ${PN} + if use nginx; then + sed -i 's/use logger$/use logger nginx/' "${ED}"/etc/init.d/${PN} \ + || die "Could not modify OpenRC init script" + fi + + einstalldocs +} + +pkg_postinst() { + elog "Run emerge --config ${CATEGORY}/${PN} to initialise the PostgreSQL database" + + einfo "Running 'yarn migrate'" + su --shell /bin/bash --login --command \ + "cd misskey && yarn --verbose migrate" \ + misskey || die "migration failed" + + if use nginx; then + einfo "An nginx example config can be found at " + fi + + optfeature "thumbnail generation support" media-video/ffmpeg +} + +pkg_config() { + einfo "Initialising PostgreSQL database" + echo -n "password for misskey user: " + read MY_PASSWORD + echo "create database misskey; create user misskey with encrypted password '${MY_PASSWORD}'; grant all privileges on database misskey to misskey; \q" \ + | su -lc psql postgres || die "database creation failed" + + su --shell /bin/bash --login --command \ + "cd misskey && yarn --verbose run init" \ + misskey || die "database initialisation failed" + + ewarn "When you first start Misskey you will be asked to add an admin account via the web interface, and registrations are enabled." + ewarn "Do not expose the web interface to the public until after you configured your instance\!" +}