blob: 9f6f4ce2fc8a0d66e256295dd36d51f905cb715f (
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
# Copyright 2023-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
CRATES="
"
declare -A GIT_CRATES=(
[mime-parse]='https://github.com/filips123/mime;e3e2e55459d2989a3f4699566ff8f203a8720add;mime-%commit%/mime-parse'
[mime]='https://github.com/filips123/mime;e3e2e55459d2989a3f4699566ff8f203a8720add;mime-%commit%'
[web_app_manifest]='https://github.com/filips123/WebAppManifestRS;c3329f3378a0039c96bd2b3f32529ea6b438c350;WebAppManifestRS-%commit%'
)
inherit cargo desktop flag-o-matic shell-completion toolchain-funcs xdg
DESCRIPTION="A tool to install, manage and use PWAs in Mozilla Firefox (native component)"
HOMEPAGE="https://pwasforfirefox.filips.si/"
SRC_URI="
https://github.com/filips123/PWAsForFirefox/archive/v${PV}.tar.gz -> ${P}.tar.gz
"
if [[ ${PKGBUMPING} != ${PVR} ]]; then
SRC_URI+="
https://github.com/filips123/PWAsForFirefox/releases/download/v${PV}/firefoxpwa-${PV}-crates.tar.xz
${CARGO_CRATE_URIS}
"
fi
S="${WORKDIR}/PWAsForFirefox-${PV}/native"
# Main project license
LICENSE="MPL-2.0"
# Dependent crate licenses
LICENSE+="
Apache-2.0 BSD-2 BSD ISC MIT MPL-2.0 UoI-NCSA Unicode-3.0 ZLIB
"
SLOT="0"
KEYWORDS="~amd64 ~arm64"
IUSE="custom-cflags lto static"
DEPEND="
!static? (
app-arch/zstd:=
app-arch/xz-utils:=
dev-libs/openssl:=
)
"
RDEPEND="${DEPEND}"
# As Rust produces LLVM IR when using LTO, lld is needed to link. Furthermore,
# as some crates contain C code, clang should be used to compile them to produce
# compatible IR.
BDEPEND="
lto? (
!custom-cflags? (
llvm-core/clang
llvm-core/lld
)
)
!static? ( virtual/pkgconfig )
"
QA_FLAGS_IGNORED="
usr/bin/firefoxpwa
usr/libexec/firefoxpwa-connector
"
src_prepare() {
default
# Set version in source files as per build instructions
sed -i "s/version = \"0.0.0\"/version = \"${PV}\"/g" Cargo.toml || die
sed -i "s/DISTRIBUTION_VERSION = '0.0.0'/DISTRIBUTION_VERSION = '${PV}'/g" \
userchrome/profile/chrome/pwa/chrome.sys.mjs || die
}
src_configure() {
# Setup toolchain
export CARGO_PROFILE_RELEASE_LTO=$(usex lto true false)
strip-flags
if use lto; then
if ! use custom-cflags; then
CC="${CHOST}-clang"
CXX="${CHOST}-clang++"
RUSTFLAGS="-Clinker=clang -Clink-arg=-fuse-ld=lld ${RUSTFLAGS}"
# Fix -flto[=n] not being recognized by clang
if tc-is-clang && is-flag "-flto=*"; then
replace-flags "-flto=*" "-flto"
fi
fi
else
filter-lto
fi
# Ask to use system dependencies
if ! use static; then
export PKG_CONFIG_ALLOW_CROSS=1
export ZSTD_SYS_USE_PKG_CONFIG=1
export OPENSSL_NO_VENDOR=1
fi
# Configure features
local myfeatures=(
$(usev static)
)
cargo_src_configure
}
src_install() {
# Executables
dobin "$(cargo_target_dir)/firefoxpwa"
exeinto /usr/libexec
doexe "$(cargo_target_dir)/firefoxpwa-connector"
# Manifest
local target_dirs=( /usr/lib{,64}/mozilla/native-messaging-hosts )
for target_dir in "${target_dirs[@]}"; do
insinto "${target_dir}"
newins manifests/linux.json firefoxpwa.json
done
# Completions
newbashcomp "$(cargo_target_dir)/completions/firefoxpwa.bash" firefoxpwa
dofishcomp "$(cargo_target_dir)/completions/firefoxpwa.fish"
dozshcomp "$(cargo_target_dir)/completions/_firefoxpwa"
# UserChrome
insinto /usr/share/firefoxpwa
doins -r ./userchrome
# Documentation
dodoc ../README.md
newdoc ../native/README.md README-NATIVE.md
newdoc ../extension/README.md README-EXTENSION.md
# AppStream Metadata
insinto /usr/share/metainfo
doins packages/appstream/si.filips.FirefoxPWA.metainfo.xml
# Icon
doicon -s scalable packages/appstream/si.filips.FirefoxPWA.svg
}
pkg_postinst() {
if [[ ! ${REPLACING_VERSIONS} ]]; then
elog "You have successfully installed the native part of the PWAsForFirefox project."
elog "You should also install the Firefox extension if you haven't already."
elog
elog "Download: https://addons.mozilla.org/firefox/addon/pwas-for-firefox/"
fi
xdg_pkg_postinst
}
pkg_postrm() {
if [[ ! ${REPLACED_BY_VERSION} ]]; then
elog "Runtime, profiles and web apps are still installed in user directories."
elog "You can remove them manually after this package is uninstalled."
elog "Doing that will remove all installed web apps and their data."
fi
xdg_pkg_postrm
}
|