Init Script zwavejs2mqtt #269

Closed
opened 2022-03-22 12:14:03 +01:00 by jump · 20 comments

Do you have a more convenient init-script ? The tricky part was to stop the WS Server on port 3000. Changed the owner of /opt/zwavejs2mqtt after building with chown -R homeassistant:homeassistant.

#!/sbin/openrc-run
#Copyright 1999-2016 Gentoo Foundation
#Distributed under the terms of the GNU General Public License v2

name="Z-Wave JS Server"

depend() {
need net
}

start() {
ebegin "Starting ${RC_SVCNAME}"
cd /opt/${RC_SVCNAME}
start-stop-daemon --start --background --pidfile /var/run/${RC_SVCNAME}.pid --make-pidfile --user=homeassistant:homeassistant --exec /usr/bin/yarn -- start
sleep 3
eend $?
}

stop() {
ebegin "Stopping ${RC_SVCNAME}"
start-stop-daemon --stop --signal USR1 --pidfile /var/run/${RC_SVCNAME}.pid
sleep 1
ps aux | grep -v colour | grep -i server/bin/www.js | awk {'print $2'} | xargs kill -9 > /dev/null 2>&1
eend
}

Do you have a more convenient init-script ? The tricky part was to stop the WS Server on port 3000. Changed the owner of /opt/zwavejs2mqtt after building with chown -R homeassistant:homeassistant. #!/sbin/openrc-run #Copyright 1999-2016 Gentoo Foundation #Distributed under the terms of the GNU General Public License v2 name="Z-Wave JS Server" depend() { need net } start() { ebegin "Starting ${RC_SVCNAME}" cd /opt/${RC_SVCNAME} start-stop-daemon --start --background --pidfile /var/run/${RC_SVCNAME}.pid --make-pidfile --user=homeassistant:homeassistant --exec /usr/bin/yarn -- start sleep 3 eend $? } stop() { ebegin "Stopping ${RC_SVCNAME}" start-stop-daemon --stop --signal USR1 --pidfile /var/run/${RC_SVCNAME}.pid sleep 1 ps aux | grep -v colour | grep -i server/bin/www.js | awk {'print $2'} | xargs kill -9 > /dev/null 2>&1 eend }
onkelbeh added the
Enhancement
label 2022-03-24 06:47:10 +01:00
onkelbeh self-assigned this 2022-03-24 06:47:14 +01:00
Owner

:-)

to be honest, I don't have a script.

16436 ?        Ss     0:31 SCREEN
16437 pts/2    Ss     0:00 -/bin/bash
17760 ?        I      0:58 [kworker/1:0-events_freezable]
22277 pts/2    Sl+    0:00 node /usr/bin/yarn start
22283 pts/2    Sl+    0:01 /usr/bin/node /opt/zwavejs2mqtt/.yarn/releases/yarn-3.1.1.cjs start
22297 pts/2    Sl+   43:41 /usr/bin/node --preserve-symlinks server/bin/www.js

It runs in a disconnected screen session since a couple of years.
Making an Ebuild for it is on the schedule since .... ever.

:-) to be honest, I don't have a script. ``` 16436 ? Ss 0:31 SCREEN 16437 pts/2 Ss 0:00 -/bin/bash 17760 ? I 0:58 [kworker/1:0-events_freezable] 22277 pts/2 Sl+ 0:00 node /usr/bin/yarn start 22283 pts/2 Sl+ 0:01 /usr/bin/node /opt/zwavejs2mqtt/.yarn/releases/yarn-3.1.1.cjs start 22297 pts/2 Sl+ 43:41 /usr/bin/node --preserve-symlinks server/bin/www.js ``` It runs in a disconnected screen session since a couple of years. Making an Ebuild for it is on the schedule since .... ever.
Author

A better way to stop the WS Server

netstat -nlp | grep node | grep 3000 | awk {'print $7//[!0-9]/'} | xargs kill -9 > /dev/null 2>&1

A better way to stop the WS Server netstat -nlp | grep node | grep 3000 | awk {'print $7//[!0-9]/'} | xargs kill -9 > /dev/null 2>&1

I'm doing a similar thing in systemd for Z-Wave JS. It runs as my user but ideally would run as its own dedicated user. Plus read from /etc/zwave.js as I needed this to set my S0 and S2 keys. For some reason that never worked from within HA or core.config_entries file.

I can submit a PR to add this sort of thing.

Also, zwave-js server can be an ebuild. It only has a few dependencies and can be done in a flat manner (compared to the average NPM project having thousands of dependencies and not being able to be flattened).

zwave-js.service:

[Unit]
Description=Z-Wave JS Server
After=network-online.target
Before=homeassistant.service
Wants=network-online.target

[Service]
ExecStart=/usr/bin/node /home/tatsh/.node/bin/zwave-server --host=localhost --port=3000 --config=/etc/zwave.js /dev/serial/by-id/usb-0658_0200-if00
PermissionsStartOnly=True
Restart=on-failure

CapabilityBoundingSet=~CAP_BLOCK_SUSPEND
CapabilityBoundingSet=~CAP_CHOWN
CapabilityBoundingSet=~CAP_FOWNER
CapabilityBoundingSet=~CAP_FSETID
CapabilityBoundingSet=~CAP_IPC_LOCK
CapabilityBoundingSet=~CAP_KILL
CapabilityBoundingSet=~CAP_LEASE
CapabilityBoundingSet=~CAP_LINUX_IMMUTABLE
CapabilityBoundingSet=~CAP_MKNOD
CapabilityBoundingSet=~CAP_NET_ADMIN
CapabilityBoundingSet=~CAP_SETFCAP
CapabilityBoundingSet=~CAP_SETGID
CapabilityBoundingSet=~CAP_SETPCAP
CapabilityBoundingSet=~CAP_SETUID
CapabilityBoundingSet=~CAP_SYS_ADMIN
CapabilityBoundingSet=~CAP_SYS_BOOT
CapabilityBoundingSet=~CAP_SYS_CHROOT
CapabilityBoundingSet=~CAP_SYS_PACCT
CapabilityBoundingSet=~CAP_SYS_PTRACE
CapabilityBoundingSet=~CAP_SYS_RAWIO
CapabilityBoundingSet=~CAP_SYS_TTY_CONFIG
DeviceAllow=char-ttyACM
DevicePolicy=closed
LockPersonality=yes
NoNewPrivileges=yes
PrivateTmp=yes
ProcSubset=pid
ProtectClock=yes
ProtectControlGroups=yes
ProtectHostname=yes
ProtectKernelLogs=yes
ProtectKernelModules=yes
ProtectKernelTunables=yes
ProtectProc=noaccess
ProtectSystem=strict
RemoveIPC=yes
RestrictAddressFamilies=AF_INET
RestrictNetworkInterfaces=lo
RestrictRealtime=yes
RestrictSUIDSGID=yes
SocketBindDeny=any
SystemCallArchitectures=native
SystemCallFilter=~@clock
SystemCallFilter=~@cpu-emulation
SystemCallFilter=~@debug
SystemCallFilter=~@module
SystemCallFilter=~@mount
SystemCallFilter=~@obsolete
SystemCallFilter=~@privileged
SystemCallFilter=~@raw-io
SystemCallFilter=~@reboot
SystemCallFilter=~@resources
SystemCallFilter=~@swap

Group=tatsh
User=tatsh

[Install]
WantedBy=multi-user.target
I'm doing a similar thing in systemd for Z-Wave JS. It runs as my user but ideally would run as its own dedicated user. Plus read from /etc/zwave.js as I needed this to set my S0 and S2 keys. For some reason that never worked from within HA or `core.config_entries` file. I can submit a PR to add this sort of thing. Also, zwave-js server can be an ebuild. It only has a few dependencies and can be done in a flat manner (compared to the average NPM project having thousands of dependencies and not being able to be flattened). `zwave-js.service`: ```ini [Unit] Description=Z-Wave JS Server After=network-online.target Before=homeassistant.service Wants=network-online.target [Service] ExecStart=/usr/bin/node /home/tatsh/.node/bin/zwave-server --host=localhost --port=3000 --config=/etc/zwave.js /dev/serial/by-id/usb-0658_0200-if00 PermissionsStartOnly=True Restart=on-failure CapabilityBoundingSet=~CAP_BLOCK_SUSPEND CapabilityBoundingSet=~CAP_CHOWN CapabilityBoundingSet=~CAP_FOWNER CapabilityBoundingSet=~CAP_FSETID CapabilityBoundingSet=~CAP_IPC_LOCK CapabilityBoundingSet=~CAP_KILL CapabilityBoundingSet=~CAP_LEASE CapabilityBoundingSet=~CAP_LINUX_IMMUTABLE CapabilityBoundingSet=~CAP_MKNOD CapabilityBoundingSet=~CAP_NET_ADMIN CapabilityBoundingSet=~CAP_SETFCAP CapabilityBoundingSet=~CAP_SETGID CapabilityBoundingSet=~CAP_SETPCAP CapabilityBoundingSet=~CAP_SETUID CapabilityBoundingSet=~CAP_SYS_ADMIN CapabilityBoundingSet=~CAP_SYS_BOOT CapabilityBoundingSet=~CAP_SYS_CHROOT CapabilityBoundingSet=~CAP_SYS_PACCT CapabilityBoundingSet=~CAP_SYS_PTRACE CapabilityBoundingSet=~CAP_SYS_RAWIO CapabilityBoundingSet=~CAP_SYS_TTY_CONFIG DeviceAllow=char-ttyACM DevicePolicy=closed LockPersonality=yes NoNewPrivileges=yes PrivateTmp=yes ProcSubset=pid ProtectClock=yes ProtectControlGroups=yes ProtectHostname=yes ProtectKernelLogs=yes ProtectKernelModules=yes ProtectKernelTunables=yes ProtectProc=noaccess ProtectSystem=strict RemoveIPC=yes RestrictAddressFamilies=AF_INET RestrictNetworkInterfaces=lo RestrictRealtime=yes RestrictSUIDSGID=yes SocketBindDeny=any SystemCallArchitectures=native SystemCallFilter=~@clock SystemCallFilter=~@cpu-emulation SystemCallFilter=~@debug SystemCallFilter=~@module SystemCallFilter=~@mount SystemCallFilter=~@obsolete SystemCallFilter=~@privileged SystemCallFilter=~@raw-io SystemCallFilter=~@reboot SystemCallFilter=~@resources SystemCallFilter=~@swap Group=tatsh User=tatsh [Install] WantedBy=multi-user.target ```
Owner

What about install / update? OK, to wrench these into an Ebuild, I never did this with node stuff. There aren't any re-usable node-js 'templates' in main repo either. Wish I'd know more about building with yarn, currently I am stuck (again) at the forbidden network access in Gentoo's build sandbox.

I wonder if a pre-compiled binary would work across architectures. Anton made one for the frontend: https://github.com/onkelbeh/HomeAssistantRepository/actions/workflows/make-ha-frontend-sdist.yml

Currently I update it with:

root@ms3:cd /opt/zwavejs2mqtt
root@ms3:/opt/zwavejs2mqtt # git remote -v
origin	https://github.com/zwave-js/zwavejs2mqtt (fetch)
origin	https://github.com/zwave-js/zwavejs2mqtt (push)
root@ms3:/opt/zwavejs2mqtt # git pull origin master
root@ms3:/opt/zwavejs2mqtt # yarn install
root@ms3:/opt/zwavejs2mqtt # yarn run build

then, start with

root@ms3:/opt/zwavejs2mqtt # yarn start

as long I keep it running in foreground (in it's screen session), a simple ^C is catching the process, so I had no problem stopping it, yet. And we should find a clean way to end the process :-)

The update process won't fit into an Ebuild anyway, so a clean install is neccesary.
Where (and how) should the config be located? Think about /etc/${PN}. There binaries to /opt/${PN}?

What about install / update? OK, to wrench these into an Ebuild, I never did this with node stuff. There aren't any re-usable node-js 'templates' in main repo either. Wish I'd know more about building with yarn, currently I am stuck (again) at the forbidden network access in Gentoo's build sandbox. I wonder if a pre-compiled binary would work across architectures. Anton made one for the frontend: https://github.com/onkelbeh/HomeAssistantRepository/actions/workflows/make-ha-frontend-sdist.yml Currently I update it with: ```bash root@ms3:cd /opt/zwavejs2mqtt root@ms3:/opt/zwavejs2mqtt # git remote -v origin https://github.com/zwave-js/zwavejs2mqtt (fetch) origin https://github.com/zwave-js/zwavejs2mqtt (push) root@ms3:/opt/zwavejs2mqtt # git pull origin master root@ms3:/opt/zwavejs2mqtt # yarn install root@ms3:/opt/zwavejs2mqtt # yarn run build ``` then, start with ```bash root@ms3:/opt/zwavejs2mqtt # yarn start ``` as long I keep it running in foreground (in it's screen session), a simple ^C is catching the process, so I had no problem stopping it, yet. And we should find a clean way to end the process :-) The update process won't fit into an Ebuild anyway, so a clean install is neccesary. Where (and how) should the config be located? Think about /etc/${PN}. There binaries to /opt/${PN}?
Author

Both instances are desired (config 8091 and server 3000). Problem is you can start 3000 server from within 8091. So a second init script is useless.

No home entries needed after building so far
chown -R zwavejs2mqtt:zwavejs2mqtt /opt/zwavejs2mqtt
/opt/zwavejs2mqtt/store/settings.json
gpasswd --add zwavejs2mqtt dialout (ttyACL0)
env var HOST=x.x.x.x (Binding of 8091 instance)

#!/sbin/openrc-run
# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

name="Z-Wave JS Server"

depend() {
	need net
}

checkconfig() {
        if [ ! -e /opt/${RC_SVCNAME} ] ; then
                eerror "No /opt/${RC_SVCNAME} directory exists!"
        fi
}

start() {
	checkconfig || return 1
        ebegin "Starting ${RC_SVCNAME}"
        cd /opt/${RC_SVCNAME}
        start-stop-daemon --start --background --pidfile /var/run/${RC_SVCNAME}.pid --make-pidfile --user=zwavejs2mqtt:zwavejs2mqtt --exec /usr/bin/yarn -- start
        sleep 3
        eend $?
}

stop() {
        ebegin "Stopping ${RC_SVCNAME}"
        start-stop-daemon --stop --signal USR1 --pidfile /var/run/${RC_SVCNAME}.pid
        sleep 1
        netstat -nlp | grep node | grep 3000 | awk {'print $7//[!0-9]/'} | xargs kill -9 > /dev/null 2>&1
        eend
}

Both instances are desired (config 8091 and server 3000). Problem is you can start 3000 server from within 8091. So a second init script is useless. No home entries needed after building so far chown -R zwavejs2mqtt:zwavejs2mqtt /opt/zwavejs2mqtt /opt/zwavejs2mqtt/store/settings.json gpasswd --add zwavejs2mqtt dialout (ttyACL0) env var HOST=x.x.x.x (Binding of 8091 instance) ``` #!/sbin/openrc-run # Copyright 1999-2016 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 name="Z-Wave JS Server" depend() { need net } checkconfig() { if [ ! -e /opt/${RC_SVCNAME} ] ; then eerror "No /opt/${RC_SVCNAME} directory exists!" fi } start() { checkconfig || return 1 ebegin "Starting ${RC_SVCNAME}" cd /opt/${RC_SVCNAME} start-stop-daemon --start --background --pidfile /var/run/${RC_SVCNAME}.pid --make-pidfile --user=zwavejs2mqtt:zwavejs2mqtt --exec /usr/bin/yarn -- start sleep 3 eend $? } stop() { ebegin "Stopping ${RC_SVCNAME}" start-stop-daemon --stop --signal USR1 --pidfile /var/run/${RC_SVCNAME}.pid sleep 1 netstat -nlp | grep node | grep 3000 | awk {'print $7//[!0-9]/'} | xargs kill -9 > /dev/null 2>&1 eend } ```

What about install / update? OK, to wrench these into an Ebuild, I never did this with node stuff. There aren't any re-usable node-js 'templates' in main repo either.

You may not have to really build anything. Node stuff is supposed to come with the 'dist' version of the code unless it requires compiling (like code in C++, etc). This is the version of the code that is ready to run. Since we are talking about scripts it's the same as installing a random Perl/Python script in /usr/bin. So generally your ebuild just has to install the dist pre-built files.

I am happy to make these ebuilds, but eventually there should be a script to generate them by using npm or going through the npmjs.com APIs.

> What about install / update? OK, to wrench these into an Ebuild, I never did this with node stuff. There aren't any re-usable node-js 'templates' in main repo either. You may not have to really build anything. Node stuff is supposed to come with the 'dist' version of the code unless it requires compiling (like code in C++, etc). This is the version of the code that is ready to run. Since we are talking about scripts it's the same as installing a random Perl/Python script in `/usr/bin`. So generally your ebuild just has to install the dist pre-built files. I am happy to make these ebuilds, but eventually there should be a script to generate them by using `npm` or going through the `npmjs.com` APIs.
Owner

You are very welcome :-)

Had to fight a lot with the node stuff from https://github.com/home-assistant/frontend related to Bug #259, where the frontend guys discontinued the SDIST from pypi due to upload restrictions.

I first tried to 'compile' or whatever their install script does in the Ebuild, installation took ~25 minutes on a bigger host. This did not work on smaller appliances like Rapberry or Odroids, and the source on Github did not contain the build artifacts and was also lacking of some newer translations.

Then we made https://github.com/onkelbeh/HomeAssistantRepository/actions/workflows/make-ha-frontend-sdist.yml, which runs about half an hour on Github (with 3 XEON Silver CPU's), which works until now.

The next release of the frontend will use the new Asset.

You are very welcome :-) Had to fight a lot with the node stuff from https://github.com/home-assistant/frontend related to Bug https://git.edevau.net/onkelbeh/HomeAssistantRepository/issues/259, where the frontend guys discontinued the SDIST from pypi due to upload restrictions. I first tried to 'compile' or whatever their install script does in the [Ebuild](https://git.edevau.net/onkelbeh/HomeAssistantRepository/commit/ce2d37ebe89f0d5e92430da963d0f79193481946), installation took ~25 minutes on a bigger host. This did not work on smaller appliances like Rapberry or Odroids, and the source on Github did not contain the build artifacts and was also lacking of some newer translations. Then we made https://github.com/onkelbeh/HomeAssistantRepository/actions/workflows/make-ha-frontend-sdist.yml, which runs about half an hour on Github (with 3 XEON Silver CPU's), which works until now. The next release of the frontend will use the [new Asset](https://github.com/home-assistant/frontend/pull/11566).
jump closed this issue 2022-03-31 22:21:09 +02:00

As an update on doing zwave-js-server as an ebuild, it's too difficult right now without some script to handle it. The zwave-js dependency is only set as a development one, so I mistakenly thought it would be simple to package just a few Node deps. Simple Node deps do work great as ebuilds if the files get put in /usr/lib/node (one of the only default module paths in /usr).

On a semi-related note, go-module.eclass deprecated EGO_SUM because it makes really large manifests for some packages. Instead Gentoo will now do tarballs of dependencies, which means you need somewhere to host said tarballs unfortunately. On this front, Node.js packages can be treated the same way, and every package will have to have its own root like /usr/lib/node/<package name> and all the deps go in /usr/lib/node/<package name>/node_modules as captured from npm or similar.

The approach used by Python and Perl in Gentoo is not scalable for Node.js. Multiple issues:

  • Too many ebuilds to maintain
  • Most major packages cannot use a flat dependency tree (slotting would be a nightmare)
  • Versioning of often used dependencies is sporadic between major packages even for simple ones like is-string
As an update on doing zwave-js-server as an ebuild, it's too difficult right now without some script to handle it. The `zwave-js` dependency is only set as a development one, so I mistakenly thought it would be simple to package just a few Node deps. Simple Node deps do work great as ebuilds if the files get put in `/usr/lib/node` (one of the only default module paths in `/usr`). On a semi-related note, `go-module.eclass` deprecated `EGO_SUM` because it makes really large manifests for some packages. Instead Gentoo will now do tarballs of dependencies, which means you need somewhere to host said tarballs unfortunately. On this front, Node.js packages can be treated the same way, and every package will have to have its own root like `/usr/lib/node/<package name>` and all the deps go in `/usr/lib/node/<package name>/node_modules` as captured from npm or similar. The approach used by Python and Perl in Gentoo is not scalable for Node.js. Multiple issues: * Too many ebuilds to maintain * Most major packages cannot use a flat dependency tree (slotting would be a nightmare) * Versioning of often used dependencies is sporadic between major packages even for simple ones like `is-string`
Owner

Think we should keep this case open for the Ebuild.

Another approach could be to install the whole stuff, and pack it to a 'binary' release (like we do with the frontend). Cannot tell if a pre-installed binary will be independend (platform, locale, etc.).

Hosting won't be a problem, and I think it could be possible to setup an action at Github to do the work.

Take a look at https://github.com/onkelbeh/HomeAssistantRepository/blob/master/.github/workflows/make-ha-frontend-sdist.yml, this one builds the frontend. It puts it to my Nextcloud, currently I have the binary frontend published on hasf.edevau.net (Home Assistant Supplementary Files = hasf), mostly to keep track of the count of 'real' installations.

Think we should keep this case open for the Ebuild. Another approach could be to install the whole stuff, and pack it to a 'binary' release (like we do with the frontend). Cannot tell if a pre-installed binary will be independend (platform, locale, etc.). Hosting won't be a problem, and I think it could be possible to setup an action at Github to do the work. Take a look at https://github.com/onkelbeh/HomeAssistantRepository/blob/master/.github/workflows/make-ha-frontend-sdist.yml, this one builds the frontend. It puts it to my Nextcloud, currently I have the binary frontend published on hasf.edevau.net (Home Assistant Supplementary Files = hasf), mostly to keep track of the count of 'real' installations.
onkelbeh reopened this issue 2022-04-03 10:36:38 +02:00

Here is the ebuild, still a WIP, especially since it does not have a OpenRC init script.

https://github.com/Tatsh/tatsh-overlay/blob/master/app-misc/zwave-js-server/zwave-js-server-1.15.0.ebuild

Note that keys are specified in a separate file and these are imported in the configuration file (since the configuration file is normal Node code).

More files can probably be cleaned out in src_prepare().

Here is the ebuild, still a WIP, especially since it does not have a OpenRC init script. https://github.com/Tatsh/tatsh-overlay/blob/master/app-misc/zwave-js-server/zwave-js-server-1.15.0.ebuild Note that keys are specified in a separate file and these are imported in the configuration file (since the configuration file is normal Node code). More files can probably be cleaned out in `src_prepare()`.

Main issue with above is that NodeJS compiled stuff is both architecture (of course) and ABI version specific. Something compiled for NodeJS 16 will not work on 14. Maybe the reverse is true but I doubt it. One way to resolve this may be to run npm rebuild inside the package directory. This worked on one of my machines to fix ABI issues.

Main issue with above is that NodeJS compiled stuff is both architecture (of course) and ABI version specific. Something compiled for NodeJS 16 will not work on 14. Maybe the reverse is true but I doubt it. One way to resolve this may be to run `npm rebuild` inside the package directory. This worked on one of my machines to fix ABI issues.

@Tatsh
If you put 'RDEPEND="net-libs/nodejs:="' in the ebuild then portage would rebuild the package every time nodejs is updated.

@Tatsh If you put 'RDEPEND="net-libs/nodejs:="' in the ebuild then portage would rebuild the package every time nodejs is updated.

First I have to figure out how to make npm rebuild work within the sandbox. It makes some network requests.

First I have to figure out how to make `npm rebuild` work within the sandbox. It makes some network requests.

I'm still using homeassistant-bin. Thats the ebuild that makes a python virtualenv.
So i did make a package.env with 'app-misc/homeassistant-bin no-network-sandbox'.
Of course that's a last resort.

I'm still using homeassistant-bin. Thats the ebuild that makes a python virtualenv. So i did make a package.env with 'app-misc/homeassistant-bin no-network-sandbox'. Of course that's a last resort.
Owner

sandbox network issues have been the main reason for #269 (comment).

I believe that some sort of node stuff (cache etc.) goes into the building users home dir. After a clean build I have ~250 MB in ~/.npm

sandbox network issues have been the main reason for https://git.edevau.net/onkelbeh/HomeAssistantRepository/issues/269#issuecomment-1594. I believe that some sort of node stuff (cache etc.) goes into the building users home dir. After a clean build I have ~250 MB in `~/.npm`
Owner

I have contacted a nodejs expert (IT teacher), unfortunaltely I am out on a trip with limited time & access, will return wednesday.

I have contacted a nodejs expert (IT teacher), unfortunaltely I am out on a trip with limited time & access, will return wednesday.
onkelbeh added the
help wanted
label 2022-04-09 14:25:38 +02:00

I have figured out how to package this more properly with Yarn's offline feature. BDEPEND gets yarn added. No big deal to me.

Ebuilds:

Node-gyp is required to build a native dependency that zwave-js-server needs. We should never depend on prebuilt binaries. Any package that does not have a binary dependency does not need Node-gyp.

How to reproduce this for any NPM package (run yarn cache clean first):

  1. Get the dependency URLs by running yarn --verbose add NAME_OF_PACKAGE 2>&1 | egrep 'Performing "GET" request to "https://registry.yarnpkg.*tgz' | sed -e 's/"\.\?//g' > urls.log

  2. I am prefixing these distfiles with node- to avoid generic name collissions like so:

    sed -re 's/^"//g' -e 's/"\.$//g' -e 's|/-/(.*)|/-/\1 -> node-\1|g' < urls.log
    

    Note that this does not fix the @-prefixed packages. For those you should edit the target name and add @SCOPE- after node-. So for example: node-config-9.0.0.tgz becomes node-@zwave-js-config-9.0.0.tgz.
    All of these lines become SRC_URI.

  3. In the ebuild, set up src_unpack to not unpack .tgz files.

  4. Set up a packages directory and symlink all the node-* packages removing the node- prefix. See src_prepare.

  5. Set up Yarn to use a prefix (does not matter what it is but it must be accessible and writeable).

  6. Set up Yarn to use an offline mirror. This is the packages directory you made in step 4.

  7. Copy the project's generated package.json to the FILESDIR as well as yarn.lock. You must place these in the work directory prior to running any Yarn command.

  8. You must set the npm_config_nodedir environment variable for Node-gyp to not download a tarball of headers. The correct value for Gentoo is /usr/include/node.

  9. Use the yarn install command, but pass --offline --build-from-source at minimum.

  10. In src_install, if the package has items to place in PATH, symlink them into /usr/bin (or appropriate location) manually. See src_install.

If during src_compile you see an error regarding a missing package attempting to be downloaded by Yarn, add this URI to SRC_URI in the same format as the others.

I have figured out how to package this more properly with Yarn's offline feature. BDEPEND gets yarn added. No big deal to me. Ebuilds: * [node-gyp](https://github.com/Tatsh/tatsh-overlay/blob/master/dev-util/node-gyp/node-gyp-9.0.0.ebuild) * [zwave-js-server](https://github.com/Tatsh/tatsh-overlay/blob/master/app-misc/zwave-js-server/zwave-js-server-1.16.0.ebuild) Node-gyp is required to build a native dependency that zwave-js-server needs. We should never depend on prebuilt binaries. Any package that does not have a binary dependency does not need Node-gyp. How to reproduce this for any NPM package (run `yarn cache clean` first): 1. Get the dependency URLs by running `yarn --verbose add NAME_OF_PACKAGE 2>&1 | egrep 'Performing "GET" request to "https://registry.yarnpkg.*tgz' | sed -e 's/"\.\?//g' > urls.log` 2. I am prefixing these distfiles with `node-` to avoid generic name collissions like so: ```shell sed -re 's/^"//g' -e 's/"\.$//g' -e 's|/-/(.*)|/-/\1 -> node-\1|g' < urls.log ``` Note that this does not fix the `@`-prefixed packages. For those you should edit the target name and add `@SCOPE-` after `node-`. So for example: `node-config-9.0.0.tgz` becomes `node-@zwave-js-config-9.0.0.tgz`. All of these lines become `SRC_URI`. 3. In the ebuild, [set up `src_unpack` to not unpack `.tgz` files](https://github.com/Tatsh/tatsh-overlay/blob/master/app-misc/zwave-js-server/zwave-js-server-1.16.0.ebuild#L157=). 4. Set up a packages directory and symlink all the `node-*` packages removing the `node-` prefix. See [src_prepare](https://github.com/Tatsh/tatsh-overlay/blob/master/app-misc/zwave-js-server/zwave-js-server-1.16.0.ebuild#L157=). 5. [Set up Yarn to use a prefix](https://github.com/Tatsh/tatsh-overlay/blob/master/app-misc/zwave-js-server/zwave-js-server-1.16.0.ebuild#L181=) (does not matter what it is but it must be accessible and writeable). 6. [Set up Yarn to use an offline mirror](https://github.com/Tatsh/tatsh-overlay/blob/master/app-misc/zwave-js-server/zwave-js-server-1.16.0.ebuild#L182=). This is the packages directory you made in step 4. 5. Copy the project's generated `package.json` to the `FILESDIR` as well as `yarn.lock`. You must place these in the work directory prior to running any Yarn command. 6. [You must set the `npm_config_nodedir` environment variable](https://github.com/Tatsh/tatsh-overlay/blob/master/app-misc/zwave-js-server/zwave-js-server-1.16.0.ebuild#L193=) for Node-gyp to not download a tarball of headers. The correct value for Gentoo is `/usr/include/node`. 7. Use the `yarn install` command, but pass `--offline --build-from-source` at minimum. 8. In `src_install`, if the package has items to place in PATH, symlink them into `/usr/bin` (or appropriate location) manually. See [src_install](https://github.com/Tatsh/tatsh-overlay/blob/master/app-misc/zwave-js-server/zwave-js-server-1.16.0.ebuild#L204=). If during `src_compile` you see an error regarding a missing package attempting to be downloaded by Yarn, add this URI to `SRC_URI` in the same format as the others.
Owner

This is cool, have not tried it yet, currently too busy otherwise, and I would have to add sysvinit scripts, I do not use systemd anywhere.

Two questions:

  1. would you mind if I add it to this repo?
  2. when are you going to use zigbee2mqtt :-)
This is cool, have not tried it yet, currently too busy otherwise, and I would have to add sysvinit scripts, I do not use systemd anywhere. Two questions: 1) would you mind if I add it to this repo? 2) when are you going to use [zigbee2mqtt](https://github.com/onkelbeh/HomeAssistantRepository/issues/17) :-)
Owner
@Tatsh did it already: https://github.com/Tatsh/tatsh-overlay/tree/master/app-misc/zwave-js-server

This is cool, have not tried it yet, currently too busy otherwise, and I would have to add sysvinit scripts, I do not use systemd anywhere.

Two questions:

  1. would you mind if I add it to this repo?
  2. when are you going to use zigbee2mqtt :-)

on 2), why should i use that? I don't own any Zigbee devices.

> This is cool, have not tried it yet, currently too busy otherwise, and I would have to add sysvinit scripts, I do not use systemd anywhere. > > Two questions: > 1) would you mind if I add it to this repo? > 2) when are you going to use [zigbee2mqtt](https://github.com/onkelbeh/HomeAssistantRepository/issues/17) :-) > on 2), why should i use that? I don't own any Zigbee devices.
Sign in to join this conversation.
No Label
Bug
Bump/Update
Cleanup
Dupe
Enhancement
File Collision
Forked
help wanted
Integration: accuweather
Integration: acmeda
Integration: acomax
Integration: adax
Integration: adguard
Integration: aemet
Integration: aep_ohio
Integration: aep_texas
Integration: airq
Integration: airthings
Integration: airthings_ble
Integration: airtouch5
Integration: airzone
Integration: airzone_cloud
Integration: amazon_polly
Integration: amberelectric
Integration: ambient_station
Integration: analytics_insights
Integration: anel_pwrctrl
Integration: aosmith
Integration: apache_kafka
Integration: apcupsd
Integration: appalachianpower
Integration: apprise
Integration: aprilaire
Integration: aranet
Integration: aseko_pool_live
Integration: asuswrt
Integration: august
Integration: aws
Integration: axis
Integration: backup
Integration: bang_olufsen
Integration: blebox
Integration: blink
Integration: bluetooth
Integration: blue_current
Integration: bmw_connected_drive
Integration: bosch_shc
Integration: bring
Integration: brother
Integration: brottsplatskartan
Integration: bsblan
Integration: bthome
Integration: caldav
Integration: cast
Integration: ccm15
Integration: cloud
Integration: cloudflare
Integration: co2signal
Integration: coautilities
Integration: comelit
Integration: conversation
Integration: debugpy
Integration: deconz
Integration: deluge
Integration: denonavr
Integration: devialet
Integration: devolo_home_control
Integration: dhcp
Integration: discord
Integration: discovergy
Integration: dlna_dmr
Integration: dlna_dms
Integration: doods
Integration: drop_connect
Integration: dsmr
Integration: duotecno
Integration: duquesne_light
Integration: dwd_weather_warnings
Integration: easyenergy
Integration: ecobee
Integration: ecoforest
Integration: ecovacs
Integration: ecowitt
Integration: elgato
Integration: elvia
Integration: energyzero
Integration: enigma2
Integration: enphase_envoy
Integration: epion
Integration: esphome
Integration: evohome
Integration: ffmpeg
Integration: fjaraskupan
Integration: flexit_bacnet
Integration: flipr
Integration: forecast_solar
Integration: foscam
Integration: fritzbox
Integration: fronius
Integration: frontend
Integration: fujitsu_anywair
Integration: fyta
Integration: garages_amsterdam
Integration: gardena_bluetooth
Integration: gdacs
Integration: generic
Integration: geonetnz_quakes
Integration: geonetnz_volcano
Integration: geo_json_events
Integration: geo_rss_events
Integration: gios
Integration: glances
Integration: goodwe
Integration: google
Integration: google_assistant_sdk
Integration: google_generative_ai_conversation
Integration: govee_ble
Integration: govee_light_local
Integration: hive
Integration: hko
Integration: holiday
Integration: homekit_controller
Integration: homematicip_cloud
Integration: homewizard
Integration: honeywell
Integration: hp_ilo
Integration: html5
Integration: http
Integration: hue
Integration: hunterdouglas_powerview
Integration: husqvarna_automower
Integration: huum
Integration: hydrawise
Integration: iammeter
Integration: ibeacon
Integration: idasen_desk
Integration: ign_sismologia
Integration: image_upload
Integration: indianamichiganpower
Integration: insteon
Integration: ipp
Integration: islamic_prayer_times
Integration: justnimbus
Integration: jvc_projector
Integration: kef
Integration: kentuckypower
Integration: keymitt_ble
Integration: knx
Integration: kostal_plenticore
Integration: krispol
Integration: lamarzocco
Integration: ld2410_ble
Integration: leaone
Integration: led_ble
Integration: life360
Integration: lifx
Integration: linear_garage_door
Integration: litejet
Integration: litterrobot
Integration: local_calendar
Integration: local_todo
Integration: loqed
Integration: luci
Integration: lupusec
Integration: lutron
Integration: lutron_caseta
Integration: madeco
Integration: mastodon
Integration: matrix
Integration: matter
Integration: media_extractor
Integration: melcloud
Integration: met
Integration: meteoclimatic
Integration: meteo_france
Integration: metoffice
Integration: microbees
Integration: mill
Integration: minecraft_server
Integration: modbus
Integration: mopeka
Integration: motionblinds_ble
Integration: motionmount
Integration: motion_blinds
Integration: myuplink
Integration: nam
Integration: neato
Integration: netatmo
Integration: nexia
Integration: nextbus
Integration: nextcloud
Integration: nextdns
Integration: nibe_heatpump
Integration: nmap_tracker
Integration: nobo_hub
Integration: norway_air
Integration: notion
Integration: nsw_rural_fire_service_feed
Integration: nuki
Integration: numato
Integration: nut
Integration: nws
Integration: ollama
Integration: oncue
Integration: ondilo_ico
Integration: openai_conversation
Integration: openerz
Integration: open_meteo
Integration: opower
Integration: orvibo
Integration: osoenergy
Integration: otbr
Integration: ourgroceries
Integration: overkiz
Integration: p1_monitor
Integration: pegel_online
Integration: permobil
Integration: plex
Integration: plugwise
Integration: powerwall
Integration: private_ble_device
Integration: proxy
Integration: prusalink
Integration: psoklahoma
Integration: pure_energie
Integration: pvoutput
Integration: qingping
Integration: qld_bushfire
Integration: qrcode
Integration: rabbitair
Integration: rachio
Integration: radio_browser
Integration: rainbird
Integration: rainforest_raven
Integration: rainmachine
Integration: rdw
Integration: recorder
Integration: refoss
Integration: renault
Integration: renson
Integration: reolink
Integration: rflink
Integration: rfxtrx
Integration: ridwell
Integration: ring
Integration: risco
Integration: roborock
Integration: roku
Integration: romy
Integration: roomba
Integration: roon
Integration: route53
Integration: rova
Integration: samsam
Integration: samsungtv
Integration: schlage
Integration: scl
Integration: screenlogic
Integration: sensibo
Integration: sensorpush
Integration: sentry
Integration: seven_segments
Integration: sfr_box
Integration: shelly
Integration: sighthound
Integration: signal_messenger
Integration: simplisafe
Integration: sleepiq
Integration: slimproto
Integration: smarttub
Integration: smud
Integration: snmp
Integration: songpal
Integration: sonos
Integration: sql
Integration: squeezebox
Integration: ssdp
Integration: subaru
Integration: suez_water
Integration: sunweg
Integration: surepetcare
Integration: swepco
Integration: swiss_public_transport
Integration: switchbot
Integration: switchbot_cloud
Integration: switcher_kis
Integration: system_bridge
Integration: tado
Integration: tailwind
Integration: tankerkoenig
Integration: tasmota
Integration: technove
Integration: tedee
Integration: telegram_bot
Integration: temper
Integration: tensorflow
Integration: teslemetry
Integration: tessie
Integration: thermobeacon
Integration: thermopro
Integration: thread
Integration: tile
Integration: tolo
Integration: tplink
Integration: tplink_omada
Integration: tplink_tapo
Integration: traccar
Integration: traccar_server
Integration: trafikverket_camera
Integration: trafikverket_ferry
Integration: trafikverket_train
Integration: trafikverket_weatherstation
Integration: transmission
Integration: tuya
Integration: twentemilieu
Integration: unifi
Integration: unifiprotect
Integration: unifi_direct
Integration: upnp
Integration: usgs_earthquakes_feed
Integration: utility_meter
Integration: v2c
Integration: vallox
Integration: valve
Integration: velbus
Integration: velux
Integration: vicare
Integration: vilfo
Integration: vodafone_station
Integration: vulcan
Integration: wallbox
Integration: waqi
Integration: waze_travel_time
Integration: weatherflow_cloud
Integration: weatherkit
Integration: webmin
Integration: webostv
Integration: wemo
Integration: whirlpool
Integration: withings
Integration: wolflink
Integration: workday
Integration: wyoming
Integration: xiaomi_ble
Integration: yalexs_ble
Integration: yeelight
Integration: yolink
Integration: zamg
Integration: zeroconf
Integration: zha
Integration: zhong_hong
Integration: zondergas
Integration: zoneminder
Integration: zwave_js
invalid
New Integration
Python 3.10
Python 3.11
question
requirement
Requirement vanished
slot-conflict
Source Incomplete
SrcDir ${S} mismatch
TopLevelViolation
Update required
virtual
wontfix
No Milestone
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: onkelbeh/HomeAssistantRepository#269
No description provided.