summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe/patch.py
Commit message (Collapse)AuthorAgeFilesLines
* oe/patch: print cleaner error message when patch fails to applyMarkus Lehtonen2016-04-031-5/+9
| | | | | | | | | [YOCTO #9344] (From OE-Core rev: 574405a97f956278d31d52cfc934be2840cf2fa6) Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* oe/patch: more detailed error reportingMarkus Lehtonen2016-04-031-3/+5
| | | | | | | | | | | | Show the actual command that failed when raising a CmdError. Makes figuring out what actually failed much easier. [YOCTO #9344] (From OE-Core rev: 8e9c03df1810daab7171733f1713ef94d3a18ab2) Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* devtool: commit for extra tasks that modify source when extractingPaul Eggleton2016-02-111-0/+3
| | | | | | | | | | | | | | | | When extracting source for a recipe, if there are additional custom tasks run that make changes to the source, create a commit in the generated git branch so they are contained. This is particularly useful for tasks that come before do_patch since otherwise the changes might get incorporated in the first applied patch, but otherwise it helps avoid the tree being dirty at any point. Fixes [YOCTO #7626]. (From OE-Core rev: 997a77d9b20af1778b804778e5d8c8a7424f7582) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* lib/oe/patch: Make GitApplyTree._applypatch() support read-only .git/hooksPeter Kjellerstedt2016-01-301-14/+12
| | | | | | | | | | | | Rather than modifying files in .git/hooks, which can be read-only (e.g., if it is a link to a directory in /usr/share), move away the entire .git/hooks directory temporarily. (From OE-Core rev: a88d603b51a9ebb39210d54b667519acfbe465c3) Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* lib/oe/patch: improve extraction of patch headerPaul Eggleton2015-12-011-15/+43
| | | | | | | | | | | | | | | | | | | | | For patches that we have to extract the header information by hand (i.e. will not apply with "git am"), make the following improvements: * If we can't extract author/date/subject, then try to do so from the commit that added the patch in git (assuming the metadata is tracked by git) * Take only first Signed-off-by line instead of last * Accept any case for "Signed-off-by" in case author has typed it by hand * Improve conditional - we can skip the other cases if one matches Implements [YOCTO #7624]. (From OE-Core rev: 13ec296b5c35aefa2c44f64f8bd1ef54c4a0a731) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* oe.patch.GitApplyTree: add paths argument to extractPatchesMarkus Lehtonen2015-10-011-1/+4
| | | | | | | | | Makes it possible to define which paths are included in the patches. (From OE-Core rev: 640e57b423e5a8f0e4572eac985f87139780f247) Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* lib/oe/patch: fix for git am not cleaning up after itselfPaul Eggleton2015-09-231-0/+7
| | | | | | | | | | | | | | | Unfortunately it appears that under certain circumstances, a failed git am followed by git am --abort won't clean up any changes the patch might have made - this was seen when running "devtool extract" on the unzip recipe; unzip-6.0_overflow3.diff has a malformed date as far as git am is concerned but it triggers this condition. Add a git reset --hard HEAD followed by git clean -f in order to recover from this scenario. (From OE-Core rev: 21fdbd76f458b70a6646dd6d0749e3a465ebd320) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* lib/oe/patch: handle patches that delete files with older gitPaul Eggleton2015-08-301-1/+1
| | | | | | | | | | | | | | | | | | | | When running "git add" on a directory with older git versions, deleted files aren't added to what is to be committed unless you explicitly specify the -A option. The result of this is that when applying a patch from a recipe which doesn't apply with "git am" (and we fall back to applying the patch through other means then "git add" following by a "git commit") these deletes weren't committed with the patch, leaving them sitting deleted but not committed at the end. This should fix test_devtool_modify_native (which unwittingly exercises this scenario by attempting to run "devtool modify" on apt-native) on machines with older git versions. (From OE-Core rev: 367ffba394bb815d776f48a367d5d7e5ea9b3bba) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* lib/oe/patch: Fix git patch application for source in subdirectoryRichard Purdie2015-06-261-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Similarly to: http://git.yoctoproject.org/cgit.cgi/poky/commit/meta/lib/oe/patch.py?id=f205ccaf48ac36f4b26efc4aeb2e9d2939b28646 we need to fix patch application for source which is in a subdirectory. Passing "." as the git directory or work-dir appears to work (or is ignored) in some versions of git but does not work in others, probably quite correctly. Since we have reporoot from the above patch, pass this in directly. This bug caused this sanity test failure on some machines: FAIL: test_devtool_modify_git (oeqa.selftest.devtool.DevtoolTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/pokybuild/yocto-autobuilder/yocto-worker/nightly-oe-selftest/build/meta/lib/oeqa/selftest/devtool.py", line 390, in test_devtool_modify_git self.assertEqual(result.output.strip(), "", 'Created git repo is not clean') AssertionError: '?? util/mkelfImage/patches/' != '' : Created git repo is not clean since git apply would fail, it would then fall back to quilt and the git tree would be left unclean. [YOCTO #7911] (From OE-Core rev: 91d76e632336d6af96f24bcf92be25f41a216856) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* recipetool: add appendfile subcommandPaul Eggleton2015-05-201-0/+63
| | | | | | | | | | | | | | | | | | | | | | Locating which recipe provides a file in an image that you want to modify and then figuring out how to bbappend the recipe in order to replace it can be a tedious process. Thus, add a new appendfile subcommand to recipetool, providing the ability to create a bbappend file to add/replace any file in the target system. Without the -r option, it will search for the recipe packaging the specified file (using pkgdata from previously built recipes). The bbappend will be created at the appropriate path within the specified layer directory (which may or may not be in your bblayers.conf) or if one already exists it will be updated appropriately. Fairly extensive oe-selftest tests are also provided. Implements [YOCTO #6447]. (From OE-Core rev: dd2aa93b3c13d2c6464ef0fda59620c7dba450bb) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* lib/oe/patch: use with open() for all file operationsPaul Eggleton2015-05-201-21/+19
| | | | | | | | | | with open(...)... is preferred for reading/writing files as it is neater and takes care of closing the file for you. (From OE-Core rev: 99ac382d84667eb496dc510d3277b8c55b237738) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* lib/oe/patch: fix PATCHTOOL = "git" with source in a subdirectoryPaul Eggleton2015-02-231-2/+5
| | | | | | | | | | | | | For recipes that have their actual source in a subdirectory of what is fetched (e.g. mkelfimage), we need to find the root of the repository within the GitApplyTree code that attempts to set up the required git hooks and use that, rather than expecting the root to be the same as ${S}. (From OE-Core rev: d820303f64ea610338ec11ffd79269e7831d1da9) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* lib/oe/patch: add support for extracting patches from git treePaul Eggleton2014-12-211-30/+82
| | | | | | | | | | | | When patches from a recipe have been written out to a git tree, we also want to be able to do the reverse so we can update the patches next to the recipe. This is implemented by adding a comment to each commit message (using git hooks) which we can extract later on. (From OE-Core rev: 765b7bad50eae5b79d13a3f4988dc440c3d9787f) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* lib/oe/patch.py: abort "git am" if it failsPaul Eggleton2014-12-211-0/+6
| | | | | | | | | | If we don't do this, you may still be in the git am resolution mode at the end of applying patches, which is not desirable. (From OE-Core rev: 630a393d01950a0d00b5d30ac376472911e50ff9) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* lib/oe/patch: use --keep-cr with git amPaul Eggleton2014-12-211-1/+1
| | | | | | | | | Preserving carriage returns is important where the patch contains them. (From OE-Core rev: 1cfcae0cd0bc776f5bb91a75bb8ffdad3d7bf200) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* lib/oe/patch: auto-commit when falling back from git amPaul Eggleton2014-12-211-0/+86
| | | | | | | | | | | | | | When PATCHTOOL = "git", if we're not able to use "git am" to apply a patch and fall back to "git apply" or "patch", it is desirable to actually commit the changes, attempting to preserve (and interpret) the patch header as part of the commit message if present. As a bonus, the code for extracting the commit message is callable externally in case it is useful elsewhere. (From OE-Core rev: 8c522846093809a8deb866079e73fa317266c80e) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* lib/oe/patch: fall back to patch if git apply failsPaul Eggleton2014-12-211-1/+5
| | | | | | | | | | | When PATCHTOOL = "git", git apply doesn't support fuzzy application, so if a patch requires that it's better to be able to apply it rather than just failing. (From OE-Core rev: a8143f33d3104adcd10968e3b05df2024e723f5a) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* lib/oe/patch.py: Prefer "git am" over "git apply" when applying git patchesLaszlo Papp2014-01-281-7/+13
| | | | | | | | | | | | | | | | | It is better to use "git am" when possible to preserve the commit messages and the mail format in general for patches when those are present. A typical use case is when developers would like to keep the changes on top of the latest upstream, and they may occasionally need to rebase. This is not possible with "git diff" and "diff" generated patches. Since this is not always the case, the fallback would be the "git apply" operation which is currently available. (From OE-Core rev: 3a14b0943731822905e6d45b13d08a6e8237e2fe) Signed-off-by: Laszlo Papp <lpapp@kde.org> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* meta: Don't use deprecated bitbake APIRichard Purdie2013-09-011-1/+1
| | | | | | | | | | These have been deprecated for a long time, convert the remaining references to the correct modules and prepare for removal of the compatibility support from bitbake. (From OE-Core rev: 6a39835af2b2b3c7797fe05479341d71a3f3aaf6) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* classes/lib: Fix getcmdstatus breakageRichard Purdie2013-05-091-2/+2
| | | | | | | | | I mistakenly thought subprocess had getcmdstatus in python 2. It doesn't so lets add a wrapper and have this work in both worlds. (From OE-Core rev: 2253e9f12734c6e6aa489942b5e4628eca1fa29d) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* sanity/patch.py: Remove commands module usageRichard Purdie2013-05-091-3/+3
| | | | | | | | | The commands module is removed in python3. Use the subprocess module instead and the pipes module to replace the mkargs usage. (From OE-Core rev: e2e1dcd74bc45381baccf507c0309dd792229afe) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* clases/lib: Use modern exception syntaxRichard Purdie2013-05-091-1/+1
| | | | | | | | | Update older code to use modern exception handling syntax which is the form accepted by python 3. (From OE-Core rev: b010501cd089e649a68f683be0cf4d0aac90fbe3) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* lib/oe/patch: Use force option when creating symlinks to patchesRichard Purdie2012-12-171-1/+1
| | | | | | | | | | | | | | | | Under the scenario where you have an existing source tree and you then change one of the patches, maybe to be architecture or machine specific, then rebuild, the build will fail since the symlink already exists but should now point at a different file. The easiest fix is to tell the system to remove and recreate the link which is done with the force option. (From OE-Core rev: 4741b90b170bc96e3a24f9c1dce871af060bc4d5) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* Remove a number of unneeded import os/bb callsRichard Purdie2012-07-191-2/+0
| | | | | | | | | | The bb and os modules are always imported so having these extra import calls are a waste of space/execution time. They also set a bad example for people copy and pasting code so clean them up. (From OE-Core rev: 7d674820958be3a7051ea619effe1a6061d9cbe2) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* meta: Convert getVar/getVarFlag(xxx, 1) -> (xxx, True)Richard Purdie2012-03-051-2/+2
| | | | | | | | | | | | Using "1" with getVar is bad coding style and "True" is preferred. This patch is a sed over the meta directory of the form: sed \ -e 's:\(\.getVar([^,()]*, \)1 *):\1True):g' \ -e 's:\(\.getVarFlag([^,()]*, [^,()]*, \)1 *):\1True):g' \ -i `grep -ril getVar *` Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* lib/oe/patch.py: Fix and improve PatchTree() resolver logicRichard Purdie2012-03-021-12/+53
| | | | | | | | | | | | | | | | | | | | | | | | Currently, if PATCHRESOLVE is user and and PatchTree() is being used, you can get backtraces if patch application fails. This is because even in the failure case, self._current is incremented, meaning second time around, there are array range issues. This patch changes the code so _current is only incremented upon successful patch application, thereby resolving this failure. Secondly, if you bitbake -c patch -f a recipe using PatchTree(), the clean method was unimplemented leading to patch failures. The other part of this patch changes the logic so a series file and set of applied patches are maintained in a quilt like fashion. This means a the Clean method can be implemented correctly and rerunning the patch task of an existing patches source now works reliably. [YOCTO #2043 partially] (From OE-Core rev: f0fc47aea37793a62c43f10eea27ca014c420924) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* classes/patch: avoid backtrace when patch does not applyPaul Eggleton2012-01-191-5/+5
| | | | | | | | | | | | | | We don't need to see a Python stack backtrace when a patch does not apply, just the error output from patch, so trap these kinds of errors and ensure that we display the message and fail the task and nothing else. Fixes [YOCTO #1143] (From OE-Core rev: ce6c80a1e68c2af0b4b5fa27582ad9c9f119e5c1) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* Convert to use direct access to the data store (instead of bb.data.*Var*())Richard Purdie2011-11-101-2/+2
| | | | | | | | | | | | | | | | | This is the result of running the following over the metadata: sed \ -e 's:bb.data.\(setVar([^,()]*,[^,()]*\), *\([^ )]*\) *):\2.\1):g' \ -e 's:bb.data.\(setVarFlag([^,()]*,[^,()]*,[^,()]*\), *\([^) ]*\) *):\2.\1):g' \ -e 's:bb.data.\(getVar([^,()]*\), *\([^(), ]*\) *,\([^)]*\)):\2.\1,\3):g' \ -e 's:bb.data.\(getVarFlag([^,()]*,[^,()]*\), *\([^(), ]*\) *,\([^)]*\)):\2.\1,\3):g' \ -e 's:bb.data.\(getVarFlag([^,()]*,[^,()]*\), *\([^() ]*\) *):\2.\1):g' \ -e 's:bb.data.\(getVar([^,()]*\), *\([^) ]*\) *):\2.\1):g' \ -i `grep -ril bb.data *` (From OE-Core rev: b22831fd63164c4db9c0b72934d7d734a6585251) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* patch: Convert to use oe_terminalRichard Purdie2011-11-041-11/+6
| | | | | | | | | | | Unfortunately we can't access oe_terminal directly from patch.py so we have to pass in the correct terminal function pointer. [YOCTO #1587] (From OE-Core rev: 9e0a21dda24f285a1c4878488e887485a749f3f2) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* patch.py: fixed message domain errorsSamuel Stirtzel2011-10-141-2/+2
| | | | | | | | | | The dynamic message domain was introduced by Richard Purdie with the following patch: http://git.yoctoproject.org/cgit.cgi/poky/commit/?id=a6c48298b17e6a5844b3638b422fe226e3b67b89 (From OE-Core rev: 2383e06c8ed7c15aa148b9dbe40445e7095b6f57) Signed-off-by: Samuel Stirtzel <s.stirtzel@googlemail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* oe/patch.py: Remove series file during Clean()Khem Raj2011-05-101-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | Currently if there is a failed do_patch the series files get appended so if there were two patches a.patch b.patch and b.patch failed during next run it would append a.patch again a.patch b.patch a.patch and this would keep growing. We can remove series file in Clean() because we populate it in Import() anyway (From OE-Core rev: fd07744ae549c2f43b18d53e6ed16c20df6b4ef3) Signed-off-by: Khem Raj <raj.khem@gmail.com> Acked-by: Chris Larson <chris_larson@mentor.com> Acked-by: Eric BĂ©nard <eric@eukrea.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* lib/oe/patch.py: Cosmetic change to avoid bitbake warningKhem Raj2011-03-231-1/+1
| | | | | | | | | bb.mkdirhier should be bb.utils.mkdirhier (From OE-Core rev: cd28d5f5ad7855d0d6a15bec5317c942e2462065) Signed-off-by: Khem Raj <raj.khem@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* oe.patch: add missing importsChris Larson2011-03-231-0/+2
| | | | | | | (From OE-Core rev: cefbf3a14fcf87e18f7a63a1f55904d9d612ed3e) Signed-off-by: Chris Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* meta/classes: Update classes to use new fetcher APIRichard Purdie2011-02-071-3/+3
| | | | Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
* lib/oe: sync with OE.devJoshua Lock2010-08-041-9/+6
| | | | | | | Most notable change is the move to creating symlinks to patches in the metadata tree rather than copying them. Signed-off-by: Joshua Lock <josh@linux.intel.com>
* lib/oe/patch.py: Fix patch application failure interaction handlingRichard Purdie2010-06-101-1/+1
| | | | Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
* lib/oe/patch.py: Fix datastore references in error pathsRichard Purdie2010-05-271-4/+4
| | | | Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
* lib/oe: Import oe lib from OE.devJoshua Lock2010-05-061-0/+407
This library moves the common Python methods into modules of an 'oe' Python package. Signed-off-by: Joshua Lock <josh@linux.intel.com>