Patch failure handling updates, added a 'patch' concrete class, so we can apply patches to quilt-native itself.

git-svn-id: https://svn.o-hand.com/repos/poky/trunk@670 311d38ba-8fff-0310-9ca6-ca027cbcb966
This commit is contained in:
Chris Larson 2006-08-28 20:36:36 +00:00
parent 01056cdbea
commit ecb32bdee7
3 changed files with 160 additions and 99 deletions

View File

@ -13,8 +13,10 @@ def base_dep_prepend(d):
# INHIBIT_DEFAULT_DEPS doesn't apply to the patch command. Whether or not
# we need that built is the responsibility of the patch function / class, not
# the application.
patchdeps = bb.data.getVar("PATCH_DEPENDS", d, 1)
if patchdeps and not patchdeps in bb.data.getVar("PROVIDES", d, 1):
patchdeps = bb.data.getVar("PATCHTOOL", d, 1)
if patchdeps:
patchdeps = "%s-native" % patchdeps
if not patchdeps in bb.data.getVar("PROVIDES", d, 1):
deps = patchdeps
if not bb.data.getVar('INHIBIT_DEFAULT_DEPS', d):
@ -685,7 +687,7 @@ python () {
# Patch handling
inherit patch
EXPORT_FUNCTIONS do_clean do_mrproper do_fetch do_unpack do_configure do_compile do_install do_package do_patch do_populate_pkgs do_stage
EXPORT_FUNCTIONS do_clean do_mrproper do_fetch do_unpack do_configure do_compile do_install do_package do_populate_pkgs do_stage
MIRRORS[func] = "0"
MIRRORS () {

View File

@ -1,4 +1,6 @@
def patch_init():
# Copyright (C) 2006 OpenedHand LTD
def patch_init(d):
import os, sys
def md5sum(fname):
@ -107,6 +109,60 @@ def patch_init():
raise NotImplementedError()
class PatchTree(PatchSet):
def __init__(self, dir, d):
PatchSet.__init__(self, dir, d)
def Import(self, patch, force = None):
""""""
PatchSet.Import(self, patch, force)
self.patches.insert(self._current or 0, patch)
def _applypatch(self, patch, force = None, reverse = None):
shellcmd = ["patch", "<", patch['file'], "-p", patch['strippath']]
if reverse:
shellcmd.append('-R')
shellcmd.append('--dry-run')
try:
output = runcmd(["sh", "-c", " ".join(shellcmd)], self.dir)
except CmdError:
if force:
shellcmd.pop(len(shellcmd) - 1)
output = runcmd(["sh", "-c", " ".join(shellcmd)], self.dir)
else:
import sys
raise sys.exc_value
return output
def Push(self, force = None, all = None):
if all:
for i in self.patches:
if self._current is not None:
self._current = self._current + 1
else:
self._current = 0
self._applypatch(i, force)
else:
if self._current is not None:
self._current = self._current + 1
else:
self._current = 0
self._applypatch(self.patches[self._current], force)
def Pop(self, force = None, all = None):
if all:
for i in self.patches:
self._applypatch(i, force, True)
else:
self._applypatch(self.patches[self._current], force, True)
def Clean(self):
""""""
class QuiltTree(PatchSet):
def _runcmd(self, args):
runcmd(["quilt"] + args, self.dir)
@ -123,13 +179,10 @@ def patch_init():
try:
self._runcmd(["pop", "-a", "-f"])
except CmdError:
if sys.exc_value.output.strip() == "No patch removed":
pass
else:
raise PatchError("Unable to clean patches from tree:\n"+str(sys.exc_value))
except NotFoundError:
pass
runcmd(["rm", "-rf", os.path.join(self.dir, "patches"), os.path.join(self.dir, ".pc")])
# runcmd(["rm", "-rf", os.path.join(self.dir, "patches"), os.path.join(self.dir, ".pc")])
self.initialized = True
def InitFromDir(self):
@ -314,6 +367,7 @@ def patch_init():
g = globals()
g["PatchSet"] = PatchSet
g["PatchTree"] = PatchTree
g["QuiltTree"] = QuiltTree
g["Resolver"] = Resolver
g["UserResolver"] = UserResolver
@ -322,17 +376,18 @@ def patch_init():
addtask patch after do_unpack
do_patch[dirs] = "${WORKDIR}"
python base_do_patch() {
python patch_do_patch() {
import re
import bb.fetch
patch_init()
patch_init(d)
src_uri = (bb.data.getVar('SRC_URI', d, 1) or '').split()
if not src_uri:
return
patchsetmap = {
"patch": PatchTree,
"quilt": QuiltTree,
}
@ -346,6 +401,8 @@ python base_do_patch() {
s = bb.data.getVar('S', d, 1)
path = os.getenv('PATH')
os.putenv('PATH', bb.data.getVar('PATH', d, 1))
patchset = cls(s, d)
patchset.Clean()
@ -415,3 +472,5 @@ python base_do_patch() {
raise bb.build.FuncFailed(str(sys.exc_value))
resolver.Resolve()
}
EXPORT_FUNCTIONS do_patch

View File

@ -238,6 +238,12 @@ export BUILD_STRIP = "${BUILD_PREFIX}strip"
export MAKE = "make"
EXTRA_OEMAKE = "-e MAKEFLAGS="
##################################################################
# Patch handling.
##################################################################
PATCHTOOL = 'quilt'
PATCHRESOLVE = 'user'
##################################################################
# Build flags and options.
##################################################################
@ -336,12 +342,6 @@ SRC_URI = "file://${FILE}"
MKTEMPDIRCMD = "mktemp -d -q ${TMPBASE}"
MKTEMPCMD = "mktemp -q ${TMPBASE}"
# Program to be used to patch sources, use 'inherit patcher' to overwrite this:
PATCHCLEANCMD = 'if [ -n "`quilt applied`" ]; then quilt pop -a -R -f || exit 1; fi'
PATCHCMD = "pnum='%s'; name='%s'; patch='%s'; mkdir -p patches ; quilt upgrade >/dev/null 2>&1; quilt import -f -p $pnum -P $name $patch; chmod u+w patches/$name; quilt push"
PATCH_DEPENDS = "quilt-native"
# GNU patch tries to be intellgent about checking out read-only files from
# a RCS, which freaks out those special folks with active Perforce clients
# the following makes patch ignore RCS: