Leave behind build artifacts for debugging
This commit is contained in:
parent
9a828c8a5d
commit
825aa534c2
|
@ -1,3 +1,4 @@
|
||||||
*.deb
|
|
||||||
*.log
|
*.log
|
||||||
|
debs
|
||||||
node_modules
|
node_modules
|
||||||
|
work
|
||||||
|
|
2
Makefile
2
Makefile
|
@ -2,7 +2,7 @@ export PATH := bin:$(PATH)
|
||||||
|
|
||||||
.PHONY: debug
|
.PHONY: debug
|
||||||
debug:
|
debug:
|
||||||
node builder/build.js python riju-lang-python.deb
|
node builder/build.js python
|
||||||
|
|
||||||
.PHONY: build-image
|
.PHONY: build-image
|
||||||
build-image:
|
build-image:
|
||||||
|
|
|
@ -3,7 +3,6 @@ const fs = require("fs").promises;
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const process = require("process");
|
const process = require("process");
|
||||||
|
|
||||||
const tmp = require("tmp-promise");
|
|
||||||
const YAML = require("yaml");
|
const YAML = require("yaml");
|
||||||
|
|
||||||
// The build scripts in the language configs assume a specific build
|
// The build scripts in the language configs assume a specific build
|
||||||
|
@ -12,14 +11,20 @@ const YAML = require("yaml");
|
||||||
// * the working directory starts out empty
|
// * the working directory starts out empty
|
||||||
// * the ${pkg} environment variable has been set to an absolute path
|
// * the ${pkg} environment variable has been set to an absolute path
|
||||||
// to the directory where the package should be built
|
// to the directory where the package should be built
|
||||||
// * we are using bash with 'set -euxo pipefail'
|
// * we are using bash with 'set -euo pipefail'
|
||||||
|
|
||||||
tmp.setGracefulCleanup();
|
|
||||||
|
|
||||||
// Read the YAML config file for the language with the given string ID
|
// Read the YAML config file for the language with the given string ID
|
||||||
// and return it as an object.
|
// and return it as an object.
|
||||||
async function readLangConfig(lang) {
|
async function readLangConfig(lang) {
|
||||||
return YAML.parse(await fs.readFile(`langs/${lang}.yaml`, "utf-8"));
|
const langConfig = YAML.parse(
|
||||||
|
await fs.readFile(`langs/${lang}.yaml`, "utf-8")
|
||||||
|
);
|
||||||
|
if (langConfig.id !== lang) {
|
||||||
|
throw new Error(
|
||||||
|
`lang config id ${langConfig.id} doesn't match expected ${lang}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return langConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used to log all progress messages. Not sure what this should do
|
// Used to log all progress messages. Not sure what this should do
|
||||||
|
@ -32,9 +37,13 @@ function log(message) {
|
||||||
async function runCommand(cmd) {
|
async function runCommand(cmd) {
|
||||||
log(`$ ${cmd}`);
|
log(`$ ${cmd}`);
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const proc = child_process.spawn("bash", ["-c", cmd], {
|
const proc = child_process.spawn(
|
||||||
stdio: "inherit",
|
"bash",
|
||||||
});
|
["-c", `set -euo pipefail; ${cmd}`],
|
||||||
|
{
|
||||||
|
stdio: "inherit",
|
||||||
|
}
|
||||||
|
);
|
||||||
proc.on("error", reject);
|
proc.on("error", reject);
|
||||||
proc.on("close", (code) => {
|
proc.on("close", (code) => {
|
||||||
if (code === 0) {
|
if (code === 0) {
|
||||||
|
@ -57,7 +66,7 @@ async function buildPackage(langConfig, debPath) {
|
||||||
install: { apt, pip, manual },
|
install: { apt, pip, manual },
|
||||||
} = langConfig;
|
} = langConfig;
|
||||||
const timestamp = new Date().getTime();
|
const timestamp = new Date().getTime();
|
||||||
const pkgDir = process.env.pkg;
|
const pkgdir = process.env.pkg;
|
||||||
log();
|
log();
|
||||||
log(`Building package riju-lang-${id}...`);
|
log(`Building package riju-lang-${id}...`);
|
||||||
let debianControlData = `\
|
let debianControlData = `\
|
||||||
|
@ -74,9 +83,9 @@ Depends: ${apt.join(", ")}
|
||||||
}
|
}
|
||||||
log("Writing Debian control file:");
|
log("Writing Debian control file:");
|
||||||
log(debianControlData.replaceAll(/^/gm, " "));
|
log(debianControlData.replaceAll(/^/gm, " "));
|
||||||
await fs.mkdir(`${pkgDir}/DEBIAN`);
|
await fs.mkdir(`${pkgdir}/DEBIAN`);
|
||||||
await fs.writeFile(`${pkgDir}/DEBIAN/control`, debianControlData);
|
await fs.writeFile(`${pkgdir}/DEBIAN/control`, debianControlData);
|
||||||
await runCommand(`fakeroot dpkg-deb --build ${pkgDir} ${debPath}`);
|
await runCommand(`fakeroot dpkg-deb --build ${pkgdir} ${debPath}`);
|
||||||
log(`Finished building package riju-lang-${id}.`);
|
log(`Finished building package riju-lang-${id}.`);
|
||||||
log();
|
log();
|
||||||
}
|
}
|
||||||
|
@ -99,23 +108,28 @@ async function withTempDir(cb) {
|
||||||
// process environment destructively.
|
// process environment destructively.
|
||||||
async function main() {
|
async function main() {
|
||||||
const args = process.argv.slice(2);
|
const args = process.argv.slice(2);
|
||||||
if (args.length !== 2) {
|
if (args.length !== 1) {
|
||||||
console.error("usage: build.js LANG DEB");
|
console.error("usage: build.js LANG");
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
let [lang, debPath] = args;
|
const [lang] = args;
|
||||||
debPath = path.resolve(process.cwd(), debPath);
|
const cwd = process.cwd();
|
||||||
|
const srcdir = `${cwd}/work/${lang}/src`;
|
||||||
|
const pkgdir = `${cwd}/work/${lang}/pkg`;
|
||||||
|
const debPath = `${cwd}/debs/riju-lang-${lang}.deb`;
|
||||||
const langConfig = await readLangConfig(lang);
|
const langConfig = await readLangConfig(lang);
|
||||||
await withTempDir(async (srcDir) => {
|
log(`Source directory: ${srcdir}`);
|
||||||
await withTempDir(async (pkgDir) => {
|
log(`Package directory: ${pkgdir}`);
|
||||||
log(`Source directory: ${srcDir}`);
|
log(`Will write .deb file to: ${debPath}`);
|
||||||
log(`Package directory: ${pkgDir}`);
|
await fs.rmdir(srcdir, { recursive: true });
|
||||||
log(`Will write .deb file to: ${debPath}`);
|
await fs.rmdir(pkgdir, { recursive: true });
|
||||||
process.chdir(srcDir);
|
await fs.rm(debPath, { force: true });
|
||||||
process.env.pkg = pkgDir;
|
await fs.mkdir(srcdir, { recursive: true });
|
||||||
await buildPackage(langConfig, debPath);
|
await fs.mkdir(pkgdir, { recursive: true });
|
||||||
});
|
await fs.mkdir(path.dirname(debPath), { recursive: true });
|
||||||
});
|
process.chdir(srcdir);
|
||||||
|
process.env.pkg = pkgdir;
|
||||||
|
await buildPackage(langConfig, debPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
main().catch((err) => {
|
main().catch((err) => {
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"tmp-promise": "^3.0.2",
|
|
||||||
"yaml": "^1.10.0"
|
"yaml": "^1.10.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
93
yarn.lock
93
yarn.lock
|
@ -2,99 +2,6 @@
|
||||||
# yarn lockfile v1
|
# yarn lockfile v1
|
||||||
|
|
||||||
|
|
||||||
balanced-match@^1.0.0:
|
|
||||||
version "1.0.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
|
|
||||||
integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c=
|
|
||||||
|
|
||||||
brace-expansion@^1.1.7:
|
|
||||||
version "1.1.11"
|
|
||||||
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
|
|
||||||
integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==
|
|
||||||
dependencies:
|
|
||||||
balanced-match "^1.0.0"
|
|
||||||
concat-map "0.0.1"
|
|
||||||
|
|
||||||
concat-map@0.0.1:
|
|
||||||
version "0.0.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
|
|
||||||
integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=
|
|
||||||
|
|
||||||
fs.realpath@^1.0.0:
|
|
||||||
version "1.0.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
|
|
||||||
integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8=
|
|
||||||
|
|
||||||
glob@^7.1.3:
|
|
||||||
version "7.1.6"
|
|
||||||
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6"
|
|
||||||
integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==
|
|
||||||
dependencies:
|
|
||||||
fs.realpath "^1.0.0"
|
|
||||||
inflight "^1.0.4"
|
|
||||||
inherits "2"
|
|
||||||
minimatch "^3.0.4"
|
|
||||||
once "^1.3.0"
|
|
||||||
path-is-absolute "^1.0.0"
|
|
||||||
|
|
||||||
inflight@^1.0.4:
|
|
||||||
version "1.0.6"
|
|
||||||
resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
|
|
||||||
integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=
|
|
||||||
dependencies:
|
|
||||||
once "^1.3.0"
|
|
||||||
wrappy "1"
|
|
||||||
|
|
||||||
inherits@2:
|
|
||||||
version "2.0.4"
|
|
||||||
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c"
|
|
||||||
integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==
|
|
||||||
|
|
||||||
minimatch@^3.0.4:
|
|
||||||
version "3.0.4"
|
|
||||||
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
|
|
||||||
integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==
|
|
||||||
dependencies:
|
|
||||||
brace-expansion "^1.1.7"
|
|
||||||
|
|
||||||
once@^1.3.0:
|
|
||||||
version "1.4.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
|
|
||||||
integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E=
|
|
||||||
dependencies:
|
|
||||||
wrappy "1"
|
|
||||||
|
|
||||||
path-is-absolute@^1.0.0:
|
|
||||||
version "1.0.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
|
|
||||||
integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18=
|
|
||||||
|
|
||||||
rimraf@^3.0.0:
|
|
||||||
version "3.0.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a"
|
|
||||||
integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==
|
|
||||||
dependencies:
|
|
||||||
glob "^7.1.3"
|
|
||||||
|
|
||||||
tmp-promise@^3.0.2:
|
|
||||||
version "3.0.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/tmp-promise/-/tmp-promise-3.0.2.tgz#6e933782abff8b00c3119d63589ca1fb9caaa62a"
|
|
||||||
integrity sha512-OyCLAKU1HzBjL6Ev3gxUeraJNlbNingmi8IrHHEsYH8LTmEuhvYfqvhn2F/je+mjf4N58UmZ96OMEy1JanSCpA==
|
|
||||||
dependencies:
|
|
||||||
tmp "^0.2.0"
|
|
||||||
|
|
||||||
tmp@^0.2.0:
|
|
||||||
version "0.2.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.2.1.tgz#8457fc3037dcf4719c251367a1af6500ee1ccf14"
|
|
||||||
integrity sha512-76SUhtfqR2Ijn+xllcI5P1oyannHNHByD80W1q447gU3mp9G9PSpGdWmjUOHRDPiHYacIk66W7ubDTuPF3BEtQ==
|
|
||||||
dependencies:
|
|
||||||
rimraf "^3.0.0"
|
|
||||||
|
|
||||||
wrappy@1:
|
|
||||||
version "1.0.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
|
|
||||||
integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=
|
|
||||||
|
|
||||||
yaml@^1.10.0:
|
yaml@^1.10.0:
|
||||||
version "1.10.0"
|
version "1.10.0"
|
||||||
resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.0.tgz#3b593add944876077d4d683fee01081bd9fff31e"
|
resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.0.tgz#3b593add944876077d4d683fee01081bd9fff31e"
|
||||||
|
|
Loading…
Reference in New Issue