public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
* [PATCH v7 00/10] Improving base-apt usage
@ 2024-07-25 15:07 Uladzimir Bely
  2024-07-25 15:07 ` [PATCH v7 01/10] scripts: Add debrepo python script handling base-apt Uladzimir Bely
                   ` (10 more replies)
  0 siblings, 11 replies; 13+ messages in thread
From: Uladzimir Bely @ 2024-07-25 15:07 UTC (permalink / raw)
  To: isar-users

`base-apt` is a local apt repository containing all upstream (Debian, Raspberry Pi OS, Ubuntu...) packages needed for a particular build. This series implements upfront repository downloading. This is the first step towards local partial mirror management.

The current approach in `next`:

- On the first build, debootstrap and sbuild are used for building Isar artifacts. The packages downloaded from the Internet are cached in local directories.
- On the next build:
  - Analyze the logs from the previous build, save packages downloaded by the bootstraps, sbuilds and imagers into `base-apt`.
  - Use `base-apt` for bootstrapping, building and image creation.

Some issues with the current approach:

1. Different policies must be followed for the first and the subsequent builds.
2. As we have multiple versions of the same package from the main and security repositories and rely on build logs and `find` for populating `base-apt`, extra care must be taken to ensure that the right package version lands in `base-apt`.
3. We rely on internal implementation of `debootstrap` and `sbuild` for saving and reusing the packages. Changing to e.g. `mmdebstrap` breaks the unrelated `base-apt` functionality.
4. Source packages are stored in a different flat directory, `apt-get source` for upstream packages is not possible.
5. At the moment of `base-apt` creation all we have is the package name. The knowledge about the upstream repositories is lost and no local repository policy implementation is possible (e.g., for the "multiple products, multiple distros" use case).
6. For implementing further use cases like "fetch all sources necessary for bootstrapping the base system itself", additional logic is necessary.

The new approach:

- On the first build:
  - All packages necessary for bootstrapping and building are identified and downloaded upfront.
  - `base-apt` is used for bootstrapping, building and image creation.
- On the next build:
  - `base-apt` is used for bootstrapping, building and image creation.

This series addresses issues 1-5 and provides the architecture for implementing further use cases.

The new approach is enabled by default. Setting `ISAR_PREFETCH_BASE_APT` to zero falls back to the old approach.

The implementation uses `debrepo` script which can also be called manually for pre-fetching packages to the local 'base-apt' repository. It requires `python3-apt` to be installed on the build host. Some examples of its usage in standalone mode:

```
# Create local `/build/ba` repository sufficient to debootstrap Debian system with `armhf` architecture:
debrepo --init --workdir=/build/dr --repodir=/build/ba --arch=armhf

# Add some packages to this repo (e.g., build deps for some recipe):
debrepo --workdir=/build/dr locales gnupg

# Add srcpackages for some package to the repo:
debrepo --workdir=/build/dr --srcmode tzdata
```

Changes since v6:
 - Rebased on latest next.
 - Fixed possible stuck when `cache-deb-src` feature was enabled.
 - Fixed support of debian build profiles.
 - Moved locking of `debrepo` context from the bbclass to the script itself. This makes usage from Isar simpler.

Changes since v5:
 - Rebased on latest next.
 - Changed order of the patches.
 - Fixes in `debrepo` script that allow to use it outside Isar in standalone mode.

Changes since v4:
 - Rebased on latest next.
 - Rearranged patches since some of them are already in next.
 - Added possibility to select between new "prefetch" base-apt mode and old behaviour when it's populated on 2nd build with packages downloaded during 1st build. New behaviour is disabled by default, but enabled in local.conf.example for testing purposes.
 - Code passes both full and fast CI in both "old" and "new" modes.

Changes since v3:
 - Rebased on latest next.
 - Cross-building for raspberry supported.
 - Code passes both full and fast CI.

Changes since v2:
 - Populate base-apt before using at all steps of native build.

Changes since v1:
 - Rebased on latest next.
 - Updated patchset description.

Uladzimir Bely (10):
  scripts: Add debrepo python script handling base-apt
  meta: Add debrepo bbclass handling base-apt prefetching
  meta: Always use base-apt repo in local mode
  meta: Use cached base-apt repo to debootstrap
  base-apt: Predownload packages to base-apt before install
  meta: Add cache-deb-src functionality in base-apt mode
  testsuite: Set ISAR_PREFETCH_BASE_APT by default
  Disable deb-dl-dir in base-apt prefetch mode
  kas: Add PREFETCH_BASE_APT config entry
  ci_build.sh: Install python3-apt if not installed

 RECIPE-API-CHANGELOG.md                       |  10 +
 kas/opt/Kconfig                               |  13 +
 kas/opt/prefetch-base-apt.yaml                |   9 +
 meta-test/conf/local.conf.sample              |   3 +
 meta/classes/crossvars.bbclass                |   1 +
 meta/classes/deb-dl-dir.bbclass               |  21 +
 meta/classes/debrepo.bbclass                  |  90 +++
 meta/classes/dpkg-base.bbclass                |  27 +-
 meta/classes/dpkg.bbclass                     |   8 +
 meta/classes/image-locales-extension.bbclass  |   5 +
 meta/classes/image-tools-extension.bbclass    |  13 +
 meta/classes/rootfs.bbclass                   |  12 +-
 meta/conf/bitbake.conf                        |   5 +
 .../isar-bootstrap/isar-bootstrap-host.bb     |   2 +
 .../isar-bootstrap/isar-bootstrap.inc         |  99 ++-
 meta/recipes-devtools/base-apt/base-apt.bb    |  21 +-
 .../sbuild-chroot/sbuild-chroot-host.bb       |   2 +
 scripts/ci_build.sh                           |   8 +-
 scripts/debrepo                               | 590 ++++++++++++++++++
 testsuite/cibase.py                           |   4 +
 testsuite/cibuilder.py                        |   8 +-
 21 files changed, 927 insertions(+), 24 deletions(-)
 create mode 100644 kas/opt/prefetch-base-apt.yaml
 create mode 100644 meta/classes/debrepo.bbclass
 create mode 100755 scripts/debrepo

-- 
2.44.2

-- 
You received this message because you are subscribed to the Google Groups "isar-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/isar-users/20240725151006.2129-1-ubely%40ilbers.de.

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

end of thread, other threads:[~2024-08-02  5:37 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-25 15:07 [PATCH v7 00/10] Improving base-apt usage Uladzimir Bely
2024-07-25 15:07 ` [PATCH v7 01/10] scripts: Add debrepo python script handling base-apt Uladzimir Bely
2024-07-25 15:07 ` [PATCH v7 02/10] meta: Add debrepo bbclass handling base-apt prefetching Uladzimir Bely
2024-07-25 15:07 ` [PATCH v7 03/10] meta: Always use base-apt repo in local mode Uladzimir Bely
2024-07-25 15:07 ` [PATCH v7 04/10] meta: Use cached base-apt repo to debootstrap Uladzimir Bely
2024-07-25 15:07 ` [PATCH v7 05/10] base-apt: Predownload packages to base-apt before install Uladzimir Bely
2024-07-25 15:07 ` [PATCH v7 06/10] meta: Add cache-deb-src functionality in base-apt mode Uladzimir Bely
2024-07-25 15:07 ` [PATCH v7 07/10] testsuite: Set ISAR_PREFETCH_BASE_APT by default Uladzimir Bely
2024-07-25 15:07 ` [PATCH v7 08/10] Disable deb-dl-dir in base-apt prefetch mode Uladzimir Bely
2024-07-25 15:07 ` [PATCH v7 09/10] kas: Add PREFETCH_BASE_APT config entry Uladzimir Bely
2024-07-25 15:07 ` [PATCH v7 10/10] ci_build.sh: Install python3-apt if not installed Uladzimir Bely
2024-08-01  8:57 ` [PATCH v7 00/10] Improving base-apt usage 'MOESSBAUER, Felix' via isar-users
2024-08-02  5:37   ` Uladzimir Bely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox