/[autoepatch]/trunk/autoepatch.sh
Gentoo

Contents of /trunk/autoepatch.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 20 - (show annotations) (download) (as text)
Mon Dec 18 21:45:46 2006 UTC (7 years, 9 months ago) by flameeyes
File MIME type: text/x-sh
File size: 2893 byte(s)
Remove temporary files if the patch gets applied fine.
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 "Testing ${patchset##*/} ..."
50
51 while read target; do
52 einfo " 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 patch_trigger_action "${target}"
63 fi
64
65 # Check if the patchset requires us to fail if the
66 # patch is not applied. By default, don't.
67 if ! type patch_required &>/dev/null; then
68 patch_required() { return 1; }
69 fi
70
71 if ! type patch_failed_msg &>/dev/null; then
72 patch_failed_msg() {
73 eerror "Failed patch ${patchset##*/}"
74 }
75 fi
76
77 if [[ -z ${PATCH_APPLIED} ]]; then
78 if patch_required; then
79 patch_failed_msg && exit 2
80 else
81 ewarn " failed, but patch not required, ignoring."
82 fi
83 fi
84 done <<<"${targets}"
85
86 rm -f "${T}"/autoepatch.$$.*
87 exit 0
88 )
89
90 case $? in
91 0) ;; # All gone well
92 1) eerror "Error in subshell"; return 1 ;; # Something didn't go well
93 2) return 1;; # The patch failed to apply, already announced.
94 esac
95 done
96
97 IFS="${save_IFS}"
98 }
99
100 main

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20