get detailed info of installed RPM packages

for rpm-based distros
This commit is contained in:
kneutron 2021-04-08 11:48:34 -05:00 committed by GitHub
parent cef2e6fb51
commit 6d3193f962
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,58 +1,30 @@
#!/bin/bash
# for RPM-based distros
# get detailed installed-packages info
echo "Getting sorted list of installed pkgs..."
date
rpm -qa |sort >~/Installedpkgs.list
echo EOF>>~/Installedpkgs.list
time rpm -qa |sort >~/Installedpkgs.list
#echo EOF>>~/Installedpkgs.list
echo "Done with sort"
date
let tr=1
let thisline=0
echo "Reading sorted list into array..."
{
while read elemt; do
let thisline=$thisline+1
# Skip comments
commentmp=`(echo $elemt |grep -c -e "\#")`
test4blank=${elemt//" "/""}
if [ $commentmp -gt 0 ]; then
echo "Found a comment in line "$thisline". Skipping."
elif [ ${#test4blank} -eq 0 ]; then
echo "Blank line at "$thisline". Skipping."
elif [ "$elemt" = "EOF" ]; then
echo "EOF found in line "$thisline"."
break
else
riptrack[$tr]=$elemt
let tr=$tr+1
fi
done
} < ~/Installedpkgs.list
echo "Done with array = "$tr" elements."
date
# Repeat array
#for i in "${riptrack[@]}"; do
# echo $i
#done
echo "$(date) - Done with sort"
# Blank it
>~/RPMInstalled.list
outfile=~/RPMInstalled.list.txt
> $outfile
echo "Querying all installed pkgs for details..."
# Do it
for i in "${riptrack[@]}"; do
rpm -qi $i >>~/RPMInstalled.list
for i in $(cat ~/Installedpkgs.list); do
rpm -qi $i >>$outfile
done
echo "Done- PK"
date
#read
echo "$(date) - Done"
#less ~/RPMInstalled.list
ls -alh $outfile
exit;
# 2021.0408 rewrite simpler