summaryrefslogtreecommitdiff
path: root/www-apps/pleroma/pleroma-2.10.2.ebuild
blob: ea7f5292580e8e8daa99289f7ed11512edc62bdf (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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# Copyright 2022-2026 Haelwenn (lanodan) Monnier <contact@hacktivis.me>
# Distributed under the terms of the GNU General Public License v2

EAPI=7

inherit mix optfeature flag-o-matic toolchain-funcs

DESCRIPTION="ActivityPub social networking software compatible with other Fediverse software"
HOMEPAGE="https://pleroma.social/"
if [[ "${PV}" == *9999 ]]; then
	inherit git-r3
	EGIT_REPO_URI="https://git.pleroma.social/pleroma/pleroma"
else
	SRC_URI="https://git.pleroma.social/pleroma/pleroma/archive/v${PV}.tar.gz -> pleroma-${PV}.tar.gz"
	S="${WORKDIR}/${PN}"
	KEYWORDS="~amd64"
fi
LICENSE="AGPL-3 CC-BY-SA-4.0 CC-BY-4.0"
SLOT="otp"

IUSE="+system-lexbor +system-vips"

# Requires network access (https) as long as elixir dependencies aren't packaged
# said dependencies have their checksum verified via `mix.lock`
RESTRICT="network-sandbox"

BDEPEND="
	<dev-lang/erlang-27:=
	>=dev-lang/elixir-1.14:=
	<dev-lang/elixir-1.18
	dev-build/cmake
	>=dev-util/rebar-3.20.0-r1
	dev-elixir/hex
	dev-vcs/git
"
DEPEND="
	dev-libs/glib
	sys-apps/file
	sys-libs/ncurses:=
	system-lexbor? ( dev-libs/lexbor )
	system-vips? ( media-libs/vips:= )
"
RDEPEND="
	${DEPEND}
	acct-user/pleroma
	acct-group/pleroma
	dev-db/postgresql[uuid]
"

src_unpack() {
	default

	[[ "${PV}" == *9999 ]] && git-r3_src_unpack

	cd "${S}" || die
	emix deps.get --only prod
}

src_prepare() {
	default

	# Point to the correct source repo, needed for AGPL compliance
	if [[ "${PV}" == *9999 ]] && [[ -n "${EGIT_OVERRIDE_REPO}" ]]; then
		sed -i "s!source_url: .*!source_url: \"${EGIT_OVERRIDE_REPO}\",!" mix.exs || die
	fi

	# strip_beams: Keep debug information in Erlang BEAM bytecode
	# include_erts: Depend on system erlang for the runtime
	sed -i '/include_executables_for:/a\          strip_beams: false,\n\          include_erts: false,' mix.exs || die

	sed -i \
		-e '/update \[OPTIONS\]/,/--tmp-dir/d' \
		-e 's;update "$@";echo "Unsupported, check the '"${CATEGORY}/${PN}"' package instead.";' \
		rel/files/bin/pleroma_ctl || die

	# Default ends up being inside /opt/pleroma which should be kept read-only to pleroma
	echo 'config :tzdata, :data_dir, "/var/lib/pleroma/tzdata"' >> config/prod.exs || die

	echo "import Config" > config/prod.secret.exs || die
}

src_compile() {
	mkdir -p pleroma || die

	tc-export CC

	# Needs -fPIC under glibc for exile library
	# https://bugs.gentoo.org/937130
	append-flags -fPIC

	use system-vips && export VIX_COMPILATION_MODE="PLATFORM_PROVIDED_LIBVIPS"

	use system-lexbor && export WITH_SYSTEM_LEXBOR=1

	emix release --overwrite --path pleroma
}

src_install() {
	# doins doesn't seems to preserve permissions
	mkdir -p "${ED}/opt" || die
	cp -pr ./pleroma "${ED}/opt/pleroma" || die
	fperms 0750 /opt/pleroma
	fperms -R g-w,o= /opt/pleroma
	fowners -R 0:pleroma /opt/pleroma

	doinitd ./pleroma/installation/init.d/pleroma

	# Generated by Elixir, see lib/mix/lib/mix/tasks/release.init.ex
	# Real executable needs to be in /opt/pleroma/bin due to usage of readlink to guess install path
	dosym /opt/pleroma/bin/pleroma /usr/bin/pleroma

	# Technically could be with regular binaries via dobin,
	# but useless without the pleroma command, which has restricted access
	dosym /opt/pleroma/bin/pleroma_ctl /usr/bin/pleroma_ctl

	# This file controls console access
	fperms 0750 /opt/pleroma/releases/COOKIE
	fowners 0:pleroma /opt/pleroma/releases/COOKIE

	keepdir /etc/pleroma
	fperms 0750 /etc/pleroma
	fowners 0:pleroma /etc/pleroma

	keepdir /var/lib/pleroma
	fperms 0750 /var/lib/pleroma
	fowners pleroma:pleroma /var/lib/pleroma

	# So that www-apps/pleroma-fe (optional) doesn't ends up creating namespace conflicts
	dosym /opt/pleroma-fe/dist /var/lib/pleroma/static/frontends/pleroma-fe/gentoo
}

pkg_postinst() {
	optfeature "For Pleroma.Upload.Filters.{Mogrify,Mogrifun} & images in previews" media-gfx/imagemagick
	optfeature "For video support in Media Preview Proxy" media-video/ffmpeg
	optfeature "For Pleroma.Upload.Filters.Exiftool.* filters" media-libs/exiftool
	optfeature "Allows to pick system-managed frontend instead of bundled" www-apps/pleroma-fe
}