-
Notifications
You must be signed in to change notification settings - Fork 39
/
mesa-quilt
executable file
·108 lines (80 loc) · 3.55 KB
/
mesa-quilt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/bash
# Copyright (C) 2017 by Mike Gabriel <[email protected]>
#
# This is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
d=. ; while [ ! -d "$d/nx-X11/extras" ] && [ "$(readlink -e "$d")" != "/" ]; do d="$d/.."; done
# only continue, if in nx-libs tree
if [ -d "$d/nx-X11/extras" ]; then
if which quilt 1>/dev/null; then
echo "$(basename $0): quilt utility found, so we use it..."
echo
export QUILT_PATCHES="../Mesa.patches"
export QUILT_PATCH_OPTS="--reject-format=unified"
export QUILT_DIFF_ARGS="-p ab --no-timestamps --no-index --color=auto"
export QUILT_REFRESH_ARGS="-p ab --no-timestamps --no-index"
export QUILT_COLORS="diff_hdr=1;32:diff_add=1;34:diff_rem=1;31:diff_hunk=1;33:diff_ctx=35:diff_cctx=33"
mkdir -p "$d/nx-X11/extras/Mesa.patches"
cd "$d/nx-X11/extras/Mesa/"
# "--quiltrc -" disables reading global or user-local configuration files.
# These can override the environment settings if the quiltrc is not
# carefully crafted.
# For instance, it should set variables only if they aren't already
# provided through the environment, but since the quiltrc file is
# actually sourced as a shell script, there's no way to assume that
# a user's quiltrc is "sane".
quilt --quiltrc - "$@"
cd - 1> /dev/null
else
echo "$(basename $0): no quilt utility found, falling back to stupidly (un)applying our patches..."
echo
CMDLINE_ARGS="$@"
# we are really stupid here, we only understand 'push -a' and 'pop -a'
# this should be sufficient for the build process...
cd "$d/nx-X11/extras/Mesa/"
# make sure all need dirs and files exist
mkdir -p ./Mesa.patches/
touch "../Mesa.patches/series"
# this file will be needed temporarily
touch "../Mesa.patches/.applied-patches"
if [ "$CMDLINE_ARGS" = "push -a" ]; then
grep -E -v "^#.*" < "../Mesa.patches/series" | while read patchfile; do
if [ -n "$patchfile" ] && [ -r "../Mesa.patches/$patchfile" ] && ! grep -q "$patchfile" < "../Mesa.patches/.applied-patches"; then
echo "Applying patch ../Mesa.patches/$patchfile"
patch -p1 < "../Mesa.patches/$patchfile"
echo "$patchfile" >> "../Mesa.patches/.applied-patches"
echo
fi
done
elif [ "$CMDLINE_ARGS" = "pop -a" ]; then
tac "../Mesa.patches/.applied-patches" | while read patchfile; do
if [ -n "$patchfile" ] && [ -r "../Mesa.patches/$patchfile" ]; then
echo "Removing patch ../Mesa.patches/$patchfile"
patch -R -p1 < "../Mesa.patches/$patchfile"
sed -e "/$patchfile/d" "../Mesa.patches/.applied-patches" > "../Mesa.patches/.applied-patches.tmp"
mv "../Mesa.patches/.applied-patches.tmp" "../Mesa.patches/.applied-patches"
echo
fi
done
else
echo "$(basename $0): Doing nothing! Cmdline options not understood: $CMDLINE_ARGS"
fi
# remove the .applied-patches file, if empty again
if [ ! -s "../Mesa.patches/.applied-patches" ]; then
rm -f "../Mesa.patches/.applied-patches"
fi
cd - 1> /dev/null
fi
fi