-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add build script for bb-debs update (#239)
* Create bb-debs updatescript * Create bb-debs build.sh * Remove package directory after build
- Loading branch information
1 parent
131c5b7
commit 3cb2f76
Showing
2 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}); | ||
}); |