/[autoepatch]/trunk/autoepatch.sh
Gentoo

Contents of /trunk/autoepatch.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 40 - (show annotations) (download) (as text)
Sun Jan 7 20:20:55 2007 UTC (7 years, 8 months ago) by flameeyes
File MIME type: text/x-sh
File size: 2946 byte(s)
Replace 'Testing' with 'Applying', use ebegin/eend to give the status of patching, and make sure that if the trigger action works the patch is considered applied.
1 #!/bin/bash
2 # autoepatch - Automatic patch scripting
3 # Copyright (C) 2006 Gentoo Foundation
4 #
5 # This program 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 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program 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 autoepatch; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19 main() {
20 # To allow installing on any prefix, make sure that
21 # the prefix is actually set
22 local PREFIX="@PREFIX@"
23 [[ ${PREFIX//@/|} == "|PREFIX|" ]] && PREFIX="/usr"
24
25 # When running out of SVN, load local modules and
26 # libraries only.
27 local basedir="$(dirname $0)"
28 [[ $0 == "${PREFIX}/bin/autoepatch.sh" ]] && \
29 basedir="${PREFIX}/share/autoepatch"
30
31 # Source baselayout functions.sh for einfo/ewarn and similar
32 # functions. If on an offset prefix, use the prefixed path.
33 [[ ${PREFIX} == "/usr" ]] && \
34 source "/sbin/functions.sh" || \
35 source "${PREFIX}/sbin/functions.sh"
36
37 source "${basedir}/lib/functions.sh"
38
39 [[ -z ${CHOST} ]] && CHOST="$(portageq envvar CHOST)"
40 [[ -z ${WORKDIR} ]] && WORKDIR="$(pwd)"
41 [[ -z ${T} ]] && T="/tmp"
42
43 for patchset in "${basedir}"/patches/*; do
44 (
45 source "${patchset}/${patchset##*/}.sh"
46 targets="$(patch_targets)"
47 [[ -z ${targets} ]] && exit 0
48
49 einfo "Applying ${patchset##*/} ..."
50
51 while read target; do
52 ebegin " on ${target##$(pwd)/} ..."
53
54 for patch in "${patchset}"/*.patch; do
55 if try_patch "${target}" "${patch}"; then
56 PATCH_APPLIED="yes"
57 break
58 fi
59 done
60
61 if type patch_trigger_action &>/dev/null; then
62 if patch_trigger_action "${target}"; then
63 PATCH_APPLIED="yes"
64 fi
65 fi
66
67 # Check if the patchset requires us to fail if the
68 # patch is not applied. By default, don't.
69 if ! type patch_required &>/dev/null; then
70 patch_required() { return 1; }
71 fi
72
73 if ! type patch_failed_msg &>/dev/null; then
74 patch_failed_msg() {
75 eerror "Failed patch ${patchset##*/}"
76 }
77 fi
78
79 if [[ -n ${PATCH_APPLIED} ]]; then
80 eend 0
81 else
82 eend 1
83 if patch_required; then
84 patch_failed_msg && exit 2
85 else
86 ewarn " failed, but patch not required, ignoring."
87 fi
88 fi
89 done <<<"${targets}"
90
91 rm -f "${T}"/autoepatch.$$.*
92 exit 0
93 )
94
95 case $? in
96 0) ;; # All gone well
97 1) eerror "Error in subshell"; return 1 ;; # Something didn't go well
98 2) return 1;; # The patch failed to apply, already announced.
99 esac
100 done
101 }
102
103 main

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20