All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: Why does setting PATCHTOOL="git" result in do_patch trying to look at git hooks in the host repo?
       [not found] <1614E8638286601C.21938@lists.yoctoproject.org>
@ 2020-06-03 18:44 ` Sean McKay
  0 siblings, 0 replies; 2+ messages in thread
From: Sean McKay @ 2020-06-03 18:44 UTC (permalink / raw)
  To: McKay, Sean, yocto

[-- Attachment #1: Type: text/plain, Size: 4431 bytes --]

I retract my question and apologize for being an idiot...
Apparently somewhere along the line while I wasn't paying attention, the entirety of that upstream git repo got pulled into our local codebase, so I was trying to use git patching on a directory fetched with file://

Sigh... time to go fix it. At least it makes sense.

Cheers!
-Sean

From: yocto@lists.yoctoproject.org <yocto@lists.yoctoproject.org> On Behalf Of Sean McKay
Sent: Tuesday, June 2, 2020 7:41 PM
To: yocto@lists.yoctoproject.org
Subject: [yocto] Why does setting PATCHTOOL="git" result in do_patch trying to look at git hooks in the host repo?

Hi all,

I have a component in our build that's pulling from an upstream git server, so I decided to set the PATCHTOOL="git" so that it's easier to determine in the local repository what patches have been applied (since using the git PATCHTOOL results in full commits, whereas quilt just makes a mess and everything goes into the child git repo as a giant unstaged change).

However, in testing, I'm hitting this failure if I'm building in a git worktree:
*** 0505:        os.mkdir(hooks_dir)
     0506:        commithook = os.path.join(hooks_dir, 'commit-msg')
     0507:        applyhook = os.path.join(hooks_dir, 'applypatch-msg')
     0508:        with open(commithook, 'w') as f:
     0509:            # NOTE: the formatting here is significant; if you change it you'll also need to
Exception: NotADirectoryError: [Errno 20] Not a directory: '/ws/mckays/zeus-test/.git/hooks'

Now, to be fair, it's quite correct - that isn't a directory, since that's not how git worktrees operate.
I can probably come up with a patch to submit upstream to correct this behavior, but I can't fathom why the patcher should logically be trying to do anything with the parent git repo for any reason. And I can solve this for git worktrees, but what if someone just has a tarball and isn't trying to build inside git at all - wouldn't they hit the same failure?

I'd appreciate any clarity you can provide. Thanks!!!

-Sean


Full stack trace:
The stack trace of python calls that resulted in this exception/failure was:
File: 'exec_python_func() autogenerated', lineno: 2, function: <module>
    0001:
*** 0002:patch_do_patch(d)
     0003:
File: '/ws/mckays/zeus-test/yocto/poky/meta/classes/patch.bbclass', lineno: 145, function: patch_do_patch
     0141:        except Exception as exc:
     0142:            bb.utils.remove(process_tmpdir, True)
     0143:            bb.fatal(str(exc))
     0144:        try:
*** 0145:            resolver.Resolve()
     0146:        except bb.BBHandledException as e:
     0147:            bb.utils.remove(process_tmpdir, True)
     0148:            bb.fatal(str(e))
     0149:
File: '/ws/mckays/zeus-test/yocto/poky/meta/lib/oe/patch.py', lineno: 716, function: Resolve
     0712:    def Resolve(self):
     0713:        olddir = os.path.abspath(os.curdir)
     0714:        os.chdir(self.patchset.dir)
     0715:        try:
*** 0716:            self.patchset.Push()
     0717:        except Exception:
     0718:            import sys
     0719:            os.chdir(olddir)
     0720:            raise
File: '/ws/mckays/zeus-test/yocto/poky/meta/lib/oe/patch.py', lineno: 267, function: Push
     0263:            else:
     0264:                next = 0
     0265:
     0266:            bb.note("applying patch %s" % self.patches[next])
*** 0267:            ret = self._applypatch(self.patches[next], force)
     0268:
     0269:            self._current = next
     0270:            return ret
     0271:
File: '/ws/mckays/zeus-test/yocto/poky/meta/lib/oe/patch.py', lineno: 505, function: _applypatch
     0501:        if os.path.lexists(hooks_dir_backup):
     0502:            raise Exception("Git hooks backup directory already exists: %s" % hooks_dir_backup)
     0503:        if os.path.lexists(hooks_dir):
     0504:            shutil.move(hooks_dir, hooks_dir_backup)
*** 0505:        os.mkdir(hooks_dir)
     0506:        commithook = os.path.join(hooks_dir, 'commit-msg')
     0507:        applyhook = os.path.join(hooks_dir, 'applypatch-msg')
     0508:        with open(commithook, 'w') as f:
     0509:            # NOTE: the formatting here is significant; if you change it you'll also need to
Exception: NotADirectoryError: [Errno 20] Not a directory: '/ws/mckays/zeus-test/.git/hooks'


[-- Attachment #2: Type: text/html, Size: 15811 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Why does setting PATCHTOOL="git" result in do_patch trying to look at git hooks in the host repo?
@ 2020-06-03  2:41 Sean McKay
  0 siblings, 0 replies; 2+ messages in thread
From: Sean McKay @ 2020-06-03  2:41 UTC (permalink / raw)
  To: yocto

[-- Attachment #1: Type: text/plain, Size: 3800 bytes --]

Hi all,

I have a component in our build that's pulling from an upstream git server, so I decided to set the PATCHTOOL="git" so that it's easier to determine in the local repository what patches have been applied (since using the git PATCHTOOL results in full commits, whereas quilt just makes a mess and everything goes into the child git repo as a giant unstaged change).

However, in testing, I'm hitting this failure if I'm building in a git worktree:
*** 0505:        os.mkdir(hooks_dir)
     0506:        commithook = os.path.join(hooks_dir, 'commit-msg')
     0507:        applyhook = os.path.join(hooks_dir, 'applypatch-msg')
     0508:        with open(commithook, 'w') as f:
     0509:            # NOTE: the formatting here is significant; if you change it you'll also need to
Exception: NotADirectoryError: [Errno 20] Not a directory: '/ws/mckays/zeus-test/.git/hooks'

Now, to be fair, it's quite correct - that isn't a directory, since that's not how git worktrees operate.
I can probably come up with a patch to submit upstream to correct this behavior, but I can't fathom why the patcher should logically be trying to do anything with the parent git repo for any reason. And I can solve this for git worktrees, but what if someone just has a tarball and isn't trying to build inside git at all - wouldn't they hit the same failure?

I'd appreciate any clarity you can provide. Thanks!!!

-Sean


Full stack trace:
The stack trace of python calls that resulted in this exception/failure was:
File: 'exec_python_func() autogenerated', lineno: 2, function: <module>
    0001:
*** 0002:patch_do_patch(d)
     0003:
File: '/ws/mckays/zeus-test/yocto/poky/meta/classes/patch.bbclass', lineno: 145, function: patch_do_patch
     0141:        except Exception as exc:
     0142:            bb.utils.remove(process_tmpdir, True)
     0143:            bb.fatal(str(exc))
     0144:        try:
*** 0145:            resolver.Resolve()
     0146:        except bb.BBHandledException as e:
     0147:            bb.utils.remove(process_tmpdir, True)
     0148:            bb.fatal(str(e))
     0149:
File: '/ws/mckays/zeus-test/yocto/poky/meta/lib/oe/patch.py', lineno: 716, function: Resolve
     0712:    def Resolve(self):
     0713:        olddir = os.path.abspath(os.curdir)
     0714:        os.chdir(self.patchset.dir)
     0715:        try:
*** 0716:            self.patchset.Push()
     0717:        except Exception:
     0718:            import sys
     0719:            os.chdir(olddir)
     0720:            raise
File: '/ws/mckays/zeus-test/yocto/poky/meta/lib/oe/patch.py', lineno: 267, function: Push
     0263:            else:
     0264:                next = 0
     0265:
     0266:            bb.note("applying patch %s" % self.patches[next])
*** 0267:            ret = self._applypatch(self.patches[next], force)
     0268:
     0269:            self._current = next
     0270:            return ret
     0271:
File: '/ws/mckays/zeus-test/yocto/poky/meta/lib/oe/patch.py', lineno: 505, function: _applypatch
     0501:        if os.path.lexists(hooks_dir_backup):
     0502:            raise Exception("Git hooks backup directory already exists: %s" % hooks_dir_backup)
     0503:        if os.path.lexists(hooks_dir):
     0504:            shutil.move(hooks_dir, hooks_dir_backup)
*** 0505:        os.mkdir(hooks_dir)
     0506:        commithook = os.path.join(hooks_dir, 'commit-msg')
     0507:        applyhook = os.path.join(hooks_dir, 'applypatch-msg')
     0508:        with open(commithook, 'w') as f:
     0509:            # NOTE: the formatting here is significant; if you change it you'll also need to
Exception: NotADirectoryError: [Errno 20] Not a directory: '/ws/mckays/zeus-test/.git/hooks'


[-- Attachment #2: Type: text/html, Size: 14813 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-06-03 18:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1614E8638286601C.21938@lists.yoctoproject.org>
2020-06-03 18:44 ` Why does setting PATCHTOOL="git" result in do_patch trying to look at git hooks in the host repo? Sean McKay
2020-06-03  2:41 Sean McKay

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.