Skip to content

Instantly share code, notes, and snippets.

@jflemer-ndp
Last active December 2, 2017 22:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jflemer-ndp/1b73884f1a270619d1db9f03235fcf5f to your computer and use it in GitHub Desktop.
Save jflemer-ndp/1b73884f1a270619d1db9f03235fcf5f to your computer and use it in GitHub Desktop.
Generate markdown software report for yum repos
#!/bin/sh
# Usage:
# pps_yum.sh /path/to/repo1 ... /path/to/repoN
#
# Example:
# pps_yum.sh /export/repos/rhel-7-* /export/repos/rhel-*-7-* > rhel7_pps.md
# Copyright 2017, NDP LLC
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from this
# software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
pps_repoquery() {
for repopath in "$@"; do
repoquery \
--repofrompath=PPSYUM,"$repopath" \
--disablerepo='*' \
--enablerepo=PPSYUM \
-a \
--qf='%{sourcerpm}||%{name}||%{version}||%{summary}||%{url}||%{license}||%{vendor}||%{buildhost}||%{packager}\n'
done
}
pps_yum() {
echo '| Software | Version | Summary | URL | License | Vendor | Build Host | Packager |'
echo '| --- | --- | --- | --- | --- | --- | --- | --- |'
pps_repoquery "$@" | \
LC_ALL=C sort -t '|' -k1,1V -k 3,3 | \
perl -e 'while (<>) {
chomp;
s/[\\\`]//g;
@d=split/\|\|/;
map { s/\|/:/g } @d;
if ($d[0] ne $p) {
$p=$d[0];
($d[1] = $d[0]) =~ s/-\d+\..*//;
map { $d[$_] =~ s/\b([*_])/\\$1/g } 1..$#d;
print "| ", join(" | ", @d[1..$#d]), " |\n";
}
}'
}
pps_yum "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment