post-sdp_upgrade.sh #2

  • //
  • p4-hms/
  • dev/
  • p4/
  • common/
  • site/
  • upgrade/
  • post-sdp_upgrade.sh
  • View
  • Commits
  • Open Download .zip Download (3 KB)
#!/bin/bash
#------------------------------------------------------------------------------
set -u

#------------------------------------------------------------------------------
# The SDP upgrade.sh script add files/symlinks to /p4/common/bin. This
# script captures them.

#------------------------------------------------------------------------------
# Declarations and Environment
declare ThisScript=${0##*}
declare Version=1.1.1
declare ThisUser=
declare -i ErrorCount=0
declare -i NoOp=1
declare RunMode="Dry Run"
declare Dir=
declare DirList=

#------------------------------------------------------------------------------
# Local Function
function msg () { echo -e "$*"; }
function errmsg () { msg "\nError: ${1:-Unknown Error}\n"; ErrorCount+=1; }
function bail () { errmsg "${1:-Unknown Error}"; exit "${2:-1}"; }

#------------------------------------------------------------------------------
# Command Line Procesing
[[ "$*" == *-y* ]] && NoOp=0

#------------------------------------------------------------------------------
# Main Program

ThisUser=$(id -n -u)
[[ "$NoOp" -eq 0 ]] && RunMode="Live Operation"
msg "Started $ThisScript ($RunMode) as $ThisUser@${HOSTNAME%%.*} on $(date)."

export P4CONFIG=/p4/.p4config.SDP

# List of dirs to process.  Include /p4/sdp/helix_binaries, and all dirs under
# /p4/common except a select few special dirs that we don't want upgrades to
# interact with.
DirList="/p4/sdp/helix_binaries $(ls -d /p4/common/* | grep -E -v '(python|perl|ruby)$')"

for Dir in $DirList; do
   msg "Post-upgrade HMS updates in: $Dir"
   cd "$Dir" || bail "Could not do: cd \"$Dir\""
   msg "Operating in directory: $PWD"

   if [[ "$NoOp" -eq 0 ]]; then
      msg "Running: p4 -s flush ..."
      p4 -s flush ...
      msg "Running: p4 rec"
      p4 rec
      if [[ -n "$(p4 -ztag -F %depotFile% opened ...)" ]]; then
         msg "Submitting ..."
         p4 -s submit -d "Post-upgrade updates in $PWD/..." ...
      else
         msg "No changes to submit in $PWD/..."
      fi
   else
      msg "NO-OP: Would do: p4 -s flush ..."
      p4 status
      msg "Submitting ..."
      msg "NO-OP: Would do: p4 -s submit -d \"Post-upgrade updates in $PWD/...\""
   fi
done

if [[ "$NoOp" -eq 0 ]]; then
   msg "Running: p4 -s flush /p4/sdp/Version"
   p4 -s flush /p4/sdp/Version
   msg "Running: p4 rec /p4/sdp/Version"
   p4 rec /p4/sdp/Version
   if [[ -n "$(p4 -ztag -F %depotFile% opened /p4/sdp/Version)" ]]; then
      msg "Submitting /p4/sdp/Version."
      p4 -s submit -d "Post-upgrade update to /p4/sdp/Version." /p4/sdp/Version
   else
      msg "No changes to submit to /p4/sdp/Version."
   fi
else
   msg "NO-OP: Would do: p4 -s flush /p4/sdp/Version"
   p4 status /p4/sdp/Version
   msg "Submitting /p4/sdp/Version."
   msg "NO-OP: Would do: p4 -s submit -d \"Post-upgrade update of /p4/sdp/Version\""
fi

exit "$ErrorCount"
# Change User Description Committed
#2 33529 C. Thomas Tyler Cosmetic: normalize double-backslash \\n / \\t to single-backslash \n / \t

An older version of ShellCheck once recommended escaping backslash-n and
backslash-t as \\n / \\t in double-quoted strings; a later version reversed
that guidance since it was unnecessary. Both forms behave identically at
runtime, but the double-backslash form is visual clutter. Applied via
tools/sed_fixer.sh across the tree; no functional change.
#1 33516 C. Thomas Tyler Consistency pass: fix absolute URLs, p4ms->hms renames, script/doc typos and bugs

- Convert absolute workshop.perforce.com URLs to relative paths in dlp/ReadMe.md
- Fix case-mismatch link to HMS_Product_Roadmap.md in README.md
- Rename reset_p4ms.sh -> reset_hms.sh and p4broker_p4ms_test -> p4broker_hms_test
- Fix .sh-suffix bugs: bin/hms calling global_replica_status.sh (should be no ext),
  and matching SEE ALSO / doc references for sdp_sync and global_replica_status
- Add missing scripts (gtu, hrun, irun, global_replica_status) to gen_script_man_pages.sh
- Add stub scripts: nj_help.sh, broker_njob.pl, broker_mkproj.pl, broker_jr.pl
- Remove dangling absolute symlinks HostCM/p4 and HostCM/p4d (cruft)
- Rename test/b -> test/broker_ctl.sh for clarity
- Fix real bugs: broker_imply-u.pl broken regex match, gen_dlp_broker_cfg.sh and
  gen_nj_broker_cfg.sh copy-pasted Version-file existence check, garbled comment
  in broker_must_be_owner.pl, unclosed quote in tools/gsr.sh usage(), missing 'h'
  in HMS_SystemComponents.md broker command example (^ms$ -> ^hms$)
- Fix broken sed command and incomplete sentence in HMS_Install_Notes.md and
  SDP_and_HMS_Update_Process.md
- Fix broken markdown table in HMS_Product_Roadmap.md
- Fix unclosed parenthesis, missing verb, and FKA Swarm mislabel in
  HMSDeploymentPlanning.adoc
- Standardize //streams/main/... naming in HostCM/ReadMe.md
- Numerous typo fixes across README.md, HMS_SystemComponents.md,
  SDP_and_HMS_Update_Process.md, HMS_TightShipManagement.adoc,
  HMSDeploymentPlanning.adoc, HostCM/ReadMe.md, and various scripts

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>