diff options
| author | Peter Kjellerstedt <peter.kjellerstedt@axis.com> | 2016-01-27 15:39:52 +0100 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-03-20 09:55:53 +0000 |
| commit | 45a2977b83ff8f968d6ccfc5135dccffbe12c95e (patch) | |
| tree | 9af21a3a9e70eb45f2c0e5053ece6b4aa120e713 /meta | |
| parent | c8e5c38b8a36cbb45831fcd8469bd96068ae300c (diff) | |
| download | poky-45a2977b83ff8f968d6ccfc5135dccffbe12c95e.tar.gz | |
lib/oe/patch: Make GitApplyTree._applypatch() support read-only .git/hooks
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 master rev: a88d603b51a9ebb39210d54b667519acfbe465c3)
(From OE-Core rev: 09a2718cb030f8cce202ded0e823cadea4c71f6a)
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>
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
| -rw-r--r-- | meta/lib/oe/patch.py | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py index 2bf501e9e6..c25d3c7a0f 100644 --- a/meta/lib/oe/patch.py +++ b/meta/lib/oe/patch.py | |||
| @@ -383,14 +383,15 @@ class GitApplyTree(PatchTree): | |||
| 383 | reporoot = (runcmd("git rev-parse --show-toplevel".split(), self.dir) or '').strip() | 383 | reporoot = (runcmd("git rev-parse --show-toplevel".split(), self.dir) or '').strip() |
| 384 | if not reporoot: | 384 | if not reporoot: |
| 385 | raise Exception("Cannot get repository root for directory %s" % self.dir) | 385 | raise Exception("Cannot get repository root for directory %s" % self.dir) |
| 386 | commithook = os.path.join(reporoot, '.git', 'hooks', 'commit-msg') | 386 | hooks_dir = os.path.join(reporoot, '.git', 'hooks') |
| 387 | commithook_backup = commithook + '.devtool-orig' | 387 | hooks_dir_backup = hooks_dir + '.devtool-orig' |
| 388 | applyhook = os.path.join(reporoot, '.git', 'hooks', 'applypatch-msg') | 388 | if os.path.lexists(hooks_dir_backup): |
| 389 | applyhook_backup = applyhook + '.devtool-orig' | 389 | raise Exception("Git hooks backup directory already exists: %s" % hooks_dir_backup) |
| 390 | if os.path.exists(commithook): | 390 | if os.path.lexists(hooks_dir): |
| 391 | shutil.move(commithook, commithook_backup) | 391 | shutil.move(hooks_dir, hooks_dir_backup) |
| 392 | if os.path.exists(applyhook): | 392 | os.mkdir(hooks_dir) |
| 393 | shutil.move(applyhook, applyhook_backup) | 393 | commithook = os.path.join(hooks_dir, 'commit-msg') |
| 394 | applyhook = os.path.join(hooks_dir, 'applypatch-msg') | ||
| 394 | with open(commithook, 'w') as f: | 395 | with open(commithook, 'w') as f: |
| 395 | # NOTE: the formatting here is significant; if you change it you'll also need to | 396 | # NOTE: the formatting here is significant; if you change it you'll also need to |
| 396 | # change other places which read it back | 397 | # change other places which read it back |
| @@ -439,12 +440,9 @@ class GitApplyTree(PatchTree): | |||
| 439 | os.remove(tmpfile) | 440 | os.remove(tmpfile) |
| 440 | return output | 441 | return output |
| 441 | finally: | 442 | finally: |
| 442 | os.remove(commithook) | 443 | shutil.rmtree(hooks_dir) |
| 443 | os.remove(applyhook) | 444 | if os.path.lexists(hooks_dir_backup): |
| 444 | if os.path.exists(commithook_backup): | 445 | shutil.move(hooks_dir_backup, hooks_dir) |
| 445 | shutil.move(commithook_backup, commithook) | ||
| 446 | if os.path.exists(applyhook_backup): | ||
| 447 | shutil.move(applyhook_backup, applyhook) | ||
| 448 | 446 | ||
| 449 | 447 | ||
| 450 | class QuiltTree(PatchSet): | 448 | class QuiltTree(PatchSet): |
