Commit Graph

27 Commits

Author SHA1 Message Date
Chris Evich 86660f745e
[5.0.0] Fix truncating stdio magic devices
Redirecting to `/dev/stderr` or `/dev/stdout` can have a normally
unintended side-effect when the caller wishes to send either of those
elsewhere (like an actual file).  Namely, it will truncate the file
before writing.  This is almost never the expected behavior.  Update all
redirects to magic devices to append instead.

N/B: These scripts are used far and wide.  On the off-chance some
downstream caller has previously depended on this side-effect, I'm
marking this commit as 'breaking' accordingly.

Signed-off-by: Chris Evich <cevich@redhat.com>
2024-02-12 10:49:20 -05:00
Chris Evich 47cf77670e
Add common timebomb function to mark workarounds
Because otherwise, as the saying goes:
    "There's nothing more permanent than temporary"

Signed-off-by: Chris Evich <cevich@redhat.com>
2024-01-23 09:40:43 -05:00
Chris Evich 92ed5911d6
Resolve a bunch of shellcheck findings
Signed-off-by: Chris Evich <cevich@redhat.com>
2024-01-16 15:43:40 -05:00
Chris Evich 67c74ffe7c
Remove unnecessary/dangerous -u option
Signed-off-by: Chris Evich <cevich@redhat.com>
2023-12-01 10:51:07 -05:00
Chris Evich 8b968401af
Fix a handful of shellcheck complaints
Signed-off-by: Chris Evich <cevich@redhat.com>
2023-12-01 10:51:07 -05:00
Chris Evich a5fb655295
Add passthrough_envars() function and test
This function is otherwise duplicated in both buildah and podman CI,
along with it's associated env. vars.  Provide it here to help limit
duplication and cover it with testing.

Signed-off-by: Chris Evich <cevich@redhat.com>
2023-06-22 16:11:38 -04:00
Chris Evich adda8b1c76
Support $SUDO setup for debian environments
This is esp. used during CI VM image builds where only a user account is
available for some stages.  It's important to block `sudo apt-get` calls
from asking for user input during update/install.

Signed-off-by: Chris Evich <cevich@redhat.com>
2023-06-22 14:57:06 -04:00
Chris Evich 7dfa5d11e4
Fix use of overly generic DEBUG env. var.
It was an unfortunate mistake to name this variable as such.  It was
observed to collide with other non-conforming usages in downstream.
This was esp. leading to some difficult to debug situations, such as
https://github.com/containers/podman/issues/13932  The common
automation library is used far/wide by many environments, which
unfortunately may also rely on a generic `$DEBUG`.  Fix the issue here,
by renaming the variable.

Let this serve as a warning to all downstream, everywhere: ***Avoid all
use of similar generic variable names, make them context-specific!***

Signed-off-by: Chris Evich <cevich@redhat.com>
2022-04-20 13:47:11 -04:00
Chris Evich 979968704e
Mass spelling/typo fix
Signed-off-by: Chris Evich <cevich@redhat.com>
2021-09-13 14:24:48 -04:00
Chris Evich 118c39e3e7
Add commonly used platform definitions
Signed-off-by: Chris Evich <cevich@redhat.com>
2021-08-24 15:50:36 -04:00
Chris Evich 9748964ec9
Add common showrun() function and unit-tests
Signed-off-by: Chris Evich <cevich@redhat.com>
2020-12-14 14:26:01 -05:00
Chris Evich ce894eed2e
Fix code-context references
Previously due to practical reasons, the unit-tests did a very poor
jobs checking the code-context information shown by functions like
`die()`.  Prior to this commit, the stack-level used was too great,
resulting in unhelpful output such as:

`ERROR: blah blah blah (<stdin>:0 in ())`

Fix the stack-level and context output.  Add a helper-script
and new unit-test to confirm it does not break again in the future.

Signed-off-by: Chris Evich <cevich@redhat.com>
2020-10-30 14:23:42 -04:00
Chris Evich 11182c3fb5
Add shortcut for loading all common libraries
One internal, and several external users of this library don't bother
sourcing individual `common/lib/*.sh` files.  Instead they iterate
over all of them by name, which is messy and inconvenient.  Add a
short-cut script which callers can source to load all common libraries.

Signed-off-by: Chris Evich <cevich@redhat.com>
2020-10-23 10:05:26 -04:00
Chris Evich dd7246c569
Avoid double-escaping env. var values
Signed-off-by: Chris Evich <cevich@redhat.com>
2020-09-28 15:59:34 -04:00
Chris Evich bae2d2d018
Simplify indent function
For some input line values, escape-characters were being eaten.  Fix this by
not interpreting the input line in any way, simply prefix each line with
spaces.

Signed-off-by: Chris Evich <cevich@redhat.com>
2020-09-24 13:28:17 -04:00
Chris Evich 74f60bf47b
Simplify indent function and tests
Signed-off-by: Chris Evich <cevich@redhat.com>
2020-09-23 11:58:15 -04:00
Chris Evich 6cda65f9a1
Add show_env_vars function and tests
Signed-off-by: Chris Evich <cevich@redhat.com>
2020-09-18 14:15:31 -04:00
Chris Evich e4ffb24b3c
Fix exit behavior & tests
Signed-off-by: Chris Evich <cevich@redhat.com>
2020-08-04 16:40:22 -04:00
Chris Evich c479f7bb03
Add req_env_vars() function + tests
Signed-off-by: Chris Evich <cevich@redhat.com>
2020-08-04 13:48:50 -04:00
Chris Evich 602fe22adf
Implement exponential retry function and script
Signed-off-by: Chris Evich <cevich@redhat.com>
2020-07-28 14:30:01 -04:00
Chris Evich a48cb086d5
Implement tests for copy/rename_function utils
Signed-off-by: Chris Evich <cevich@redhat.com>
2020-07-28 14:30:00 -04:00
Chris Evich 8782676973
Implement indent function and unittests
Signed-off-by: Chris Evich <cevich@redhat.com>
2020-07-28 14:30:00 -04:00
Chris Evich dae7114d66
Add github action common lib installer
Some users of the common library are not operating under a github
actions environment.  To support installation under a github actions
environment while retaining that characteristic, new installer behavior
is required to allow subdirectory installers to modify the environment
file before "installation finished" (version file) is put in place.

Add a github action common lib installer which adds it's installation
directory into the system-wide environment file.

Update cirrus-ci_retrospective to utilize the new github action common
lib for some operations.

Update unit-tests.

Fix bug installing system-wide environment in Ubuntu vs Fedora

Signed-off-by: Chris Evich <cevich@redhat.com>
2020-07-28 11:40:34 -04:00
Chris Evich 40c4608cd3
Image for performing secure ephemeral gpg+git
Signed-off-by: Chris Evich <cevich@redhat.com>
2020-06-22 16:11:36 -04:00
Chris Evich d3645dcba6
Add copy/rename function utilities
Did not add unit tests for these, since they would be quite complex.
Both functions were manually tested.

Also, added use of `realpath` in a few places to prevent changing
direcories from breaking debugging messages.

Signed-off-by: Chris Evich <cevich@redhat.com>
2020-06-22 06:51:06 -04:00
Chris Evich aa5f7ba49d
Implement fully functional cirrus-ci_retrospective
Signed-off-by: Chris Evich <cevich@redhat.com>
2020-03-31 12:09:56 -04:00
Chris Evich a9cb93a650
Implement common + cirrus-ci_retrospective + tests
See the `README.md` changes for details.

Signed-off-by: Chris Evich <cevich@redhat.com>
2020-03-17 10:49:22 -04:00