From f4b18fced24ea7704b429db86f7638a779079407 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Wed, 23 Aug 2006 12:29:20 +0000 Subject: base.bbclass: Remove empty messages --- classes/base.bbclass | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'classes') diff --git a/classes/base.bbclass b/classes/base.bbclass index 56a13ff309..6f8468b119 100644 --- a/classes/base.bbclass +++ b/classes/base.bbclass @@ -543,7 +543,8 @@ python base_eventhandler() { msg += messages.get(name[5:]) or name[5:] elif name == "UnsatisfiedDep": msg += "package %s: dependency %s %s" % (e.pkg, e.dep, name[:-3].lower()) - note(msg) + if msg: + note(msg) if name.startswith("BuildStarted"): bb.data.setVar( 'BB_VERSION', bb.__version__, e.data ) -- cgit v1.2.3 From 6bdb98734e08cf7f1adb65a39ddfc108b1e85b45 Mon Sep 17 00:00:00 2001 From: Koen Kooi Date: Fri, 25 Aug 2006 18:14:28 +0000 Subject: classes: run do_package before do_stage so we can populate staging with package if we want --- classes/base.bbclass | 6 ++---- classes/package.bbclass | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'classes') diff --git a/classes/base.bbclass b/classes/base.bbclass index 6f8468b119..f936dff870 100644 --- a/classes/base.bbclass +++ b/classes/base.bbclass @@ -601,8 +601,6 @@ base_do_compile() { fi } - -addtask stage after do_compile base_do_stage () { : } @@ -614,13 +612,13 @@ do_populate_staging[dirs] = "${STAGING_DIR}/${TARGET_SYS}/bin ${STAGING_DIR}/${T ${STAGING_DATADIR} \ ${S} ${B}" -addtask populate_staging after do_compile +addtask populate_staging after do_package python do_populate_staging () { bb.build.exec_func('do_stage', d) } -addtask install after do_compile +addtask install after do_compile do_install[dirs] = "${S} ${B}" base_do_install() { diff --git a/classes/package.bbclass b/classes/package.bbclass index 0d6a7734af..d6f50fb49d 100644 --- a/classes/package.bbclass +++ b/classes/package.bbclass @@ -738,4 +738,4 @@ do_package[dirs] = "${D}" do_package[deptask] = "do_package" populate_packages[dirs] = "${D}" EXPORT_FUNCTIONS do_package do_shlibs do_split_locales mapping_rename_hook -addtask package before do_build after do_populate_staging +addtask package before do_build after do_install -- cgit v1.2.3 From eda54eb6defc01f75d6cc5b4e604911375592f2b Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Sat, 26 Aug 2006 16:51:18 +0000 Subject: base.bbclass: Change FILESPATH handling to allow it to be appended/prepended to. Should be backwards compatible. --- classes/base.bbclass | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'classes') diff --git a/classes/base.bbclass b/classes/base.bbclass index f936dff870..e413afb2b3 100644 --- a/classes/base.bbclass +++ b/classes/base.bbclass @@ -50,7 +50,7 @@ def base_set_filespath(path, d): overrides = overrides + ":" for o in overrides.split(":"): filespath.append(os.path.join(p, o)) - bb.data.setVar("FILESPATH", ":".join(filespath), d) + return ":".join(filespath) FILESPATH = "${@base_set_filespath([ "${FILE_DIRNAME}/${PF}", "${FILE_DIRNAME}/${P}", "${FILE_DIRNAME}/${PN}", "${FILE_DIRNAME}/files", "${FILE_DIRNAME}" ], d)}" -- cgit v1.2.3 From 6d0f7e06b5dac45bc9ebbf418bb465a440d6bf8c Mon Sep 17 00:00:00 2001 From: Koen Kooi Date: Sun, 27 Aug 2006 08:30:17 +0000 Subject: package.bbclass: remove do_install from PACKAGE_FUNCS, as noted by Philipp Zabel --- classes/package.bbclass | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'classes') diff --git a/classes/package.bbclass b/classes/package.bbclass index d6f50fb49d..9b913ecf82 100644 --- a/classes/package.bbclass +++ b/classes/package.bbclass @@ -725,7 +725,7 @@ python package_do_split_locales() { bb.data.setVar('RDEPENDS_%s' % mainpkg, ' '.join(rdep), d) } -PACKAGEFUNCS ?= " do_install package_do_split_locales \ +PACKAGEFUNCS ?= " package_do_split_locales \ populate_packages package_do_shlibs \ package_do_pkgconfig read_shlibdeps" python package_do_package () { -- cgit v1.2.3 From c3352186941a100ee3812472531ca3359fef4b95 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Sun, 27 Aug 2006 16:00:40 +0000 Subject: gconf.bbclass: Add gconf to DEPENDS (from poky) --- classes/gconf.bbclass | 2 ++ 1 file changed, 2 insertions(+) (limited to 'classes') diff --git a/classes/gconf.bbclass b/classes/gconf.bbclass index b0c5723873..686f8e6596 100644 --- a/classes/gconf.bbclass +++ b/classes/gconf.bbclass @@ -1,3 +1,5 @@ +DEPENDS += "gconf" + gconf_postinst() { if [ "$1" = configure ]; then if [ "x$D" != "x" ]; then -- cgit v1.2.3 From e609b8070d657674563ae304991f8b3307dc1b73 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Sun, 27 Aug 2006 16:02:10 +0000 Subject: base.bbclass: Add base_contains and base_both_containg - useful functions for the new task-machine code (from poky) --- classes/base.bbclass | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'classes') diff --git a/classes/base.bbclass b/classes/base.bbclass index e413afb2b3..670b97a72d 100644 --- a/classes/base.bbclass +++ b/classes/base.bbclass @@ -40,6 +40,20 @@ def base_conditional(variable, checkvalue, truevalue, falsevalue, d): else: return falsevalue +def base_contains(variable, checkvalue, truevalue, falsevalue, d): + import bb + if bb.data.getVar(variable,d,1).find(checkvalue) != -1: + return truevalue + else: + return falsevalue + +def base_both_contain(variable1, variable2, checkvalue, d): + import bb + if bb.data.getVar(variable1,d,1).find(checkvalue) != -1 and bb.data.getVar(variable2,d,1).find(checkvalue) != -1: + return checkvalue + else: + return "" + DEPENDS_prepend="${@base_dep_prepend(d)} " def base_set_filespath(path, d): -- cgit v1.2.3 From e71a84f77fd700c1001a68795e3220c41915f105 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Sun, 27 Aug 2006 16:06:28 +0000 Subject: gtk-icon-cache.bbclass: Add from poky --- classes/gtk-icon-cache.bbclass | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 classes/gtk-icon-cache.bbclass (limited to 'classes') diff --git a/classes/gtk-icon-cache.bbclass b/classes/gtk-icon-cache.bbclass new file mode 100644 index 0000000000..0f68e6812b --- /dev/null +++ b/classes/gtk-icon-cache.bbclass @@ -0,0 +1,38 @@ +FILES_${PN} += "${datadir}/icons/hicolor" + +gtk-icon-cache_postinst() { +if [ "x$D" != "x" ]; then + exit 1 +fi +gtk-update-icon-cache -q /usr/share/icons/hicolor +} + +gtk-icon-cache_postrm() { +gtk-update-icon-cache -q /usr/share/icons/hicolor +} + +python populate_packages_append () { + import os.path + packages = bb.data.getVar('PACKAGES', d, 1).split() + workdir = bb.data.getVar('WORKDIR', d, 1) + + for pkg in packages: + icon_dir = '%s/install/%s/%s/icons/hicolor' % (workdir, pkg, bb.data.getVar('datadir', d, 1)) + if not os.path.exists(icon_dir): + continue + + bb.note("adding gtk-icon-cache postinst and postrm scripts to %s" % pkg) + + postinst = bb.data.getVar('pkg_postinst_%s' % pkg, d, 1) or bb.data.getVar('pkg_postinst', d, 1) + if not postinst: + postinst = '#!/bin/sh\n' + postinst += bb.data.getVar('gtk-icon-cache_postinst', d, 1) + bb.data.setVar('pkg_postinst_%s' % pkg, postinst, d) + + postrm = bb.data.getVar('pkg_postrm_%s' % pkg, d, 1) or bb.data.getVar('pkg_postrm', d, 1) + if not postrm: + postrm = '#!/bin/sh\n' + postrm += bb.data.getVar('gtk-icon-cache_postrm', d, 1) + bb.data.setVar('pkg_postrm_%s' % pkg, postrm, d) +} + -- cgit v1.2.3 From 395ef28947528cc4cd955ae4480c2b6b5561c892 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Mon, 28 Aug 2006 19:29:30 +0000 Subject: rm_work.bbclass: stop cleaning out before populate_staging --- classes/rm_work.bbclass | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'classes') diff --git a/classes/rm_work.bbclass b/classes/rm_work.bbclass index 340446917e..7f590e1b15 100644 --- a/classes/rm_work.bbclass +++ b/classes/rm_work.bbclass @@ -19,4 +19,4 @@ do_rm_work () { } addtask rm_work before do_build -addtask rm_work after do_package +addtask rm_work after do_populate_staging -- cgit v1.2.3 From d3c0ca658f75bf8f2aa96c51126712eb8d45c875 Mon Sep 17 00:00:00 2001 From: Chris Larson Date: Mon, 28 Aug 2006 20:30:14 +0000 Subject: Merge from poky: Rework the way patches are handled. There are now two abstract base classes, initialized in patch.bbclass. One for patchset operations on a directory, and another for patch failure resolution. Currently includes 'patch' and 'quilt' concrete PatchSet classes, and a 'user' resolver class, which simply drops you into a shell in the source tree to fix the rejects. --- classes/base.bbclass | 96 ++-------- classes/patch.bbclass | 476 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 487 insertions(+), 85 deletions(-) create mode 100644 classes/patch.bbclass (limited to 'classes') diff --git a/classes/base.bbclass b/classes/base.bbclass index 670b97a72d..51b6d2111f 100644 --- a/classes/base.bbclass +++ b/classes/base.bbclass @@ -1,5 +1,4 @@ BB_DEFAULT_TASK = "build" -PATCHES_DIR="${S}" def base_dep_prepend(d): import bb; @@ -13,9 +12,11 @@ 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): - deps = patchdeps + 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): if (bb.data.getVar('HOST_SYS', d, 1) != @@ -451,86 +452,6 @@ python base_do_unpack() { raise bb.build.FuncFailed() } -addtask patch after do_unpack -do_patch[dirs] = "${WORKDIR}" -python base_do_patch() { - import re - import bb.fetch - - src_uri = (bb.data.getVar('SRC_URI', d, 1) or '').split() - if not src_uri: - return - - patchcleancmd = bb.data.getVar('PATCHCLEANCMD', d, 1) - if patchcleancmd: - bb.data.setVar("do_patchcleancmd", patchcleancmd, d) - bb.data.setVarFlag("do_patchcleancmd", "func", 1, d) - bb.build.exec_func("do_patchcleancmd", d) - - 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) - bb.data.setVar("do_patchcmd", bb.data.getVar("PATCHCMD", d, 1) % (pnum, pname, unpacked), d) - bb.data.setVarFlag("do_patchcmd", "func", 1, d) - bb.data.setVarFlag("do_patchcmd", "dirs", "${WORKDIR} ${S}", d) - bb.build.exec_func("do_patchcmd", d) -} - addhandler base_eventhandler python base_eventhandler() { @@ -615,6 +536,8 @@ base_do_compile() { fi } + +addtask stage after do_compile base_do_stage () { : } @@ -759,7 +682,10 @@ python () { return } -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 +# Patch handling +inherit patch + +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 () { diff --git a/classes/patch.bbclass b/classes/patch.bbclass new file mode 100644 index 0000000000..ea0182484e --- /dev/null +++ b/classes/patch.bbclass @@ -0,0 +1,476 @@ +# 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) + + 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) + + 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 + + def Clean(self): + try: + self._runcmd(["pop", "-a", "-f"]) + except CmdError: + pass + except NotFoundError: + pass + # runcmd(["rm", "-rf", os.path.join(self.dir, "patches"), os.path.join(self.dir, ".pc")]) + 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() + + # 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) + + # Throw away the changes to the patches in the patchset made by resolve() + def Revert(self): + raise NotImplementedError() + + # Apply the changes to the patches in the patchset made by resolve() + def Finalize(self): + raise NotImplementedError() + + g = globals() + g["PatchSet"] = PatchSet + g["PatchTree"] = PatchTree + g["QuiltTree"] = QuiltTree + g["Resolver"] = Resolver + g["UserResolver"] = UserResolver + 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 = { + "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 -- cgit v1.2.3 From 4b58334866dda9b3415fee5668b2c7bc08447905 Mon Sep 17 00:00:00 2001 From: Jamie Lenehan Date: Wed, 30 Aug 2006 07:18:07 +0000 Subject: classes/patch.bbclass: Create a "patches" directory when initialising the quilt patcher class. Without this quilt will search for a patches directory - starting from the current directory up to the root directory. If it finds an existing patches directory it will use it for its patches. This causes all sorts of problems since it is not where the patches are expected to be. Prior to the recent patcher changes this directory was being created. --- classes/patch.bbclass | 3 +++ 1 file changed, 3 insertions(+) (limited to 'classes') diff --git a/classes/patch.bbclass b/classes/patch.bbclass index ea0182484e..c62a8ebd76 100644 --- a/classes/patch.bbclass +++ b/classes/patch.bbclass @@ -174,6 +174,9 @@ def patch_init(d): 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.mkdir(p) def Clean(self): try: -- cgit v1.2.3 From dc8d0a5f1ea8956bc4af88132472cccde4a0e7c3 Mon Sep 17 00:00:00 2001 From: Chris Larson Date: Wed, 30 Aug 2006 07:29:56 +0000 Subject: patch.bbclass: * Add NOOPResolver class, which simply passes the patch failure on up, not doing any actual patch resolution. Set PATCHRESOLVE = "noop" to make use of it. Most useful for unattended builds. --- classes/patch.bbclass | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'classes') diff --git a/classes/patch.bbclass b/classes/patch.bbclass index c62a8ebd76..7bb0900f8a 100644 --- a/classes/patch.bbclass +++ b/classes/patch.bbclass @@ -309,6 +309,19 @@ def patch_init(d): 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). @@ -360,20 +373,13 @@ def patch_init(d): raise os.chdir(olddir) - # Throw away the changes to the patches in the patchset made by resolve() - def Revert(self): - raise NotImplementedError() - - # Apply the changes to the patches in the patchset made by resolve() - def Finalize(self): - raise NotImplementedError() - 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 @@ -397,6 +403,7 @@ python patch_do_patch() { cls = patchsetmap[bb.data.getVar('PATCHTOOL', d, 1) or 'quilt'] resolvermap = { + "noop": NOOPResolver, "user": UserResolver, } -- cgit v1.2.3 From ee5c15c58188e02db43e54b9093d9c0f73696182 Mon Sep 17 00:00:00 2001 From: Chris Larson Date: Wed, 30 Aug 2006 08:32:22 +0000 Subject: patch.bbclass: * switch os.mkdir to os.makedirs. * pass on all errors from QuiltTree.Clean(), as it can fail in ways that do not need to be reported to the user, and a failure will end up being seen again during the Import/Push of the patches. --- classes/patch.bbclass | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'classes') diff --git a/classes/patch.bbclass b/classes/patch.bbclass index 7bb0900f8a..5e40b3dc0d 100644 --- a/classes/patch.bbclass +++ b/classes/patch.bbclass @@ -176,16 +176,13 @@ def patch_init(d): self.initialized = False p = os.path.join(self.dir, 'patches') if not os.path.exists(p): - os.mkdir(p) + os.makedirs(p) def Clean(self): try: self._runcmd(["pop", "-a", "-f"]) - except CmdError: - pass - except NotFoundError: + except Exception: pass - # runcmd(["rm", "-rf", os.path.join(self.dir, "patches"), os.path.join(self.dir, ".pc")]) self.initialized = True def InitFromDir(self): -- cgit v1.2.3