[oe-commits] org.oe.packaged-staging Sync minor classes with .dev

rpurdie commit openembedded-commits at lists.openembedded.org
Fri Sep 29 03:33:26 UTC 2006


Sync minor classes with .dev

Author: rpurdie at openembedded.org
Branch: org.openembedded.packaged-staging
Revision: be4e1778f3e623c49f0b78f920e91ef648163aaf
ViewMTN: http://monotone.openembedded.org/revision.psp?id=be4e1778f3e623c49f0b78f920e91ef648163aaf
Files:
1
classes/patch.bbclass
classes/binconfig.bbclass
classes/cpan.bbclass
classes/debian.bbclass
classes/efl.bbclass
classes/gconf.bbclass
classes/gpe.bbclass
classes/icecc.bbclass
classes/image_ipk.bbclass
classes/insane.bbclass
classes/kernel-arch.bbclass
classes/kernel.bbclass
classes/module.bbclass
classes/opie.bbclass
classes/pkgconfig.bbclass
classes/rm_work.bbclass
classes/rootfs_ipk.bbclass
classes/sanity.bbclass
classes/sdl.bbclass
classes/tinderclient.bbclass
Diffs:

#
# mt diff -rf37061ded2b155e86d4e6a0e096b32418f9e3d41 -rbe4e1778f3e623c49f0b78f920e91ef648163aaf
#
# 
# 
# add_file "classes/patch.bbclass"
#  content [01233de74e5b7f50137574599e0cca158721e888]
# 
# patch "classes/binconfig.bbclass"
#  from [1a5eb9029fda4b2e3126727ac113eb6995ed5ead]
#    to [7fef4241e7aff369e878642422b6a42fdb44bc24]
# 
# patch "classes/cpan.bbclass"
#  from [b5d438fb22e00da06d5c1f08a758fc8d65fb27f5]
#    to [bcdb802e7fdeb8159868542162d2cc47440c1096]
# 
# patch "classes/debian.bbclass"
#  from [aac36f92ec4452b7ae1658b537608485c9c014e5]
#    to [132b41c84a471064940737943c193f24c73023d2]
# 
# patch "classes/efl.bbclass"
#  from [bd14a45b959946969ebbd13dab505caade34c7d7]
#    to [281c001211b59253788a12c12c92f6508f80efcf]
# 
# patch "classes/gconf.bbclass"
#  from [e6547adce688f35052d249e3bde3f63ab4ce7be0]
#    to [00c717a1c6fddfd809635163d24114284f015ddd]
# 
# patch "classes/gpe.bbclass"
#  from [20767903f072549f05e0648981821c9b4bb04f26]
#    to [f6796977213dc7ee4ea57784c67c267b6f64684e]
# 
# patch "classes/icecc.bbclass"
#  from [59fa0ec330dbc47e935c54aa85df96d4f820cc3c]
#    to [992ed9f6ddbcc5cc42dc6f8c8cde0cf217c554a8]
# 
# patch "classes/image_ipk.bbclass"
#  from [5e8b8b72db00683bd7b06c9a1a96b7a2b4fcaee0]
#    to [c432b37e7b25072c17426fba3e18a1615af1a0f2]
# 
# patch "classes/insane.bbclass"
#  from [740aef8bd9a6f7f3771d9104123671fe6d0686ba]
#    to [0d4b0b4f274544e7878a0821f87ffb900e01b3d0]
# 
# patch "classes/kernel-arch.bbclass"
#  from [22d639b154177d667c5c3e634eed40da925cf6c5]
#    to [36ea38ae5d674653d04375e34797ab2f26f918a4]
# 
# patch "classes/kernel.bbclass"
#  from [1c48c1b25073cb10e2f96b0ab7ef4c21f65fcecf]
#    to [bb10bf03ee771fdce64047ec2c5f9b470dd9c5ec]
# 
# patch "classes/module.bbclass"
#  from [5cedb5039416042e0403541a367516dee5dac4a2]
#    to [cf6a1004ebfb717a7dc9fb4cce9e7932ea9336aa]
# 
# patch "classes/opie.bbclass"
#  from [56f1af0d33515f3ce406525592cdadcec86715c4]
#    to [4def196837dde43cc357862d2d74a6517ae20acd]
# 
# patch "classes/pkgconfig.bbclass"
#  from [08b65a29a5def16ff66931c705f61ad4f055e401]
#    to [b603f5b7bce58109ce0a1bdd1310c42f61bc4029]
# 
# patch "classes/rm_work.bbclass"
#  from [b2d0b002eae85281b24474893f565c1eaacca0a6]
#    to [e61b15f538051b1039bb78184a03e0ed3e4c3e08]
# 
# patch "classes/rootfs_ipk.bbclass"
#  from [ce25bdeee2284019c8a1204a98ee9bf966ba4469]
#    to [be2c3f8e8d1506f600b4860805062a6e76654e9f]
# 
# patch "classes/sanity.bbclass"
#  from [9acddb9cfc0f278ef9c3a0d4e628318ee388f6af]
#    to [a54de34e76ba8d0e47d03f7bf019698eadfd9599]
# 
# patch "classes/sdl.bbclass"
#  from [52573c8428ac8e7642809c2217f9f214a6a449d0]
#    to [3ddeb18d45e65c5c010d546459991244e42573ea]
# 
# patch "classes/tinderclient.bbclass"
#  from [2d77b58e2f5b7311c26e7eea0bc5d00890d32500]
#    to [f3adf2518801b0b6016015877447b4a6565959f2]
# 
============================================================
--- classes/patch.bbclass	01233de74e5b7f50137574599e0cca158721e888
+++ classes/patch.bbclass	01233de74e5b7f50137574599e0cca158721e888
@@ -0,0 +1,490 @@
+# Copyright (C) 2006  OpenedHand LTD
+
+def patch_init(d):
+	import os, sys
+
+	def md5sum(fname):
+		import md5, sys
+
+		f = file(fname, 'rb')
+		m = md5.new()
+		while True:
+			d = f.read(8096)
+			if not d:
+				break
+			m.update(d)
+		f.close()
+		return m.hexdigest()
+
+	class CmdError(Exception):
+		def __init__(self, exitstatus, output):
+			self.status = exitstatus
+			self.output = output
+
+		def __str__(self):
+			return "Command Error: exit status: %d  Output:\n%s" % (self.status, self.output)
+
+	class NotFoundError(Exception):
+		def __init__(self, path):
+			self.path = path
+		def __str__(self):
+			return "Error: %s not found." % self.path
+
+	def runcmd(args, dir = None):
+		import commands
+
+		if dir:
+			olddir = os.path.abspath(os.curdir)
+			if not os.path.exists(dir):
+				raise NotFoundError(dir)
+			os.chdir(dir)
+			# print("cwd: %s -> %s" % (olddir, self.dir))
+
+		try:
+			args = [ commands.mkarg(str(arg)) for arg in args ]
+			cmd = " ".join(args)
+			# print("cmd: %s" % cmd)
+			(exitstatus, output) = commands.getstatusoutput(cmd)
+			if exitstatus != 0:
+				raise CmdError(exitstatus >> 8, output)
+			return output
+
+		finally:
+			if dir:
+				os.chdir(olddir)
+
+	class PatchError(Exception):
+		def __init__(self, msg):
+			self.msg = msg
+
+		def __str__(self):
+			return "Patch Error: %s" % self.msg
+
+	import bb, bb.data, bb.fetch
+
+	class PatchSet(object):
+		defaults = {
+			"strippath": 1
+		}
+
+		def __init__(self, dir, d):
+			self.dir = dir
+			self.d = d
+			self.patches = []
+			self._current = None
+
+		def current(self):
+			return self._current
+
+		def Clean(self):
+			"""
+			Clean out the patch set.  Generally includes unapplying all
+			patches and wiping out all associated metadata.
+			"""
+			raise NotImplementedError()
+
+		def Import(self, patch, force):
+			if not patch.get("file"):
+				if not patch.get("remote"):
+					raise PatchError("Patch file must be specified in patch import.")
+				else:
+					patch["file"] = bb.fetch.localpath(patch["remote"], self.d)
+
+			for param in PatchSet.defaults:
+				if not patch.get(param):
+					patch[param] = PatchSet.defaults[param]
+
+			if patch.get("remote"):
+				patch["file"] = bb.data.expand(bb.fetch.localpath(patch["remote"], self.d), self.d)
+
+			patch["filemd5"] = md5sum(patch["file"])
+
+		def Push(self, force):
+			raise NotImplementedError()
+
+		def Pop(self, force):
+			raise NotImplementedError()
+
+		def Refresh(self, remote = None, all = None):
+			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)
+
+			if self._current is not None:
+				i = self._current + 1
+			else:
+				i = 0
+			self.patches.insert(i, patch)
+
+		def _applypatch(self, patch, force = None, reverse = None):
+			shellcmd = ["cat", patch['file'], "|", "patch", "-p", patch['strippath']]
+			if reverse:
+				shellcmd.append('-R')
+
+			if not force:
+				shellcmd.append('--dry-run')
+
+			output = runcmd(["sh", "-c", " ".join(shellcmd)], self.dir)
+
+			if force:
+				return
+
+			shellcmd.pop(len(shellcmd) - 1)
+			output = runcmd(["sh", "-c", " ".join(shellcmd)], self.dir)
+			return output
+
+		def Push(self, force = None, all = None):
+			bb.note("self._current is %s" % self._current)
+			bb.note("patches is %s" % self.patches)
+			if all:
+				for i in self.patches:
+					if self._current is not None:
+						self._current = self._current + 1
+					else:
+						self._current = 0
+					bb.note("applying patch %s" % i)
+					self._applypatch(i, force)
+			else:
+				if self._current is not None:
+					self._current = self._current + 1
+				else:
+					self._current = 0
+				bb.note("applying patch %s" % self.patches[self._current])
+				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)
+
+		def _quiltpatchpath(self, file):
+			return os.path.join(self.dir, "patches", os.path.basename(file))
+
+
+		def __init__(self, dir, d):
+			PatchSet.__init__(self, dir, d)
+			self.initialized = False
+			p = os.path.join(self.dir, 'patches')
+			if not os.path.exists(p):
+				os.makedirs(p)
+
+		def Clean(self):
+			try:
+				self._runcmd(["pop", "-a", "-f"])
+			except Exception:
+				pass
+			self.initialized = True
+
+		def InitFromDir(self):
+			# read series -> self.patches
+			seriespath = os.path.join(self.dir, 'patches', 'series')
+			if not os.path.exists(self.dir):
+				raise Exception("Error: %s does not exist." % self.dir)
+			if os.path.exists(seriespath):
+				series = file(seriespath, 'r')
+				for line in series.readlines():
+					patch = {}
+					parts = line.strip().split()
+					patch["quiltfile"] = self._quiltpatchpath(parts[0])
+					patch["quiltfilemd5"] = md5sum(patch["quiltfile"])
+					if len(parts) > 1:
+						patch["strippath"] = parts[1][2:]
+					self.patches.append(patch)
+				series.close()
+
+				# determine which patches are applied -> self._current
+				try:
+					output = runcmd(["quilt", "applied"], self.dir)
+				except CmdError:
+					if sys.exc_value.output.strip() == "No patches applied":
+						return
+					else:
+						raise sys.exc_value
+				output = [val for val in output.split('\n') if not val.startswith('#')]
+				for patch in self.patches:
+					if os.path.basename(patch["quiltfile"]) == output[-1]:
+						self._current = self.patches.index(patch)
+			self.initialized = True
+
+		def Import(self, patch, force = None):
+			if not self.initialized:
+				self.InitFromDir()
+			PatchSet.Import(self, patch, force)
+
+			args = ["import", "-p", patch["strippath"]]
+			if force:
+				args.append("-f")
+			args.append(patch["file"])
+
+			self._runcmd(args)
+
+			patch["quiltfile"] = self._quiltpatchpath(patch["file"])
+			patch["quiltfilemd5"] = md5sum(patch["quiltfile"])
+
+			# TODO: determine if the file being imported:
+			#	   1) is already imported, and is the same
+			#	   2) is already imported, but differs
+
+			self.patches.insert(self._current or 0, patch)
+
+
+		def Push(self, force = None, all = None):
+			# quilt push [-f]
+
+			args = ["push"]
+			if force:
+				args.append("-f")
+			if all:
+				args.append("-a")
+
+			self._runcmd(args)
+
+			if self._current is not None:
+				self._current = self._current + 1
+			else:
+				self._current = 0
+
+		def Pop(self, force = None, all = None):
+			# quilt pop [-f]
+			args = ["pop"]
+			if force:
+				args.append("-f")
+			if all:
+				args.append("-a")
+
+			self._runcmd(args)
+
+			if self._current == 0:
+				self._current = None
+
+			if self._current is not None:
+				self._current = self._current - 1
+
+		def Refresh(self, **kwargs):
+			if kwargs.get("remote"):
+				patch = self.patches[kwargs["patch"]]
+				if not patch:
+					raise PatchError("No patch found at index %s in patchset." % kwargs["patch"])
+				(type, host, path, user, pswd, parm) = bb.decodeurl(patch["remote"])
+				if type == "file":
+					import shutil
+					if not patch.get("file") and patch.get("remote"):
+						patch["file"] = bb.fetch.localpath(patch["remote"], self.d)
+
+					shutil.copyfile(patch["quiltfile"], patch["file"])
+				else:
+					raise PatchError("Unable to do a remote refresh of %s, unsupported remote url scheme %s." % (os.path.basename(patch["quiltfile"]), type))
+			else:
+				# quilt refresh
+				args = ["refresh"]
+				if kwargs.get("quiltfile"):
+					args.append(os.path.basename(kwargs["quiltfile"]))
+				elif kwargs.get("patch"):
+					args.append(os.path.basename(self.patches[kwargs["patch"]]["quiltfile"]))
+				self._runcmd(args)
+
+	class Resolver(object):
+		def __init__(self, patchset):
+			raise NotImplementedError()
+
+		def Resolve(self):
+			raise NotImplementedError()
+
+		def Revert(self):
+			raise NotImplementedError()
+
+		def Finalize(self):
+			raise NotImplementedError()
+
+	class NOOPResolver(Resolver):
+		def __init__(self, patchset):
+			self.patchset = patchset
+
+		def Resolve(self):
+			olddir = os.path.abspath(os.curdir)
+			os.chdir(self.patchset.dir)
+			try:
+				self.patchset.Push()
+			except Exception:
+				os.chdir(olddir)
+				raise sys.exc_value
+
+	# Patch resolver which relies on the user doing all the work involved in the
+	# resolution, with the exception of refreshing the remote copy of the patch
+	# files (the urls).
+	class UserResolver(Resolver):
+		def __init__(self, patchset):
+			self.patchset = patchset
+
+		# Force a push in the patchset, then drop to a shell for the user to
+		# resolve any rejected hunks
+		def Resolve(self):
+
+			olddir = os.path.abspath(os.curdir)
+			os.chdir(self.patchset.dir)
+			try:
+				self.patchset.Push(True)
+			except CmdError, v:
+				# Patch application failed
+				if sys.exc_value.output.strip() == "No patches applied":
+					return
+				print(sys.exc_value)
+				print('NOTE: dropping user into a shell, so that patch rejects can be fixed manually.')
+
+				os.system('/bin/sh')
+
+				# Construct a new PatchSet after the user's changes, compare the
+				# sets, checking patches for modifications, and doing a remote
+				# refresh on each.
+				oldpatchset = self.patchset
+				self.patchset = oldpatchset.__class__(self.patchset.dir, self.patchset.d)
+
+				for patch in self.patchset.patches:
+					oldpatch = None
+					for opatch in oldpatchset.patches:
+						if opatch["quiltfile"] == patch["quiltfile"]:
+							oldpatch = opatch
+
+					if oldpatch:
+						patch["remote"] = oldpatch["remote"]
+						if patch["quiltfile"] == oldpatch["quiltfile"]:
+							if patch["quiltfilemd5"] != oldpatch["quiltfilemd5"]:
+								bb.note("Patch %s has changed, updating remote url %s" % (os.path.basename(patch["quiltfile"]), patch["remote"]))
+								# user change?  remote refresh
+								self.patchset.Refresh(remote=True, patch=self.patchset.patches.index(patch))
+							else:
+								# User did not fix the problem.  Abort.
+								raise PatchError("Patch application failed, and user did not fix and refresh the patch.")
+			except Exception:
+				os.chdir(olddir)
+				raise
+			os.chdir(olddir)
+
+	g = globals()
+	g["PatchSet"] = PatchSet
+	g["PatchTree"] = PatchTree
+	g["QuiltTree"] = QuiltTree
+	g["Resolver"] = Resolver
+	g["UserResolver"] = UserResolver
+	g["NOOPResolver"] = NOOPResolver
+	g["NotFoundError"] = NotFoundError
+	g["CmdError"] = CmdError
+
+addtask patch after do_unpack
+do_patch[dirs] = "${WORKDIR}"
+python patch_do_patch() {
+	import re
+	import bb.fetch
+
+	patch_init(d)
+
+	src_uri = (bb.data.getVar('SRC_URI', d, 1) or '').split()
+	if not src_uri:
+		return
+
+	patchsetmap = {
+		"patch": PatchTree,
+		"quilt": QuiltTree,
+	}
+
+	cls = patchsetmap[bb.data.getVar('PATCHTOOL', d, 1) or 'quilt']
+
+	resolvermap = {
+		"noop": NOOPResolver,
+		"user": UserResolver,
+	}
+
+	rcls = resolvermap[bb.data.getVar('PATCHRESOLVE', d, 1) or 'user']
+
+	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()
+
+	resolver = rcls(patchset)
+
+	workdir = bb.data.getVar('WORKDIR', d, 1)
+	for url in src_uri:
+		(type, host, path, user, pswd, parm) = bb.decodeurl(url)
+		if not "patch" in parm:
+			continue
+
+		bb.fetch.init([url],d)
+		url = bb.encodeurl((type, host, path, user, pswd, []))
+		local = os.path.join('/', bb.fetch.localpath(url, d))
+
+		# did it need to be unpacked?
+		dots = os.path.basename(local).split(".")
+		if dots[-1] in ['gz', 'bz2', 'Z']:
+			unpacked = os.path.join(bb.data.getVar('WORKDIR', d),'.'.join(dots[0:-1]))
+		else:
+			unpacked = local
+		unpacked = bb.data.expand(unpacked, d)
+
+		if "pnum" in parm:
+			pnum = parm["pnum"]
+		else:
+			pnum = "1"
+
+		if "pname" in parm:
+			pname = parm["pname"]
+		else:
+			pname = os.path.basename(unpacked)
+
+		if "mindate" in parm:
+			mindate = parm["mindate"]
+		else:
+			mindate = 0
+
+		if "maxdate" in parm:
+			maxdate = parm["maxdate"]
+		else:
+			maxdate = "20711226"
+
+		pn = bb.data.getVar('PN', d, 1)
+		srcdate = bb.data.getVar('SRCDATE_%s' % pn, d, 1)
+
+		if not srcdate:
+			srcdate = bb.data.getVar('SRCDATE', d, 1)
+
+		if srcdate == "now":
+			srcdate = bb.data.getVar('DATE', d, 1)
+
+		if (maxdate < srcdate) or (mindate > srcdate):
+			if (maxdate < srcdate):
+				bb.note("Patch '%s' is outdated" % pname)
+
+			if (mindate > srcdate):
+				bb.note("Patch '%s' is predated" % pname)
+
+			continue
+
+		bb.note("Applying patch '%s'" % pname)
+		try:
+			patchset.Import({"file":unpacked, "remote":url, "strippath": pnum}, True)
+		except NotFoundError:
+			import sys
+			raise bb.build.FuncFailed(str(sys.exc_value))
+		resolver.Resolve()
+}
+
+EXPORT_FUNCTIONS do_patch
============================================================
--- classes/binconfig.bbclass	1a5eb9029fda4b2e3126727ac113eb6995ed5ead
+++ classes/binconfig.bbclass	7fef4241e7aff369e878642422b6a42fdb44bc24
@@ -5,11 +5,12 @@ def get_binconfig_mangle(d):
 	import bb.data
 	s = "-e ''"
 	if not bb.data.inherits_class('native', d):
-		s += " -e 's:=${libdir}:=OELIBDIR:;'"
-		s += " -e 's:=${includedir}%s
>>> DIFF TRUNCATED @ 16K






More information about the Openembedded-commits mailing list