mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-24 07:46:39 +00:00
Fix Windows standalone zip installer (missing mmmagic db for CRLF conversion)
Change-type: patch
This commit is contained in:
parent
654d1dcff8
commit
be209f1626
@ -95,17 +95,18 @@ async function buildPkg() {
|
||||
|
||||
await execPkg(args);
|
||||
|
||||
const xpaths: Array<[string, string[]]> = [
|
||||
// [platform, [path, to, file]]
|
||||
['*', ['open', 'xdg-open']],
|
||||
['darwin', ['denymount', 'bin', 'denymount']],
|
||||
const paths: Array<[string, string[], string[]]> = [
|
||||
// [platform, [source path], [destination path]]
|
||||
['*', ['open', 'xdg-open'], ['xdg-open']],
|
||||
['darwin', ['denymount', 'bin', 'denymount'], ['denymount']],
|
||||
['win32', ['mmmagic', 'magic', 'magic.mgc'], ['mmmagic', 'magic.mgc']],
|
||||
];
|
||||
await Bluebird.map(xpaths, ([platform, xpath]) => {
|
||||
await Bluebird.map(paths, ([platform, source, dest]) => {
|
||||
if (platform === '*' || platform === process.platform) {
|
||||
// eg copy from node_modules/opn/xdg-open to build-bin/xdg-open
|
||||
// eg copy from node_modules/open/xdg-open to build-bin/xdg-open
|
||||
return fs.copy(
|
||||
path.join(ROOT, 'node_modules', ...xpath),
|
||||
path.join(ROOT, 'build-bin', xpath.pop()!),
|
||||
path.join(ROOT, 'node_modules', ...source),
|
||||
path.join(ROOT, 'build-bin', ...dest),
|
||||
);
|
||||
}
|
||||
});
|
||||
|
@ -1804,7 +1804,8 @@ left hand side of the = character will be treated as the variable name.
|
||||
|
||||
#### --convert-eol, -l
|
||||
|
||||
Convert line endings from CRLF (Windows format) to LF (Unix format). Source files are not modified.
|
||||
On Windows only, convert line endings from CRLF (Windows format) to LF (Unix format).
|
||||
Source files are not modified.
|
||||
|
||||
# Settings
|
||||
|
||||
@ -1933,7 +1934,7 @@ Path to a YAML or JSON file with passwords for a private Docker registry
|
||||
|
||||
#### --convert-eol, -l
|
||||
|
||||
Convert line endings from CRLF (Windows format) to LF (Unix format). Source files are not modified.
|
||||
On Windows only, convert line endings from CRLF (Windows format) to LF (Unix format). Source files are not modified.
|
||||
|
||||
#### --docker, -P <docker>
|
||||
|
||||
@ -2062,7 +2063,7 @@ Path to a YAML or JSON file with passwords for a private Docker registry
|
||||
|
||||
#### --convert-eol, -l
|
||||
|
||||
Convert line endings from CRLF (Windows format) to LF (Unix format). Source files are not modified.
|
||||
On Windows only, convert line endings from CRLF (Windows format) to LF (Unix format). Source files are not modified.
|
||||
|
||||
#### --docker, -P <docker>
|
||||
|
||||
|
@ -248,7 +248,8 @@ export const push: CommandDefinition<
|
||||
signature: 'convert-eol',
|
||||
alias: 'l',
|
||||
description: stripIndent`
|
||||
Convert line endings from CRLF (Windows format) to LF (Unix format). Source files are not modified.`,
|
||||
On Windows only, convert line endings from CRLF (Windows format) to LF (Unix format).
|
||||
Source files are not modified.`,
|
||||
boolean: true,
|
||||
},
|
||||
],
|
||||
|
@ -54,7 +54,9 @@ exports.appendOptions = (opts) ->
|
||||
},
|
||||
{
|
||||
signature: 'convert-eol'
|
||||
description: 'Convert line endings from CRLF (Windows format) to LF (Unix format). Source files are not modified.'
|
||||
description: '
|
||||
On Windows only, convert line endings from CRLF (Windows format) to LF (Unix format).
|
||||
Source files are not modified.'
|
||||
boolean: true
|
||||
alias: 'l'
|
||||
}
|
||||
@ -149,7 +151,11 @@ exports.tarDirectory = tarDirectory = (dir, { preFinalizeCallback, convertEol }
|
||||
streamToPromise = require('stream-to-promise')
|
||||
{ FileIgnorer } = require('./ignore')
|
||||
{ toPosixPath } = require('resin-multibuild').PathUtils
|
||||
{ readFileWithEolConversion } = require('./eol-conversion')
|
||||
if process.platform == 'win32'
|
||||
{ readFileWithEolConversion } = require('./eol-conversion')
|
||||
readFile = (file) -> readFileWithEolConversion(file, convertEol)
|
||||
else
|
||||
readFile = fs.readFile
|
||||
|
||||
getFiles = ->
|
||||
streamToPromise(klaw(dir))
|
||||
@ -166,7 +172,7 @@ exports.tarDirectory = tarDirectory = (dir, { preFinalizeCallback, convertEol }
|
||||
.filter(ignore.filter)
|
||||
.map (file) ->
|
||||
relPath = path.relative(path.resolve(dir), file)
|
||||
Promise.join relPath, fs.stat(file), readFileWithEolConversion(file, convertEol),
|
||||
Promise.join relPath, fs.stat(file), readFile(file),
|
||||
(filename, stats, data) ->
|
||||
pack.entry({ name: toPosixPath(filename), size: stats.size, mode: stats.mode }, data)
|
||||
.then ->
|
||||
|
@ -92,11 +92,6 @@ export async function readFileWithEolConversion(
|
||||
): Promise<Buffer> {
|
||||
const { fs } = await import('mz');
|
||||
const fileBuffer = await fs.readFile(filepath);
|
||||
|
||||
if (process.platform !== 'win32') {
|
||||
return fileBuffer;
|
||||
}
|
||||
|
||||
const Logger = await import('./logger');
|
||||
const globalLogger = Logger.getLogger();
|
||||
|
||||
|
14
patches/mmmagic+0.5.3.patch
Normal file
14
patches/mmmagic+0.5.3.patch
Normal file
@ -0,0 +1,14 @@
|
||||
diff --git a/node_modules/mmmagic/lib/index.js b/node_modules/mmmagic/lib/index.js
|
||||
index bd18a4b..a19a149 100644
|
||||
--- a/node_modules/mmmagic/lib/index.js
|
||||
+++ b/node_modules/mmmagic/lib/index.js
|
||||
@@ -1,5 +1,8 @@
|
||||
var Magic = require('../build/Release/magic');
|
||||
-var fbpath = require('path').join(__dirname, '..', 'magic', 'magic');
|
||||
+var path = require('path');
|
||||
+var fbpath = process.pkg
|
||||
+ ? path.join(path.dirname(process.execPath), 'mmmagic', 'magic')
|
||||
+ : path.join(__dirname, '..', 'magic', 'magic');
|
||||
Magic.setFallback(fbpath);
|
||||
|
||||
module.exports = {
|
Loading…
Reference in New Issue
Block a user