commit:     c7fdbf8cac194e8c386439ba2d1a55f7b166829d
Author:     Rahil Bhimjiani <me <AT> rahil <DOT> rocks>
AuthorDate: Sun Mar 10 16:01:33 2024 +0000
Commit:     Rahil Bhimjiani <rahil3108 <AT> gmail <DOT> com>
CommitDate: Sun Mar 10 16:01:47 2024 +0000
URL:        https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=c7fdbf8c

net-irc/thelounge: misc improvements

Changes:
* provide USE flag, sqlite
* fix failing build on FEATURES=-network-sandbox
* build sqlite from source instead of using upstream's binary

Signed-off-by: Rahil Bhimjiani <me <AT> rahil.rocks>

 net-irc/thelounge/Manifest                   |  4 +--
 net-irc/thelounge/thelounge-4.4.1.ebuild     | 40 ++++++++++++++++++++++------
 net-irc/thelounge/thelounge-4.4.2_rc1.ebuild | 40 ++++++++++++++++++++++------
 3 files changed, 66 insertions(+), 18 deletions(-)

diff --git a/net-irc/thelounge/Manifest b/net-irc/thelounge/Manifest
index e05384ffc8..bd5029c276 100644
--- a/net-irc/thelounge/Manifest
+++ b/net-irc/thelounge/Manifest
@@ -1,6 +1,6 @@
 DIST thelounge-4.4.1-deps.tar.xz 81407420 BLAKE2B 
027652411cf7848fae713770444ee6c20c18b2d90abf8967976954df844dea8b39110bc0a1742926174346fbfa976c06883f9538722ab02a94579203e3d61dde
 SHA512 
0626e55b16a92346729b4504a1b8d3f5cc108a2a59d648476abbc844043efe3f577d83240c3ea5a61572216ab1af53018cab8e0dac133b938ad0ab9d42878fbe
-DIST thelounge-4.4.1-sqlite3.tar.xz 3994944 BLAKE2B 
01d12ca8947465c91e4ac455c743503fedce2f53ce8ee5fbdf0e77188bfc67378bfcc58a1ad4172ef46a5c1ba04a37fcb19726f0b7aa3352efa4f5ceca6245d1
 SHA512 
b81734ca8b32d5ddc7bad28aead5a96e578844aa2a8e6635ffe62b7dcd38daf3b7e218569d43e0cb9e6cd12adfa07a8c41fb51877f65717e3c98e6ce3c25a017
+DIST thelounge-4.4.1-sqlite.tar.xz 11717368 BLAKE2B 
575ca85823f190444f8b32be11af778fd822ec32bce256e8225b4640023d84d17c3aee50f10a9dcc4045bd9101c88702f086e86e092e213b41f39f9712d6794b
 SHA512 
ca69be8fe1d51affc77c350d38de74d6e4af5b3f51abd9b3b0f5d14ceb86d5336723b7afc9a3bcff3c5127fbfc36dc7f6a9d6ac43aeb3db94454a2d850b256f8
 DIST thelounge-4.4.1.tar.gz 577766 BLAKE2B 
f5ce4b381445e7d8d33e83431e4222b3fdc7ad2870c7819c9d641b2e7aca9e4cbd7d000a188132f40a39b775904d8d145e87a5edda6d6195bb2de2d9a6b6eb0a
 SHA512 
7695121a713a23688bc6f52dae2574bab1288eea930fd50d4dd85037233e9f23bd8e460980c69cdd14ea8648da4720d84e8196547b6a18e69d2f478b43d6e29a
 DIST thelounge-4.4.2_rc1-deps.tar.xz 82563560 BLAKE2B 
4511199d37825a2627f1865386da988047d33471b3b12ef8e84b3b3aca14d4bf50180a54436ba13487ddd21583abe2db2fdb830cde38c4872479b485117f5763
 SHA512 
3358b07fd9a27f8e4f16cdcff00c13b7a08850db4629f28320e485a9ad35a081174245715c3089fdf95307317cf2e198c959611a291070cfc1bdb0f0e4b567ca
-DIST thelounge-4.4.2_rc1-sqlite3.tar.xz 4110020 BLAKE2B 
39eaf47ea4f18b7e5f73af53771a5b3042f547476608579de0d36417e58693956fa2b6dbed17cdbadc254bc9844c452c45fb8fb016f2aed66c4220193e2c69e2
 SHA512 
a39202018e3927504913d62f4eaaeeda70a20dc7b35ed7b9f40b46a709982b46fc5a618bc425084b533ff6634c1f56924aec5e3a5bcc2393ae176d8f72e5f237
+DIST thelounge-4.4.2_rc1-sqlite.tar.xz 57426856 BLAKE2B 
ebcb9f1b6bc256125fe1b93d764a3cd6032615ccf5b45c6b1ac9549c6b3cab1c06155a9bfa00b13e44f86dfa31572be103277ff0023a6381ddff47c684e89b90
 SHA512 
dfab9ff0537b633f5d1361cefa2ae6047988d74c9e3599365adc6139e4b434e0b9abc1b8e47d0a2c00e57b37fe8bb7feb99aca9312a311cd4e0444b10decd919
 DIST thelounge-4.4.2_rc1.tar.gz 588927 BLAKE2B 
24e1b47e124ac1654cfeb967ceffc0d72e54691b59a0c71bfd00fe9a4ef68b8e0279561cb52f56bd281876af1d04a995481602f8a0e647bf30af3fa9a7ce5ef7
 SHA512 
24c8304566aca12fa0264e175e8340687f8488afbb1cb49430323c7d5c6a5fdc6e0ad14f1bd0e327e4284d3b7477cd61a18677a63836a2c49a1f4c7f785a8e33

diff --git a/net-irc/thelounge/thelounge-4.4.1.ebuild 
b/net-irc/thelounge/thelounge-4.4.1.ebuild
index 7244624efd..1f86cc3737 100644
--- a/net-irc/thelounge/thelounge-4.4.1.ebuild
+++ b/net-irc/thelounge/thelounge-4.4.1.ebuild
@@ -11,19 +11,22 @@ HOMEPAGE="https://thelounge.chat/";
 SRC_URI="
        
https://github.com/thelounge/thelounge/archive/refs/tags/v${PV/_rc/-rc.}.tar.gz 
-> ${P}.tar.gz
        
https://github.com/rahilarious/gentoo-distfiles/releases/download/${P}/deps.tar.xz
 -> ${P}-deps.tar.xz
-       
https://github.com/rahilarious/gentoo-distfiles/releases/download/${P}/sqlite3.tar.xz
 -> ${P}-sqlite3.tar.xz
+       sqlite? ( 
https://github.com/rahilarious/gentoo-distfiles/releases/download/${P}/sqlite.tar.xz
 -> ${P}-sqlite.tar.xz )
 "
 
 S="${WORKDIR}/${PN}-${PV/_rc/-rc.}"
-LICENSE="MIT"
+LICENSE="BSD MIT"
 SLOT="0"
 KEYWORDS="~amd64"
+IUSE="+sqlite"
 
 RDEPEND="
        acct-user/${PN}
        acct-group/${PN}
        >=net-libs/nodejs-16
+       sqlite? ( dev-db/sqlite:3= )
 "
+DEPEND="${RDEPEND}"
 BDEPEND="
        >=net-libs/nodejs-16[npm]
        sys-apps/yarn
@@ -34,24 +37,45 @@ DOC_CONTENTS="\n
 Data directory: /var/lib/${PN}\n
 Listens on: 0.0.0.0:9000\n
 Log file (openrc): /var/log/${PN}.log\n
+Config file: /var/lib/${PN}/config.js\n
 \n
 ##### Initialization #####\n
 Run \`THELOUNGE_HOME=/var/lib/${PN} ${PN} add <user>\`
 "
 
 mooyarn() {
-       yarn --verbose  --non-interactive --frozen-lockfile --cache-folder 
../yarn-cache \
-                --offline --global-folder moobuild "${@}" || die
+       use !sqlite && local YARN_OPTS="--ignore-optional"
+       yarn --verbose  --non-interactive --frozen-lockfile --cache-folder 
"${WORKDIR}"/yarn-cache --offline \
+                --ignore-scripts ${YARN_OPTS} "${@}" || die
 }
 
+src_prepare() {
+       default
+       use !sqlite && { sed -i -e 's|\["sqlite", |\[|g;' defaults/config.js  
|| die ; }
+
+}
 src_compile() {
+       # thelounge build
        mooyarn install
        NODE_ENV=production mooyarn build
-       local BUILT_TAR=$(npm pack)
-       NODE_ENV=production mooyarn global add file:$(realpath ${BUILT_TAR})
+       local BUILT_TAR=$(realpath $(npm pack || die))
+       # thelounge install
+       mkdir -v moobuild && cp -v {package.json,yarn.lock} moobuild/ || die
+       pushd moobuild || die
+       NODE_ENV=production mooyarn add file:${BUILT_TAR:?}
+
+       if use sqlite; then
+               # sqlite3 build
+               pushd node_modules/sqlite3 || die
+               export npm_config_cache="${WORKDIR}"/npm-cache 
npm_config_nodedir="${EPREFIX}"/usr || die
+               npm --verbose --offline install --build-from-source 
--sqlite="${EPREFIX}"/usr || die
+               # sqlite3 cleanup
+               rm -rf node_modules || die
+               find build* -type f -not -path build/Release/node_sqlite3.node 
-delete || die
+               popd || die
+       fi
+       popd || die
 
-       # this workaround because sqlite3 module requires network access
-       mv -v ../sqlite3 moobuild/node_modules/ || die
 }
 
 src_install() {

diff --git a/net-irc/thelounge/thelounge-4.4.2_rc1.ebuild 
b/net-irc/thelounge/thelounge-4.4.2_rc1.ebuild
index b5a73eb092..475c04eae3 100644
--- a/net-irc/thelounge/thelounge-4.4.2_rc1.ebuild
+++ b/net-irc/thelounge/thelounge-4.4.2_rc1.ebuild
@@ -11,19 +11,22 @@ HOMEPAGE="https://thelounge.chat/";
 SRC_URI="
        
https://github.com/thelounge/thelounge/archive/refs/tags/v${PV/_rc/-rc.}.tar.gz 
-> ${P}.tar.gz
        
https://github.com/rahilarious/gentoo-distfiles/releases/download/${P}/deps.tar.xz
 -> ${P}-deps.tar.xz
-       
https://github.com/rahilarious/gentoo-distfiles/releases/download/${P}/sqlite3.tar.xz
 -> ${P}-sqlite3.tar.xz
+       sqlite? ( 
https://github.com/rahilarious/gentoo-distfiles/releases/download/${P}/sqlite.tar.xz
 -> ${P}-sqlite.tar.xz )
 "
 
 S="${WORKDIR}/${PN}-${PV/_rc/-rc.}"
-LICENSE="MIT"
+LICENSE="BSD MIT"
 SLOT="0"
 KEYWORDS="~amd64"
+IUSE="+sqlite"
 
 RDEPEND="
        acct-user/${PN}
        acct-group/${PN}
        >=net-libs/nodejs-18
+       sqlite? ( dev-db/sqlite:3= )
 "
+DEPEND="${RDEPEND}"
 BDEPEND="
        >=net-libs/nodejs-18[npm]
        sys-apps/yarn
@@ -34,24 +37,45 @@ DOC_CONTENTS="\n
 Data directory: /var/lib/${PN}\n
 Listens on: 0.0.0.0:9000\n
 Log file (openrc): /var/log/${PN}.log\n
+Config file: /var/lib/${PN}/config.js\n
 \n
 ##### Initialization #####\n
 Run \`THELOUNGE_HOME=/var/lib/${PN} ${PN} add <user>\`
 "
 
 mooyarn() {
-       yarn --verbose  --non-interactive --frozen-lockfile --cache-folder 
../yarn-cache \
-                --offline --global-folder moobuild "${@}" || die
+       use !sqlite && local YARN_OPTS="--ignore-optional"
+       yarn --verbose  --non-interactive --frozen-lockfile --cache-folder 
"${WORKDIR}"/yarn-cache --offline \
+                --ignore-scripts ${YARN_OPTS} "${@}" || die
 }
 
+src_prepare() {
+       default
+       use !sqlite && { sed -i -e 's|\["sqlite", |\[|g;' defaults/config.js  
|| die ; }
+
+}
 src_compile() {
+       # thelounge build
        mooyarn install
        NODE_ENV=production mooyarn build
-       local BUILT_TAR=$(npm pack)
-       NODE_ENV=production mooyarn global add file:$(realpath ${BUILT_TAR})
+       local BUILT_TAR=$(realpath $(npm pack || die))
+       # thelounge install
+       mkdir -v moobuild && cp -v {package.json,yarn.lock} moobuild/ || die
+       pushd moobuild || die
+       NODE_ENV=production mooyarn add file:${BUILT_TAR:?}
+
+       if use sqlite; then
+               # sqlite3 build
+               pushd node_modules/sqlite3 || die
+               export npm_config_cache="${WORKDIR}"/npm-cache 
npm_config_nodedir="${EPREFIX}"/usr || die
+               npm --verbose --offline install --build-from-source 
--sqlite="${EPREFIX}"/usr || die
+               # sqlite3 cleanup
+               rm -rf node_modules || die
+               find build* -type f -not -path build/Release/node_sqlite3.node 
-delete || die
+               popd || die
+       fi
+       popd || die
 
-       # this workaround because sqlite3 module requires network access
-       mv -v ../sqlite3 moobuild/node_modules/ || die
 }
 
 src_install() {

Reply via email to