summaryrefslogtreecommitdiff
blob: 173a518ba34d1ca3f0abcfd9ef4613bea541a9f6 (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
# Copyright 2023-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

if [[ ${PV} == 9999 ]] ; then
	EGIT_REPO_URI="https://github.com/kovidgoyal/rapydscript-ng"
	# this is nodejs software, so possibly unfixable. I am sorry.
	# Instead, we will have to generate this with the live ebuild and upload assets
	# using EGIT_OVERRIDE_COMMIT for the tagged version we need.
	BDEPEND="app-arch/libarchive"

	inherit git-r3
else
	SRC_URI="
		https://github.com/kovidgoyal/rapydscript-ng/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz
		https://dev.gentoo.org/~sam/distfiles/${CATEGORY}/${PN}/rapydscript-ng-node_modules-${PV}.tar.xz
	"
	KEYWORDS="amd64 ~arm64"
fi

inherit edo

DESCRIPTION="Pythonic JavaScript that doesn't suck"
HOMEPAGE="https://github.com/kovidgoyal/rapydscript-ng"

LICENSE="BSD"
SLOT="0"

BDEPEND+=" net-libs/nodejs"
RDEPEND="net-libs/nodejs"

maint_pkg_create() {
	cd "${S}" || die

	edo npm install --omit=optional

	local ver=$(git describe)
	ver=${ver#v}
	local tar="${T}/rapydscript-ng-node_modules-${ver}.tar.xz"

	bsdtar -s "#\(.*\)#${PN}-node_modules-${ver}/~#S" -caf "${tar}" package-lock.json node_modules/ || die
	einfo "Packaged tar now available:"
	einfo "$(du -b "${tar}")"
}

src_unpack() {
	if [[ ${PV} == 9999 ]] ; then
		git-r3_src_unpack
		maint_pkg_create
	else
		unpack ${A}
		cp -r "${WORKDIR}"/${PN}-node_modules-${PV}/{node_modules,package-lock.json} "${S}" || die
	fi
}

src_compile() {
	edo bin/rapydscript self --complete
	rm -r release/ || die
	mv dev/ release/ || die
}

src_test() {
	edo bin/rapydscript test
}

src_install() {
	local modulesdir=/usr/$(get_libdir)/node_modules/rapydscript-ng

	insinto "${modulesdir}"
	doins -r *

	fperms +x "${modulesdir}"/bin/rapydscript
	dosym -r "${modulesdir}"/bin/rapydscript /usr/bin/rapydscript
}