Feature/squashfs (#356)
* shorten link * Add zip to squash * squashfs signing * Format * add secrets * release fix * revert testing * check for needed commands * changelog
This commit is contained in:
1 parent
dc7cded3f5
commit
b534ea68db
9 files changed
+80
-55
No files matched your search
+19
-3
@@ -3,16 +3,32 @@
|
||||
|
||||
const getEnvVars = require('./get-env-vars');
|
||||
const rokuDeploy = require('roku-deploy');
|
||||
const { ArgumentParser } = require('argparse');
|
||||
|
||||
const config = getEnvVars(['ROKU_DEV_TARGET', 'ROKU_DEVPASSWORD', 'ROKU_SIGN_PASSWORD']);
|
||||
|
||||
const parser = new ArgumentParser({
|
||||
description: 'Sign package'
|
||||
});
|
||||
|
||||
parser.add_argument('--out-file', { help: 'A zip file to sign' });
|
||||
parser.add_argument('--out-dir', { help: 'Folder of the zip file' });
|
||||
parser.add_argument('--staging-dir', { help: 'Path to the staging directory' });
|
||||
|
||||
const args = parser.parse_args();
|
||||
|
||||
const outFile = args.out_file;
|
||||
const outDir = args.out_dir;
|
||||
const stagingDir = args.staging_dir;
|
||||
|
||||
const options = {
|
||||
host: config.ROKU_DEV_TARGET,
|
||||
packagePort: config.ROKU_DEV_TARGET_PORT || 80,
|
||||
password: config.ROKU_DEVPASSWORD,
|
||||
outDir: 'release',
|
||||
outFile: 'playlet.zip',
|
||||
outDir: outDir,
|
||||
outFile: outFile,
|
||||
failOnCompileError: true,
|
||||
stagingDir: 'build/playlet-app',
|
||||
stagingDir: stagingDir,
|
||||
retainStagingDir: true,
|
||||
signingPassword: config.ROKU_SIGN_PASSWORD,
|
||||
};
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
// Description: pulls the release zip from github, signs it and retrieves it from the Roku device
|
||||
|
||||
const shell = require('shelljs');
|
||||
|
||||
if (!shell.which('git')) {
|
||||
shell.echo('Sorry, this script requires git');
|
||||
shell.exit(1);
|
||||
}
|
||||
|
||||
shell.exec('git fetch --tags --force');
|
||||
|
||||
// get current commit hash
|
||||
const gitCommitHash = shell.exec('git rev-parse HEAD').stdout.trim();
|
||||
|
||||
// get current tag
|
||||
const gitTags = shell.exec(`git tag --contains ${gitCommitHash}`)
|
||||
.stdout.trim()
|
||||
.split('\n')
|
||||
.map(tag => tag.trim());
|
||||
|
||||
const expectedGitTag = `v${require('../package.json').version}`;
|
||||
if (gitTags.length === 0) {
|
||||
console.error(`No git tag found. Signing anyway...`);
|
||||
}
|
||||
if (!gitTags.includes(expectedGitTag)) {
|
||||
console.error(`Expected git tag ${expectedGitTag} but found [${gitTags.join(",")}]. Signing anyway...`);
|
||||
}
|
||||
|
||||
// download playlet.zip from github
|
||||
const zipUrl = `https://github.com/iBicha/playlet/releases/download/${expectedGitTag}/playlet.zip`
|
||||
shell.exec(`curl --fail -L -o release/playlet.zip "${zipUrl}"`);
|
||||
|
||||
// sign the package
|
||||
shell.exec('node tools/sign-package.js');
|
||||
@@ -0,0 +1,41 @@
|
||||
const shell = require('shelljs');
|
||||
const { ArgumentParser } = require('argparse')
|
||||
|
||||
if (!shell.which('unzip')) {
|
||||
shell.echo('Sorry, this script requires unzip');
|
||||
shell.exit(1);
|
||||
}
|
||||
|
||||
if (!shell.which('mksquashfs')) {
|
||||
shell.echo('Sorry, this script requires mksquashfs');
|
||||
shell.exit(1);
|
||||
}
|
||||
|
||||
const parser = new ArgumentParser({
|
||||
description: 'Convert a zip file to a squashfs file'
|
||||
});
|
||||
|
||||
parser.add_argument('--in-file', { help: 'A zip file to squash' });
|
||||
parser.add_argument('--out-file', { help: 'A squashfs file to create' });
|
||||
|
||||
const args = parser.parse_args();
|
||||
|
||||
const inFile = args.in_file;
|
||||
const outFile = args.out_file;
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
const { execSync } = require('child_process');
|
||||
|
||||
// Create a temporary directory
|
||||
const tempDir = fs.mkdtempSync('squash-fs-');
|
||||
|
||||
// Unzip the file
|
||||
execSync(`unzip ${inFile} -d ${tempDir}`);
|
||||
|
||||
execSync(`mksquashfs ${tempDir} ${outFile} -force-uid 500 -force-gid 500 -comp zstd -b 32768 -Xcompression-level 22`);
|
||||
|
||||
// Remove the temporary directory
|
||||
execSync(`rm -rf ${tempDir}`);
|
||||
|
||||
console.log(`Created squashfs file: ${outFile}`);
|
||||
Reference in new issue
Block a user