Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
181 commits
Select commit Hold shift + click to select a range
d49ad10
Support upgrade and list as standalone scripts
DevonianTeuchter Mar 14, 2024
3fbd950
Enable alternative repo support - generate default GH repo if not setup
DevonianTeuchter Mar 14, 2024
e846ebe
Enable use of pre/post scriptlets (for man-db processing)
DevonianTeuchter Mar 14, 2024
cb96768
Use pre/post scriptlets (for man-db);
DevonianTeuchter Mar 14, 2024
1988ee6
Use renamed function to get repository information;
DevonianTeuchter Mar 14, 2024
96e908f
Add new script to provide "list" capabilities;
DevonianTeuchter Mar 14, 2024
410b0e2
Add delay to prevent screen overlays
DevonianTeuchter Mar 14, 2024
02a3ae6
Utilize dedicated zopen-list script to provide list capabilities
DevonianTeuchter Mar 14, 2024
679a7c0
Split into install and upgrade scripts.
DevonianTeuchter Mar 14, 2024
2fdcbf7
New script to allow better zopen --help display and
DevonianTeuchter Mar 14, 2024
82761c9
Prevent screen overlay issues with ansi progress displays
DevonianTeuchter Mar 14, 2024
0fc35f9
Code tidy - remove unused, correct shellcheck issues
DevonianTeuchter Mar 14, 2024
73ed6b5
Remove intermediary variable - output directly
DevonianTeuchter Mar 14, 2024
72bce1c
Use dynamic location for JSON cache file
DevonianTeuchter Mar 14, 2024
67eb893
Rename functions to reflect not just GH
DevonianTeuchter Mar 14, 2024
bc93182
Add common functions that can be included into a jq query for formatting
DevonianTeuchter Mar 14, 2024
826d862
Add utility functions
DevonianTeuchter Mar 14, 2024
679bb22
Run pre/post action scriplets
DevonianTeuchter Mar 14, 2024
3de15e6
Logic to determine which JSON asset to use
DevonianTeuchter Mar 14, 2024
3757885
Package installation database
DevonianTeuchter Mar 14, 2024
c907f94
Calculate any inputted port names that are invalid
DevonianTeuchter Mar 14, 2024
51693c8
Implement file installation graph
DevonianTeuchter Mar 14, 2024
43c626d
Process an installation file, running pre/post actions
DevonianTeuchter Mar 14, 2024
7addf69
Function to download pax file from repo
DevonianTeuchter Mar 14, 2024
ff963c5
Implement function to extract the metadata.json from pax file
DevonianTeuchter Mar 14, 2024
44c8b41
Function to handle pax installation
DevonianTeuchter Mar 14, 2024
ded466c
Re-implement caveat support using scriptlet
DevonianTeuchter Mar 18, 2024
f71835c
Add mutex during install
DevonianTeuchter Mar 19, 2024
b1fde6f
Fix issue during zopen init and packagedb
DevonianTeuchter Apr 29, 2024
0b5c43f
Move scriptlets into meta/include dir for consistency
DevonianTeuchter Sep 12, 2024
d2db05e
Match install script with new location
DevonianTeuchter Sep 12, 2024
fcd7ce2
Pre-req checks
DevonianTeuchter Oct 1, 2024
1a9e4d2
Minor bug fixes
DevonianTeuchter Oct 29, 2024
5b19515
Scriptlet processing updates
DevonianTeuchter Jan 13, 2025
116e741
Scriptlets - including prereq and signature verification
DevonianTeuchter Jan 13, 2025
f69af49
Disable command trace
DevonianTeuchter Jan 15, 2025
9def9c1
Ensure bootstrapped Pinentry comes before gnugp
DevonianTeuchter Jan 15, 2025
7280be9
Sourcing issue with gnupg & pinentry
DevonianTeuchter Jan 15, 2025
69e20c1
Generate database after updating tools
DevonianTeuchter Jan 15, 2025
7e6cac1
Add back in zopen-config generate code
DevonianTeuchter Jan 15, 2025
cdc938e
Handle metadata that still references legacy ZOSOpenTools
DevonianTeuchter Jan 15, 2025
0c7af75
GPG QoL changes as a scriptlet
DevonianTeuchter Jan 15, 2025
bd6e28c
Simplify and fix cleanup logic
DevonianTeuchter Jan 15, 2025
80a195a
Assume cleanup commands need redirection!
DevonianTeuchter Jan 16, 2025
34ed26f
Cleaner sub-process exits
DevonianTeuchter Jan 16, 2025
df1cd16
Ensure updates to config.json remain
DevonianTeuchter Jan 16, 2025
d7ca7c7
More cleanup of files
DevonianTeuchter Jan 16, 2025
87b44fe
Propogate skipping of gpg validation
DevonianTeuchter Jan 16, 2025
52bb3e3
Additional error handling
DevonianTeuchter Jan 21, 2025
7c76653
Chtag downloaded metadata
DevonianTeuchter Jan 21, 2025
b97e592
Always hide curl progress meter.
DevonianTeuchter Jan 21, 2025
4fec973
Add help about all configuration variables
DevonianTeuchter Jan 21, 2025
64c1be7
For parity, reinstall only named package(s) [or use new option for deps]
DevonianTeuchter Jan 21, 2025
eb0a642
QOL: Fix param parsing, more shellcheck issues and unneeded code
DevonianTeuchter Feb 4, 2025
c75e77b
Read file into jq directly for processing, no piping into it
DevonianTeuchter Feb 5, 2025
78c6e79
Rework (simplify) progresshandler calls
DevonianTeuchter Feb 5, 2025
26df115
QOL update to signature verification scriptlet
DevonianTeuchter Feb 6, 2025
cab76a1
Better pre-installed pkg processing and
DevonianTeuchter Feb 6, 2025
48ea3ea
Handle scriptlet errors
DevonianTeuchter Feb 6, 2025
5110721
Warn when uninstalling a package pre-req
DevonianTeuchter Feb 6, 2025
8deeaa6
Older jq issue with variable keys & fix merge issues
DevonianTeuchter Feb 14, 2025
71358e4
Ensure promptYesNoAlways enforces always
DevonianTeuchter Mar 4, 2025
cf72c0b
Handle print* function output change to redirection
DevonianTeuchter Mar 4, 2025
733c9a4
Ensure skip-verify is listed in help
DevonianTeuchter Mar 4, 2025
04497df
Fix issues running with --verbose and output additional
DevonianTeuchter Mar 4, 2025
67def02
Prevent error if local file is not actually an install package
DevonianTeuchter Mar 5, 2025
3171846
Failed gpg start does not propogate
DevonianTeuchter Mar 5, 2025
875b17a
Simplify jq queries usage of shell parameters to aid debug
DevonianTeuchter Mar 5, 2025
15d752f
Implement list of available updates (rework legacy/obsolete code)
DevonianTeuchter Mar 6, 2025
32c7fbf
Update message for clarity when nothing needs installing
DevonianTeuchter Mar 11, 2025
5220945
Update zopen-info with agnostic repo support
DevonianTeuchter Mar 11, 2025
48be860
Ensure use of /bin/echo not coreutils/shell in progresshandler
DevonianTeuchter Mar 13, 2025
b279702
support legacy options in zopen-list
DevonianTeuchter Mar 16, 2025
6df8214
Fix insert to error message
DevonianTeuchter Mar 16, 2025
b624850
More granularity & specific messages to space check
DevonianTeuchter Mar 16, 2025
3490324
Additional error handling around alt-repos, versioning and tagged rel…
DevonianTeuchter Mar 17, 2025
7d5e96c
Add zopen-mirror capability
DevonianTeuchter Mar 18, 2025
21d2247
Ensure mirror tags json files and downloads correctly
DevonianTeuchter Mar 18, 2025
483b76c
Actually use the correct json key for latest flie
DevonianTeuchter Mar 19, 2025
49cd7b7
Rework metadata downloads to work around GH .json response with 404
DevonianTeuchter Mar 19, 2025
adad93a
Use mirror pkg name rather than trying to calculate
DevonianTeuchter Mar 19, 2025
5c3199d
Easier activation of repo when on z/OS
DevonianTeuchter Mar 19, 2025
70bd609
Ensure metadata and pax are both available, downloaded as needed
DevonianTeuchter Mar 19, 2025
3f76ff7
fix typos in zopen and zopen-clean help output
IgorTodorovskiIBM Mar 31, 2025
0a76b9c
Correct list output for "No Tests"
DevonianTeuchter Apr 2, 2025
e723313
Sanity check and attempt to rebuild the default repository config file
DevonianTeuchter Apr 2, 2025
99e7cf7
Ensure zopen community terminology used
DevonianTeuchter Apr 2, 2025
d7635af
Disable command trace
DevonianTeuchter Apr 2, 2025
37c1b2a
Merge with main (for updated clean & diagnostics)
DevonianTeuchter Apr 2, 2025
6f6c229
Merge issue with common.sh
DevonianTeuchter Apr 2, 2025
fd9144e
Allow install without initial update of tools
DevonianTeuchter May 14, 2025
7513fd9
Remove commented out code
DevonianTeuchter May 14, 2025
7d92f8b
Handle "no-package" systems db creation
DevonianTeuchter May 14, 2025
df0dcc3
Ensure caches update
DevonianTeuchter May 14, 2025
608022b
More granular package installs (kb v Mb)
DevonianTeuchter May 14, 2025
6131e41
Local pax install validation
DevonianTeuchter May 14, 2025
0339adf
Use correct variable for cached filename
DevonianTeuchter May 14, 2025
3aed2d9
Remove extra size report.
DevonianTeuchter May 14, 2025
fa031fc
Allow skipping of broken packages during install
DevonianTeuchter May 15, 2025
34951ae
Try to preserve exit codes from failures
DevonianTeuchter May 15, 2025
3c5dc54
Turn off debug trace during process handling
DevonianTeuchter May 15, 2025
7d109ab
Use Last-Modified for file-type repos, etag for http
DevonianTeuchter May 19, 2025
1038a80
Don't update CA cert when offline init
DevonianTeuchter Jun 4, 2025
a7cb39b
Allow bypass for upgrades if a prereq is added
DevonianTeuchter Jun 4, 2025
1cc9896
Pinned package breaks upgrades
DevonianTeuchter Jun 4, 2025
e8fd601
Offline mode installer
DevonianTeuchter Jun 4, 2025
735d4a8
Correctly generate local file location
DevonianTeuchter Jun 4, 2025
a1d62e8
Fix unused counter for all shells
DevonianTeuchter Jun 6, 2025
0f1e34c
Handle removal of fstype during promote
DevonianTeuchter Jun 17, 2025
2416982
Only parse package man pages during install, not full scan
DevonianTeuchter Jun 17, 2025
0e2d920
Better handling of error during init
DevonianTeuchter Jun 17, 2025
c0a837b
split cleanup logic per pid
DevonianTeuchter Jun 17, 2025
827672e
Better calculation during --downloadonly install
DevonianTeuchter Jun 17, 2025
15d0591
Don't assume /tmp; allow $TMPDIR or $TMP
DevonianTeuchter Jul 15, 2025
7e35950
Stop leak of functions into env during sourcing
DevonianTeuchter Jul 15, 2025
6456378
Issue with zsh passing vars to awk; remove awk call use expansion
DevonianTeuchter Jul 15, 2025
309dd48
Failure during dotenv find now stops
DevonianTeuchter Jul 15, 2025
eafd680
Fail early if install issue during zopen-init
DevonianTeuchter Jul 15, 2025
bf66c32
Issues with awk syntax when creating config
DevonianTeuchter Aug 13, 2025
5b614ae
Add bootstrapped meta to package tracker during offline init
DevonianTeuchter Aug 14, 2025
4bacec3
Move GPG code to common.sh; add socket sanity check
DevonianTeuchter Aug 14, 2025
76bcf2d
Fix more Shellcheck issues and remove spurious blank spaces
DevonianTeuchter Aug 14, 2025
36e466a
merge with main
DevonianTeuchter Sep 11, 2025
668b54e
Add ability to skip size checks [on a dynamic fs for example]
DevonianTeuchter Sep 22, 2025
fcfeccf
Ensure permission to write audit logs or issue as warning
DevonianTeuchter Sep 22, 2025
faeabb5
Fix package capitalisation issues with upgrading
DevonianTeuchter Sep 22, 2025
7b53890
Add missing pipe/continuation character
DevonianTeuchter Sep 30, 2025
5de49d6
Typo on printVerbose
DevonianTeuchter Sep 30, 2025
b83d2ee
Hardcode /bin into path; replace any zos* wrappers & /bin/ prefixes
DevonianTeuchter Sep 30, 2025
5a29ff5
Replace jq query for package name validation
DevonianTeuchter Sep 30, 2025
3195a6d
Add typo suggestions for package names from PR 1087
DevonianTeuchter Oct 1, 2025
a1c8815
Update packageDb when alternating versions
DevonianTeuchter Oct 6, 2025
6b06117
Fix zopen X --version
DevonianTeuchter Oct 6, 2025
8ad4ddb
Refix matadata.json parsing to handle GH API
DevonianTeuchter Oct 6, 2025
2fd21fb
Bump version number
DevonianTeuchter Oct 6, 2025
f8b9fe9
Backup rather than destroy old etc/zopen-config
DevonianTeuchter Oct 6, 2025
4aeee75
Refactor cache lookups
DevonianTeuchter Oct 15, 2025
7fb1f8a
Use jqw wrapper in audit script
DevonianTeuchter Oct 15, 2025
31d00d9
Write debug/verbose to stderr
DevonianTeuchter Oct 15, 2025
e3ad6cd
Give progresshandler time to start [prevent line overwrites]
DevonianTeuchter Oct 15, 2025
ee035b1
Writing syslog on read-only install during promote fails
DevonianTeuchter Oct 15, 2025
2674ab5
clearer messages on non-writable ~/.gnupg
DevonianTeuchter Oct 15, 2025
51918f9
Warning message tweaks for clarity
DevonianTeuchter Oct 15, 2025
c681a29
More robust space validation messages
DevonianTeuchter Oct 15, 2025
0fbc0f1
Message tweak for older package (or git installed like meta)
DevonianTeuchter Oct 15, 2025
19b8cf5
Message tweaks; variable definiing in zopen-config
DevonianTeuchter Oct 15, 2025
35189ee
Revert zot_santizeEnvvar; fix zot_deleteDuplicateEntries
DevonianTeuchter Oct 15, 2025
96a20a4
Move zopen-config arg parse into function
DevonianTeuchter Oct 15, 2025
4cf3c3a
Backup config file to etc, not CWD!
DevonianTeuchter Oct 15, 2025
3499ea8
Fix regex for zot_deleteDuplicateEntries
DevonianTeuchter Oct 16, 2025
3a9b923
Move zopen-config backups into /etc/zopen
DevonianTeuchter Oct 17, 2025
8003d98
Ensure valid metadata added to install tracker
DevonianTeuchter Oct 20, 2025
5634473
Add zopen-promote as top-level verb
DevonianTeuchter Oct 21, 2025
6acebff
Prevent leak of zot_parse function to shell
DevonianTeuchter Oct 21, 2025
ce28a46
Rework mutex logic; check further in ancestor lineage
DevonianTeuchter Oct 21, 2025
cc912e8
Prevent recursive zopen-init
DevonianTeuchter Oct 30, 2025
362904f
Validate metadata.json could be found for gpg
DevonianTeuchter Oct 30, 2025
806893d
Prevent bootstrap update when refreshing/offline
DevonianTeuchter Oct 30, 2025
498b2a2
fix listings
DevonianTeuchter Nov 18, 2025
5b9122f
Fix zopen-info
DevonianTeuchter Nov 18, 2025
67ae972
Fix meta install during init
DevonianTeuchter Nov 18, 2025
deec944
Update releaseline detection
DevonianTeuchter Nov 18, 2025
7251638
Add back in parentPid tracker [main merge issue]
DevonianTeuchter Nov 19, 2025
244f0d4
Log before final message; error can cause scroll of IMPORTANT!
DevonianTeuchter Nov 25, 2025
96ccd17
Ensure use of tmp dir (and quoted strings)
DevonianTeuchter Nov 25, 2025
afb4858
Remove duplicate syslog
DevonianTeuchter Nov 25, 2025
f387f81
Prevent cd from modifying environment;
DevonianTeuchter Nov 25, 2025
ca64a58
Accept first verb to save confusion
DevonianTeuchter Nov 28, 2025
c8f532d
Use wrapped jq command
DevonianTeuchter Nov 28, 2025
1adc9fe
Ensure offline installer includes meta
DevonianTeuchter Nov 28, 2025
d9893f4
Track offline install in config & simplify/reuse logic
DevonianTeuchter Nov 28, 2025
dcc2de2
Rewrite awk to not throw exit from END{..}
DevonianTeuchter Nov 29, 2025
6bdddc5
EXtract function and refactor
DevonianTeuchter Nov 29, 2025
4245c33
Fix re-init logic
DevonianTeuchter Nov 29, 2025
9414fe3
Offline install tracker
DevonianTeuchter Nov 29, 2025
d4fff23
Remove extra line
DevonianTeuchter Dec 1, 2025
02c2468
Offline installer stability changes
DevonianTeuchter Dec 2, 2025
1936a78
Do not update tools on a meta refresh
DevonianTeuchter Dec 2, 2025
40cb5da
Additional returns from cd
DevonianTeuchter Dec 8, 2025
dfda0b3
Adding -x to debug
DevonianTeuchter Dec 8, 2025
d1f9df8
debug
DevonianTeuchter Dec 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 56 additions & 39 deletions bin/zopen
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/sh -x
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#!/bin/sh -x enables shell tracing by default, which will echo command lines/args (potentially including credentials like PATs/passwords) and makes normal CLI output very noisy. Consider only enabling -x under an explicit --xdebug/env flag (also applies to other scripts in this PR).

🤖 Was this useful? React with 👍 or 👎

#
# zopen wrapper script to allow single point of entry to zopen
# tooling.
Expand Down Expand Up @@ -35,13 +35,15 @@ Command:
config change zopen runtime environment settings
diagnostics collects system info for zopen troubleshooting
generate generates a new zopen project
info displays detailed information about a package
init initializes a zopen environment at the specified location
refresh refreshes your zopen environment and zopen-config file
install installs one or more zopen community packages
info displays detailed information about a package
list lists information about zopen community packages
mirror performs a synchronization of the GitHub repository
promote promote a zopen environment to another location
publish publish zopen package release to github
query list local or remote info about zopen community packages
refresh refreshes your zopen environment and zopen-config file
remove removes installed zopen community packages
update-cacert update the cacert.pem file used by zopen community
upgrade upgrades existing zopen community packages
Expand All @@ -51,6 +53,7 @@ Command:
Options:
-h, --help, -? display this help and exit
-v, --verbose run in verbose mode
--version display the zopen version

Examples:
zopen --help displays zopen help
Expand All @@ -59,7 +62,7 @@ Examples:
zopen upgrade -y upgrade all installed packages to the latest release,
without prompting
zopen alt bash list installed alternative bash packages
zopen info vim displays details information about the installed vim package
zopen info vim displays detailed information about the installed vim package
zopen usage --pie displays an ASCII-art chart showing biggest space hogs

SEE ALSO:
Expand All @@ -69,13 +72,19 @@ SEE ALSO:
zopen-clean(1)
zopen-config-helper(1)
zopen-generate(1)
zopen-info(1)
zopen-init(1)
zopen-install(1)
zopen-info(1)
zopen-list(1)
zopen-mirror(1)
zopen-promote(1)
zopen-publish(1)
zopen-query(1)
zopen-promote(1)
zopen-refresh(1)
zopen-remove(1)
zopen-update-cacert(1)
zopen-upgrade(1)
zopen-usage(1)
zopen-whichproject(1)
zopen-version(1)
Expand All @@ -92,41 +101,48 @@ subopts=""
subcmd=""
help=false
version=false
verbFound=false

for arg in $*; do
case "${arg}" in
"alt"|"audit"|"build"|"clean"|"generate"|"init"|"install"|\
"query"|"remove"|"update-cacert"|"info"|"usage"|"diagnostics"|\
"whichproject"|"publish")
subcmd="zopen-${arg}"
;;
"list")
subcmd='zopen-query'
subopts="${subopts} --list"
;;
"refresh")
subcmd='zopen-init'
subopts="${subopts} --refresh"
;;
"upgrade")
subcmd='zopen-install'
subopts="${subopts} -u"
;;
"config")
subcmd="zopen-${arg}-helper"
;;
"--version")
subcmd='zopen-version'
version=true
;;
"help" | "--help" | "-?")
help=true
;;
*)
# let unknown stuff through
subopts="${subopts} ${arg}"
;;
esac
while [ "$#" -gt 0 ]; do
arg=$1 || shift
if $verbFound; then
subopts="${subopts} ${arg}"
else
case "${arg}" in
"alt"|"audit"|"build"|"clean"|"generate"|"init"|"install"|\
"query"|"remove"|"update-cacert"|"info"|"usage"|"diagnostics"|\
"whichproject"|"publish"|"list"|"upgrade"|"mirror"|"promote")
subcmd="zopen-${arg}"
verbFound=true
;;
"refresh")
subcmd='zopen-init'
subopts="${subopts} --refresh"
verbFound=true
;;
"config")
subcmd="zopen-${arg}-helper"
verbFound=true
;;
"--version")
if [ -z "${subcmd}" ]; then
subcmd='zopen-version'
version=true
else
subopts="${subopts} ${arg}"
fi
;;
"help" | "--help" | "-?")
help=true
verbFound=true
;;
*)
# let unknown stuff through
subopts="${subopts} ${arg}"
;;
esac
fi
shift
done

if [ -z "${subcmd}" ]; then
Expand All @@ -152,4 +168,5 @@ if ${version}; then
fi
fi

# shellcheck disable=SC2086 # We want globbing in this case
${subcmd} ${subopts}
57 changes: 39 additions & 18 deletions bin/zopen-alt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/sh -x
#
# "Alternatives" utility for zopen community - https://github.com/zopencommunity
#
Expand Down Expand Up @@ -55,14 +55,29 @@ mergeNewVersion()
{
package="$1"
newver="$2"
oldver="$2"
[ -z "${package}" ] && printError "Internal error; no packagename provided to merge."
[ -d "${ZOPEN_PKGINSTALL}/${package}/${newver}" ] || printError "Version '${newver}' was not available to set as current"

[ -z "${package}" ] && printError "Internal error; no package name provided to merge."
newVerDir="${ZOPEN_PKGINSTALL}/${package}/${newver}"
[ -d "${newVerDir}" ] || printError "Version '${newver}' was not available to set as current"

# We are effectively re-installing so run some scriptlets, noting that for the
# alternative to be available on the system, it must have passed various the
# checks in installPre (GPG/prereq)
if ! processActionScripts "transactionPre"; then
exit 1
fi
if [ -e "${ZOPEN_PKGINSTALL}/${package}/${package}" ]; then
printVerbose "Removing main link"
rm -rf "${ZOPEN_PKGINSTALL}/${package}/${package}"
if ! rm -rf "${ZOPEN_PKGINSTALL}/${package}/${package}:?"; then
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This rm -rf "${ZOPEN_PKGINSTALL}/${package}/${package}:?" looks like a typo for the ${var:?} safety expansion; as written it targets a literal .../package:? path and won’t remove the existing symlink. That can leave the old "current" link in place and break zopen alt --set behavior.

🤖 Was this useful? React with 👍 or 👎

printSoftError "Unable to remove previously set package link: ${ZOPEN_PKGINSTALL}/${package}/${package}"
printError "Check permissions and retry command."
fi
fi
if ! runLogProgress "mergeIntoSystem \"${package}\" \"${ZOPEN_PKGINSTALL}/${package}//${newver}\" \"${ZOPEN_ROOTFS}\"" \
"Merging ${package} into symlink mesh" "Merged ${package} into symlink mesh"; then
printSoftError "Unexpected errors merging symlinks into mesh tree"
printError "Use zopen alt to select previous version to ensure known state"
fi
mergeIntoSystem "${package}" "${ZOPEN_PKGINSTALL}/${package}/${newver}" "${ZOPEN_ROOTFS}"
printVerbose "New version merged; checking for orphaned files from previous version"
# This will remove any old symlinks or dirs that might have changed in an up/downgrade
# as the merge process overwrites existing files to point to different version. If there was
Expand All @@ -84,7 +99,12 @@ mergeNewVersion()
if [ -e "${ZOPEN_PKGINSTALL}/${package}/${package}/.releaseinfo" ]; then
version=$(cat "${ZOPEN_PKGINSTALL}/${package}/${package}/.releaseinfo")
fi
printVerbose "Updating package DB"
updatePackageDB

syslog "${ZOPEN_LOG_PATH}/audit.log" "${LOG_A}" "${CAT_PACKAGE}" "ALT" "setAlt" "Set '${package}' to version:${version};"
processActionScripts "installPost" "${package}"
processActionScripts "transactionPost"
}

setAlt()
Expand All @@ -93,7 +113,7 @@ setAlt()
newver="$2"
if [ -e "${ZOPEN_PKGINSTALL}/${package}/" ]; then
printVerbose "${package} is either installed or has been previously"
found=$(zosfind "${ZOPEN_PKGINSTALL}/${package}/" -type l -prune -o -type d -print | sed -e "s#${ZOPEN_PKGINSTALL}/${package}/\([^/]*\).*#\1#" | uniq)
found=$(find "${ZOPEN_PKGINSTALL}/${package}/" -type l -prune -o -type d -print | sed -e "s#${ZOPEN_PKGINSTALL}/${package}/\([^/]*\).*#\1#" | uniq)
else
printVerbose "${package} has never been installed on the system"
fi
Expand Down Expand Up @@ -145,7 +165,7 @@ listAlts()
package=$(echo "${package}" | awk '{$1=$1};1')
if [ -e "${ZOPEN_PKGINSTALL}/${package}/" ]; then
printVerbose "${package} is either installed or has been previously"
found=$(zosfind "${ZOPEN_PKGINSTALL}/${package}/" -type l -prune -o -type d -print | sed -e "s#${ZOPEN_PKGINSTALL}/${package}/\([^/]*\).*#\1#" | uniq)
found=$(find "${ZOPEN_PKGINSTALL}/${package}/" -type l -prune -o -type d -print | sed -e "s#${ZOPEN_PKGINSTALL}/${package}/\([^/]*\).*#\1#" | uniq)
else
printVerbose "${package} has never been installed on the system"
fi
Expand All @@ -164,19 +184,19 @@ listAlts()
# echo "${found}" | xargs | tr ' ' '\n' | while read repo; do
TMP_FIFO_PIPE="${HOME}/altselect.pipe"
[ ! -p "${TMP_FIFO_PIPE}" ] || rm -f "${TMP_FIFO_PIPE}"
mkfifo ${TMP_FIFO_PIPE}
mkfifo "${TMP_FIFO_PIPE}"
echo "${found}" | xargs | tr ' ' '\n' >> "${TMP_FIFO_PIPE}" &
while read repo; do
printVerbose "Parsing repo: '${repo}' as '${repo#"${ZOPEN_PKGINSTALL}"/}'"
i=$(expr ${i} + 1)
i=$((i + 1))
if [ "${deref#"${ZOPEN_PKGINSTALL}"/}" = "${repo#"${ZOPEN_PKGINSTALL}"/}" ]; then
current=${i}
printInfo "${NC}${GREEN}${i}: ${repo#"${ZOPEN_PKGINSTALL}"/} <- current${NC}"
else
printInfo "${i}: ${repo#"${ZOPEN_PKGINSTALL}"/}"
fi
done < "${TMP_FIFO_PIPE}"
[ ! -p ${TMP_FIFO_PIPE} ] || rm -rf "${TMP_FIFO_PIPE}"
[ ! -p "${TMP_FIFO_PIPE}" ] || rm -rf "${TMP_FIFO_PIPE}"

if ${select}; then
mutexReq "zopen" "zopen"
Expand All @@ -202,19 +222,14 @@ while [ $# -gt 0 ]; do
case "$1" in
"-s" | "--set")
shift
[ $# -lt 2 ] && printError "Missing argument(s) for set option. Check program arguments"
[ $# -lt 1 ] && printError "Missing argument for 'set' option. Check program arguments"
sett=true
select=false
package="$1"
newver="$2"
shift
newver="$1"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--set parsing no longer captures the package argument (only newver="$1"), so zopen alt --set <pkg> <ver> will end up swapping/misassigning package and newver (since package is set later in the default branch). This makes setAlt "${package}" "${newver}" unreliable for normal usage.

🤖 Was this useful? React with 👍 or 👎

;;
"--select")
select=true
sett=false
shift
[ $# -lt 1 ] && printError "Missing argument for select option."
package="$1"
;;
"-h" | "--help" | "-?")
printHelp "${args}"
Expand All @@ -228,7 +243,9 @@ while [ $# -gt 0 ]; do
verbose=true
;;
"--debug")
# shellcheck disable=SC2034
verbose=true
# shellcheck disable=SC2034
debug=true
;;
*)
Expand All @@ -238,6 +255,10 @@ while [ $# -gt 0 ]; do
shift
done

if ${select} && [ -z "${package}" ]; then
printError "Missing argument for select option."
fi

if ${sett}; then
setAlt "${package}" "${newver}"
elif [ -n "${package}" ]; then
Expand Down
32 changes: 4 additions & 28 deletions bin/zopen-audit
Original file line number Diff line number Diff line change
Expand Up @@ -84,39 +84,15 @@ if [ $upgrade = true ] && [ $remove = true ]; then
exit 1
fi

JSON_VULNERABILITIES_URL="https://raw.githubusercontent.com/zopencommunity/meta/main/docs/api/zopen_vulnerability.json"
LATEST_RELEASES_URL="https://raw.githubusercontent.com/zopencommunity/meta/main/docs/api/zopen_releases_latest.json"

downloadJsonCaches()
{
cachedir="${ZOPEN_ROOTFS}/var/cache/zopen"
[ ! -e "${cachedir}" ] && mkdir -p "${cachedir}"
JSON_CVE_CACHE="${cachedir}/zopen_vulnerability.json"

if ! curlout=$(curlCmd -L --fail --no-progress-meter -o "${JSON_CVE_CACHE}" "${JSON_VULNERABILITIES_URL}"); then
printError "Failed to obtain vulnerability json from ${JSON_VULNERABILITIES_URL}; ${curlout}"
fi
chtag -tc 819 "${JSON_CVE_CACHE}"

if $upgrade; then
LATEST_RELEASES_CACHE="${cachedir}/zopen_releases_latest.json"

if ! curlout=$(curlCmd -L --fail --no-progress-meter -o "${LATEST_RELEASES_CACHE}" "${LATEST_RELEASES_URL}"); then
printError "Failed to obtain latest releases json from ${LATEST_RELEASES_URL}; ${curlout}"
fi
chtag -tc 819 "${LATEST_RELEASES_CACHE}"
fi
}

downloadJsonCaches
updateCaches

if [ ! -f "${JSON_CVE_CACHE}" ]; then
printError "Vulnerability json cache file not found."
exit 1
fi
printVerbose "Obtained vulnerability json cache."

if [ $upgrade = true ] && [ ! -f "${LATEST_RELEASES_CACHE}" ]; then
if [ $upgrade = true ] && [ ! -f "${JSON_LATEST_CACHE}" ]; then
printError "Latest releases json cache file not found."
fi
printVerbose "Obtained latest releases json cache."
Expand All @@ -129,7 +105,7 @@ high_vulns=0
critical_vulns=0

# Check for CVEs in all installed projects
installed_packages=$(cd "${ZOPEN_PKGINSTALL}" && zosfind ./*/. ! -name . -prune -type l)
installed_packages=$(cd "${ZOPEN_PKGINSTALL}" && find ./*/. ! -name . -prune -type l)
printVerbose "Found all installed packages."

# Variables for --upgrade flag
Expand Down Expand Up @@ -190,7 +166,7 @@ while IFS= read -r repo; do
latest_release_vulns=""
is_latest_release=true
if $upgrade; then
latest_release=$(jq -cr '.release_data | .["'$repo'"] | .[0] | .assets | .[0] | .release' $LATEST_RELEASES_CACHE)
latest_release=$(jqw -cr '.release_data | .["'$repo'"] | .[0] | .assets | .[0] | .release' $JSON_LATEST_CACHE)

if [ "$release" != "$latest_release" ]; then
is_latest_release=false
Expand Down
Loading
Loading