summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Burrows <dburrows@debian.org>2007-07-08 10:26:59 -0700
committerDaniel Burrows <dburrows@debian.org>2007-07-08 10:26:59 -0700
commit3e7c190b7a1cc393980ae77e9aa7881e83c4723c (patch)
treec6c8a95830b80424838a0f7692cea1b89c3153d6
parent435233b9835c7e8986bd16c6c4d598c3df97ecc0 (diff)
downloadaptitude-3e7c190b7a1cc393980ae77e9aa7881e83c4723c.tar.gz
Add two utility scripts to the package that codify the process of snapshotting the state and running with a state snapshot.
-rw-r--r--Makefile.am5
-rwxr-xr-xaptitude-create-state-bundle43
-rw-r--r--aptitude-create-state-bundle.155
-rwxr-xr-xaptitude-run-state-bundle111
-rw-r--r--aptitude-run-state-bundle.170
5 files changed, 283 insertions, 1 deletions
diff --git a/Makefile.am b/Makefile.am
index 5eb2336c..0e3b4971 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -8,9 +8,12 @@ DOCDIRS=@DOCDIRS@
SUBDIRS=$(SRCDIRS) $(DOCDIRS) m4 po tests
+bin_SCRIPTS = aptitude-create-state-bundle aptitude-run-state-bundle
+MANPAGES = aptitude-create-state-bundle.1 aptitude-run-state-bundle.1
+
MANPAGE_LOCALES=gl it pl
-TLMANPAGES = $(wildcard aptitude.??.8)
+TLMANPAGES = $(wildcard aptitude.??.8) $(wildcard aptitude-create-state-bundle.??.1) $(wildcard aptitude-run-state-bundle.??.1)
TLHELPTXTS = help.txt $(wildcard help-??.txt) $(wildcard help-??_??.txt)
EXTRA_DIST = config.rpath ChangeLog.SVN Doxyfile.in FAQ README.i18n README.SMART-POINTERS README.THREADS README.VSCREEN aptitude-hackers-guide.txt aclocal.m4 \
function_groups function_pkgs aptitude-defaults \
diff --git a/aptitude-create-state-bundle b/aptitude-create-state-bundle
new file mode 100755
index 00000000..44ba62c7
--- /dev/null
+++ b/aptitude-create-state-bundle
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+HELP=0
+PRINT_INPUTS=0
+
+DONE=0
+while [ $DONE = 0 ]
+do
+ case "$1" in
+ --print-inputs )
+ PRINT_INPUTS=1
+ shift
+ ;;
+ --help )
+ HELP=1
+ shift
+ ;;
+ * )
+ DONE=1
+ ;;
+ esac
+done
+
+if [ "$#" -ne 1 ] || [ $HELP = 1 ]
+then
+ echo "Usage: $0 [options ... ] <output-file>"
+ echo
+ echo "This script will collect the copious information needed to"
+ echo "reproduce an aptitude bug, storing it in the given output file."
+ echo
+ echo "Options:"
+ echo " --help Print this message, then exit."
+ echo " --print-inputs Display the list of files and directories"
+ echo " that would be included in the bundle, then exit."
+
+ exit 1
+fi
+
+
+
+OUTFILE="$1"
+
+(cd / && tar c ./$HOME/.aptitude ./var/lib/aptitude ./var/lib/apt ./var/cache/apt/*.bin ./etc/apt ./var/lib/dpkg/status) | gzip -c > "$OUTFILE"
diff --git a/aptitude-create-state-bundle.1 b/aptitude-create-state-bundle.1
new file mode 100644
index 00000000..a6dc7349
--- /dev/null
+++ b/aptitude-create-state-bundle.1
@@ -0,0 +1,55 @@
+.\" Title: \fBaptitude-create-state-bundle\fR
+.\" Author: Daniel Burrows <dburrows@debian.org>
+.\" Date: 7/8/2007
+.TH "\f8APTITUDE-CREATE-STATE-BUNDLE\fR" "1" "7/8/2007" "aptitude-create-state-bundle" "aptitude utilities"
+.SH "NAME"
+aptitude-create-state-bundle \- bundle the current aptitude state
+.SH "SYNOPSIS"
+\fBaptitude-create-state-bundle\fR [<\fIoptions\fR> ...] <output-file>
+.SH "DESCRIPTION"
+.PP
+\fBaptitude-create-state-bundle\fR produces a compressed archive storing
+the files that are required to replicate the current package archive
+state. The following files and directories are included in the bundle:
+.IP \(bu
+$HOME/.aptitude
+.IP \(bu
+/var/lib/aptitude
+.IP \(bu
+/var/lib/apt
+.IP \(bu
+/var/cache/apt/*.bin
+.IP \(bu
+/etc/apt
+.IP \(bu
+/var/lib/dpkg/status
+.PP
+The output of this program can be used as an argument to
+\fBaptitude-run-state-bundle\fR(1).
+.SH "OPTIONS"
+.PP
+\fB--help\fR
+.RS
+Print a brief usage message, then exit.
+.RE
+.PP
+\fB--print-inputs\fR
+.RS
+Display a list of the input files and directories, then exit. This
+list is guaranteed to be up-to-date.
+.RE
+.SH "FILE FORMAT"
+The bundle file is simply a \fBtar\fR(1) file compressed with
+\fBgzip\fR(1), with each of the input directory trees rooted at \(lq\fB.\fR\(rq.
+.SH "SEE ALSO"
+.PP
+\fBaptitude-run-state-bundle\fR(1), \fBaptitude\fR(8), \fBapt(8)\fR
+.SH "AUTHOR"
+.PP
+\fBDaniel Burrows\fR <\&dburrows@debian.org\&>
+.SH "COPYRIGHT"
+.PP
+Copyright 2007 Daniel Burrows.
+
+aptitude-create-state-bundle and its manpage may be copied, modified, and
+redistributed in any manner whatsoever.
diff --git a/aptitude-run-state-bundle b/aptitude-run-state-bundle
new file mode 100755
index 00000000..07b1247e
--- /dev/null
+++ b/aptitude-run-state-bundle
@@ -0,0 +1,111 @@
+#!/bin/bash
+
+NO_CLEAN=0
+STATEDIR=0
+UNPACK_ONLY=0
+HELP=0
+
+DONE=0
+while [ $DONE = 0 ]
+do
+ case "$1" in
+ --no-clean )
+ NO_CLEAN=1
+ shift
+ ;;
+ --really-clean )
+ NO_CLEAN=0
+ shift
+ ;;
+ --statedir )
+ STATEDIR=1
+ NO_CLEAN=1
+ shift
+ ;;
+ --unpack )
+ UNPACK_ONLY=1
+ shift
+ ;;
+ --help )
+ HELP=1
+ shift
+ ;;
+ * )
+ DONE=1
+ ;;
+ esac
+done
+
+if ( [ $UNPACK_ONLY = 0 ] && [ "$#" -lt 1 ] ) ||
+ ( [ $UNPACK_ONLY = 1 ] && [ "$#" -ne 1 ] ) ||
+ [ $HELP = 1 ]
+then
+ echo "Usage: $0 [options] <input-file> [<program> [arguments ...]]"
+ echo
+ echo "This command will unpack the given archive of aptitude state"
+ echo "information, then invoke the given program with the given"
+ echo "list of arguments, passing appropriate -o options to cause"
+ echo "aptitude to use the contents of that archive as its global"
+ echo "data store."
+ echo
+ echo "Options:"
+ echo " --help Display this message and exit."
+ echo " --no-clean Do not remove the temporary directory after"
+ echo " invoking aptitude."
+ echo " --really-clean Remove the state directory, even if --statedir"
+ echo " was passed as an argument."
+ echo " --statedir The <input-file> is an unpacked aptitude bundle,"
+ echo " not a bundle file; implicitly sets --no-clean."
+ echo " --unpack Just unpack the <input-file>, don't run aptitude."
+ exit 1
+fi
+
+INPUTFILE="$1"
+shift
+
+if [ "$#" -lt 1 ]
+then
+ PROGRAM=aptitude
+else
+ PROGRAM="$2"
+ shift
+fi
+
+if [ $STATEDIR = 0 ]
+then
+ tempdir=$(mktemp -p ${TMPDIR:-/tmp} -d aptitudebug.XXXXXXXXX) || exit 1
+ if [ -z "$tempdir" ]
+ then
+ exit 1
+ fi
+else
+ tempdir=$INPUTFILE
+fi
+
+trap '
+if [ $NO_CLEAN = 1 ]
+then echo "Leaving final state in $tempdir"
+else echo "Removing $tempdir"; rm -fr $tempdir
+fi' 0
+
+if [ $STATEDIR = 0 ]
+then
+ if [ -d "$INPUTFILE" ]
+ then
+ echo "Can't use $INPUTFILE as the input bundle: it's a directory."
+ exit 1
+ fi
+ if ! [ -f "$INPUTFILE" ]
+ then
+ echo "Can't use $INPUTFILE as the input bundle: file not found."
+ exit 1
+ fi
+ (gunzip -c < "$INPUTFILE") | (cd "$tempdir" && tar x) || exit 1
+fi
+
+if [ $UNPACK_ONLY = 1 ]
+then
+ exit 0
+fi
+
+"$PROGRAM" -o "Dir=$tempdir" -o "Dir::State::status=$tempdir/var/lib/dpkg/status" "$@"
diff --git a/aptitude-run-state-bundle.1 b/aptitude-run-state-bundle.1
new file mode 100644
index 00000000..d31c684b
--- /dev/null
+++ b/aptitude-run-state-bundle.1
@@ -0,0 +1,70 @@
+.\" Title: \fBaptitude-run-state-bundle\fR
+.\" Author: Daniel Burrows <dburrows@debian.org>
+.\" Date: 7/8/2007
+.TH "\f8APTITUDE-RUN-STATE-BUNDLE\fR" "1" "7/8/2007" "aptitude-run-state-bundle" "aptitude utilities"
+.SH "NAME"
+aptitude-run-state-bundle \- unpack an aptitude state bundle and
+invoke aptitude on it
+.SH "SYNOPSIS"
+\fBaptitude-run-state-bundle\fR [<\fIoptions\fR> ...] <input-file>
+[<program> [<\fIprogram-arguments\fR> ...]]
+.SH "DESCRIPTION"
+.PP
+\fBaptitude-run-state-bundle\fR unpacks the given aptitude state
+bundle created by \fBaptitude-create-state-bundle\fR(1) to a temporary
+directory, invokes \(lq\fBprogram\fR\(rq on it with the supplied
+arguments, and removes the temporary directory afterwards. If
+\(lq\fBprogram\fR\(rq is not supplied, it defaults to
+\fBaptitude\fR(8).
+.SH "OPTIONS"
+.PP
+The following options may occur on the command-line before the input
+file. Options following the input file are presumed to be arguments
+to aptitude.
+.PP
+\fB--help\fR
+.RS
+Display a brief usage summary.
+.RE
+\fB--no-clean\fR
+.RE
+.RS
+Do not remove the unpacked state directory after running
+\fBaptitude\fR. You might want to use this if, for instance, you are
+debugging a problem that appears when aptitude's state file is
+modified. When \fBaptitude\fR finishes running, the name of the state
+directory will be printed so that you can access it in the future.
+.PP
+This option is enabled automatically by \fB--statedir\fR.
+.RE
+.PP
+\fB--really-clean\fR
+.RS
+Delete the state directory after running \fBaptitude\fR, even if
+\fB--no-clean\fR or \fB--statedir\fR was supplied.
+.RE
+.PP
+\fB--statedir\fR
+.RS
+Instead of treating the input file as a state bundle, treat it as an
+unpacked state bundle. For instance, you can use this to access the
+state directory that was created by a prior run with \fB--no-clean\fR.
+.RE
+.PP
+\fB--unpack\fR
+.RS
+Unpack the input file to a temporary directory, but don't actually run
+\fBaptitude\fR.
+.RE
+.SH "SEE ALSO"
+.PP
+\fBaptitude-create-state-bundle\fR(1), \fBaptitude\fR(8), \fBapt(8)\fR
+.SH "AUTHOR"
+.PP
+\fBDaniel Burrows\fR <\&dburrows@debian.org\&>
+.SH "COPYRIGHT"
+.PP
+Copyright 2007 Daniel Burrows.
+
+aptitude-run-state-bundle and its manpage may be copied, modified, and
+redistributed in any manner whatsoever.