-
Notifications
You must be signed in to change notification settings - Fork 38
Improved installer #742
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Improved installer #742
Changes from all commits
d49ad10
3fbd950
e846ebe
cb96768
1988ee6
96e908f
410b0e2
02a3ae6
679a7c0
2fdcbf7
82761c9
0fc35f9
73ed6b5
72bce1c
67eb893
bc93182
826d862
679bb22
3de15e6
3757885
c907f94
51693c8
43c626d
7addf69
ff963c5
44c8b41
ded466c
f71835c
b1fde6f
0b5c43f
d2db05e
fcd7ce2
1a9e4d2
5b19515
116e741
f69af49
9def9c1
7280be9
69e20c1
7e6cac1
cdc938e
0c7af75
bd6e28c
80a195a
34ed26f
df1cd16
d7ca7c7
87b44fe
52bb3e3
7c76653
b97e592
4fec973
64c1be7
eb0a642
c75e77b
78c6e79
26df115
cab76a1
48ea3ea
5110721
8deeaa6
71358e4
cf72c0b
733c9a4
04497df
67def02
3171846
875b17a
15d752f
32c7fbf
5220945
48be860
b279702
6df8214
b624850
3490324
7d5e96c
21d2247
483b76c
49cd7b7
adad93a
5c3199d
70bd609
3f76ff7
0a76b9c
e723313
99e7cf7
d7635af
37c1b2a
6f6c229
fd9144e
7513fd9
7d92f8b
df0dcc3
608022b
6131e41
0339adf
3aed2d9
fa031fc
34951ae
3c5dc54
7d109ab
1038a80
a7cb39b
1cc9896
e8fd601
735d4a8
a1d62e8
0f1e34c
2416982
0e2d920
c0a837b
827672e
15d0591
7e35950
6456378
309dd48
eafd680
bf66c32
5b614ae
4bacec3
76bcf2d
36e466a
668b54e
fcfeccf
faeabb5
7b53890
5de49d6
b83d2ee
5a29ff5
3195a6d
a1c8815
6b06117
8ad4ddb
2fd21fb
f8b9fe9
4aeee75
7fb1f8a
31d00d9
e3ad6cd
ee035b1
2674ab5
51918f9
c681a29
0fbc0f1
19b8cf5
35189ee
96a20a4
4cf3c3a
3499ea8
3a9b923
8003d98
5634473
6acebff
ce28a46
cc912e8
362904f
806893d
498b2a2
5b9122f
67ae972
deec944
7251638
244f0d4
96ccd17
afb4858
f387f81
ca64a58
c8f532d
1adc9fe
d9893f4
dcc2de2
6bdddc5
4245c33
9414fe3
d4fff23
02c2468
1936a78
40cb5da
dfda0b3
d1f9df8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||
| # | ||
|
|
@@ -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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This 🤖 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 | ||
|
|
@@ -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() | ||
|
|
@@ -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 | ||
|
|
@@ -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 | ||
|
|
@@ -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" | ||
|
|
@@ -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" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
🤖 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}" | ||
|
|
@@ -228,7 +243,9 @@ while [ $# -gt 0 ]; do | |
| verbose=true | ||
| ;; | ||
| "--debug") | ||
| # shellcheck disable=SC2034 | ||
| verbose=true | ||
| # shellcheck disable=SC2034 | ||
| debug=true | ||
| ;; | ||
| *) | ||
|
|
@@ -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 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#!/bin/sh -xenables 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-xunder an explicit--xdebug/env flag (also applies to other scripts in this PR).🤖 Was this useful? React with 👍 or 👎