mirror of
https://git.yoctoproject.org/poky
synced 2026-06-02 01:19:52 +00:00
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>
This commit is contained in:
committed by
Richard Purdie
parent
c8e5c38b8a
commit
45a2977b83
+12
-14
@@ -383,14 +383,15 @@ class GitApplyTree(PatchTree):
|
|||||||
reporoot = (runcmd("git rev-parse --show-toplevel".split(), self.dir) or '').strip()
|
reporoot = (runcmd("git rev-parse --show-toplevel".split(), self.dir) or '').strip()
|
||||||
if not reporoot:
|
if not reporoot:
|
||||||
raise Exception("Cannot get repository root for directory %s" % self.dir)
|
raise Exception("Cannot get repository root for directory %s" % self.dir)
|
||||||
commithook = os.path.join(reporoot, '.git', 'hooks', 'commit-msg')
|
hooks_dir = os.path.join(reporoot, '.git', 'hooks')
|
||||||
commithook_backup = commithook + '.devtool-orig'
|
hooks_dir_backup = hooks_dir + '.devtool-orig'
|
||||||
applyhook = os.path.join(reporoot, '.git', 'hooks', 'applypatch-msg')
|
if os.path.lexists(hooks_dir_backup):
|
||||||
applyhook_backup = applyhook + '.devtool-orig'
|
raise Exception("Git hooks backup directory already exists: %s" % hooks_dir_backup)
|
||||||
if os.path.exists(commithook):
|
if os.path.lexists(hooks_dir):
|
||||||
shutil.move(commithook, commithook_backup)
|
shutil.move(hooks_dir, hooks_dir_backup)
|
||||||
if os.path.exists(applyhook):
|
os.mkdir(hooks_dir)
|
||||||
shutil.move(applyhook, applyhook_backup)
|
commithook = os.path.join(hooks_dir, 'commit-msg')
|
||||||
|
applyhook = os.path.join(hooks_dir, 'applypatch-msg')
|
||||||
with open(commithook, 'w') as f:
|
with open(commithook, 'w') as f:
|
||||||
# NOTE: the formatting here is significant; if you change it you'll also need to
|
# NOTE: the formatting here is significant; if you change it you'll also need to
|
||||||
# change other places which read it back
|
# change other places which read it back
|
||||||
@@ -439,12 +440,9 @@ class GitApplyTree(PatchTree):
|
|||||||
os.remove(tmpfile)
|
os.remove(tmpfile)
|
||||||
return output
|
return output
|
||||||
finally:
|
finally:
|
||||||
os.remove(commithook)
|
shutil.rmtree(hooks_dir)
|
||||||
os.remove(applyhook)
|
if os.path.lexists(hooks_dir_backup):
|
||||||
if os.path.exists(commithook_backup):
|
shutil.move(hooks_dir_backup, hooks_dir)
|
||||||
shutil.move(commithook_backup, commithook)
|
|
||||||
if os.path.exists(applyhook_backup):
|
|
||||||
shutil.move(applyhook_backup, applyhook)
|
|
||||||
|
|
||||||
|
|
||||||
class QuiltTree(PatchSet):
|
class QuiltTree(PatchSet):
|
||||||
|
|||||||
Reference in New Issue
Block a user