-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the capability to specify and apply multiple dmwm/deployment PRs …
…via DMWM_PRS
- Loading branch information
1 parent
9c4a742
commit fd25bcd
Showing
1 changed file
with
76 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/bash | ||
#!/bin/env bash | ||
# | ||
# Script intended for installing [legacy] DQMGUI on online HLT machines (dqmsrv-...). | ||
# It tries to imitate the behavior of the Deploy script without installing external RPMs. | ||
|
@@ -13,6 +13,8 @@ | |
# | ||
# Required system packages: See os_packages.txt which accompanies this script. | ||
# | ||
# Required tools: patch, curl (if patching DMWM directly from github PRs) | ||
# | ||
# Contact: [email protected] | ||
|
||
# Stop at any non-zero return | ||
|
@@ -46,6 +48,10 @@ source $SCRIPT_DIR/config.sh | |
|
||
TMP_BASE_PATH=/tmp | ||
|
||
DMWM_PRS_URL_BASE="https://github.com/dmwm/deployment/pull" | ||
# Comma-separated DMWM PRs to apply. E.g., 1312,1315 | ||
DMWM_PRS= | ||
|
||
# Function to sanitize args to a folder name | ||
# From here: https://stackoverflow.com/a/44811468/6562491 | ||
# echoes "null" if no input given. | ||
|
@@ -82,8 +88,37 @@ preliminary_checks() { | |
echo "WARNING: $INSTALLATION_DIR/$DMWM_GIT_TAG exists, deleting contents" | ||
rm -rf "${INSTALLATION_DIR:?}/${DMWM_GIT_TAG:?}/*" | ||
fi | ||
} | ||
|
||
if [ -n "$DMWM_PRS" ]; then | ||
# If there are PRs to apply, check if patch is available locally | ||
if ! command -v patch >/dev/null; then | ||
echo "ERROR: PRs to apply were specified but the patch command is not available" | ||
exit 1 | ||
fi | ||
OLD_IFS=$IFS | ||
IFS=',' | ||
# Split PRs with commas | ||
for pr in $DMWM_PRS; do | ||
# Each should be a number | ||
if ! [[ "$pr" =~ ^[0-9]+$ ]]; then | ||
echo "ERROR: $pr is not a valid PR number" | ||
exit 1 | ||
fi | ||
# Did not find diff locally, try downloading it | ||
if ! _find_patch $pr >/dev/null; then | ||
if ! command -v curl >/dev/null; then | ||
echo "ERROR: $pr not available locally and curl is not installed" | ||
fi | ||
echo "INFO: Did not find $pr diff locally, trying downloading it from $DMWM_PRS_URL_BASE" | ||
if ! curl --silent -L "${DMWM_PRS_URL_BASE}/${pr}.diff" >"/tmp/${pr}.diff"; then | ||
echo "ERROR: Could not download diff for PR $pr from $DMWM_PRS_URL_BASE" | ||
exit 1 | ||
fi | ||
fi | ||
done | ||
IFS=$OLD_IFS | ||
fi | ||
} | ||
# Check for needed OS-wide dependencies | ||
check_dependencies() { | ||
# Read in the required packages | ||
|
@@ -309,16 +344,13 @@ install_classlib() { | |
install_boost_gil() { | ||
mkdir -p $INSTALLATION_DIR/$DMWM_GIT_TAG/sw/external/src/ | ||
tar -xzf "$SCRIPT_DIR/boost_gil/boost_gil.tar.gz" -C "${TMP_BASE_PATH}" | ||
|
||
rm -rf "$INSTALLATION_DIR/$DMWM_GIT_TAG/sw/external/src/boost" # Cleanup dir if exists | ||
mv "${TMP_BASE_PATH}/boost_gil/include/boost" "$INSTALLATION_DIR/$DMWM_GIT_TAG/sw/external/src/boost" | ||
} | ||
|
||
install_gil_numeric() { | ||
|
||
tar -xzf "$SCRIPT_DIR/numeric/numeric.tar.gz" -C "${TMP_BASE_PATH}" | ||
mkdir -p "$INSTALLATION_DIR/$DMWM_GIT_TAG/sw/external/src/boost/gil/extension/" | ||
|
||
rm -rf "$INSTALLATION_DIR/$DMWM_GIT_TAG/sw/external/src/boost/gil/extension/numeric" # Cleanup dir if exists | ||
mv "$NUMERIC_TMP_DIR" "$INSTALLATION_DIR/$DMWM_GIT_TAG/sw/external/src/boost/gil/extension/numeric" | ||
} | ||
|
@@ -350,6 +382,44 @@ install_dmwm() { | |
rm -rf $DMWM_TMP_DIR | ||
} | ||
|
||
# Tries to look for a <pr_num>.patch or <pr_num>.diff in /tmp or /globalscratch | ||
# Returns nothing if it wasn't found. | ||
_find_patch() { | ||
pr_num=${1?} | ||
dirs_to_check=("/tmp" "/globalscratch") | ||
valid_extensions=(".patch" ".diff") | ||
for dir in "${dirs_to_check[@]}"; do | ||
for extension in "${valid_extensions[@]}"; do | ||
patch_filename="${pr_num}${extension}" | ||
patch_filepath="${dir}/${patch_filename}" | ||
if [ -f "$patch_filepath" ]; then | ||
echo "$patch_filepath" | ||
return 0 | ||
fi | ||
done | ||
done | ||
return 1 | ||
} | ||
|
||
# Apply patches to DMWM. Assumes that the patches are avilable | ||
patch_dmwm() { | ||
OLD_IFS=$IFS | ||
IFS=',' | ||
cd $DMWM_TMP_DIR | ||
for pr in $DMWM_PRS; do | ||
echo "INFO: Looking for the PR $pr patch" | ||
patch_filepath="$(_find_patch $pr)" | ||
if [ -z "$patch_filepath" ]; then | ||
echo "ERROR: Could not find patch for PR $pr" | ||
return 1 | ||
fi | ||
echo "INFO: Applying $patch_filepath" | ||
patch -p1 <"$patch_filepath" | ||
done | ||
IFS=$OLD_IFS | ||
cd - | ||
} | ||
|
||
# Create a configuration file for logrotate to manage...(surprise!) rotating logs. | ||
_create_logrotate_conf() { | ||
echo "# DQMGUI logrotate configuration file | ||
|
@@ -602,6 +672,7 @@ declare -a installation_steps=(preliminary_checks | |
install_classlib | ||
compile_classlib | ||
extract_dmwm | ||
patch_dmwm | ||
install_dmwm | ||
install_root | ||
compile_root | ||
|