From ecefe454e07326c444476c2d1e4c0956e27eb65d Mon Sep 17 00:00:00 2001 From: Skip Grube Date: Sat, 13 May 2023 22:05:34 -0400 Subject: [PATCH] Updated serveral things: - Removed RHEL Beta comparisons, until we figure out dual subscriptions on single box - Revamped module comparison script, runs much faster now -Skip G. --- module_compare_html.sh | 73 +++++++++++++++++++++++++++------------- repo_compare_launcher.sh | 34 +++++++++---------- 2 files changed, 65 insertions(+), 42 deletions(-) diff --git a/module_compare_html.sh b/module_compare_html.sh index 30802ab..01a9f79 100755 --- a/module_compare_html.sh +++ b/module_compare_html.sh @@ -63,35 +63,59 @@ echo " Module Name:Version ${REPOS1} Pkg Diffs (-) ${REPOS2} Pkg Diffs (+) " - +# Grab module info (artifacts, streams, versions) from all modules, in the source repo and target repo +MODULE1=$(dnf --disablerepo '*' --enablerepo "${REPOS1}" module info "*" 2> /dev/null) +MODULE2=$(dnf --disablerepo '*' --enablerepo "${REPOS2}" module info "*" 2> /dev/null) # Big loop where we go through every possible module/version combination: for module in ${MODULE_LIST1}; do - # MODULE1 == complete module info from the 1st repos, while MODULE2 == complete module info from 2nd repos - # This includes all the different versions/releases, so we want to filter for the latest later - MODULE1=$(dnf --disablerepo '*' --enablerepo "${REPOS1}" module info "${module}" 2> /dev/null) - MODULE2=$(dnf --disablerepo '*' --enablerepo "${REPOS2}" module info "${module}" 2> /dev/null) - + # isolate what stream ("version") of the module we want + mod_name=$(echo "${module}" | awk -F ':' '{print $1}') + mod_stream=$(echo "${module}" | awk -F ':' '{print $2}') + + # Isolate the latest released version of each module, that's the only one we're intrested in (indicated by the "Version :" line in module info) - latest_version1=$(echo "${MODULE1}" | grep 'Version ' | awk '{print $3}' | sort -n | tail -1) - latest_version2=$(echo "${MODULE2}" | grep 'Version ' | awk '{print $3}' | sort -n | tail -1) + # Strategy: + # get the module name and 3 lines after, + # from that ensure the module stream is the one we want, + # from that isolate the "Version :" line, + # then isolate the version number only, sort, and grab the newest + latest_version1=$(echo "${MODULE1}" | + grep -A3 ": ${mod_name}$" | + grep -A2 ": ${mod_stream}" | + grep "^Version" | + awk '{print $3}' | + sort -n | tail -1) + + + latest_version2=$(echo "${MODULE2}" | + grep -A3 ": ${mod_name}$" | + grep -A2 ": ${mod_stream}" | + grep "^Version" | + awk '{print $3}' | + sort -n | tail -1) + # Isolate individual module artifacts and write them (sorted) to a text file - # order of operations: awk to find version string through blank line, - # awk to find "Requires :" line, - # sed to remove "Artifacts", - # awk to isolate module rpm artifact ($2), - # sed to remove the distro tag after module (module+el8.4.0+xyz) - # sed to remove the git hash after "module+" ONLY IF we have a minor patch release (ie. module ends in a ".1.x86_64" or a ".2.src" or something similar) - # sed to remove everything after .module in the normal case (no minor patch release at the end) - #everything after ".module" (which is unique per-distro), except for ending ".$arch" (src/noarch/x86_64/etc.) - # remove any blank lines, - # and finally sort and write to text file + # order of operations: + # grep to find the module name, then grep to find the version, followed by 1000 lines of continued text + # sed to get this single module:stream:version, ending at the blank line (blank line separates all versions) + # awk to find "Requires :" line, + # sed to remove "Artifacts", + # awk to isolate module rpm artifact ($2), + # sed to remove the distro tag after module (module+el8.4.0+xyz) + # sed to remove the git hash after "module+" ONLY IF we have a minor patch release (ie. module ends in a ".1.x86_64" or a ".2.src" or something similar) + # sed to remove everything after .module in the normal case (no minor patch release at the end) + #everything after ".module" (which is unique per-distro), except for ending ".$arch" (src/noarch/x86_64/etc.) + # remove any blank lines, + # and finally sort and write to text file echo "${MODULE1}" | - awk "/${latest_version1}/ { show=1; next } show; /^$/ { show=0 }" | + grep -A1000 ": ${mod_name}$" | + grep -A1000 "${latest_version1}" | + sed -n '0,/^$/p' | awk "/Requires / { show=1; next } show; /^$/ { show=0 }" | sed 's/Artifacts //' | awk '{print $2}' | @@ -104,17 +128,20 @@ for module in ${MODULE_LIST1}; do # Do the same isolation of module rpms for module 2 and write that to a text file echo "${MODULE2}" | - awk "/${latest_version2}/ { show=1; next } show; /^$/ { show=0 }" | + grep -A1000 ": ${mod_name}$" | + grep -A1000 "${latest_version2}" | + sed -n '0,/^$/p' | awk "/Requires / { show=1; next } show; /^$/ { show=0 }" | sed 's/Artifacts //' | awk '{print $2}' | - sed 's/module+.*+/module+/g' | - sed 's/module+.*\.\(.*\)\./module.\1./g' | - sed 's/module+.*\./module./g' | + sed 's/module+.*+/module+/g' | + sed 's/module+.*\.\(.*\)\./module.\1./g' | + sed 's/module+.*\./module./g' | grep -v '^$' | sort > "/tmp/module_compare/${module}_2" + # Get list of differences from source repo (the "-" in git diff) diff1=$(git --no-pager diff "/tmp/module_compare/${module}_1" "/tmp/module_compare/${module}_2" | grep -A1000 '@@' | grep '^\-' | sort) diff --git a/repo_compare_launcher.sh b/repo_compare_launcher.sh index 0146468..382fe42 100755 --- a/repo_compare_launcher.sh +++ b/repo_compare_launcher.sh @@ -21,17 +21,15 @@ mkdir -p "${RESULTSDIR}" for version in "8" "9"; do for rockyStage in "" "_stg"; do - for rhelBeta in "" "_Beta"; do - for sourceFlag in "" "_Source"; do - for repo in "BaseOS" "AppStream" "CodeReady" "HighAvailability" "ResilientStorage"; do - >&2 echo "Now running compare for: ${RESULTSDIR}/RHEL${version}${rhelBeta}_Rocky${version}_${repo}${sourceFlag}${rockyStage}_${now}.html" - "${SCRIPTSDIR}"/mkrepofile.sh - "${SCRIPTSDIR}"/repo_compare_html.sh "RHEL${version}${rhelBeta}_${repo}${sourceFlag}" "Rocky${version}_${repo}${sourceFlag}${rockyStage}" > "${RESULTSDIR}/RHEL${version}${rhelBeta}_Rocky${version}_${repo}${sourceFlag}${rockyStage}_${now}.html" - - # Copy the timestamped html file to the "standard" one - removing the "_$now" timestamp at the end: - cp -f "${RESULTSDIR}/RHEL${version}${rhelBeta}_Rocky${version}_${repo}${sourceFlag}${rockyStage}_${now}.html" "${RESULTSDIR}/RHEL${version}${rhelBeta}_Rocky${version}_${repo}${sourceFlag}${rockyStage}.html" - - done + for sourceFlag in "" "_Source"; do + for repo in "BaseOS" "AppStream" "CodeReady" "HighAvailability" "ResilientStorage"; do + >&2 echo "Now running compare for: ${RESULTSDIR}/RHEL${version}_Rocky${version}_${repo}${sourceFlag}${rockyStage}_${now}.html" + "${SCRIPTSDIR}"/mkrepofile.sh + "${SCRIPTSDIR}"/repo_compare_html.sh "RHEL${version}_${repo}${sourceFlag}" "Rocky${version}_${repo}${sourceFlag}${rockyStage}" > "${RESULTSDIR}/RHEL${version}_Rocky${version}_${repo}${sourceFlag}${rockyStage}_${now}.html" + + # Copy the timestamped html file to the "standard" one - removing the "_$now" timestamp at the end: + cp -f "${RESULTSDIR}/RHEL${version}_Rocky${version}_${repo}${sourceFlag}${rockyStage}_${now}.html" "${RESULTSDIR}/RHEL${version}_Rocky${version}_${repo}${sourceFlag}${rockyStage}.html" + done done done @@ -41,25 +39,23 @@ done # Module Compare 1: RHEL 8 vs. Rocky 8 production: "${SCRIPTSDIR}"/mkrepofile.sh -"${SCRIPTSDIR}"/module_compare_html.sh RHEL8_AppStream,RHEL8_CodeReady Rocky8_AppStream,Rocky8_PowerTools > "${RESULTSDIR}/RHEL8_Rocky8_Modules_${now}.html" +"${SCRIPTSDIR}"/module_compare_html.sh RHEL8_AppStream,RHEL8_CodeReady Rocky8_AppStream,Rocky8_CodeReady > "${RESULTSDIR}/RHEL8_Rocky8_Modules_${now}.html" cp -f "${RESULTSDIR}/RHEL8_Rocky8_Modules_${now}.html" "${RESULTSDIR}/RHEL8_Rocky8_Modules.html" # Module Compare 2: RHEL 8 vs. Rocky 8 staging: "${SCRIPTSDIR}"/mkrepofile.sh -"${SCRIPTSDIR}"/module_compare_html.sh RHEL8_AppStream,RHEL8_CodeReady Rocky8_AppStream_stg,Rocky8_PowerTools_stg > "${RESULTSDIR}/RHEL8_Rocky8_Modules_stg_${now}.html" +"${SCRIPTSDIR}"/module_compare_html.sh RHEL8_AppStream,RHEL8_CodeReady Rocky8_AppStream_stg,Rocky8_CodeReady_stg > "${RESULTSDIR}/RHEL8_Rocky8_Modules_stg_${now}.html" cp -f "${RESULTSDIR}/RHEL8_Rocky8_Modules_stg_${now}.html" "${RESULTSDIR}/RHEL8_Rocky8_Modules_stg.html" -# Module Compare 3: RHEL 8 Beta vs. Rocky 8 staging: +# Module Compare 3: RHEL 9 vs. Rocky 9 production: "${SCRIPTSDIR}"/mkrepofile.sh -"${SCRIPTSDIR}"/module_compare_html.sh RHEL8_Beta_AppStream,RHEL8_Beta_CodeReady Rocky8_AppStream_stg,Rocky8_PowerTools_stg > "${RESULTSDIR}/RHEL8_Beta_Rocky8_Modules_stg_${now}.html" -cp -f "${RESULTSDIR}/RHEL8_Beta_Rocky8_Modules_stg_${now}.html" "${RESULTSDIR}/RHEL8_Beta_Rocky8_Modules_stg_${now}.html" +"${SCRIPTSDIR}"/module_compare_html.sh RHEL9_AppStream,RHEL9_CodeReady Rocky9_AppStream,Rocky9_CodeReady > "${RESULTSDIR}/RHEL9_Rocky9_Modules_${now}.html" +cp -f "${RESULTSDIR}/RHEL9_Rocky9_Modules_${now}.html" "${RESULTSDIR}/RHEL9_Rocky9_Modules.html" - - -# Module Compare: RHEL 9 vs. Rocky 9 staging: +# Module Compare 4: RHEL 9 vs. Rocky 9 staging: "${SCRIPTSDIR}"/module_compare_html.sh RHEL9_AppStream,RHEL9_CodeReady Rocky9_AppStream_stg,Rocky9_CodeReady_stg > "${RESULTSDIR}/RHEL9_Rocky9_Modules_stg_${now}.html" cp -f "${RESULTSDIR}/RHEL9_Rocky9_Modules_stg_${now}.html" "${RESULTSDIR}/RHEL9_Rocky9_Modules_stg.html"