Skip to content

Instantly share code, notes, and snippets.

@rduplain
Created November 18, 2011 22:16
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rduplain/1377951 to your computer and use it in GitHub Desktop.
Save rduplain/1377951 to your computer and use it in GitHub Desktop.
Produce CSV of each installed package and full copyright of each package. (Debian/Ubuntu)
#!/bin/bash
# Produce CSV of each installed package and full copyright of each package. (Debian)
#
# Sample CSV:
# Package,Version,Section,Homepage,Source
# bash,4.1-2ubuntu3,shells,http://tiswww.case.edu/php/chet/bash/bashtop.html,
# git-core,1:1.7.0.4-1ubuntu0.2,vcs,,
# python,2.6.5-0ubuntu1,python,,python-defaults
AUDIT_DIR="${HOSTNAME}-package-audit/`date +'%Y-%m-%d'`"
echo "Placing audit files in $AUDIT_DIR" 1>&2
mkdir -p $AUDIT_DIR
echo 'Package,Version,Section,Homepage,Source' > $AUDIT_DIR/packages.csv
dpkg-query -Wf '${Package},${Version},${Section},${Homepage},${Source}\n' | sort -n >> $AUDIT_DIR/packages.csv
for package in `dpkg-query -Wf '${Package} '`; do
cp /usr/share/doc/$package/copyright $AUDIT_DIR/${package}-copyright.txt
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment