Start seriously screwing around with GBS.js

This commit is contained in:
Radon Rosborough 2021-06-11 22:17:08 -07:00
parent bcd8551e55
commit 6c678c73ce
17 changed files with 235 additions and 202 deletions

View File

@ -96,28 +96,17 @@ repkg: script # L=<lang> T=<type> : Build fresh .deb and install into live conta
$(MAKE_QUIETLY) shell I=packaging CMD="make pkg L=$(L) T=$(T)"
ctr="$$(docker container ls -f label="riju-install-target=yes" -l -q)"; test "$${ctr}" || (echo "no valid container is live"; exit 1); docker exec "$${ctr}" make install L=$(L) T=$(T)
## This is equivalent to 'make repkg T=lang', 'make repkg T=config'.
## For shared dependencies, use 'make repkg T=shared' directly.
repkgs: # L=<lang> : Build and install fresh lang and config .debs
@: $${L}
node tools/make-foreach.js --types repkg L=$(L)
### Build packaging scripts
script: # L=<lang> T=<type> : Generate a packaging script
@: $${L} $${T}
mkdir -p $(BUILD)
node tools/generate-build-script.js --lang $(L) --type $(T) > $(BUILD)/build.bash
ifeq ($(T),lang)
node tools/generate-build-script.js --lang $(L) --type install > $(BUILD)/install.bash
endif
chmod +x $(BUILD)/build.bash
scripts: # L=<lang> : Generate both lang and config packaging scripts
@: $${L}
node tools/make-foreach.js --types script L=$(L)
## This is equivalent to 'make script T=lang', 'make script T=config'.
## For shared dependencies, use 'make script T=shared' directly.
all-scripts: # Generate packaging scripts for all languages
node tools/write-all-build-scripts.js
@ -146,20 +135,9 @@ pkg-deb: # L=<lang> T=<type> [Z=gzip|xz] : Build .deb from packaging environment
@: $${L} $${T}
fakeroot dpkg-deb --build -Z$(Z) $(BUILD)/pkg $(BUILD)/$(DEB)
## This is equivalent to the sequence 'script', 'pkg-clean', 'pkg-build', 'pkg-deb'.
## This is equivalent to the sequence 'pkg-clean', 'pkg-build', 'pkg-deb'.
pkg: script pkg-clean pkg-build pkg-deb # L=<lang> T=<type> [Z=gzip|xz] : Build fresh .deb
## This is equivalent to 'make pkg T=lang', 'make pkg T=config'. For
## shared dependencies, use 'make pkg T=shared' directly.
#
## Z is the compression type to use; defaults to none. Higher
## compression levels (gzip is moderate, xz is high) take much longer
## but produce much smaller packages.
pkgs: # L=<lang> [Z=gzip|xz] : Build both lang and config .debs
@: $${L}
node tools/make-foreach.js --types pkg L=$(L)
pkg: pkg-clean pkg-build pkg-deb # L=<lang> T=<type> [Z=gzip|xz] : Build fresh .deb
### Install packages
@ -168,10 +146,6 @@ install: # L=<lang> T=<type> : Install built .deb
if [[ -z "$$(ls -A /var/lib/apt/lists)" ]]; then sudo apt update; fi
DEBIAN_FRONTEND=noninteractive sudo -E apt reinstall -y ./$(BUILD)/$(DEB)
installs: # L=<lang> : Install both lang and config .debs
@: $${L}
node tools/make-foreach.js --types install L=$(L)
### Build and run application code
frontend: # Compile frontend assets for production

View File

@ -11,99 +11,30 @@ pushd /tmp/riju-work
export DEBIAN_FRONTEND=noninteractive
dpkg --add-architecture i386
apt-get update
apt-get dist-upgrade -y
(yes || true) | unminimize
apt-get install -y curl gnupg lsb-release wget
# Ceylon
wget https://cacerts.digicert.com/DigiCertTLSRSASHA2562020CA1.crt.pem -O /usr/local/share/ca-certificates/DigiCertTLSRSASHA2562020CA1.crt
# D
wget https://letsencrypt.org/certs/lets-encrypt-r3.pem -O /usr/local/share/ca-certificates/lets-encrypt-r3.crt
update-ca-certificates
ubuntu_ver="$(lsb_release -rs)"
ubuntu_name="$(lsb_release -cs)"
cran_repo="$(curl -fsSL https://cran.r-project.org/bin/linux/ubuntu/ | grep -Eo 'cran[0-9]+' | head -n1)"
node_repo="$(curl -fsSL https://deb.nodesource.com/setup_current.x | grep NODEREPO= | grep -Eo 'node_[0-9]+\.x' | head -n1)"
# .NET
wget "https://packages.microsoft.com/config/ubuntu/${ubuntu_ver}/packages-microsoft-prod.deb"
apt-get install ./packages-microsoft-prod.deb
# Ceylon
curl -fsSL https://downloads.ceylon-lang.org/apt/ceylon-debian-repo.gpg.key | apt-key add -
# Crystal
curl -fsSL https://keybase.io/crystal/pgp_keys.asc | apt-key add -
# Dart
curl -fsSL https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
# Hack
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B4112585D386EB94
# MongoDB
curl -fsSL https://www.mongodb.org/static/pgp/server-4.4.asc | apt-key add -
# Node.js
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
# R
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
# Yarn
curl -fsSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
tee -a /etc/apt/sources.list.d/custom.list >/dev/null <<EOF
# Ceylon
deb [arch=amd64] https://downloads.ceylon-lang.org/apt/ unstable main
# Crystal
deb [arch=amd64] https://dist.crystal-lang.org/apt crystal main
# Dart
deb [arch=amd64] https://storage.googleapis.com/download.dartlang.org/linux/debian stable main
# Hack
deb [arch=amd64] https://dl.hhvm.com/ubuntu ${ubuntu_name} main
# MongoDB
deb [arch=amd64] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse
# Node.js
deb [arch=amd64] https://deb.nodesource.com/${node_repo} ${ubuntu_name} main
# R
deb [arch=amd64] https://cloud.r-project.org/bin/linux/ubuntu ${ubuntu_name}-${cran_repo}/
# Yarn
deb [arch=amd64] https://dl.yarnpkg.com/debian/ stable main
EOF
# Work around brutal packaging error courtesy of Microsoft.
# Unfortunately, the Microsoft repo includes a duplicate version of
# the libodbc1 package whose version is not in sync with the one
# shipped by the corresponding release of Ubuntu. If this one happens
# to be newer, then it can cause horrifyingly difficult to diagnose
# errors later on because there's a conflict between the
# default-available versions of libodbc1 and libodbc1:i386, which has
# in the past surfaced as an inability to install dependencies for
# Erlang. Thanks Microsoft. Please don't. Anyway, solution is to pin
# this repository at a lower priority than the Ubuntu standard
# packages, so the correct version of libodbc1 gets installed by
# default.
tee -a /etc/apt/preferences.d/riju >/dev/null <<EOF
Package: *
Pin: origin packages.microsoft.com
Pin-Priority: 1
EOF
apt-get update
apt-get install -y dctrl-tools

View File

@ -14,6 +14,7 @@ function riju-curl {
export DEBIAN_FRONTEND=noninteractive
riju-curl "build/lang/${LANG}/install.bash" > "install-lang-${LANG}.bash"
riju-curl "build/lang/${LANG}/riju-lang-${LANG}.deb" > "riju-lang-${LANG}.deb"
(
@ -21,6 +22,7 @@ riju-curl "build/lang/${LANG}/riju-lang-${LANG}.deb" > "riju-lang-${LANG}.deb"
(grep -Eo 'riju-shared-[^, ]+' || true) |
sed 's/riju-shared-//'
) | while read name; do
riju-curl "build/shared/${name}/install.bash" > "install-shared-${name}.bash"
riju-curl "build/shared/${name}/riju-shared-${name}.deb" > "riju-shared-${name}.deb"
done
@ -28,12 +30,19 @@ if dpkg-deb -f "riju-lang-${LANG}.deb" -f Depends | grep .; then
apt-get update
fi
if compgen -G "./install-shared-*.bash"; then
for file in ./install-shared-*.bash; do
"${file}"
done
fi
if compgen -G "./riju-shared-*.deb"; then
for file in ./riju-shared-*.deb; do
apt-get install -y "${file}"
done
fi
"./install-lang-${LANG}.bash"
apt-get install -y "./riju-lang-${LANG}.deb"
popd

View File

@ -10,42 +10,24 @@ pushd /tmp/riju-work
export DEBIAN_FRONTEND=noninteractive
dpkg --add-architecture i386
apt-get update
apt-get dist-upgrade -y
(yes || true) | unminimize
apt-get install -y curl gnupg lsb-release wget
wget https://cacerts.digicert.com/DigiCertTLSRSASHA2562020CA1.crt.pem -O /usr/local/share/ca-certificates/DigiCertTLSRSASHA2562020CA1.crt
wget https://letsencrypt.org/certs/lets-encrypt-r3.pem -O /usr/local/share/ca-certificates/lets-encrypt-r3.crt
update-ca-certificates
ubuntu_ver="$(lsb_release -rs)"
ubuntu_name="$(lsb_release -cs)"
node_repo="$(curl -sS https://deb.nodesource.com/setup_current.x | grep NODEREPO= | grep -Eo 'node_[0-9]+\.x' | head -n1)"
wget "https://packages.microsoft.com/config/ubuntu/${ubuntu_ver}/packages-microsoft-prod.deb"
apt-get install ./packages-microsoft-prod.deb
curl -fsSL https://downloads.ceylon-lang.org/apt/ceylon-debian-repo.gpg.key | apt-key add -
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
curl -fsSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
tee -a /etc/apt/sources.list.d/custom.list >/dev/null <<EOF
deb [arch=amd64] https://downloads.ceylon-lang.org/apt/ unstable main
deb [arch=amd64] https://deb.nodesource.com/${node_repo} ${ubuntu_name} main
deb [arch=amd64] https://dl.yarnpkg.com/debian/ stable main
EOF
tee -a /etc/apt/preferences.d/riju >/dev/null <<EOF
Package: *
Pin: origin packages.microsoft.com
Pin-Priority: 1
EOF
packages="
# compilation tools

View File

@ -20,6 +20,14 @@ info:
usage: []
install:
prepare: &add-ceylon-repo
cert:
- "https://cacerts.digicert.com/DigiCertTLSRSASHA2562020CA1.crt.pem"
aptKey:
- "https://downloads.ceylon-lang.org/apt/ceylon-debian-repo.gpg.key"
aptRepo:
- "https://downloads.ceylon-lang.org/apt/ unstable main"
<<: *add-ceylon-repo
apt:
- $(grep-aptavail -F Package ceylon -s Package -n | sort -rV | head -n1)
- openjdk-8-jdk-headless

View File

@ -20,6 +20,10 @@ info:
usage: []
install:
aptKey:
- "https://keybase.io/crystal/pgp_keys.asc"
aptRepo:
- "https://dist.crystal-lang.org/apt crystal main"
apt:
- crystal

View File

@ -4,11 +4,14 @@ aliases:
name: "D"
install:
prepare:
prepare: &add-d-cert
cert:
- "https://letsencrypt.org/certs/lets-encrypt-r3.pem"
manual: |
file="$(curl -fsSL https://dlang.org/download.html | grep -Eo '"https://[^"]+amd64.deb"' | grep -v pre-release | tr -d '"')"
wget "${file}" -O dmd.deb
sudo apt-get install -y ./dmd.deb
sudo --preserve-env=DEBIAN_FRONTEND apt-get install -y ./dmd.deb
<<: *add-d-cert
manual: |
install -d "${pkg}/usr/local/bin"
dub fetch dfmt@~master

View File

@ -3,6 +3,10 @@ name: "Dart"
monacoLang: dart
install:
aptKey:
- "https://dl-ssl.google.com/linux/linux_signing_key.pub"
aptRepo:
- "https://storage.googleapis.com/download.dartlang.org/linux/debian stable main"
apt:
- dart

View File

@ -6,6 +6,10 @@ aliases:
name: "Hack"
install:
aptKey:
- "B4112585D386EB94"
aptRepo:
- "https://dl.hhvm.com/ubuntu ${ubuntu_name} main"
apt:
- hhvm

View File

@ -2,17 +2,14 @@ id: "mongodb"
aliases:
- "mongo"
- "mongod"
- "webscale"
name: "MongoDB"
install:
prepare:
aptRepo:
- "http://archive.ubuntu.com/ubuntu/ focal main universe"
manual: |
sudo tee -a /etc/apt/sources.list.d/focal.list >/dev/null <<EOF
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ focal main universe
EOF
sudo apt-get update
for name in mongodb mongodb-clients mongodb-server mongodb-server-core; do
apt-get download "${name}"
mv "${name}"_*.deb "${name}.deb"

View File

@ -7,11 +7,14 @@ name: "Q#"
install:
# Apparently, the Q# project template is hardcoded to use version
# 3.x of the .NET SDK. Not sure why.
prepare:
prepare: &install-dotnet
preface: |
sudo --preserve-env=DEBIAN_FRONTEND apt-get update
wget "https://packages.microsoft.com/config/ubuntu/${ubuntu_ver}/packages-microsoft-prod.deb"
sudo --preserve-env=DEBIAN_FRONTEND apt-get install ./packages-microsoft-prod.deb
apt:
- $(grep-aptavail -wF Package "dotnet-sdk-3\.[0-9.]+" -s Package -n | sort -Vr | head -n1)
apt:
- $(grep-aptavail -wF Package "dotnet-sdk-3\.[0-9.]+" -s Package -n | sort -Vr | head -n1)
<<: *install-dotnet
# We should cache the .dotnet directory to avoid a .NET banner being
# printed, and we should cache the main directory because there is a
# generated main.csproj file that is needed by .NET. Finally we

View File

@ -5,6 +5,10 @@ name: "R"
monacoLang: r
install:
aptKey:
- "E298A3A825C0D65DFD57CBB651716619E084DAB9"
aptRepo:
- "https://cloud.r-project.org/bin/linux/ubuntu ${ubuntu_name}-$(curl -fsSL https://cran.r-project.org/bin/linux/ubuntu/ | grep -Eo 'cran[0-9]+' | head -n1)/"
apt:
- r-base

View File

@ -14,7 +14,9 @@ import YAML from "yaml";
// * we are using bash with 'set -euxo pipefail'
async function readJSONSchemaFromDisk() {
return YAML.parse(await fs.readFile("tools/jsonschema.yaml", "utf-8"));
return YAML.parse(await fs.readFile("tools/jsonschema.yaml", "utf-8"), {
merge: true,
});
}
const jsonSchemaPromise = readJSONSchemaFromDisk();
@ -38,8 +40,8 @@ export async function getSharedDeps() {
// Return a list of objects representing the packages to be built. See
// the function implementation for the full list of keys.
export async function getPackages() {
// The order (shared, lang, config) is important to get dependencies
// correct due to poor abstractions in plan-publish.js.
// The order (shared, then lang) is important to get dependencies
// correct when building artifacts.
const packages = [];
for (const lang of await getSharedDeps()) {
const type = "shared";
@ -53,16 +55,15 @@ export async function getPackages() {
});
}
for (const lang of await getLangs()) {
for (const type of ["lang", "config"]) {
const name = `riju-${type}-${lang}`;
packages.push({
lang,
type,
name,
buildScriptPath: `build/${type}/${lang}/build.bash`,
debPath: `build/${type}/${lang}/${name}.deb`,
});
}
const type = "lang";
const name = `riju-${type}-${lang}`;
packages.push({
lang,
type,
name,
buildScriptPath: `build/${type}/${lang}/build.bash`,
debPath: `build/${type}/${lang}/${name}.deb`,
});
}
return packages;
}
@ -90,7 +91,8 @@ function fixupLangConfig(langConfig) {
// and return it as an object.
export async function readLangConfig(lang) {
const langConfig = YAML.parse(
await fs.readFile(`langs/${lang}.yaml`, "utf-8")
await fs.readFile(`langs/${lang}.yaml`, "utf-8"),
{ merge: true }
);
validateJSONSchema(langConfig, await jsonSchemaPromise, { throwAll: true });
if (langConfig.id !== lang) {
@ -105,7 +107,8 @@ export async function readLangConfig(lang) {
// string ID and return it as an object.
export async function readSharedDepConfig(lang) {
const langConfig = YAML.parse(
await fs.readFile(`shared/${lang}.yaml`, "utf-8")
await fs.readFile(`shared/${lang}.yaml`, "utf-8"),
{ merge: true }
);
if (langConfig.id !== lang) {
throw new Error(

View File

@ -349,7 +349,6 @@ async function executeDepGraph({
yes,
targets,
}) {
await runCommand(`make all-scripts`);
const artifacts = {};
for (const artifact of depgraph.artifacts) {
for (const dep of artifact.dependencies) {

View File

@ -18,9 +18,11 @@ import { readLangConfig, readSharedDepConfig } from "../lib/yaml.js";
// package.
function makeLangScript(langConfig, isShared) {
const { id, name, install } = langConfig;
let prefaceParts = [];
let parts = [];
let depends = [];
const dependsCfg = (install && install.depends) || {};
let needsAptGetUpdate = false;
if (
install &&
((install.prepare &&
@ -30,8 +32,21 @@ function makeLangScript(langConfig, isShared) {
install.apt.filter((pkg) => pkg.includes("$")).length > 0))
) {
parts.push(`\
export DEBIAN_FRONTEND=noninteractive
sudo --preserve-env=DEBIAN_FRONTEND apt-get update`);
export DEBIAN_FRONTEND=noninteractive`);
if (
install.prepare &&
((install.prepare.manual &&
install.prepare.manual.includes("apt-get") &&
install.prepare.manual.includes(":i386")) ||
(install.prepare.apt &&
install.prepare.apt.filter((pkg) => pkg.includes(":i386")).length >
0))
) {
parts.push(`\
dpkg --add-architecture i386`);
}
parts.push(`\
sudo --preserve-env=DEBIAN_FRONTEND apt-get update`);
}
if (install) {
const {
@ -49,23 +64,67 @@ sudo --preserve-env=DEBIAN_FRONTEND apt-get update`);
deb,
} = install;
if (prepare) {
const { apt, npm, opam, manual } = prepare;
const {
preface,
cert,
aptKey,
aptRepo,
apt,
npm,
opam,
manual,
} = prepare;
if (preface) {
prefaceParts.push(preface);
}
if (cert && cert.length > 0) {
prefaceParts.push(
cert
.map(
(url, idx) =>
`sudo wget "${url}" -O /usr/local/share/ca-certificates/riju-${id}-${idx}.crt`
)
.join("\n")
);
prefaceParts.push(`sudo update-ca-certificates`);
}
if (aptKey && aptKey.length > 0) {
prefaceParts.push(
aptKey
.map((src) => {
if (src.startsWith("http://") || src.startsWith("https://")) {
return `curl -fsSL "${src}" | sudo apt-key add -`;
} else if (/^[0-9A-F]+$/.match(src)) {
return `sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys "${src}"`;
} else {
throw new Error(`unknown aptKey format: ${src}`);
}
})
.join("\n")
);
}
if (aptRepo && aptRepo.length > 0) {
prefaceParts.push(`sudo tee -a /etc/apt/sources.list.d/custom.list >/dev/null <<EOF
${aptRepo.join("\n")}
EOF`);
}
if (apt && apt.length > 0) {
parts.push(`\
needsAptGetUpdate = true;
prefaceParts.push(`\
sudo --preserve-env=DEBIAN_FRONTEND apt-get install -y ${apt.join(" ")}`);
}
if (npm && npm.length > 0) {
parts.push(`\
prefaceParts.push(`\
sudo npm install -g ${npm.join(" ")}`);
}
if (opam && opam.length > 0) {
parts.push(`\
prefaceParts.push(`\
sudo opam init -n --disable-sandboxing --root /opt/opam
sudo opam install "${opam.join(" ")}" -y --root /opt/opam
sudo ln -s /opt/opam/default/bin/* /usr/local/bin/`);
}
if (manual) {
parts.push(manual);
prefaceParts.push(manual);
}
}
if (npm && npm.length > 0) {
@ -215,6 +274,9 @@ chmod +x "${path}"`);
}
}
if (manual) {
if (manual.includes("apt-get")) {
needsAptGetUpdate = true;
}
parts.push(manual);
}
if (deb) {
@ -223,6 +285,9 @@ chmod +x "${path}"`);
);
}
if (apt) {
if (apt.filter((pkg) => pkg.includes("$")).length > 0) {
needsAptGetUpdate = true;
}
depends = depends.concat(apt);
}
if (dependsCfg.unpin) {
@ -237,6 +302,13 @@ chmod +x "${path}"`);
);
}
}
if (needsAptGetUpdate) {
prefaceParts.unshift(`\
export DEBIAN_FRONTEND=noninteractive`);
prefaceParts.push(`\
sudo --preserve-env=DEBIAN_FRONTEND apt-get update`);
}
parts = prefaceParts.concat(parts);
parts.push(`depends=(${depends.map((dep) => `"${dep}"`).join(" ")})`);
let stripDependsFilter = "";
const stripDepends = (dependsCfg.strip || []).concat(dependsCfg.unpin || []);
@ -280,40 +352,6 @@ set -euxo pipefail`);
return parts.join("\n\n");
}
// Given a language config object, return the text of a Bash script
// that will build the (unpacked) riju-config-foo Debian package into
// ${pkg} when run in an appropriate environment. This is a package
// that will install configuration files and/or small scripts that
// encode the language configuration so that Riju can operate on any
// installed languages without knowing their configuration in advance.
function makeConfigScript(langConfig) {
const { id, name } = langConfig;
let parts = [];
parts.push(`\
#!/usr/bin/env bash
set -euxo pipefail`);
let debianControlData = `\
Package: riju-config-${id}
Version: \$(date +%s%3N)
Architecture: all
Maintainer: Radon Rosborough <radon.neon@gmail.com>
Description: Riju configuration for the ${name} language
Depends: riju-lang-${id}
Riju-Script-Hash: \$(sha1sum "$0" | awk '{ print $1 }')`;
parts.push(`\
install -d "\${pkg}/DEBIAN"
cat <<EOF > "\${pkg}/DEBIAN/control"
${debianControlData}
EOF`);
parts.push(`\
install -d "\${pkg}/opt/riju/langs"
cat <<"EOF" > "\${pkg}/opt/riju/langs/${id}.json"
${JSON.stringify(langConfig, null, 2)}
EOF`);
return parts.join("\n\n");
}
// Given a language config object, return the text of a Bash script
// that will build the (unpacked) riju-shared-foo Debian package into
// ${pkg} when run in an appropriate environment. This is a package
@ -323,20 +361,66 @@ function makeSharedScript(langConfig) {
return makeLangScript(langConfig, true);
}
// Given a language ID, return the text of a Bash script that will do
// any necessary setup before the language package is installed (along
// with its shared dependencies, if any).
function makeInstallScript(lang) {
let parts = [];
if (install) {
const { apt, cert, aptKey, aptRepo } = install;
if (apt && apt.filter((pkg) => pkg.includes(":i386")).length > 0) {
parts.push(`\
dpkg --add-architecture i386`);
}
if (cert && cert.length > 0) {
parts.push(
cert
.map(
(url, idx) =>
`sudo wget "${url}" -O /usr/local/share/ca-certificates/riju-${id}-${idx}.crt`
)
.join("\n")
);
parts.push(`sudo update-ca-certificates`);
}
if (aptKey && aptKey.length > 0) {
parts.push(
aptKey
.map((src) => {
if (src.startsWith("http://") || src.startsWith("https://")) {
return `curl -fsSL "${src}" | sudo apt-key add -`;
} else if (/^[0-9A-F]+$/.match(src)) {
return `sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys "${src}"`;
} else {
throw new Error(`unknown aptKey format: ${src}`);
}
})
.join("\n")
);
}
if (aptRepo && aptRepo.length > 0) {
parts.push(`sudo tee -a /etc/apt/sources.list.d/custom.list >/dev/null <<EOF
${aptRepo.join("\n")}
EOF`);
}
}
parts.unshift(`\
#!/usr/bin/env bash
set -euxo pipefail`);
return parts.join("\n\n");
}
export async function generateBuildScript({ lang, type }) {
const scriptMaker = {
lang: makeLangScript,
config: makeConfigScript,
shared: makeSharedScript,
lang: async () => makeLangScript(await readLangConfig(lang)),
shared: async () => makeSharedScript(await readSharedDepConfig(lang)),
install: async () => await makeInstallScript(lang),
}[type];
if (!scriptMaker) {
throw new Error(`unsupported script type ${type}`);
}
return scriptMaker(
type === "shared"
? await readSharedDepConfig(lang)
: await readLangConfig(lang)
);
return scriptMaker();
}
// Parse command-line arguments, run main functionality, and exit.
@ -346,7 +430,7 @@ async function main() {
.requiredOption("--lang <id>", "language ID")
.requiredOption(
"--type <value>",
"package category (lang, config, shared)"
"package category (lang, shared, install)"
);
program.parse(process.argv);
console.log(await generateBuildScript(program.opts()));

View File

@ -511,6 +511,31 @@ properties:
type: object
additionalProperties: false
properties:
preface: &preface
type: string
minLength: 1
cert: &cert
type: array
items:
type: string
pattern: "^https?://"
examples:
- "https://cacerts.digicert.com/DigiCertTLSRSASHA2562020CA1.crt.pem"
aptKey: &aptKey
type: array
items:
type: string
pattern: "^https?://|^[0-9A-F]+$"
examples:
- "https://downloads.ceylon-lang.org/apt/ceylon-debian-repo.gpg.key"
- "B4112585D386EB94"
aptRepo: &aptRepo
type: array
items:
type: string
pattern: "^https?://"
examples:
- "https://downloads.ceylon-lang.org/apt/ unstable main"
apt:
type: array
items:
@ -529,6 +554,10 @@ properties:
manual:
type: string
minLength: 1
preface: *preface
cert: *cert
aptKey: *aptKey
aptRepo: *aptRepo
apt:
type: array
items:

View File

@ -20,11 +20,6 @@ async function main() {
);
}
break;
case "--types":
for (const type of ["lang", "config"]) {
await runCommand(`MAKELEVEL= make ${targets.join(" ")} T=${type}`);
}
break;
default:
console.error(`make-foreach.js: unknown selector: ${selector}`);
process.exit(1);