Skip to contentSkip to conversation

fetch: Add README on fetcher design constraints

PATCH In review Richard Purdie 2 participants 2 messages Nov 11, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fetch: Add README on fetcher design constraints

There have been requests to better document the contraints of fetcher design and operation. This README attempts to start that.

---
 lib/bb/fetch2/README | 58 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)
 create mode 100644 lib/bb/fetch2/README
lib/bb/fetch2/README new file +58 -0
new file mode 100644
index 0000000000..eb214709e5
@@ -0,0 +1,58 @@
+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 step.
+   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
+
+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 out 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 it's 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 to 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.
+
Signature · 1 line
2.32.0
#1 lore raw

Hi Richard,

Quoted 1 line · Richard Purdie

There have been requests to better document the contraints of fetcher

s/contraints/constraints/

Quoted 14 lines

design and operation. This README attempts to start that.

---
 lib/bb/fetch2/README | 58 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)
 create mode 100644 lib/bb/fetch2/README
lib/bb/fetch2/README new file +0 -0
new file mode 100644
index 0000000000..eb214709e5

lib/bb/fetch2/README line 5

Quoted 5 lines
lib/bb/fetch2/README new file +5 -0
@@ -0,0 +1,58 @@
+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 step.

s/step/task/ ?

lib/bb/fetch2/README line 15

Quoted 10 lines
lib/bb/fetch2/README new file +10 -0
+   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
+

s/do_unpack/do_unpack task/ ?

lib/bb/fetch2/README line 22

Quoted 7 lines
lib/bb/fetch2/README new file +7 -0
+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 

Surprising place for a newline, shouldn't the ( start above?

Quoted 10 lines
lib/bb/fetch2/README new file +10 -0
+    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 

lib/bb/fetch2/README line 42

Quoted 10 lines
lib/bb/fetch2/README new file +10 -0
+   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 out automated upgrage code to function (it is implied this does always 

s/out/our/ ?

lib/bb/fetch2/README line 48

Quoted 6 lines
lib/bb/fetch2/README new file +6 -0
+   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 it's corner cases, it still doesn't give entire coverage 

s/it's/its/

lib/bb/fetch2/README line 54

Quoted 6 lines
lib/bb/fetch2/README new file +6 -0
+   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 to ls-remote.
+

s/to// ?

As a side note, there's some inconsistency on how you end the list items, sometimes with a dot, sometimes not. Some items such as c, h and k are written in "active" form (as opposed to passive form). e.g. I'd reword to something like:

c) DL_DIR alone - as a mirror - shall be enough for offline builds.

Not a biggie but since I'm sending a mail anyway, better say it :)

Cheers,
Quentin