diff options
author | 2006-12-18 09:45:47 +0000 | |
---|---|---|
committer | 2006-12-18 09:45:47 +0000 | |
commit | b815207e7ff9c3a380c897698891f38a57125351 (patch) | |
tree | a41468fa68d498d883cd2f5d7c9f93f288c148cf /autoepatch.sh | |
parent | Add a patch for KDE's admindir to show that autoepatch can be used for more t... (diff) | |
download | autoepatch-b815207e7ff9c3a380c897698891f38a57125351.tar.gz autoepatch-b815207e7ff9c3a380c897698891f38a57125351.tar.bz2 autoepatch-b815207e7ff9c3a380c897698891f38a57125351.zip |
Add first implementation of autoepatch; patches define a function to find which targets are to be patched, and autoepatch tries all the patches on them. There's a long list of TODOs to handle though.
svn path=/trunk/; revision=5
Diffstat (limited to 'autoepatch.sh')
-rwxr-xr-x | autoepatch.sh | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/autoepatch.sh b/autoepatch.sh new file mode 100755 index 0000000..3b43d87 --- /dev/null +++ b/autoepatch.sh @@ -0,0 +1,63 @@ +#!/bin/bash +# autoepatch - Automatic patch scripting +# Copyright (C) 2006 Gentoo Foundation +# +# This program 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 2 of the License, or +# (at your option) any later version. +# +# This program 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 autoepatch; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +main() { + # To allow installing on any prefix, make sure that + # the prefix is actually set + local PREFIX="@PREFIX@" + [[ ${PREFIX//@/|} == "|PREFIX|" ]] && PREFIX="/usr" + + # When running out of SVN, load local modules and + # libraries only. + local basedir="$(dirname $0)" + [[ $0 == "${PREFIX}/bin/autoepatch.sh" ]] && \ + basedir="${PREFIX}/share/autoepatch" + + # Source baselayout functions.sh for einfo/ewarn and similar + # functions. If on an offset prefix, use the prefixed path. + [[ ${PREFIX} == "/usr" ]] && \ + source "/sbin/functions.sh" || \ + source "${PREFIX}/sbin/functions.sh" + + source "${basedir}/lib/functions.sh" + + [[ -z ${CHOST} ]] && CHOST="$(portageq envvar CHOST)" + [[ -z ${WORKDIR} ]] && WORKDIR="$(pwd)" + [[ -z ${T} ]] && T="/tmp" + + for patchset in "${basedir}"/patches/*; do + ( + source "${patchset}/${patchset##*/}.sh" + targets="$(patch_targets)" + [[ -z ${targets} ]] && exit 0 + + while read target; do + for patch in "${patchset}"/*.patch; do + echo $patch + try_patch "${target}" "${patch}" && break; + done + done <<<"${targets}" + + exit 0 + ) || eerror "Error in subshell" + done + + IFS="${save_IFS}" +} + +main |