1

I have a bunch of Yocto recipe files that contain the configs for various git repositories in the format

SRC_URI = "git://XXX;protocol=ssh;branch=YYY;"
SRCREV = "abc123"

I am wondering if I can use these files to only clone the git repositories at the configured branch + commit hash. I want to then build these repos separately (not using Yocto/Bitbake)

I came across git.py from Bitbake's source code which seems to perform the clone operations in Bitbake. I could write a wrapper around this module, but wondering if there is a pre-built command that would let me invoke this module using Bitbake.

Daddy
  • 61
  • 2

1 Answers1

1

You can see in openembedded/bitbake/lib/bb/fetch2/git.py an example of clone as you mention:

        # If the repo still doesn't exist, fallback to cloning it
        if not os.path.exists(ud.clonedir):
            # We do this since git will use a "-l" option automatically for local urls where possible
            if repourl.startswith("file://"):
                repourl = repourl[7:]
            clone_cmd = "LANG=C %s clone --bare --mirror %s %s --progress" % (ud.basecmd, shlex.quote(repourl), ud.clonedir)
            if ud.proto.lower() != 'file':
                bb.fetch2.check_network_access(d, clone_cmd, ud.url)
            progresshandler = GitProgressHandler(d)
            runfetchcmd(clone_cmd, d, log=progresshandler)

You would have to code something similar (without the --bare option in your case) to clone your own repository.


The OP Daddy adds in the comments:

I unblocked myself by writing a simple shell script that greps for the SRC_URI/SRCREV and extracts the relevant details.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I unblocked myself by writing a simple shell script that greps for the SRC_URI/SRCREV and extracts the relevant details, I will try this soon. Thanks! – Daddy Nov 17 '22 at 19:59
  • @Daddy That is a possible workaround indeed. I have included your comment in the answer for more visibility. – VonC Nov 17 '22 at 21:08