Skip to content

Commit

Permalink
tools/install_opte: Freeze the package to the pinned version. (#4215)
Browse files Browse the repository at this point in the history
  • Loading branch information
luqmana authored Oct 5, 2023
1 parent a2bb889 commit fb2b4a1
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tools/install_opte.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,26 @@ fi
# Grab the version of the opte package to install
OPTE_VERSION="$(cat "$OMICRON_TOP/tools/opte_version")"

OMICRON_FROZEN_PKG_COMMENT="OMICRON-PINNED-PACKAGE"

# Once we install, we mark the package as frozen at that particular version.
# This makes sure that a `pkg update` won't automatically move us forward
# (and hence defeat the whole point of pinning).
# But this also prevents us from installig the next version so we must
# unfreeze first.
if PKG_FROZEN=$(pkg freeze | grep driver/network/opte); then
FROZEN_COMMENT=$(echo "$PKG_FROZEN" | awk '{ print $(NF) }')

# Compare the comment to make sure this is indeed our previous doing
if [ "$FROZEN_COMMENT" != "$OMICRON_FROZEN_PKG_COMMENT" ]; then
echo "Found driver/network/opte previously frozen but not by us:"
echo $PKG_FROZEN
exit 1
fi

pfexec pkg unfreeze driver/network/opte
fi

# Actually install the xde kernel module and opteadm tool
RC=0
pfexec pkg install -v pkg://helios-dev/driver/network/opte@"$OPTE_VERSION" || RC=$?
Expand All @@ -63,6 +83,13 @@ else
exit "$RC"
fi

RC=0
pfexec pkg freeze -c "$OMICRON_FROZEN_PKG_COMMENT" driver/network/opte@"$OPTE_VERSION" || RC=$?
if [[ "$RC" -ne 0 ]]; then
echo "Failed to pin opte package to $OPTE_VERSION"
exit $RC
fi

# Check the user's path
RC=0
which opteadm > /dev/null || RC=$?
Expand Down
14 changes: 14 additions & 0 deletions tools/uninstall_opte.sh
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,19 @@ function restore_xde_and_opte {
fi
}

function unfreeze_opte_pkg {
OMICRON_FROZEN_PKG_COMMENT="OMICRON-PINNED-PACKAGE"

# If we've frozen a particular version, let's be good citizens
# and clear that as well.
if PKG_FROZEN=$(pkg freeze | grep driver/network/opte); then
FROZEN_COMMENT=$(echo "$PKG_FROZEN" | awk '{ print $(NF) }')
if [ "$FROZEN_COMMENT" == "$OMICRON_FROZEN_PKG_COMMENT" ]; then
pkg unfreeze driver/network/opte
fi
fi
}

function ensure_not_already_on_helios {
local RC=0
pkg list "$STOCK_CONSOLIDATION"* || RC=$?
Expand All @@ -179,5 +192,6 @@ uninstall_xde_and_opte
for PUBLISHER in "${PUBLISHERS[@]}"; do
remove_publisher "$PUBLISHER"
done
unfreeze_opte_pkg
ensure_not_already_on_helios
to_stock_helios "$CONSOLIDATION"

0 comments on commit fb2b4a1

Please sign in to comment.