poky/bitbake/lib/bb/fetch2
Gyorgy Sarvari 3d451f3452 bitbake: fetch2/git: verify if local clone contains tag
In case a recipe specifies a git SRC_URI along with revision and tag, but only the
revision is present in the local clone without the tag (because it was tagged after
it was cloned), then unpacking fails with the following error:

... rev-list -n 1 1.0 failed with exit code 128, output:\nfatal: ambiguous argument \'1.0\': unknown revision or path not in the working tree

This happens because the during the download step only the revision's presence is
verified to decide if the repository needs to be updated.

To avoid this, check also if the tag is present in the local repository, when the "tag"
tag is specified.

(Bitbake rev: 546b347b4d3d82c01ecc99f45296f66e44638adc)

Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2025-08-19 11:35:52 +01:00
..
__init__.py bitbake: fetch2: Ensure a valid symlink in PREMIRRORS case when using shallow cloning 2025-05-28 12:37:02 +01:00
az.py bitbake: fetch/az: Add sanity check and clarify documentation 2025-06-02 22:17:43 +01:00
bzr.py bitbake: logging: Make bitbake logger compatible with python logger 2021-02-10 23:48:16 +00:00
clearcase.py bitbake: fetch2: clearcase: remove double DL_DIR from localfile 2025-02-11 21:18:39 +00:00
crate.py bitbake: fetch2/crate: add upstream latest version check function 2024-05-08 14:51:43 +01:00
cvs.py bitbake: logging: Make bitbake logger compatible with python logger 2021-02-10 23:48:16 +00:00
gcp.py bitbake: fetch2: remove unnecessary unquote 2025-02-11 21:18:39 +00:00
git.py bitbake: fetch2/git: verify if local clone contains tag 2025-08-19 11:35:52 +01:00
gitannex.py bitbake: lib: remove unused imports 2020-01-19 13:31:05 +00:00
gitsm.py bitbake: fetch2: Fix LFS object checkout in submodules 2025-05-08 11:37:32 +01:00
gomod.py bitbake: fetch2/gomod: Fix mirroring problem 2025-03-27 11:19:33 +00:00
hg.py bitbake: fetch2: Add API for upstream source tracing 2023-10-15 09:12:43 +01:00
local.py bitbake: fetch2: local: use path variable 2025-02-11 21:18:39 +00:00
npm.py bitbake: fetch2/npm: Adding npmrc support for private registry authentication 2025-03-09 20:10:06 +00:00
npmsw.py bitbake: fetch2: npmsw: remove old lockfile format support 2025-01-08 11:34:04 +00:00
osc.py bitbake: bitbake: Add copyright headers where missing 2022-08-12 11:49:29 +01:00
perforce.py bitbake: fetch2/perforce: Fix typo 2021-10-26 13:47:24 +01:00
README bitbake: fetch: Add README on fetcher design constraints 2021-11-11 17:27:20 +00:00
repo.py bitbake: logging: Make bitbake logger compatible with python logger 2021-02-10 23:48:16 +00:00
s3.py bitbake: fetch2: remove unnecessary unquote 2025-02-11 21:18:39 +00:00
sftp.py bitbake: fetch2: remove unnecessary unquote 2025-02-11 21:18:39 +00:00
ssh.py bitbake: fetch2: ssh: use common localpath handling 2025-02-11 21:18:39 +00:00
svn.py bitbake: fetch2/svn: Fix mirroring issue with svn 2024-05-08 14:51:43 +01:00
wget.py bitbake: fetch2/wget: Keep query parameters in URL during checkstatus 2025-07-28 14:51:50 +01:00

There are expectations of users of the fetcher code. This file attempts to document
some of the constraints that are present. Some are obvious, some are less so. It is
documented in the context of how OE uses it but the API calls are generic.

a) network access for sources is only expected to happen in the do_fetch task.
   This is not enforced or tested but is required so that we can:

   i) audit the sources used (i.e. for license/manifest reasons) 
   ii) support offline builds with a suitable cache
   iii) allow work to continue even with downtime upstream
   iv) allow for changes upstream in incompatible ways
   v) allow rebuilding of the software in X years time

b) network access is not expected in do_unpack task.

c) you can take DL_DIR and use it as a mirror for offline builds.

d) access to the network is only made when explicitly configured in recipes
   (e.g. use of AUTOREV, or use of git tags which change revision).

e) fetcher output is deterministic (i.e. if you fetch configuration XXX now it 
   will match in future exactly in a clean build with a new DL_DIR).
   One specific pain point example are git tags. They can be replaced and change
   so the git fetcher has to resolve them with the network. We use git revisions
   where possible to avoid this and ensure determinism.

f) network access is expected to work with the standard linux proxy variables
   so that access behind firewalls works (the fetcher sets these in the 
   environment but only in the do_fetch tasks).

g) access during parsing has to be minimal, a "git ls-remote" for an AUTOREV 
   git recipe might be ok but you can't expect to checkout a git tree.

h) we need to provide revision information during parsing such that a version
   for the recipe can be constructed.

i) versions are expected to be able to increase in a way which sorts allowing 
   package feeds to operate (see PR server required for git revisions to sort).

j) API to query for possible version upgrades of a url is highly desireable to 
   allow our automated upgrage code to function (it is implied this does always 
   have network access).

k) Where fixes or changes to behaviour in the fetcher are made, we ask that 
   test cases are added (run with "bitbake-selftest bb.tests.fetch"). We do 
   have fairly extensive test coverage of the fetcher as it is the only way
   to track all of its corner cases, it still doesn't give entire coverage 
   though sadly.
   
l) If using tools during parse time, they will have to be in ASSUME_PROVIDED
   in OE's context as we can't build git-native, then parse a recipe and use
   git ls-remote.

Not all fetchers support all features, autorev is optional and doesn't make
sense for some. Upgrade detection means different things in different contexts
too.