root/aptitude-create-state-bundle

Revision 742:af9017db699d, 1.9 kB (checked in by Daniel Burrows <dburrows@…>, 3 years ago)

Add support for forcing the use of bzip2/gzip, overriding the autodetection.

  • Property exe set to *
Line 
1#!/bin/bash
2
3HELP=0
4PRINT_INPUTS=0
5FORCE_GZIP=0
6FORCE_BZIP2=0
7
8DONE=0
9while [ $DONE = 0 ]
10do
11  case "$1" in
12      --force-gzip )
13          FORCE_GZIP=1
14          FORCE_BZIP2=0
15          shift
16          ;;
17      --force-bzip2 )
18          FORCE_GZIP=0
19          FORCE_BZIP2=1
20          shift
21          ;;
22      --help )
23          HELP=1
24          shift
25          ;;
26      --print-inputs )
27          PRINT_INPUTS=1
28          shift
29          ;;
30      * )
31          DONE=1
32          ;;
33  esac
34done
35
36if ([ $PRINT_INPUTS = 0 ] && [ "$#" -ne 1 ]) ||
37   ([ $PRINT_INPUTS = 1 ] && [ "$#" -ne 0 ]) ||
38   [ $HELP = 1 ]
39then
40    echo "Usage: $0 [options ... ] <output-file>"
41    echo
42    echo "This script will collect the copious information needed to"
43    echo "reproduce an aptitude bug, storing it in the given output file."
44    echo
45    echo "Options:"
46    echo "  --force-bzip2     Override autodetection of the comrpession"
47    echo "                    format: use bzip2 even if it appears to be"
48    echo "                    unavailable."
49    echo "  --force-gzip      Override autodetection of the compression"
50    echo "                    format: use gzip even if bzip2 is available."
51    echo "  --help            Print this message, then exit."
52    echo "  --print-inputs    Display the list of files and directories"
53    echo "                    that would be included in the bundle, then exit."
54
55    exit 1
56fi
57
58INPUTS[1]="$HOME/.aptitude"
59INPUTS[2]="/var/lib/aptitude"
60INPUTS[3]="/var/lib/apt"
61INPUTS[4]="/var/cache/apt/*.bin"
62INPUTS[5]="/etc/apt"
63INPUTS[6]="/var/lib/dpkg/status"
64
65if [ $PRINT_INPUTS = 1 ]
66then
67    for x in ${INPUTS[@]}; do echo $x; done
68    exit 0
69fi
70
71# Stick "." on the front of all inputs.
72declare -a REALINPUTS
73i=1
74while [ $i -le ${#INPUTS[*]} ]
75do
76  REALINPUTS[$i]=./${INPUTS[$i]}
77  i=$((i + 1))
78done
79
80OUTFILE="$1"
81
82if [ $FORCE_BZIP2 = 1 ] || ([ $FORCE_GZIP = 0 ] && which bzip2 2> /dev/null > /dev/null)
83then
84    COMPRESSOR=bzip2
85else
86    COMPRESSOR=gzip
87fi
88
89(cd / && tar c ${REALINPUTS[@]}) | $COMPRESSOR -c > "$OUTFILE"
Note: See TracBrowser for help on using the browser.