~ubuntu-branches/ubuntu/natty/quilt/natty

« back to all changes in this revision

Viewing changes to quilt/setup.in

  • Committer: Bazaar Package Importer
  • Author(s): Martin Quinson
  • Date: 2006-11-23 16:17:11 UTC
  • mfrom: (2.1.6 feisty)
  • Revision ID: james.westby@ubuntu.com-20061123161711-b17ess0ls8t959ca
Tags: 0.45-6
* [debian/patches/override_mail_sender_in_testsuite]
  Fix the patch to catch all occurences of 'quilt mail' since each of them
  will cause a FTBFS on misconfigured hosts (thanks to Goswin Brederlow).
  (Closes: #397285, #395482, #393985) I hope, at least.
  
* [debian/patches/doc_improvement]
  Fix some more typos in the manpages
  (Closes: #386548, #395447)

* [debian/control]
   Add procmail to suggest list to help users locating the 'formail' tool.
   (Closes: #396093)

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
# Read in library functions
10
10
if [ "$(type -t patch_file_name)" != function ]
11
11
then
12
 
        if ! [ -r @SCRIPTS@/patchfns ]
 
12
        if ! [ -r $QUILT_DIR/scripts/patchfns ]
13
13
        then
14
 
                echo "Cannot read library @SCRIPTS@/patchfns" >&2
 
14
                echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
15
15
                exit 1
16
16
        fi
17
 
        . @SCRIPTS@/patchfns
 
17
        . $QUILT_DIR/scripts/patchfns
18
18
        if [ -n "$SUBDIR" ]
19
19
        then
20
20
                cd $SUBDIR
22
22
        fi
23
23
fi
24
24
 
 
25
check_for_existing_files() {
 
26
        local dir status=0
 
27
        for dir in $(awk ' $1 == "patch" { print $2 }' $tmpfile | uniq)
 
28
        do
 
29
                if [ -e "$prefix$dir/$QUILT_PATCHES" ]
 
30
                then
 
31
                        printf $"Directory %s exists\n" \
 
32
                               "$prefix$dir/$QUILT_PATCHES" >&2
 
33
                        status=1
 
34
                fi
 
35
                if [ -e "$prefix$dir/${QUILT_SERIES:-series}" ]
 
36
                then
 
37
                        printf $"File %s exists\n" \
 
38
                               "$prefix$dir/${QUILT_SERIES:-series}" >&2
 
39
                        status=1
 
40
                fi
 
41
        done
 
42
        return $status
 
43
}
 
44
 
 
45
find_tarball() {
 
46
        if [ "${1:0:1}" = / ]
 
47
        then
 
48
                echo "$1"
 
49
                return
 
50
        fi
 
51
 
 
52
        local IFS=:
 
53
        for dir in $path
 
54
        do
 
55
                [ -z "$dir" ] && continue
 
56
                if [ -e "$dir/$1" ]
 
57
                then
 
58
                        echo "$dir/$1"
 
59
                        return
 
60
                fi
 
61
        done
 
62
        return 1
 
63
}
 
64
 
 
65
create_symlink() {
 
66
        local from=$1 to=$2 up
 
67
        if [ "${from:0:1}" = / ]
 
68
        then
 
69
                ln -s "$from" "$to"
 
70
                return
 
71
        fi
 
72
 
 
73
        set -- "$(echo "$PWD/$from" | sed -r -e 's://:/:g' \
 
74
                                             -e ':again' \
 
75
                                             -e 's:/[^/]+/\.\.(/|$):\1:g' \
 
76
                                             -e 'tagain')" \
 
77
               "$(echo "$PWD/$to" | sed -r -e 's://:/:g' \
 
78
                                           -e ':again' \
 
79
                                           -e 's:/[^/]+/\.\.(/|$):\1:g' \
 
80
                                           -e 'tagain')"
 
81
        while [ "${1%%/*}" = "${2%%/*}" ]
 
82
        do
 
83
                set -- "${1#*/}" "${2#*/}"
 
84
        done
 
85
        up=$(echo "${2%/*}" | sed -re 's:[^/]+:..:g')
 
86
        set -- "${up:+$up/}$1"
 
87
        set -- "${1%/}"
 
88
        ln -s "${1:-.}" "$to"
 
89
}
 
90
 
25
91
usage()
26
92
{
27
 
        printf $"Usage: quilt setup [-d path-prefix] [-v] {specfile|seriesfile}\n"
 
93
        printf $"Usage: quilt setup [-d path-prefix] [-v] [--path dir1:dir2] {specfile|seriesfile}\n"
28
94
        if [ x$1 = x-h ]
29
95
        then
30
96
                printf $"
31
97
Initializes a source tree from an rpm spec file or a quilt series file.
32
98
 
33
 
-d      optional path prefix (sub-directory).
34
 
 
35
 
-v      verbose debug output.
 
99
-d      Optional path prefix.
 
100
 
 
101
--path  Directories to search when looking for tarballs. Defaults to \`.'.
 
102
 
 
103
-v      Verbose debug output.
36
104
"
37
105
                exit 0
38
106
        else
40
108
        fi
41
109
}
42
110
 
43
 
options=`getopt -o d:vh -- "$@"`
 
111
options=`getopt -o d:vh --long path: -- "$@"`
44
112
 
45
113
if [ $? -ne 0 ]
46
114
then
62
130
        -v)
63
131
                verbose=-v
64
132
                shift ;;
 
133
        --path)
 
134
                path="$path:$2"
 
135
                shift 2 ;;
65
136
        --)
66
137
                shift
67
138
                break ;;
73
144
        usage
74
145
fi
75
146
 
76
 
up() {
77
 
        if [ "${1:0:1}" = / ]
78
 
        then
79
 
                echo $1
80
 
        else
81
 
                local up=
82
 
                while ! [ "$1$up" -ef . -o "$1$up" -ef / ]
83
 
                do
84
 
                        up=$up/..
85
 
                done
86
 
                echo ${up:1}
87
 
        fi
88
 
}
89
 
 
90
 
check_for_existing_files() {
91
 
        local dir status=0
92
 
        for dir in $(@AWK@ ' $1 = "patch" { print $2 }' $tmpfile | uniq)
93
 
        do
94
 
                if [ -e "$prefix$dir/$QUILT_PATCHES" ]
95
 
                then
96
 
                        printf $"Directory %s exists\n" \
97
 
                               "$prefix$dir/$QUILT_PATCHES" >&2
98
 
                        status=1
99
 
                fi
100
 
                if [ -e "$prefix$dir/series" ]
101
 
                then
102
 
                        printf $"File %s exists\n" "$prefix$dir/series" >&2
103
 
                        status=1
104
 
                fi
105
 
        done
106
 
        return $status
107
 
}
 
147
[ -z "$path" ] && path=.
108
148
 
109
149
tmpfile=$(gen_tempfile)
110
150
trap "rm -f $tmpfile" EXIT
111
151
 
112
152
case "$1" in
113
153
*.spec)
114
 
        spec_file="$1"
 
154
        spec_file=$1
115
155
 
116
 
        if ! @SCRIPTS@/inspect $verbose "$spec_file" 2>&1 > $tmpfile
 
156
        if ! $QUILT_DIR/scripts/inspect $verbose "$spec_file" 2>&1 > $tmpfile
117
157
        then
118
158
                printf $"The %%prep section of %s failed; results may be incomplete\n" "$spec_file"
119
159
                if [ -z "$verbose" ]
123
163
        fi
124
164
        ;;
125
165
*)
 
166
        series_file=$1
126
167
        # parse series file
127
168
        while read line; do
128
169
                set -- $line
141
182
                *)
142
183
                        echo "patch ${patch_dir:-.} $@" ;;
143
184
                esac
144
 
        done < "$1" > $tmpfile
 
185
        done < "$series_file" > $tmpfile
145
186
        ;;
146
187
esac
147
188
 
149
190
 
150
191
while read tag dir arg1 arg2
151
192
do
152
 
        mkdir -p "$prefix$dir"
153
193
        case "$tag" in
154
194
        tar)
155
 
                printf $"Unpacking archive %s\n" "$arg1"
156
 
                cat_file "$arg1" \
 
195
                if ! tarball=$(find_tarball "$arg1")
 
196
                then
 
197
                        printf $"File %s not found in search path\n" "$arg1" >&2
 
198
                        exit 1
 
199
                fi
 
200
                printf $"Unpacking archive %s\n" "$tarball"
 
201
                mkdir -p "${prefix:-.}" "$prefix$dir"
 
202
                cat_file "$tarball" \
157
203
                | tar xf - -C "$prefix$dir"
158
204
                ;;
159
205
        esac
160
206
done < $tmpfile
161
207
 
162
 
check_for_existing_files || exit 1
163
 
 
164
208
while read tag dir arg1 arg2
165
209
do
166
210
        case "$tag" in
171
215
                ;;
172
216
        patch)
173
217
                [ -e "$prefix$dir/$QUILT_PATCHES" ] \
174
 
                || ln -s "$(up $prefix$dir)" $prefix$dir/$QUILT_PATCHES
175
 
 
176
 
                if ! [ -e "$prefix$dir/series" ]
 
218
                || create_symlink "" "$prefix$dir/$QUILT_PATCHES"
 
219
                if [ -n "$series_file" ]
177
220
                then
178
 
                        # (There is no reliable way to associate archives with
179
 
                        #  patches; we assume that all pathes applied after
180
 
                        #  archive extraction belong to that archive.)
181
 
                        (       echo "# Patch series file for quilt," \
182
 
                                     "created by ${0##*/}"
183
 
                                [ -n "$tar_dir" ] \
184
 
                                        && echo "# Sourcedir: $tar_dir"
185
 
                                [ -n "$tar_file" ] \
186
 
                                        && echo "# Source: $tar_file"
187
 
                                echo "# Patchdir: $dir"
188
 
                                echo "#"
189
 
                        ) > "$prefix$dir/series"
 
221
                        [ -e "$prefix$dir/${QUILT_SERIES:-series}" ] \
 
222
                        || create_symlink "$series_file" \
 
223
                                          "$prefix$dir/${QUILT_SERIES:-series}"
 
224
                else
 
225
                        if ! [ -e "$prefix$dir/${QUILT_SERIES:-series}" ]
 
226
                        then
 
227
                                (       echo "# Patch series file for quilt," \
 
228
                                             "created by ${0##*/}"
 
229
                                        [ -n "$tar_dir" ] \
 
230
                                                && echo "# Sourcedir: $tar_dir"
 
231
                                        [ -n "$tar_file" ] \
 
232
                                                && echo "# Source: $tar_file"
 
233
                                        echo "# Patchdir: $dir"
 
234
                                        echo "#"
 
235
                                ) > "$prefix$dir/${QUILT_SERIES:-series}"
 
236
                        fi
 
237
                        echo "$arg1" $arg2 >> "$prefix$dir/series"
190
238
                fi
191
 
                echo "$arg1" $arg2 >> "$prefix$dir/series"
192
239
                ;;
193
240
        esac
194
241
done < $tmpfile