summaryrefslogtreecommitdiff
path: root/localbackuppkglists
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2007-05-07 12:39:38 +0000
committerJonas Smedegaard <dr@jones.dk>2007-05-07 12:39:38 +0000
commitf0a3f06f3d178e3926c5d32f122a5f901628f008 (patch)
tree9b5ba1b6537a113deb5bd3fd82bf8fc53f534936 /localbackuppkglists
parent16bb00ee13681f4d9d0d3217556daebcff965f0a (diff)
New script to dump packaging lists from aptitude and debconf.
Diffstat (limited to 'localbackuppkglists')
-rwxr-xr-xlocalbackuppkglists66
1 files changed, 66 insertions, 0 deletions
diff --git a/localbackuppkglists b/localbackuppkglists
new file mode 100755
index 0000000..5a4b5ef
--- /dev/null
+++ b/localbackuppkglists
@@ -0,0 +1,66 @@
+#!/bin/sh
+#
+# /usr/local/sbin/localbackuppkglists
+# Copyright 2007 Jonas Smedegaard <dr@jones.dk>
+#
+# $Id: localbackuppkglists,v 1.1 2007-05-07 12:39:38 jonas Exp $
+#
+
+set -e
+
+PRG=$(basename "$0")
+
+TEMP="`getopt -s sh -o t:f -l target:,force -n "$PRG" -- "$@"`"
+if [ $? != 0 ] ; then echo >&2 "ERROR: Internal getopt error." ; exit 1 ; fi
+eval set -- "$TEMP"
+
+targetdir=''
+force='no'
+while true ; do
+ case "$1" in
+ -t|--target) targetdir="$2" ; shift 2 ;;
+ -f|--force) force="yes" ; shift ;;
+ --) shift ; break ;;
+ *) echo >&2 "ERROR: Internal error resolving options." ; exit 1 ;;
+ esac
+done
+
+if [ -n "$targetdir" ]; then
+ targetdirparent="$(dirname "$targetdir")"
+ if ! [ -d "$targetdirparent" ]; then
+ if [ "$force" = "yes" ]; then
+ mkdir -p "$targetdirparent"
+ else
+ echo >&2 "Error: Parent directory for target directory does not exist."
+ exit 1
+ fi
+ elif [ -e "$targetdir" ]; then
+ if [ "$force" = "yes" ]; then
+ rm -rf "$targetdir"
+ else
+ echo >&2 "Error: Target directory already exists."
+ exit 1
+ fi
+ fi
+fi
+
+tempdir="$(mktemp -td localpkglists.XXXXXX)"
+
+origlang="$LANG"
+LANG='C'
+
+dpkg --get-selections > "$tempdir/dpkg-selections.txt"
+
+aptitude -F '%p#%v#' search '~i!~M' > "$tempdir/aptitude-installed-explicitly.txt"
+aptitude -F '%p#%v#' search '~i!~Odebian' > "$tempdir/aptitude-installed-aliens.txt"
+aptitude -F '%p#' search '!~i~Rrecommends:(~i)' > "$tempdir/aptitude-notinstalled-recommended.txt"
+
+debconf-get-selections > "$tempdir/debconf-questions.txt"
+debconf-get-selections --installer > "$tempdir/debconf-questions-di.txt" 2> /dev/null || true
+
+LANG="$origlang"
+
+if [ -n "$targetdir" ]; then
+ mv "$tempdir" "$targetdir"
+ rm -rf "$tempdir"
+fi