#!/bin/bash # Script takes 2 arguments: SOURCEREPO and TARGETREPO (ex: ./repo_compare_html.sh RHEL8_BaseOS Rocky8_BaseOS ) # The arguments must be named dnf/yum repos on the system # # We will loop through the RPM names from SOURCEREPO, and attempt to find name/version/release matches in TARGETREPO # An HTML table page will be sent to stdout showing the differences # REPO1="$1" REPO2="$2" pkglist1=$(dnf repoquery --latest-limit 1 --repo "${REPO1}" --queryformat "%{name} %{version} %{release}" | grep -vi " subscription ") pkglist2=$(dnf repoquery --latest-limit 1 --repo "${REPO2}" --queryformat "%{name} %{version} %{release}" | grep -vi " subscription ") # Strip some ending package info off like this: # 1: moduleXYZ info comes off # 2: If a dotrelease tag is present (like .el8_4.3), then preserve the .3 but remove the el8_* tag # 3: If a dotrelease tag is not present, then simply take the .el8* off from the end # 4: Remove any trailing ".rocky" tag as well from the end if a dotrelease is not present # The moduleXYZ will never match versions, and the el8 tagging may be different (el8 vs. el8_3, el8_4, etc.) pkglist1=$(echo "${pkglist1}" | sed -e 's/\.module.*$/\.module/g' | sed -e 's/\.el.*\.\(.*\)$/\.\1/g' | sed -e 's/\.el.*$//g' | sed 's/\.rocky$//') pkglist2=$(echo "${pkglist2}" | sed -e 's/\.module.*$/\.module/g' | sed -e 's/\.el.*\.\(.*\)$/\.\1/g' | sed -e 's/\.el.*$//g' | sed 's/\.rocky$//') # Turn the first pkg list into a comma-separated list (instead of newline-separated) # (makes it easier to use IFS=',' in all of our for loops) pkglist1=$(echo "${pkglist1}" | tr '\n' ',') #echo "$pkglist1" > debug1.txt #echo "$pkglist2" > debug2.txt # HTML style header for table: echo "
${REPO1} Version | ${REPO2} Version |
---|---|
${_name}-${_version}-${_tag} | (DOES NOT EXIST) |
${_name}-${_version}-${_tag} | ${pkgmatches} |