Skip to content

Commit

Permalink
Add build script for bb-debs update (#239)
Browse files Browse the repository at this point in the history
* Create bb-debs updatescript

* Create bb-debs build.sh

* Remove package directory after build
  • Loading branch information
CrypticaScriptura authored and joshmh committed Feb 1, 2019
1 parent 131c5b7 commit 3cb2f76
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
32 changes: 32 additions & 0 deletions deploy/bb-debs/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
set -e

SUB_DIR=bb-debs
SCRIPT_DIR=$(dirname $0)

EXPORT_ROOT=${1-$LAMASSU_EXPORT}

if [ -z "$EXPORT_ROOT" ]
then
echo "Builds a lamassu-machine package file for installing dependencies required for Bullish Bunene (v7.2)."
echo -e "\nUsage:"
echo -e "build <target directory>\n"
exit 1
fi

MACHINE_DIR=$SCRIPT_DIR/../..
EXPORT_BASE=$EXPORT_ROOT/$SUB_DIR
EXPORT_DIR=$EXPORT_BASE/package
UPDATESCRIPT=$SCRIPT_DIR/updatescript.js
rm -rf $EXPORT_DIR
mkdir -p $EXPORT_DIR

# Needed for update script on target device
cp $MACHINE_DIR/node_modules/async/lib/async.js $EXPORT_DIR
cp $SCRIPT_DIR/../report.js $EXPORT_DIR
cp $UPDATESCRIPT $EXPORT_DIR

echo "Building..."
node $SCRIPT_DIR/../build.js $EXPORT_BASE
rm -rf $EXPORT_DIR
echo "Complete."
52 changes: 52 additions & 0 deletions deploy/bb-debs/updatescript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
'use strict';

var fs = require('fs');
var zlib = require('zlib');
var async = require('./async');
var cp = require('child_process');

var TIMEOUT = 120000;

var hardwareCode = process.argv[2] || 'N7G1';

function report(err, cb) {
console.log('> report', err);
if (!cb && typeof(err) === 'function') {
cb = err;
err = null;
}

fs.writeFileSync('log', err)

try {
require('./report').report(err, 'finished.', cb);
} catch (err) {
cb(err);
}
}

function command(cmd, cb) {
cp.exec(cmd, {timeout: TIMEOUT}, function(err, stdout, stderr) {
console.log('> ' + cmd);
if (err && stderr) err.stderr = stderr;
cb(err);
});
}

function installDebs(cb) {
async.series([
async.retry(2, async.apply(command, 'apt install -y libopencv-core2.4 libopencv-highgui2.4 libopencv-imgproc2.4 libopencv-video2.4 libopencv-features2d2.4 libopencv-objdetect2.4')),
], cb);
}

async.series([
async.apply(installDebs),
async.apply(report)
], function(err) {
async.series([
async.apply(report, err),
], function (err2) {
if (err2) throw err2;
else throw err;
});
});

0 comments on commit 3cb2f76

Please sign in to comment.