2021-04-01 15:10:43 -04:00
|
|
|
# Building Moonfire NVR <!-- omit in toc -->
|
2021-01-21 19:00:38 -05:00
|
|
|
|
|
|
|
This document has notes for software developers on building Moonfire NVR from
|
|
|
|
source code for development. If you just want to install precompiled
|
2023-10-14 18:52:06 -04:00
|
|
|
binaries, see the [installation instructions](install.md) instead.
|
2021-01-21 19:00:38 -05:00
|
|
|
|
|
|
|
This document doesn't spell out as many details as the installation
|
|
|
|
instructions. Please ask on Moonfire NVR's [issue
|
|
|
|
tracker](https://github.com/scottlamb/moonfire-nvr/issues) or
|
|
|
|
[mailing list](https://groups.google.com/d/forum/moonfire-nvr-users) when
|
|
|
|
stuck. Please also send pull requests to improve this doc.
|
|
|
|
|
2021-04-01 15:10:43 -04:00
|
|
|
* [Downloading](#downloading)
|
2023-10-14 18:52:06 -04:00
|
|
|
* [Building](#building)
|
2021-04-01 15:10:43 -04:00
|
|
|
* [Running interactively straight from the working copy](#running-interactively-straight-from-the-working-copy)
|
2023-10-14 18:52:06 -04:00
|
|
|
* [Release procedure](#release-procedure)
|
2021-03-12 15:18:24 -05:00
|
|
|
|
2021-01-21 19:00:38 -05:00
|
|
|
## Downloading
|
|
|
|
|
|
|
|
See the [github page](https://github.com/scottlamb/moonfire-nvr) (in case
|
|
|
|
you're not reading this text there already). You can download the
|
|
|
|
bleeding-edge version from the commandline via git:
|
|
|
|
|
2021-08-23 15:40:14 -04:00
|
|
|
```console
|
2021-01-21 19:00:38 -05:00
|
|
|
$ git clone https://github.com/scottlamb/moonfire-nvr.git
|
2021-08-11 16:52:53 -04:00
|
|
|
$ cd moonfire-nvr
|
2021-01-21 19:00:38 -05:00
|
|
|
```
|
|
|
|
|
2023-10-14 18:52:06 -04:00
|
|
|
## Building
|
2021-01-21 19:00:38 -05:00
|
|
|
|
2023-10-14 18:52:06 -04:00
|
|
|
Moonfire NVR should run natively on any Unix-like system. It's been tested on
|
|
|
|
Linux, macOS, and FreeBSD. (In theory [Windows Subsystem for
|
2021-01-21 19:00:38 -05:00
|
|
|
Linux](https://docs.microsoft.com/en-us/windows/wsl/about) should also work.
|
|
|
|
Please speak up if you try it.)
|
|
|
|
|
2023-10-14 18:52:06 -04:00
|
|
|
To build the server, you will need [SQLite3](https://www.sqlite.org/). You
|
|
|
|
can skip this if compiling with `--features=rusqlite/bundled` and don't
|
|
|
|
mind the `moonfire-nvr sql` command not working.
|
2021-01-21 19:00:38 -05:00
|
|
|
|
2021-08-12 01:27:36 -04:00
|
|
|
To build the UI, you'll need a [nodejs](https://nodejs.org/en/download/) release
|
2023-01-11 22:37:13 -05:00
|
|
|
in "Maintenance" or "LTS" status: currently v14, v16, or v18.
|
2021-02-12 11:46:10 -05:00
|
|
|
|
2021-01-21 19:00:38 -05:00
|
|
|
On recent Ubuntu or Raspbian Linux, the following command will install
|
2021-08-12 01:27:36 -04:00
|
|
|
most non-Rust dependencies:
|
2021-01-21 19:00:38 -05:00
|
|
|
|
2021-08-23 15:40:14 -04:00
|
|
|
```console
|
2021-01-21 19:00:38 -05:00
|
|
|
$ sudo apt-get install \
|
|
|
|
build-essential \
|
|
|
|
libsqlite3-dev \
|
|
|
|
pkgconf \
|
|
|
|
sqlite3 \
|
|
|
|
tzdata
|
|
|
|
```
|
|
|
|
|
2023-01-11 00:03:01 -05:00
|
|
|
Ubuntu 20.04 LTS (still popular, supported by Ubuntu until April 2025) bundles
|
|
|
|
node 10, which has reached end-of-life (see
|
|
|
|
[node.js: releases](https://nodejs.org/en/about/releases/)).
|
2021-08-12 01:27:36 -04:00
|
|
|
So rather than install the `nodejs` and `npm` packages from the built-in
|
|
|
|
repository, see [Installing Node.js via package
|
|
|
|
manager](https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions).
|
|
|
|
|
2021-01-21 19:00:38 -05:00
|
|
|
On macOS with [Homebrew](https://brew.sh/) and Xcode installed, try the
|
|
|
|
following command:
|
|
|
|
|
2021-08-23 15:40:14 -04:00
|
|
|
```console
|
2022-03-18 13:30:23 -04:00
|
|
|
$ brew install node
|
2021-01-21 19:00:38 -05:00
|
|
|
```
|
|
|
|
|
2023-07-04 17:59:10 -04:00
|
|
|
Next, you need Rust 1.65+ and Cargo. The easiest way to install them is by
|
2021-08-19 13:37:02 -04:00
|
|
|
following the instructions at [rustup.rs](https://www.rustup.rs/). Avoid
|
|
|
|
your Linux distribution's Rust packages, which tend to be too old.
|
|
|
|
(At least on Debian-based systems; Arch and Gentoo might be okay.)
|
2021-01-21 19:00:38 -05:00
|
|
|
|
|
|
|
Once prerequisites are installed, you can build the server and find it in
|
|
|
|
`target/release/moonfire-nvr`:
|
|
|
|
|
2021-08-23 15:40:14 -04:00
|
|
|
```console
|
2021-01-22 17:43:41 -05:00
|
|
|
$ cd server
|
2021-01-21 19:00:38 -05:00
|
|
|
$ cargo test
|
|
|
|
$ cargo build --release
|
2021-08-20 00:42:52 -04:00
|
|
|
$ sudo install -m 755 target/release/moonfire-nvr /usr/local/bin
|
2021-09-26 11:40:22 -04:00
|
|
|
$ cd ..
|
2021-01-21 19:00:38 -05:00
|
|
|
```
|
|
|
|
|
2021-08-20 00:42:52 -04:00
|
|
|
You can build the UI via `npm` and find it in the `ui/build` directory:
|
2021-01-21 19:00:38 -05:00
|
|
|
|
2021-08-23 15:40:14 -04:00
|
|
|
```console
|
2021-01-22 17:43:41 -05:00
|
|
|
$ cd ui
|
2021-02-12 11:46:10 -05:00
|
|
|
$ npm install
|
|
|
|
$ npm run build
|
2021-08-20 00:54:58 -04:00
|
|
|
$ sudo mkdir /usr/local/lib/moonfire-nvr
|
2021-09-14 23:28:21 -04:00
|
|
|
$ cd ..
|
2021-08-20 00:54:58 -04:00
|
|
|
$ sudo rsync --recursive --delete --chmod=D755,F644 ui/build/ /usr/local/lib/moonfire-nvr/ui
|
2021-01-21 19:00:38 -05:00
|
|
|
```
|
|
|
|
|
|
|
|
### Running interactively straight from the working copy
|
|
|
|
|
|
|
|
The author finds it convenient for local development to set up symlinks so that
|
|
|
|
the binaries in the working copy will run via just `nvr`:
|
|
|
|
|
2021-08-23 15:40:14 -04:00
|
|
|
```console
|
2021-08-20 00:42:52 -04:00
|
|
|
$ sudo mkdir /usr/local/lib/moonfire-nvr
|
|
|
|
$ sudo ln -s `pwd`/ui/build /usr/local/lib/moonfire-nvr/ui
|
2021-01-21 19:00:38 -05:00
|
|
|
$ sudo mkdir /var/lib/moonfire-nvr
|
2023-02-15 09:35:46 -05:00
|
|
|
$ sudo chown $USER: /var/lib/moonfire-nvr
|
2021-10-01 00:30:03 -04:00
|
|
|
$ ln -s `pwd`/server/target/release/moonfire-nvr $HOME/bin/moonfire-nvr
|
2021-01-21 19:00:38 -05:00
|
|
|
$ ln -s moonfire-nvr $HOME/bin/nvr
|
|
|
|
$ nvr init
|
|
|
|
$ nvr config
|
|
|
|
$ nvr run
|
|
|
|
```
|
|
|
|
|
|
|
|
(Alternatively, you could symlink to `target/debug/moonfire-nvr` and compile
|
|
|
|
with `cargo build` rather than `cargo build --release`, for a faster build
|
|
|
|
cycle and slower performance.)
|
|
|
|
|
2023-10-14 18:52:06 -04:00
|
|
|
## Release procedure
|
2021-01-21 19:00:38 -05:00
|
|
|
|
2023-10-14 18:52:06 -04:00
|
|
|
Releases are currently a bit manual. From a completely clean git work tree,
|
2021-01-21 19:00:38 -05:00
|
|
|
|
2023-10-14 18:52:06 -04:00
|
|
|
1. manually verify the current commit is pushed to github's master branch and
|
|
|
|
has a green checkmark indicating CI passed.
|
|
|
|
2. update versions:
|
|
|
|
* update `server/Cargo.toml` version by hand; run `cargo test --workspace`
|
|
|
|
to update `Cargo.lock`.
|
|
|
|
* ensure `README.md` and `CHANGELOG.md` refer to the new version.
|
|
|
|
3. run commands:
|
|
|
|
```bash
|
|
|
|
VERSION=x.y.z
|
|
|
|
git commit -am "prepare version ${VERSION}"
|
|
|
|
git tag -a "v${VERSION}" -m "version ${VERSION}"
|
|
|
|
git push origin "v${VERSION}"
|
|
|
|
```
|
2021-01-21 19:00:38 -05:00
|
|
|
|
2023-10-14 18:52:06 -04:00
|
|
|
The rest should happen automatically—the tag push will fire off a GitHub
|
|
|
|
Actions workflow which creates a release, cross-compiles statically compiled
|
|
|
|
binaries for three different platforms, and uploads them to the release.
|