/[autoepatch]/trunk/autoepatch.sh
Gentoo

Contents of /trunk/autoepatch.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 40 - (hide 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 flameeyes 5 #!/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 flameeyes 40 einfo "Applying ${patchset##*/} ..."
50 flameeyes 10
51 flameeyes 5 while read target; do
52 flameeyes 40 ebegin " on ${target##$(pwd)/} ..."
53 flameeyes 8
54 flameeyes 5 for patch in "${patchset}"/*.patch; do
55 flameeyes 7 if try_patch "${target}" "${patch}"; then
56     PATCH_APPLIED="yes"
57     break
58     fi
59 flameeyes 5 done
60 flameeyes 15
61     if type patch_trigger_action &>/dev/null; then
62 flameeyes 40 if patch_trigger_action "${target}"; then
63     PATCH_APPLIED="yes"
64     fi
65 flameeyes 15 fi
66 flameeyes 7
67     # Check if the patchset requires us to fail if the
68 flameeyes 13 # patch is not applied. By default, don't.
69     if ! type patch_required &>/dev/null; then
70     patch_required() { return 1; }
71     fi
72 flameeyes 7
73     if ! type patch_failed_msg &>/dev/null; then
74 flameeyes 13 patch_failed_msg() {
75 flameeyes 7 eerror "Failed patch ${patchset##*/}"
76     }
77     fi
78    
79 flameeyes 40 if [[ -n ${PATCH_APPLIED} ]]; then
80     eend 0
81     else
82     eend 1
83 flameeyes 13 if patch_required; then
84     patch_failed_msg && exit 2
85     else
86     ewarn " failed, but patch not required, ignoring."
87     fi
88 flameeyes 7 fi
89 flameeyes 5 done <<<"${targets}"
90    
91 flameeyes 20 rm -f "${T}"/autoepatch.$$.*
92 flameeyes 5 exit 0
93 flameeyes 9 )
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 flameeyes 5 done
101     }
102    
103     main

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20