Debian Codegraph @

mesa-quilt

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