Skip to content
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

Add check for ZOPEN_ROOTFS before refreshing zopen #35

Merged
merged 2 commits into from
Nov 29, 2023
Merged
Changes from all commits
Commits
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
29 changes: 28 additions & 1 deletion buildenv
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,37 @@ zopen_install()

zopen_append_to_setup() {
cat <<ZZ
\$PWD/bin/zopen init --refresh
if [ -n "\$ZOPEN_ROOTFS" ] && [ -d "\$ZOPEN_ROOTFS" ] && [ -x "\$PWD/bin/zopen" ]; then
\$PWD/bin/zopen init --refresh
Copy link
Collaborator

Choose a reason for hiding this comment

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

do you want to verify that $PWD/bin/zopen is executable first in case we move stuff around in the future and break this layout?

Copy link
Collaborator

Choose a reason for hiding this comment

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

There are probably other places we have this assumption so ok if we don't do this one - but seems a bit dangerous without a check

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, curl, git, and a few others :) Although we have checks in place for the return code there: https://github.com/ZOSOpenTools/gitport/blob/main/buildenv#L109

fi
ZZ
}

zopen_pre_terminate() {
# Test setup of meta
set -e
rm -rf $ZOPEN_ROOT/zopen_test
cd $ZOPEN_INSTALL_DIR
unset ZOPEN_ROOTFS
rm -f .installed
. ./.env
zopen init -y $ZOPEN_ROOT/zopen_test
. $ZOPEN_ROOT/zopen_test/etc/zopen-config
rm -rf .installed

# Test refresh on an existing install
timestamp1=$(stat -c %Y "$ZOPEN_ROOT/zopen_test/etc/zopen-config")
. ./.env # runs setup.sh which should now refresh the zopen-config
timestamp2=$(stat -c %Y "$ZOPEN_ROOT/zopen_test/etc/zopen-config")

# zopen-config timestamp should be updated
if [ "$timestamp1" -ge "$timestamp2" ]; then
printError "zopen-config did not get refreshed"
fi
rm -rf $ZOPEN_ROOT/zopen_test
cd -
}

zopen_get_version()
{
version="$(./bin/zopen --version 2>/dev/null)"
Expand Down