Message ID | 20211201141543.32206-1-pavel@zhukoff.net |
---|---|
State | New |
Headers | show |
Series | [meta-oe,v2] patch.py: Initialize git repo before patching | expand |
Does the test fail without the change in lib/oepatch.py? Can you show how? Alex On Wed, 1 Dec 2021 at 15:17, Pavel Zhukov <pavel@zhukoff.net> wrote: > From: Pavel Zhukov <pavel.zhukov@huawei.com> > > If PATCHTOOL="git" has been specified but workdir is not git repo > bitbake fails to apply the patches. Fix this by initializing the repo > before patching. > This allows binary git patches to be applied. > > Signed-off-by: Pavel Zhukov <pavel.zhukov@huawei.com> > --- > meta/lib/oe/patch.py | 17 +++++++++++++++++ > meta/lib/oeqa/selftest/cases/bbtests.py | 6 ++++++ > 2 files changed, 23 insertions(+) > > diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py > index 7cd8436da5..720c6f663c 100644 > --- a/meta/lib/oe/patch.py > +++ b/meta/lib/oe/patch.py > @@ -52,6 +52,10 @@ def runcmd(args, dir = None): > if dir: > os.chdir(olddir) > > +def getstatusoutput(cmd): > + import subprocess > + return subprocess.getstatusoutput(cmd.split()) > + > class PatchError(Exception): > def __init__(self, msg): > self.msg = msg > @@ -294,6 +298,19 @@ class GitApplyTree(PatchTree): > PatchTree.__init__(self, dir, d) > self.commituser = d.getVar('PATCH_GIT_USER_NAME') > self.commitemail = d.getVar('PATCH_GIT_USER_EMAIL') > + if not self._isInitialized(): > + self._initRepo() > + > + def _isInitialized(self): > + cmd = "git rev-parse --show-toplevel" > + (status, output) = getstatusoutput(cmd) > + ## Make sure we're in builddir to not break top-level git repos > + return status == 0 and os.path.samedir(output, self.dir) > + > + def _initRepo(self): > + runcmd("git init".split(), self.dir) > + runcmd("git add .".split(), self.dir) > + runcmd("git commit -a --allow-empty -m Patching_started".split(), > self.dir) > > @staticmethod > def extractPatchHeader(patchfile): > diff --git a/meta/lib/oeqa/selftest/cases/bbtests.py > b/meta/lib/oeqa/selftest/cases/bbtests.py > index d4f6a08991..8c046074f6 100644 > --- a/meta/lib/oeqa/selftest/cases/bbtests.py > +++ b/meta/lib/oeqa/selftest/cases/bbtests.py > @@ -294,3 +294,9 @@ INHERIT_remove = \"report-error\" > > test_recipe_summary_after = get_bb_var('SUMMARY', test_recipe) > self.assertEqual(expected_recipe_summary, > test_recipe_summary_after) > + > + def test_git_patchtool(self): > + self.write_recipeinc('man-db', 'PATCHTOOL=\"git\"') > + result = bitbake('man-db -c patch', ignore_status=False) > + self.delete_recipeinc('man-db') > + bitbake('-cclean man-db') > -- > 2.34.0 > > > -=-=-=-=-=-=-=-=-=-=-=- > Links: You receive all messages sent to this group. > View/Reply Online (#159031): > https://lists.openembedded.org/g/openembedded-core/message/159031 > Mute This Topic: https://lists.openembedded.org/mt/87428914/1686489 > Group Owner: openembedded-core+owner@lists.openembedded.org > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [ > alex.kanavin@gmail.com] > -=-=-=-=-=-=-=-=-=-=-=- > >
Thanks :) You can add the failure into the commit message. Alex On Wed, 1 Dec 2021 at 17:00, Pavel Zhukov <pavel@zhukoff.net> wrote: > without change in patch.py: > ERROR: man-db-2.9.0-r1 do_patch: Applying patch > 'man_db.conf-avoid-multilib-install-file-conflict.patch' on target > directory > '/mnt/builds/oniroproject/builds/build-oniro-linux-st/tmp/work/core2-64-oniro-linux-musl/man-db/2.9.0-r1/man-db-2.9.0' > Command Error: 'git rev-parse --show-toplevel' exited with 0 Output: > fatal: not a git repository (or any of the parent directories): .git > ERROR: Logfile of failure stored in: > /mnt/builds/oniroproject/builds/build-oniro-linux-st/tmp/work/core2-64-oniro-linux-musl/man-db/2.9.0-r1/temp/log.do_patch.21491 > NOTE: recipe man-db-2.9.0-r1: task do_patch: Failed > ERROR: Task > (/mnt/builds/oniroproject/sources/oe-core/meta/recipes-extended/man-db/man-db_2.9.0.bb:do_patch) > failed with exit code '1' > NOTE: Tasks Summary: Attempted 102 tasks of which 0 didn't need to be > rerun and 1 failed. > > Summary: 1 task failed: > > /mnt/builds/oniroproject/sources/oe-core/meta/recipes-extended/man-db/man-db_2.9.0.bb: > do_patch > Summary: There was 1 ERROR message shown, returning a non-zero exit code. > ---------------------------------------------------------------------- > 2021-12-01 15:11:56,184 - oe-selftest - INFO - Ran 1 test in 147.083s > 2021-12-01 15:11:56,184 - oe-selftest - INFO - FAILED > 2021-12-01 15:11:56,184 - oe-selftest - INFO - (failures=1) > 2021-12-01 15:11:58,721 - oe-selftest - INFO - RESULTS: > 2021-12-01 15:11:58,722 - oe-selftest - INFO - RESULTS - > bbtests.BitbakeTests.test_git_patchtool: FAILED (145.51s) > 2021-12-01 15:11:58,724 - oe-selftest - INFO - SUMMARY: > 2021-12-01 15:11:58,724 - oe-selftest - INFO - oe-selftest () - Ran 1 test > in 147.084s > 2021-12-01 15:11:58,724 - oe-selftest - INFO - oe-selftest - FAIL - > Required tests failed (successes=0, skipped=0, failures=1, errors=0) > > > with change in patch.py: > 2021-12-01 15:12:20,910 - oe-selftest - INFO - Adding: "include > selftest.inc" in > /mnt/builds/oniroproject/builds/build-oniro-linux-st/conf/local.conf > 2021-12-01 15:12:20,911 - oe-selftest - INFO - Adding: "include > bblayers.inc" in bblayers.conf > 2021-12-01 15:12:20,911 - oe-selftest - INFO - test_git_patchtool > (bbtests.BitbakeTests) > 2021-12-01 15:15:30,540 - oe-selftest - INFO - ... ok > 2021-12-01 15:15:31,717 - oe-selftest - INFO - > ---------------------------------------------------------------------- > 2021-12-01 15:15:31,717 - oe-selftest - INFO - Ran 1 test in 192.371s > 2021-12-01 15:15:31,717 - oe-selftest - INFO - OK > 2021-12-01 15:15:34,523 - oe-selftest - INFO - RESULTS: > 2021-12-01 15:15:34,524 - oe-selftest - INFO - RESULTS - > bbtests.BitbakeTests.test_git_patchtool: PASSED (189.63s) > 2021-12-01 15:15:34,526 - oe-selftest - INFO - SUMMARY: > 2021-12-01 15:15:34,526 - oe-selftest - INFO - oe-selftest () - Ran 1 test > in 192.372s > 2021-12-01 15:15:34,526 - oe-selftest - INFO - oe-selftest - OK - All > required tests passed (successes=1, skipped=0, failures=0, errors=0) > > > -- > Pavel > > > > 01.12.2021, 16:56, "Alexander Kanavin" <alex.kanavin@gmail.com>: > > Does the test fail without the change in lib/oepatch.py? Can you show how? > > Alex > > On Wed, 1 Dec 2021 at 15:17, Pavel Zhukov <pavel@zhukoff.net> wrote: > > From: Pavel Zhukov <pavel.zhukov@huawei.com> > > If PATCHTOOL="git" has been specified but workdir is not git repo > bitbake fails to apply the patches. Fix this by initializing the repo > before patching. > This allows binary git patches to be applied. > > Signed-off-by: Pavel Zhukov <pavel.zhukov@huawei.com> > --- > meta/lib/oe/patch.py | 17 +++++++++++++++++ > meta/lib/oeqa/selftest/cases/bbtests.py | 6 ++++++ > 2 files changed, 23 insertions(+) > > diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py > index 7cd8436da5..720c6f663c 100644 > --- a/meta/lib/oe/patch.py > +++ b/meta/lib/oe/patch.py > @@ -52,6 +52,10 @@ def runcmd(args, dir = None): > if dir: > os.chdir(olddir) > > +def getstatusoutput(cmd): > + import subprocess > + return subprocess.getstatusoutput(cmd.split()) > + > class PatchError(Exception): > def __init__(self, msg): > self.msg = msg > @@ -294,6 +298,19 @@ class GitApplyTree(PatchTree): > PatchTree.__init__(self, dir, d) > self.commituser = d.getVar('PATCH_GIT_USER_NAME') > self.commitemail = d.getVar('PATCH_GIT_USER_EMAIL') > + if not self._isInitialized(): > + self._initRepo() > + > + def _isInitialized(self): > + cmd = "git rev-parse --show-toplevel" > + (status, output) = getstatusoutput(cmd) > + ## Make sure we're in builddir to not break top-level git repos > + return status == 0 and os.path.samedir(output, self.dir) > + > + def _initRepo(self): > + runcmd("git init".split(), self.dir) > + runcmd("git add .".split(), self.dir) > + runcmd("git commit -a --allow-empty -m Patching_started".split(), > self.dir) > > @staticmethod > def extractPatchHeader(patchfile): > diff --git a/meta/lib/oeqa/selftest/cases/bbtests.py > b/meta/lib/oeqa/selftest/cases/bbtests.py > index d4f6a08991..8c046074f6 100644 > --- a/meta/lib/oeqa/selftest/cases/bbtests.py > +++ b/meta/lib/oeqa/selftest/cases/bbtests.py > @@ -294,3 +294,9 @@ INHERIT_remove = \"report-error\" > > test_recipe_summary_after = get_bb_var('SUMMARY', test_recipe) > self.assertEqual(expected_recipe_summary, > test_recipe_summary_after) > + > + def test_git_patchtool(self): > + self.write_recipeinc('man-db', 'PATCHTOOL=\"git\"') > + result = bitbake('man-db -c patch', ignore_status=False) > + self.delete_recipeinc('man-db') > + bitbake('-cclean man-db') > -- > 2.34.0 > > > -=-=-=-=-=-=-=-=-=-=-=- > Links: You receive all messages sent to this group. > View/Reply Online (#159031): > https://lists.openembedded.org/g/openembedded-core/message/159031 > Mute This Topic: https://lists.openembedded.org/mt/87428914/1686489 > Group Owner: openembedded-core+owner@lists.openembedded.org > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [ > alex.kanavin@gmail.com] > -=-=-=-=-=-=-=-=-=-=-=- > > >
Not seeing that in v4 :) Alex On Wed, 1 Dec 2021 at 17:14, Pavel Zhukov <pavel@zhukoff.net> wrote: > Thanks. Done in v4. > > -- > Pavel > > > > 01.12.2021, 17:08, "Alexander Kanavin" <alex.kanavin@gmail.com>: > > Thanks :) You can add the failure into the commit message. > > Alex > > On Wed, 1 Dec 2021 at 17:00, Pavel Zhukov <pavel@zhukoff.net> wrote: > > without change in patch.py: > ERROR: man-db-2.9.0-r1 do_patch: Applying patch > 'man_db.conf-avoid-multilib-install-file-conflict.patch' on target > directory > '/mnt/builds/oniroproject/builds/build-oniro-linux-st/tmp/work/core2-64-oniro-linux-musl/man-db/2.9.0-r1/man-db-2.9.0' > Command Error: 'git rev-parse --show-toplevel' exited with 0 Output: > fatal: not a git repository (or any of the parent directories): .git > ERROR: Logfile of failure stored in: > /mnt/builds/oniroproject/builds/build-oniro-linux-st/tmp/work/core2-64-oniro-linux-musl/man-db/2.9.0-r1/temp/log.do_patch.21491 > NOTE: recipe man-db-2.9.0-r1: task do_patch: Failed > ERROR: Task > (/mnt/builds/oniroproject/sources/oe-core/meta/recipes-extended/man-db/man-db_2.9.0.bb:do_patch) > failed with exit code '1' > NOTE: Tasks Summary: Attempted 102 tasks of which 0 didn't need to be > rerun and 1 failed. > > Summary: 1 task failed: > > /mnt/builds/oniroproject/sources/oe-core/meta/recipes-extended/man-db/man-db_2.9.0.bb: > do_patch > Summary: There was 1 ERROR message shown, returning a non-zero exit code. > ---------------------------------------------------------------------- > 2021-12-01 15:11:56,184 - oe-selftest - INFO - Ran 1 test in 147.083s > 2021-12-01 15:11:56,184 - oe-selftest - INFO - FAILED > 2021-12-01 15:11:56,184 - oe-selftest - INFO - (failures=1) > 2021-12-01 15:11:58,721 - oe-selftest - INFO - RESULTS: > 2021-12-01 15:11:58,722 - oe-selftest - INFO - RESULTS - > bbtests.BitbakeTests.test_git_patchtool: FAILED (145.51s) > 2021-12-01 15:11:58,724 - oe-selftest - INFO - SUMMARY: > 2021-12-01 15:11:58,724 - oe-selftest - INFO - oe-selftest () - Ran 1 test > in 147.084s > 2021-12-01 15:11:58,724 - oe-selftest - INFO - oe-selftest - FAIL - > Required tests failed (successes=0, skipped=0, failures=1, errors=0) > > > with change in patch.py: > 2021-12-01 15:12:20,910 - oe-selftest - INFO - Adding: "include > selftest.inc" in > /mnt/builds/oniroproject/builds/build-oniro-linux-st/conf/local.conf > 2021-12-01 15:12:20,911 - oe-selftest - INFO - Adding: "include > bblayers.inc" in bblayers.conf > 2021-12-01 15:12:20,911 - oe-selftest - INFO - test_git_patchtool > (bbtests.BitbakeTests) > 2021-12-01 15:15:30,540 - oe-selftest - INFO - ... ok > 2021-12-01 15:15:31,717 - oe-selftest - INFO - > ---------------------------------------------------------------------- > 2021-12-01 15:15:31,717 - oe-selftest - INFO - Ran 1 test in 192.371s > 2021-12-01 15:15:31,717 - oe-selftest - INFO - OK > 2021-12-01 15:15:34,523 - oe-selftest - INFO - RESULTS: > 2021-12-01 15:15:34,524 - oe-selftest - INFO - RESULTS - > bbtests.BitbakeTests.test_git_patchtool: PASSED (189.63s) > 2021-12-01 15:15:34,526 - oe-selftest - INFO - SUMMARY: > 2021-12-01 15:15:34,526 - oe-selftest - INFO - oe-selftest () - Ran 1 test > in 192.372s > 2021-12-01 15:15:34,526 - oe-selftest - INFO - oe-selftest - OK - All > required tests passed (successes=1, skipped=0, failures=0, errors=0) > > > -- > Pavel > > > > 01.12.2021, 16:56, "Alexander Kanavin" <alex.kanavin@gmail.com>: > > Does the test fail without the change in lib/oepatch.py? Can you show how? > > Alex > > On Wed, 1 Dec 2021 at 15:17, Pavel Zhukov <pavel@zhukoff.net> wrote: > > From: Pavel Zhukov <pavel.zhukov@huawei.com> > > If PATCHTOOL="git" has been specified but workdir is not git repo > bitbake fails to apply the patches. Fix this by initializing the repo > before patching. > This allows binary git patches to be applied. > > Signed-off-by: Pavel Zhukov <pavel.zhukov@huawei.com> > --- > meta/lib/oe/patch.py | 17 +++++++++++++++++ > meta/lib/oeqa/selftest/cases/bbtests.py | 6 ++++++ > 2 files changed, 23 insertions(+) > > diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py > index 7cd8436da5..720c6f663c 100644 > --- a/meta/lib/oe/patch.py > +++ b/meta/lib/oe/patch.py > @@ -52,6 +52,10 @@ def runcmd(args, dir = None): > if dir: > os.chdir(olddir) > > +def getstatusoutput(cmd): > + import subprocess > + return subprocess.getstatusoutput(cmd.split()) > + > class PatchError(Exception): > def __init__(self, msg): > self.msg = msg > @@ -294,6 +298,19 @@ class GitApplyTree(PatchTree): > PatchTree.__init__(self, dir, d) > self.commituser = d.getVar('PATCH_GIT_USER_NAME') > self.commitemail = d.getVar('PATCH_GIT_USER_EMAIL') > + if not self._isInitialized(): > + self._initRepo() > + > + def _isInitialized(self): > + cmd = "git rev-parse --show-toplevel" > + (status, output) = getstatusoutput(cmd) > + ## Make sure we're in builddir to not break top-level git repos > + return status == 0 and os.path.samedir(output, self.dir) > + > + def _initRepo(self): > + runcmd("git init".split(), self.dir) > + runcmd("git add .".split(), self.dir) > + runcmd("git commit -a --allow-empty -m Patching_started".split(), > self.dir) > > @staticmethod > def extractPatchHeader(patchfile): > diff --git a/meta/lib/oeqa/selftest/cases/bbtests.py > b/meta/lib/oeqa/selftest/cases/bbtests.py > index d4f6a08991..8c046074f6 100644 > --- a/meta/lib/oeqa/selftest/cases/bbtests.py > +++ b/meta/lib/oeqa/selftest/cases/bbtests.py > @@ -294,3 +294,9 @@ INHERIT_remove = \"report-error\" > > test_recipe_summary_after = get_bb_var('SUMMARY', test_recipe) > self.assertEqual(expected_recipe_summary, > test_recipe_summary_after) > + > + def test_git_patchtool(self): > + self.write_recipeinc('man-db', 'PATCHTOOL=\"git\"') > + result = bitbake('man-db -c patch', ignore_status=False) > + self.delete_recipeinc('man-db') > + bitbake('-cclean man-db') > -- > 2.34.0 > > > -=-=-=-=-=-=-=-=-=-=-=- > Links: You receive all messages sent to this group. > View/Reply Online (#159031): > https://lists.openembedded.org/g/openembedded-core/message/159031 > Mute This Topic: https://lists.openembedded.org/mt/87428914/1686489 > Group Owner: openembedded-core+owner@lists.openembedded.org > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [ > alex.kanavin@gmail.com] > -=-=-=-=-=-=-=-=-=-=-=- > > >
Nevermind, I do now :) Alex On Wed, 1 Dec 2021 at 17:26, Alexander Kanavin <alex.kanavin@gmail.com> wrote: > Not seeing that in v4 :) > > Alex > > On Wed, 1 Dec 2021 at 17:14, Pavel Zhukov <pavel@zhukoff.net> wrote: > >> Thanks. Done in v4. >> >> -- >> Pavel >> >> >> >> 01.12.2021, 17:08, "Alexander Kanavin" <alex.kanavin@gmail.com>: >> >> Thanks :) You can add the failure into the commit message. >> >> Alex >> >> On Wed, 1 Dec 2021 at 17:00, Pavel Zhukov <pavel@zhukoff.net> wrote: >> >> without change in patch.py: >> ERROR: man-db-2.9.0-r1 do_patch: Applying patch >> 'man_db.conf-avoid-multilib-install-file-conflict.patch' on target >> directory >> '/mnt/builds/oniroproject/builds/build-oniro-linux-st/tmp/work/core2-64-oniro-linux-musl/man-db/2.9.0-r1/man-db-2.9.0' >> Command Error: 'git rev-parse --show-toplevel' exited with 0 Output: >> fatal: not a git repository (or any of the parent directories): .git >> ERROR: Logfile of failure stored in: >> /mnt/builds/oniroproject/builds/build-oniro-linux-st/tmp/work/core2-64-oniro-linux-musl/man-db/2.9.0-r1/temp/log.do_patch.21491 >> NOTE: recipe man-db-2.9.0-r1: task do_patch: Failed >> ERROR: Task >> (/mnt/builds/oniroproject/sources/oe-core/meta/recipes-extended/man-db/man-db_2.9.0.bb:do_patch) >> failed with exit code '1' >> NOTE: Tasks Summary: Attempted 102 tasks of which 0 didn't need to be >> rerun and 1 failed. >> >> Summary: 1 task failed: >> >> /mnt/builds/oniroproject/sources/oe-core/meta/recipes-extended/man-db/man-db_2.9.0.bb: >> do_patch >> Summary: There was 1 ERROR message shown, returning a non-zero exit code. >> ---------------------------------------------------------------------- >> 2021-12-01 15:11:56,184 - oe-selftest - INFO - Ran 1 test in 147.083s >> 2021-12-01 15:11:56,184 - oe-selftest - INFO - FAILED >> 2021-12-01 15:11:56,184 - oe-selftest - INFO - (failures=1) >> 2021-12-01 15:11:58,721 - oe-selftest - INFO - RESULTS: >> 2021-12-01 15:11:58,722 - oe-selftest - INFO - RESULTS - >> bbtests.BitbakeTests.test_git_patchtool: FAILED (145.51s) >> 2021-12-01 15:11:58,724 - oe-selftest - INFO - SUMMARY: >> 2021-12-01 15:11:58,724 - oe-selftest - INFO - oe-selftest () - Ran 1 >> test in 147.084s >> 2021-12-01 15:11:58,724 - oe-selftest - INFO - oe-selftest - FAIL - >> Required tests failed (successes=0, skipped=0, failures=1, errors=0) >> >> >> with change in patch.py: >> 2021-12-01 15:12:20,910 - oe-selftest - INFO - Adding: "include >> selftest.inc" in >> /mnt/builds/oniroproject/builds/build-oniro-linux-st/conf/local.conf >> 2021-12-01 15:12:20,911 - oe-selftest - INFO - Adding: "include >> bblayers.inc" in bblayers.conf >> 2021-12-01 15:12:20,911 - oe-selftest - INFO - test_git_patchtool >> (bbtests.BitbakeTests) >> 2021-12-01 15:15:30,540 - oe-selftest - INFO - ... ok >> 2021-12-01 15:15:31,717 - oe-selftest - INFO - >> ---------------------------------------------------------------------- >> 2021-12-01 15:15:31,717 - oe-selftest - INFO - Ran 1 test in 192.371s >> 2021-12-01 15:15:31,717 - oe-selftest - INFO - OK >> 2021-12-01 15:15:34,523 - oe-selftest - INFO - RESULTS: >> 2021-12-01 15:15:34,524 - oe-selftest - INFO - RESULTS - >> bbtests.BitbakeTests.test_git_patchtool: PASSED (189.63s) >> 2021-12-01 15:15:34,526 - oe-selftest - INFO - SUMMARY: >> 2021-12-01 15:15:34,526 - oe-selftest - INFO - oe-selftest () - Ran 1 >> test in 192.372s >> 2021-12-01 15:15:34,526 - oe-selftest - INFO - oe-selftest - OK - All >> required tests passed (successes=1, skipped=0, failures=0, errors=0) >> >> >> -- >> Pavel >> >> >> >> 01.12.2021, 16:56, "Alexander Kanavin" <alex.kanavin@gmail.com>: >> >> Does the test fail without the change in lib/oepatch.py? Can you show how? >> >> Alex >> >> On Wed, 1 Dec 2021 at 15:17, Pavel Zhukov <pavel@zhukoff.net> wrote: >> >> From: Pavel Zhukov <pavel.zhukov@huawei.com> >> >> If PATCHTOOL="git" has been specified but workdir is not git repo >> bitbake fails to apply the patches. Fix this by initializing the repo >> before patching. >> This allows binary git patches to be applied. >> >> Signed-off-by: Pavel Zhukov <pavel.zhukov@huawei.com> >> --- >> meta/lib/oe/patch.py | 17 +++++++++++++++++ >> meta/lib/oeqa/selftest/cases/bbtests.py | 6 ++++++ >> 2 files changed, 23 insertions(+) >> >> diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py >> index 7cd8436da5..720c6f663c 100644 >> --- a/meta/lib/oe/patch.py >> +++ b/meta/lib/oe/patch.py >> @@ -52,6 +52,10 @@ def runcmd(args, dir = None): >> if dir: >> os.chdir(olddir) >> >> +def getstatusoutput(cmd): >> + import subprocess >> + return subprocess.getstatusoutput(cmd.split()) >> + >> class PatchError(Exception): >> def __init__(self, msg): >> self.msg = msg >> @@ -294,6 +298,19 @@ class GitApplyTree(PatchTree): >> PatchTree.__init__(self, dir, d) >> self.commituser = d.getVar('PATCH_GIT_USER_NAME') >> self.commitemail = d.getVar('PATCH_GIT_USER_EMAIL') >> + if not self._isInitialized(): >> + self._initRepo() >> + >> + def _isInitialized(self): >> + cmd = "git rev-parse --show-toplevel" >> + (status, output) = getstatusoutput(cmd) >> + ## Make sure we're in builddir to not break top-level git repos >> + return status == 0 and os.path.samedir(output, self.dir) >> + >> + def _initRepo(self): >> + runcmd("git init".split(), self.dir) >> + runcmd("git add .".split(), self.dir) >> + runcmd("git commit -a --allow-empty -m >> Patching_started".split(), self.dir) >> >> @staticmethod >> def extractPatchHeader(patchfile): >> diff --git a/meta/lib/oeqa/selftest/cases/bbtests.py >> b/meta/lib/oeqa/selftest/cases/bbtests.py >> index d4f6a08991..8c046074f6 100644 >> --- a/meta/lib/oeqa/selftest/cases/bbtests.py >> +++ b/meta/lib/oeqa/selftest/cases/bbtests.py >> @@ -294,3 +294,9 @@ INHERIT_remove = \"report-error\" >> >> test_recipe_summary_after = get_bb_var('SUMMARY', test_recipe) >> self.assertEqual(expected_recipe_summary, >> test_recipe_summary_after) >> + >> + def test_git_patchtool(self): >> + self.write_recipeinc('man-db', 'PATCHTOOL=\"git\"') >> + result = bitbake('man-db -c patch', ignore_status=False) >> + self.delete_recipeinc('man-db') >> + bitbake('-cclean man-db') >> -- >> 2.34.0 >> >> >> -=-=-=-=-=-=-=-=-=-=-=- >> Links: You receive all messages sent to this group. >> View/Reply Online (#159031): >> https://lists.openembedded.org/g/openembedded-core/message/159031 >> Mute This Topic: https://lists.openembedded.org/mt/87428914/1686489 >> Group Owner: openembedded-core+owner@lists.openembedded.org >> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [ >> alex.kanavin@gmail.com] >> -=-=-=-=-=-=-=-=-=-=-=- >> >> >>
diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py index 7cd8436da5..720c6f663c 100644 --- a/meta/lib/oe/patch.py +++ b/meta/lib/oe/patch.py @@ -52,6 +52,10 @@ def runcmd(args, dir = None): if dir: os.chdir(olddir) +def getstatusoutput(cmd): + import subprocess + return subprocess.getstatusoutput(cmd.split()) + class PatchError(Exception): def __init__(self, msg): self.msg = msg @@ -294,6 +298,19 @@ class GitApplyTree(PatchTree): PatchTree.__init__(self, dir, d) self.commituser = d.getVar('PATCH_GIT_USER_NAME') self.commitemail = d.getVar('PATCH_GIT_USER_EMAIL') + if not self._isInitialized(): + self._initRepo() + + def _isInitialized(self): + cmd = "git rev-parse --show-toplevel" + (status, output) = getstatusoutput(cmd) + ## Make sure we're in builddir to not break top-level git repos + return status == 0 and os.path.samedir(output, self.dir) + + def _initRepo(self): + runcmd("git init".split(), self.dir) + runcmd("git add .".split(), self.dir) + runcmd("git commit -a --allow-empty -m Patching_started".split(), self.dir) @staticmethod def extractPatchHeader(patchfile): diff --git a/meta/lib/oeqa/selftest/cases/bbtests.py b/meta/lib/oeqa/selftest/cases/bbtests.py index d4f6a08991..8c046074f6 100644 --- a/meta/lib/oeqa/selftest/cases/bbtests.py +++ b/meta/lib/oeqa/selftest/cases/bbtests.py @@ -294,3 +294,9 @@ INHERIT_remove = \"report-error\" test_recipe_summary_after = get_bb_var('SUMMARY', test_recipe) self.assertEqual(expected_recipe_summary, test_recipe_summary_after) + + def test_git_patchtool(self): + self.write_recipeinc('man-db', 'PATCHTOOL=\"git\"') + result = bitbake('man-db -c patch', ignore_status=False) + self.delete_recipeinc('man-db') + bitbake('-cclean man-db')