Automate dbus lib installation depending on system

Signed-off-by: Christina Ying Wang <christina@balena.io>
This commit is contained in:
Christina Ying Wang
2022-09-12 13:33:45 -07:00
committed by Felipe Lalanne
parent 044fa5a038
commit 670b9ff563
4 changed files with 32 additions and 2 deletions

View File

@ -135,7 +135,12 @@ RUN npm run build
# Run the production install here, to avoid the npm dependency on
# the later stage
RUN npm ci --production --no-optional --unsafe-perm --build-from-source --sqlite=/usr/lib \
RUN npm ci \
--production \
--no-optional \
--unsafe-perm \
--build-from-source \
--sqlite=/usr/lib \
&& npm cache clean --force \
# For some reason this doesn't get cleared with the other
# cache

View File

@ -254,6 +254,8 @@ When developing on macOS you may need to install DBus on the development host.
1. `brew install dbus`
2. `npm ci`
On Debian-based systems, `sudo apt install libdbus-1-dev` would be the equivalent.
#### Downgrading versions
The Supervisor will always be forwards compatible so you can just simply run newer versions. If there is data that must be normalized to a new schema such as the naming of engine resources, values in the sqlite database, etc then the new version will automatically take care of that either via [migrations](/src/migrations) or at runtime when the value is queried.

22
build-utils/install-dbus.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/sh
DEBIAN=libdbus-1-dev
OSX=dbus
if command -v apt > /dev/null; then
if dpkg --list | grep $DEBIAN > /dev/null; then
exit 0
else
echo "Installing $DEBIAN..."
sudo apt-get install $DEBIAN
fi
elif command -v brew > /dev/null; then
brew list $OSX > /dev/null || (echo "Installing $OSX..." && brew install $OSX)
else
echo "Neither 'brew' nor 'apt' are available to this system.
Please make sure Supervisor development is done on Linux, OSX, or WSL2,
and that one of the above package managers is installed. If using a
Linux distro without 'apt', please install the dbus development lib
available to your system and run 'npm ci --ignore-scripts' to continue."
exit 0
fi

View File

@ -24,7 +24,8 @@
"prettify": "balena-lint -e ts -e js --typescript --fix src/ test/ typings/ build-utils/ webpack.config.js",
"release": "tsc --project tsconfig.release.json && mv build/src/* build",
"sync": "ts-node --files sync/sync.ts",
"clean": "rimraf build"
"clean": "rimraf build",
"preinstall": "./build-utils/install-dbus.sh || true"
},
"private": true,
"dependencies": {