From: Aliaksei Karpovich <akarpovich@ilbers.de>
To: isar-users@googlegroups.com
Cc: Aliaksei Karpovich <akarpovich@ilbers.de>
Subject: [v8 14/14] debrepo: Add using override for reprepro
Date: Mon, 27 Jul 2026 13:26:32 +0200 [thread overview]
Message-ID: <20260727112812.2255297-15-akarpovich@ilbers.de> (raw)
In-Reply-To: <20260727112812.2255297-1-akarpovich@ilbers.de>
It fixes an issue when bootstrap image in case of offline build
is different than online. It happens because some packages has
different Priority field because of override.
F.e. libtext-wrapi18n-perl in trixie:
- inside deb package: 'Priority: required'
- inside Packages from deb repo: 'Priority: optional'
Solution: download the override file from repo and pass it to
reprepro.
Signed-off-by: Aliaksei Karpovich <akarpovich@ilbers.de>
---
scripts/debrepo | 88 ++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 79 insertions(+), 9 deletions(-)
diff --git a/scripts/debrepo b/scripts/debrepo
index 81056c3a..4a74be33 100755
--- a/scripts/debrepo
+++ b/scripts/debrepo
@@ -89,6 +89,8 @@ import shutil
import subprocess
import pickle
import urllib.parse
+import urllib.request
+import gzip
import apt_pkg
import apt.progress.base
@@ -96,8 +98,38 @@ import apt.progress.base
REPREPRO_TIMEOUT = 1200
+def parse_aptsources_list_line(source_list_line):
+ import re
+
+ s = source_list_line.strip()
+
+ if not s or s.startswith("#"):
+ return None
+
+ type, s = re.split("\s+", s, maxsplit=1)
+ if type not in ["deb", "deb-src"]:
+ return None
+
+ options = ""
+ options_match = re.match("\[\s*(\S+=\S+(?=\s))*\s*(\S+=\S+)\s*\]\s+", s)
+ if options_match:
+ options = options_match.group(0).strip()
+ s = s[options_match.end():]
+
+ source, s = re.split("\s+", s, maxsplit=1)
+
+ if s.startswith("/"):
+ suite = ""
+ else:
+ suite, s = re.split("\s+", s, maxsplit=1)
+
+ components = " ".join(s.split())
+
+ return [type, options, source, suite, components]
class DebRepo(object):
+ BOOTSTRAP_LIST = "/etc/apt/sources.list.d/bootstrap.list"
+
class DebRepoCtx(object):
def __init__(self, workdir):
self.distro = "debian"
@@ -181,9 +213,9 @@ class DebRepo(object):
with open(f"{self.workdir}/var/lib/dpkg/status", "w"):
pass
- os.makedirs(f"{self.workdir}/etc/apt/sources.list.d", exist_ok=True)
+ srcfile = f"{self.workdir}{self.BOOTSTRAP_LIST}"
+ os.makedirs(os.path.dirname(srcfile), exist_ok=True)
- srcfile = f"{self.workdir}/etc/apt/sources.list.d/bootstrap.list"
if aptsrcsfile and os.path.exists(aptsrcsfile):
shutil.copy(aptsrcsfile, srcfile)
else:
@@ -201,13 +233,51 @@ class DebRepo(object):
def create_repo_dist(self):
conf_dir = f"{self.ctx.repodir}/{self.ctx.distro}/conf"
os.makedirs(conf_dir, exist_ok=True)
- if not os.path.exists(f"{conf_dir}/distributions"):
- with open(f"{conf_dir}/distributions", "w") as f:
- f.write(f"Codename: {self.ctx.codename}\n")
- f.write(
- "Architectures: "
- "i386 armhf arm64 amd64 mipsel riscv64 source\n")
- f.write("Components: main\n")
+ override_fname = "override"
+ self.create_override(f"{conf_dir}/{override_fname}")
+ with open(f"{conf_dir}/distributions", "w") as f:
+ f.write(f"Codename: {self.ctx.codename}\n")
+ f.write(
+ "Architectures: "
+ "i386 armhf arm64 amd64 mipsel riscv64 source\n")
+ f.write("Components: main\n")
+ f.write(f"DebOverride: {override_fname}\n")
+
+ def create_override(self, override_file):
+ deb_override_name = f"override.{self.ctx.codename}.main.gz"
+ deb_override_file = f"{self.workdir}/tmp/{deb_override_name}"
+ if (not os.path.exists(deb_override_file) or
+ os.path.getsize(deb_override_file) < 1):
+ # Extract source URL
+ srcfile = f"{self.workdir}{self.BOOTSTRAP_LIST}"
+ with open(srcfile, "r") as f:
+ for line in f:
+ entry = parse_aptsources_list_line(line)
+ if entry:
+ source_url = entry[2]
+ # Download deb override file
+ self.fetch_file(f"{source_url}/indices/{deb_override_name}")
+ break
+
+ with open(override_file, "w") as f_out:
+ # Unpack deb override file
+ with gzip.open(deb_override_file, "rt", encoding="utf-8") as f:
+ # Convert deb override to reprepro override
+ for line in f:
+ fields = line.strip().split()
+
+ if len(fields) < 3:
+ continue
+
+ package = fields[0]
+ priority = fields[1]
+ section = fields[2]
+
+ f_out.write(f"{package} Priority {priority}\n")
+ f_out.write(f"{package} Section {section}\n")
+
+ if f_out.tell() < 1:
+ print("WARNING: override file is empty!")
def apt_config(self, init, crossbuild):
if not init and self.ctx.compatarch:
--
2.43.0
--
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 visit https://groups.google.com/d/msgid/isar-users/20260727112812.2255297-15-akarpovich%40ilbers.de.
next prev parent reply other threads:[~2026-07-27 11:29 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-27 11:26 [v8 00/14] Improving base-apt usage Aliaksei Karpovich
2026-07-27 11:26 ` [v8 01/14] scripts: Add debrepo python script handling base-apt Aliaksei Karpovich
2026-07-27 12:36 ` 'Quirin Gylstorff' via isar-users
2026-07-29 9:03 ` Aliaksei Karpovich
2026-07-27 11:26 ` [v8 02/14] meta: Add debrepo bbclass handling base-apt prefetching Aliaksei Karpovich
2026-07-27 11:26 ` [v8 03/14] meta: Always use base-apt repo in local mode Aliaksei Karpovich
2026-07-27 11:26 ` [v8 04/14] meta: Use cached base-apt repo to bootstrap Aliaksei Karpovich
2026-07-27 11:26 ` [v8 05/14] base-apt: Predownload packages to base-apt before install Aliaksei Karpovich
2026-07-27 11:26 ` [v8 06/14] meta: Add cache-deb-src functionality in base-apt mode Aliaksei Karpovich
2026-07-27 11:26 ` [v8 07/14] testsuite: Set ISAR_PREFETCH_BASE_APT by default Aliaksei Karpovich
2026-07-27 11:26 ` [v8 08/14] Disable deb-dl-dir in base-apt prefetch mode Aliaksei Karpovich
2026-07-27 11:26 ` [v8 09/14] kas: Add PREFETCH_BASE_APT config entry Aliaksei Karpovich
2026-07-27 11:53 ` 'Jan Kiszka' via isar-users
2026-07-29 8:59 ` Aliaksei Karpovich
2026-07-27 11:26 ` [v8 10/14] ci_build.sh: Install python3-apt if not installed Aliaksei Karpovich
2026-07-27 11:26 ` [v8 11/14] rootfs: Fix URL parsing Aliaksei Karpovich
2026-07-27 11:45 ` 'Jan Kiszka' via isar-users
2026-07-29 8:54 ` Aliaksei Karpovich
2026-07-27 11:26 ` [v8 12/14] rootfs: Add version and arch for downloaded package Aliaksei Karpovich
2026-07-27 11:46 ` 'Jan Kiszka' via isar-users
2026-07-28 8:25 ` 'MOESSBAUER, Felix' via isar-users
2026-07-29 8:55 ` Aliaksei Karpovich
2026-07-30 6:33 ` 'Jan Kiszka' via isar-users
2026-07-30 7:09 ` 'MOESSBAUER, Felix' via isar-users
2026-07-27 11:26 ` [v8 13/14] sbom-chroot: Fix python3-apt dependency Aliaksei Karpovich
2026-07-27 11:49 ` 'Jan Kiszka' via isar-users
2026-07-27 11:26 ` Aliaksei Karpovich [this message]
2026-07-27 12:35 ` [v8 14/14] debrepo: Add using override for reprepro 'Quirin Gylstorff' via isar-users
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260727112812.2255297-15-akarpovich@ilbers.de \
--to=akarpovich@ilbers.de \
--cc=isar-users@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox