Skip to content

Commit a949e32

Browse files
committed
Merge pull request #8 from runtimejs/fix-kernel-download
Fix kernel download issues
2 parents 46de13f + 2a3507b commit a949e32

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

bin/runtime-qemu.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env node
22

33
var argv = require('minimist')(process.argv.slice(2), {
4-
boolean: ['kvm', 'verbose', 'nographic', 'dry-run', 'netdump', 'curses', 'virtio-rng']
4+
boolean: ['kvm', 'verbose', 'nographic', 'dry-run', 'netdump', 'curses', 'virtio-rng', 'local']
55
});
66
var shell = require('shelljs');
77
var qemu = require('../qemu');
@@ -54,6 +54,7 @@ if (!command) {
5454
shell.echo(' --virtio-rng Enable VIRTIO-RNG entropy source for the runtime.js');
5555
shell.echo(' --nographic Disable graphics');
5656
shell.echo(' --kernel=<kernel> Specify local kernel file to use');
57+
shell.echo(' --local Download the kernel locally (i.e. in the module\'s directory)');
5758
shell.echo(' --kernelver=<ver> Specify kernel version to download (defaults to latest)');
5859
shell.echo('');
5960
shell.echo(' --print-log Show log file written in curses mode (using less)');
@@ -95,7 +96,7 @@ var qemuVirtioRng = !!argv['virtio-rng'];
9596
var dryRun = !!argv['dry-run'];
9697
var verbose = !!argv.verbose;
9798

98-
getRuntime(kernelVer, kernelFile, function(err, runtimeFile) {
99+
getRuntime(kernelVer, kernelFile, !!argv.local, function(err, runtimeFile) {
99100
if (err) {
100101
throw err;
101102
}

get-prebuilt.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ var nugget = require('nugget');
22
var shell = require('shelljs');
33
var path = require('path');
44

5-
module.exports = function(kernelVersion, cb) {
6-
var kernelsDir = path.resolve(__dirname, 'runtimejs-kernels');
5+
module.exports = function(kernelVersion, shouldBeLocal, cb) {
6+
var basePath = shouldBeLocal ? __dirname : process.env[(process.platform === 'win32') ? 'USERPROFILE' : 'HOME'];
7+
var kernelsDir = path.resolve(basePath, '.runtime');
78
if (!shell.test('-d', kernelsDir)) {
89
shell.mkdir(kernelsDir);
910
}

get-runtime.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
var getPrebuilt = require('./get-prebuilt');
22

3-
module.exports = function(kernelVer, kernelFile, cb) {
3+
module.exports = function(kernelVer, kernelFile, shouldBeLocal, cb) {
44
if (!kernelFile) {
5-
return getPrebuilt(kernelVer, cb);
5+
return getPrebuilt(kernelVer, shouldBeLocal, cb);
66
} else {
77
return cb(null, kernelFile);
88
}

0 commit comments

Comments
 (0)