File patch-wrapper-rpm.diff of Package quilt
99
1
From: Andreas Gruenbacher <andreas.gruenbacher@gmail.com>
2
Date: Thu, 1 Dec 2016 11:15:48 +0100
3
Subject: patch-wrapper: Make the patch names that quilt shows more convenient
4
Git-commit: 1cde19389bc5805da713361ac32869388e42f592
5
Patch-mainline: yes
6
7
When operating on an rpm package, create links to the rpm sources and
8
build directories and make patch names relative to these links. This is
9
more convenient than using ugly absolute paths.
10
11
--- a/bin/patch-wrapper.in
12
+++ b/bin/patch-wrapper.in
13
14
15
backup_files()
16
{
17
- declare dir=${QUILT_PC:-.pc}/$patch
18
+ declare dir=${QUILT_PC:-.pc}/$name
19
20
if [ "$backup_mode" = --backup-if-mismatch ]
21
then
22
23
fi
24
25
quilt_patches=${QUILT_PATCHES:-patches}
26
-dir=$(dirname "$quilt_patches/$patch")
27
-mkdir -p "$dir"
28
-if [ -e "$patch" ]
29
+
30
+if [ "${patch#$RPM_SOURCE_DIR}" != "$patch" ]
31
+then
32
+ name=SOURCES/${patch#$RPM_SOURCE_DIR/}
33
+ if [ ! -e "$quilt_patches/SOURCES" ]
34
+ then
35
+ mkdir -p "$quilt_patches"
36
+ ln -s $RPM_SOURCE_DIR "$quilt_patches/SOURCES"
37
+ fi
38
+elif [ "${patch#$RPM_BUILD_DIR}" != "$patch" ]
39
then
40
+ name=BUILD/${patch#$RPM_BUILD_DIR/}
41
+ if [ ! -e "$quilt_patches/BUILD" ]
42
+ then
43
+ mkdir -p "$quilt_patches"
44
+ ln -s $RPM_BUILD_DIR "$quilt_patches/BUILD"
45
+ fi
46
+else
47
+ name=${patch#/}
48
+ dir=$(dirname "$quilt_patches/$name")
49
+ mkdir -p "$dir"
50
+
51
if [ "${patch:0:1}" = / ]
52
then
53
- ln -s "$patch" "$quilt_patches$patch"
54
- patch=${patch#/}
55
+ ln -s "$patch" "$quilt_patches/${name#/}"
56
else
57
- while ! [ "$dir/$updir$patch" -ef "$patch" ]
58
+ while ! [ "$dir/$updir$name" -ef "$patch" ]
59
do
60
updir=$updir../
61
[ ${#updir} -gt 96 ] && break
62
done
63
- if [ "$dir/$updir$patch" -ef "$patch" ]
64
+ if [ "$dir/$updir$name" -ef "$patch" ]
65
then
66
- ln -s "$updir$patch" "$quilt_patches/$patch"
67
+ ln -s "$updir$patch" "$quilt_patches/$name"
68
fi
69
fi
70
fi
71
72
if [ "$opt_strip" = -p1 ]; then
73
- echo "$patch"
74
+ echo "$name"
75
else
76
- echo "$patch $opt_strip"
77
+ echo "$name $opt_strip"
78
fi >> $quilt_patches/series
79
80
-$PATCH "${new_options[@]}" --backup --prefix "${QUILT_PC:-.pc}/$patch/" \
81
+$PATCH "${new_options[@]}" --backup --prefix "${QUILT_PC:-.pc}/$name/" \
82
| backup_files
83
status=${PIPESTATUS[0]}
84
if [ $status -eq 0 ]
85
then
86
- dir=${QUILT_PC:-.pc}/$patch
87
+ dir=${QUILT_PC:-.pc}/$name
88
if [ ! -e "$dir" ]
89
then
90
mkdir -p "$dir"
91
92
then
93
echo 2 > ${QUILT_PC:-.pc}/.version
94
fi
95
- echo "$patch" >> "${QUILT_PC:-.pc}/applied-patches"
96
+ echo "$name" >> "${QUILT_PC:-.pc}/applied-patches"
97
fi
98
exit $status
99