~ubuntu-branches/ubuntu/saucy/devscripts/saucy

« back to all changes in this revision

Viewing changes to scripts/dscextract.sh

  • Committer: Steve Langasek
  • Date: 2012-01-24 18:54:51 UTC
  • mfrom: (10.9.8 sid)
  • Revision ID: steve.langasek@canonical.com-20120124185451-etgj6b2oici5e0k0
Merge version 2.11.3 from Debian

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
        exit 2
25
25
}
26
26
 
 
27
setzip () {
 
28
        case $1 in
 
29
                *.gz) ZIP=--gzip ;;
 
30
                *.xz) ZIP=--xz ;;
 
31
                *.lzma) ZIP=--lzma ;;
 
32
                *.bz2) ZIP=--bzip2 ;;
 
33
        esac
 
34
}
 
35
 
27
36
FAST=""
28
37
while getopts "f" opt ; do
29
38
        case $opt in
43
52
WORKDIR=$(mktemp -d --tmpdir dscextract.XXXXXX)
44
53
trap "rm -rf $WORKDIR" 0 2 3 15
45
54
 
46
 
if DIFFGZ=$(egrep '^ [0-9a-f]{32,64} [0-9]+ [^ ]+\.diff\.(gz|bz2)$' "$DSC") ; then
 
55
if DIFFGZ=$(egrep '^ [0-9a-f]{32,64} [0-9]+ [^ ]+\.diff\.(gz|xz|lzma|bz2)$' "$DSC") ; then
47
56
        DIFFGZ=$(echo "$DIFFGZ" | cut -d ' ' -f 4 | head -n 1)
48
57
        test -e "$DSCDIR/$DIFFGZ" || die "$DSCDIR/$DIFFGZ: not found"
49
58
        filterdiff -p1 -i "$FILE" -z "$DSCDIR/$DIFFGZ" > "$WORKDIR/patch"
51
60
                # case 1: file found in .diff.gz
52
61
                if ! grep -q '^@@ -0,0 ' "$WORKDIR/patch" ; then
53
62
                        # case 1a: patch requires original file
54
 
                        ORIGTGZ=$(egrep '^ [0-9a-f]{32,64} [0-9]+ [^ ]+\.orig\.tar\.(gz|bz2)$' "$DSC") || die "no orig.tar.gz found in $DSC"
 
63
                        ORIGTGZ=$(egrep '^ [0-9a-f]{32,64} [0-9]+ [^ ]+\.orig\.tar\.(gz|xz|lzma|bz2)$' "$DSC") || die "no orig.tar.* found in $DSC"
55
64
                        ORIGTGZ=$(echo "$ORIGTGZ" | cut -d ' ' -f 4 | head -n 1)
56
 
                        case $ORIGTGZ in
57
 
                                *.gz) ZIP=--gzip ;;
58
 
                                *.bz2) ZIP=--bzip2 ;;
59
 
                        esac
 
65
                        setzip $ORIGTGZ
60
66
                        test -e "$DSCDIR/$ORIGTGZ" || die "$DSCDIR/$ORIGTGZ not found"
61
 
                        tar --extract --to-stdout --gzip --file "$DSCDIR/$ORIGTGZ" --wildcards "*/$FILE" > "$WORKDIR/output" 2>/dev/null || :
 
67
                        tar --extract --to-stdout $ZIP --file "$DSCDIR/$ORIGTGZ" --wildcards "*/$FILE" > "$WORKDIR/output" 2>/dev/null || :
62
68
                        test -s "$WORKDIR/output" || die "$FILE not found in $DSCDIR/$ORIGTGZ, but required by patch"
63
69
                fi
64
70
                patch --silent "$WORKDIR/output" < "$WORKDIR/patch"
71
77
        fi
72
78
fi
73
79
 
74
 
if DEBIANTARGZ=$(egrep '^ [0-9a-f]{32,64} [0-9]+ [^ ]+\.debian\.tar\.(gz|bz2)$' "$DSC") ; then
 
80
if DEBIANTARGZ=$(egrep '^ [0-9a-f]{32,64} [0-9]+ [^ ]+\.debian\.tar\.(gz|xz|lzma|bz2)$' "$DSC") ; then
75
81
        case $FILE in
76
82
                debian/*)
77
83
                        DEBIANTARGZ=$(echo "$DEBIANTARGZ" | cut -d ' ' -f 4 | head -n 1)
78
84
                        test -e "$DSCDIR/$DEBIANTARGZ" || die "$DSCDIR/$DEBIANTARGZ not found"
79
 
                        case $DEBIANTARGZ in
80
 
                                *.gz) ZIP=--gzip ;;
81
 
                                *.bz2) ZIP=--bzip2 ;;
82
 
                        esac
 
85
                        setzip $DEBIANTARGZ
83
86
                        tar --extract --to-stdout $ZIP --file "$DSCDIR/$DEBIANTARGZ" "$FILE" > "$WORKDIR/output" 2>/dev/null || :
84
87
                        test -s "$WORKDIR/output" || exit 1
85
88
                        # case 2a: file found in .debian.tar.gz
88
91
                        # for 3.0 format, no need to look in other places here
89
92
                        ;;
90
93
                *)
91
 
                        ORIGTGZ=$(egrep '^ [0-9a-f]{32,64} [0-9]+ [^ ]+\.orig\.tar\.(gz|bz2)$' "$DSC") || die "no orig.tar.gz found in $DSC"
 
94
                        ORIGTGZ=$(egrep '^ [0-9a-f]{32,64} [0-9]+ [^ ]+\.orig\.tar\.(gz|xz|lzma|bz2)$' "$DSC") || die "no orig.tar.gz found in $DSC"
92
95
                        ORIGTGZ=$(echo "$ORIGTGZ" | cut -d ' ' -f 4 | head -n 1)
93
96
                        test -e "$DSCDIR/$ORIGTGZ" || die "$DSCDIR/$ORIGTGZ not found"
94
 
                        case $ORIGTGZ in
95
 
                                *.gz) ZIP=--gzip ;;
96
 
                                *.bz2) ZIP=--bzip2 ;;
97
 
                        esac
 
97
                        setzip $ORIGTGZ
98
98
                        tar --extract --to-stdout $ZIP --file "$DSCDIR/$ORIGTGZ" --wildcards --no-wildcards-match-slash "*/$FILE" > "$WORKDIR/output" 2>/dev/null || :
99
99
                        test -s "$WORKDIR/output" || exit 1
100
100
                        # case 2b: file found in .orig.tar.gz
105
105
        esac
106
106
fi
107
107
 
108
 
if TARGZ=$(egrep '^ [0-9a-f]{32,64} [0-9]+ [^ ]+\.tar\.(gz|bz2)$' "$DSC") ; then
 
108
if TARGZ=$(egrep '^ [0-9a-f]{32,64} [0-9]+ [^ ]+\.tar\.(gz|xz|lzma|bz2)$' "$DSC") ; then
109
109
        TARGZ=$(echo "$TARGZ" | cut -d ' ' -f 4 | head -n 1)
110
110
        test -e "$DSCDIR/$TARGZ" || die "$DSCDIR/$TARGZ not found"
111
 
        case $TARGZ in
112
 
                *.gz) ZIP=--gzip ;;
113
 
                *.bz2) ZIP=--bzip2 ;;
114
 
        esac
 
111
        setzip $TARGZ
115
112
        tar --extract --to-stdout $ZIP --file "$DSCDIR/$TARGZ" --wildcards --no-wildcards-match-slash "*/$FILE" > "$WORKDIR/output" 2>/dev/null || :
116
113
        test -s "$WORKDIR/output" || exit 1
117
114
        # case 3: file found in .tar.gz or .orig.tar.gz