Skip to content

Instantly share code, notes, and snippets.

@gojun077
Created August 6, 2016 00:27
Show Gist options
  • Save gojun077/7b47eba4a2f846926e52d1b0f067a971 to your computer and use it in GitHub Desktop.
Save gojun077/7b47eba4a2f846926e52d1b0f067a971 to your computer and use it in GitHub Desktop.
#!/bin/bash
# create-baseline-pkg-list.sh
# Jun Go [email protected]
# Last updated: 2016-08-03
# This script will create a baseline list of all the rpm
# files inside a RHEL installation ISO for RHEL 5.X and
# 6.X.
# In order to make the file list directly comparable to
# the output of 'rpm -qa', the file extenstion '.rpm' will
# be removed from all filenames.
# NOTE: On RHEL 5.X 'rpm -qa' does not by default print the
# package architecture. This must be enabled by editing
# /usr/lib/rpm/macros '%_query_all_fmt' value to
# %_query_all_fmt %%{name}-%%{version}-%%{release}.%%{arch}
# USAGE:
# ./create-baseline-pkg-list.sh <path to RHEL iso mnt>
# ex: ./create-baseline-pkg-list.sh /mnt/iso (no trailing backslash)
# ex: ./create-baseline-pkg-list.sh /media
FIVE=('Cluster'
'ClusterStorage'
'Server'
'VT'
)
FIVEOUT='rhel5.11-dvd-pkg-list.txt'
FIVECLEAN='rhel5.11-dvd-pkg-list-clean.txt'
SIX=('HighAvailability'
'LoadBalancer'
'Packages'
'ResilientStorage'
'ScalableFileSystem'
'Server'
)
SIXOUT='rhel6.8-dvd-pkg-list.txt'
SIXCLEAN='rhel6.8-dvd-pkg-list-clean.txt'
if [ -z "$1" ]; then
echo "Must enter the path to the iso mount point"
exit 1
else
if [ -f "$1/RELEASE-NOTES-en" ]; then
if grep --silent "Red Hat Enterprise Linux 5" "$1/RELEASE-NOTES-en"; then
for i in ${FIVE[*]}; do
ls "${1}/${i}" >> $FIVEOUT
done
fi
# remove non-rpm files and directory names, sort, remove dups
grep ".rpm" $FIVEOUT | sort -u > $FIVECLEAN
# remove '.rpm' from all filenames to conform with 'rpm -qa' output
sed -i "s:.rpm::g" "$FIVECLEAN"
elif [ -f "$1/README" ]; then
if grep --silent "Red Hat Enterprise Linux 6" "$1/README"; then
for j in ${SIX[*]}; do
ls "${1}/${j}" >> $SIXOUT
done
fi
# remove non-rpm files and directory names, sort, remove dups
grep ".rpm" $SIXOUT | sort -u > $SIXCLEAN
# remove '.rpm' from all filenames to conform with 'rpm -qa' output
sed -i "s:.rpm::g" "$SIXCLEAN"
else
echo "Please mount a valid RHEL 5.X or 6.X image!"
exit 1
fi
fi
# delete FIVEOUT/SIXOUT temp files
if [ -f "$FIVEOUT" ]; then
rm "$FIVEOUT"
elif [ -f "$SIXOUT" ]; then
rm "$SIXOUT"
else
echo "No temp files exist"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment