summaryrefslogtreecommitdiffstats
path: root/src/package/script.rs
AgeCommit message (Collapse)Author
2021-11-19Update Copyright string to 2020-2022Matthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-08-12Fix clippy: Remove needless borrowsMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2021-06-16Debug-Print all package details before renderingMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-06-09Add more error contextMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-01-19Fix: Linenumbers should start with 1Matthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-01-19Fix: Do not add newlines when interpolating script helpersMatthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-01-18Run `cargo fmt`Matthias Beyer
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
2021-01-15Fix clippy: writing `&Vec<_>` instead of `&[_]` involves one more reference ↵Matthias Beyer
and cannot be used with non-Vec-based slices Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2021-01-15Fix clippy: calling `push_str()` using a single-character string literalMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2021-01-13Add LICENSE file and license headersMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2021-01-11Fix: Remove indentation from script snippets when building scriptChristoph Prokop
We actually need to make an ugly (and very bad performing) hack here, to get the `unindent` crate to actually unindent here. text = format!("\n{}", text).unindent(), the format!() call is necessary to tell `unindent::Unindent::unindent()` that the intended indentation is actually zero. If we do not add that `\n` here, the first line of the to-be-unindented indented text stays unintentionally indented. For example, unindenting the intentionally indented string: " intentionally indented intentionally indented " results unintentionally in the partially indented and partially unindented text: " intentionally indented intentionally indented " Which is not our intention of course, although it seems to be the intention of the unindent crate, as documented. But with the intentionally added `\n` we unindent the indentation of all indented "intentionally indented" lines. Signed-off-by: Christoph Prokop <christoph.prokop@atos.net> Signed-off-by: Matthias Beyer <matthias.beyer@atos.net> Tested-by: Christoph Prokop <christoph.prokop@atos.net> Tested-by: Matthias Beyer <matthias.beyer@atos.net>
2020-12-16Replace manual Display implementations with deriveMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-12-14Add script helpers: join, joinwithMatthias Beyer
This adds two script helpers to join lists of strings. They do not support arrays. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-12-14Refactor: Move phase module to packageMatthias Beyer
This is the right scope anyways. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-12-11Add feature: script lintingMatthias Beyer
This patch adds script linting via a configurable script. With this patch, the configuration can point to a script or program that gets the packaging script on STDIN and might exit with a nonzero value on error. The simplest script I can think of that adds value is: #!/bin/bash shellcheck - to run the packaging script through shellcheck. stdout and stderr of the linting script are printed in case of non-zero return value. Linting can be disabled by not setting the script in the config or by passing a commandline flag to skip linting (a warning will be printed in this case). Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-12-10Fix: Add missing trailing quoteMatthias Beyer
Fixes: 1d038bae2b ("Remove feature: State message in "OK" case.") Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-12-10Remove feature: State message in "OK" case.Matthias Beyer
The "OK" case had a state message parameter. This was removed because "OK" does mean that everything went well. No need to have a message here. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-12-10Move script formatting to Script type definitionMatthias Beyer
This patch moves the script formatting to the definition of the Script type, where it belongs to. This is not an optimal implementation code-cleanness wise, because we could always improve the interface to be even more typesafe and convenient to use, but I guess this is nice for now. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-12-09Fix: Do not escape anything in handlebars templatesMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-12-07Add script helpersMatthias Beyer
This patch adds script helpers, so that we do not have to write out echo "#BUTIDO:STATE:OK:succeeded" but can write {{state "OK"}} for example. Three helpers were added, for progress, state and phase. These can be only used in bash scripts for now. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-12-07Implement shebang overwritingMatthias Beyer
This patch implements the shebang overwriting functionality that was in a TODO note. It adds a `Shebang` type for it, which is a String wrapper. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-12-04Add strict script interpolationMatthias Beyer
This patch adds strict script interpolation, which means that the script interpolation will result in an error if a variable is referenced that does not exist. Before this patch, referencing an absent variable did result in an empty string, possibly resulting in an error at runtime. This feature is on by default. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-12-03Fix: Template nameMatthias Beyer
Fixes: 788c81a4 ("Add ability to use variables from the package in its build script using handlebars syntax") Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-12-03Add ability to use variables from the package in its build script using ↵Matthias Beyer
handlebars syntax Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-11-13Remove indention in script phasesMatthias Beyer
This patch removes the indention when building the script. It also adds the phase name to the "phase-end-comment" line. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-11-13Return Script object after job ranMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-11-08Remove unused imports, sort importsMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-11-05Derive Serialize for all typesMatthias Beyer
Because we want to write the whole Tree object into the database as JSON, we need to be able to serialize all these types. Some of them (which had no implementation of Deserialize) also got an implementation of Deserialize, because we also want to be able to read them from the database and print them to the user. Signed-off-by: Matthias Beyer <mail@beyermatthias.de> (cherry picked from commit 3170c9ed14e22c5baa41618326a4db02389da445)
2020-11-03impl AsRef<str> for ScriptMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-10-22Pass reference to Vec<_> hereMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-10-22Make ScriptBuilder take only a reference to the shebang String objectMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2020-10-14Add script moduleMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>