Skip to content

Instantly share code, notes, and snippets.

@unakatsuo
Created January 9, 2014 12:07
Show Gist options
  • Save unakatsuo/8333120 to your computer and use it in GitHub Desktop.
Save unakatsuo/8333120 to your computer and use it in GitHub Desktop.
Get dependency list from RPM spec in bash.
# Read dependency information from rpmbuild/SPECS/*.spec.
# % cat rpmbuild/SPECS/*.spec | rpmspec_depends
function rpmspec_depends() {
# 0. remove redhat meta variables.
# 1. convert space list to line list.
# 2. remove trailing spaces.
# 3. remove debian meta variables. i.e. ${shlib:Depends}
# 4. remove version conditions.
# 5. remove wakame-vdc packages.
awk -F: '$1 == "BuildRequires" || $1 == "Requires" { print substr($0, length($1)+2)}' | \
egrep -v '%|=' |\
sed -e 's|\s* \s*|\n|g' | \
sed -e 's/^[ ]*//g' -e 's/[ ]*$//' | \
sed -e '/\$/d' | \
sed -e 's|[\(].*[\)]||g' | \
sort | uniq | \
egrep -v '^wakame-vdc'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment