From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6542765999964291072 X-Received: by 10.28.26.147 with SMTP id a141mr147290wma.12.1523356419949; Tue, 10 Apr 2018 03:33:39 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 10.28.209.78 with SMTP id i75ls2177113wmg.9.canary-gmail; Tue, 10 Apr 2018 03:33:39 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+qUPx74Kjn5eNFO6UmcOqSDPkd+pXlkGVhwQ0GgcwVZYGanATVlW0IjXiTiXihrc73rmhL X-Received: by 10.28.113.65 with SMTP id m62mr135021wmc.24.1523356419517; Tue, 10 Apr 2018 03:33:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523356419; cv=none; d=google.com; s=arc-20160816; b=zybYpjvhaEAznCotnNpjHZcLeLTGNHpWAF5Z9JhoEJqZzjnZxrX/ADJoHBKnvtsgwL BY26j5OHMWD9rz3dfiQZpbgqeYu0+nfklR+UP8e6Sk2OKSr/x2ov6uqf62RHuf1OE0Pq AedYKl4DiaacSeTeuVXZVtu3dJeWYTds6wq1A9u6BtMzTNgRcF7Kv4yejQusn2OeKCST Du8He3VVe0S8EshG1EDxcP6z3i6WDv9oHdMvubSQDKnRQJTD5i2V5/BgzD1kOPQDnNSM c2gLuY6WmPx2M5mT3WlT3e+/Muoi5+xzWyFAkgLFFqxlKJgWDL+zL1d28zv2W91baGFJ N7vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=+75JsX4lkXe6RYbqG1XzIpmbVc8ewSBBGjO2r1IYByo=; b=peltMRuKYZepftQ/JygXCzk40uRiTeeo+eiBBZf5tbKw4JYrGBW5NeXV0KQxA6d3CU Kufw8vmqaFpjLe2dptnf4t89qZehSa1j/4Aj+mBYOZmKm0z1Ly0erRWOIuJZ6OFFDvl6 eBt02WwTwdLF0y/7ZRev0ixJq/ggdb5X9EVb63KLxs/19F8WXM37Hs8OIJkM3Qf9GpLF EChAHZCBGl6wlEX3W+ln/n+kpN/koVhas4Hc/Kq4OP2g2y2mqpvyrp278plzR8u+Csus Rv63DeusrskeiqmL8GYHyvERcvE5FT6AXaf/ZZsKKPv4gYjvv5OYGRqvMOxtiWhBOz7T /icA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of claudius.heine.ext@siemens.com designates 192.35.17.2 as permitted sender) smtp.mailfrom=claudius.heine.ext@siemens.com Return-Path: Received: from thoth.sbs.de (thoth.sbs.de. [192.35.17.2]) by gmr-mx.google.com with ESMTPS id v195si60401wmf.0.2018.04.10.03.33.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Apr 2018 03:33:39 -0700 (PDT) Received-SPF: pass (google.com: domain of claudius.heine.ext@siemens.com designates 192.35.17.2 as permitted sender) client-ip=192.35.17.2; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of claudius.heine.ext@siemens.com designates 192.35.17.2 as permitted sender) smtp.mailfrom=claudius.heine.ext@siemens.com Received: from mail2.sbs.de (mail2.sbs.de [192.129.41.66]) by thoth.sbs.de (8.15.2/8.15.2) with ESMTPS id w3AAXcmM015538 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Apr 2018 12:33:38 +0200 Received: from ring.ppmd.siemens.net (linux-ses-ext02.ppmd.siemens.net [139.25.69.226]) by mail2.sbs.de (8.15.2/8.15.2) with ESMTP id w3AAXcPL026958; Tue, 10 Apr 2018 12:33:38 +0200 From: claudius.heine.ext@siemens.com To: isar-users@googlegroups.com Cc: Claudius Heine Subject: [PATCH 1/1] isar-bootstrap: implement DISTRO_APT_PREMIRRORS feature Date: Tue, 10 Apr 2018 12:33:12 +0200 Message-Id: <20180410103312.26468-2-claudius.heine.ext@siemens.com> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180410103312.26468-1-claudius.heine.ext@siemens.com> References: <20180410103312.26468-1-claudius.heine.ext@siemens.com> X-TUID: HaegoDT8f0AN From: Claudius Heine With this patch its now possible to overwrite Debian repositories from the 'APT_PREMIRRORS' variable. The format of this variable is similar to how OpenEmbedded handels the PREMIRROS variable: DISTRO_APT_PREMIRRORS = "source-uri-regex1 replace-uri-string1 \n \ source-uri-regex1 replace-uri-string2 \n \ ... " So for instance to select a different debian upstream mirror: DISTRO_APT_PREMIRRORS += "ftp\.(\S+\.)?debian.org ftp.us.debian.org \n" Signed-off-by: Claudius Heine --- meta/recipes-core/isar-bootstrap/isar-bootstrap.bb | 50 +++++++++++++++++++--- 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/meta/recipes-core/isar-bootstrap/isar-bootstrap.bb b/meta/recipes-core/isar-bootstrap/isar-bootstrap.bb index a38dd88..3fbf890 100644 --- a/meta/recipes-core/isar-bootstrap/isar-bootstrap.bb +++ b/meta/recipes-core/isar-bootstrap/isar-bootstrap.bb @@ -83,7 +83,44 @@ def parse_aptsources_list_line(source_list_line): components = " ".join(s.split()) - return type, options, source, suite, components + return [type, options, source, suite, components] + +def get_apt_source_mirror(d, aptsources_entry_list): + import re + + premirrors = d.getVar('DISTRO_APT_PREMIRRORS', True) or "" + mirror_list = [entry.split() + for entry in premirrors.split('\n') + if any(entry)] + + for regex, replace in mirror_list: + match = re.search(regex, aptsources_entry_list[2]) + + if match: + new_aptsources_entry_list = aptsources_entry_list.copy() + new_aptsources_entry_list[2] = re.sub(regex, replace, + aptsources_entry_list[2], + count = 1) + return new_aptsources_entry_list + + return aptsources_entry_list + +def aggregate_aptsources_list(d, file_list, file_out): + import shutil + + with open(file_out, "wb") as out_fd: + for entry in file_list: + entry_real = bb.parse.resolve_file(entry, d) + with open(entry_real, "r") as in_fd: + for line in in_fd: + parsed = parse_aptsources_list_line(line) + if parsed: + parsed = get_apt_source_mirror(d, parsed) + out_fd.write(" ".join(parsed).encode()) + else: + out_fd.write(line.encode()) + out_fd.write("\n".encode()) + out_fd.write("\n".encode()) def get_distro_primary_source_entry(d): apt_sources_list = (d.getVar("DISTRO_APT_SOURCES", True) or "").split() @@ -93,10 +130,10 @@ def get_distro_primary_source_entry(d): for line in in_fd: parsed = parse_aptsources_list_line(line) if parsed: - type, _, source, suite, components = parsed - if type == "deb": - return source, suite, components - return "", "", "" + parsed = get_apt_source_mirror(d, parsed) + if parsed[0] == "deb": + return parsed[2:] + return ["", "", ""] def get_distro_source(d): return get_distro_primary_source_entry(d)[0] @@ -141,12 +178,13 @@ python do_apt_config_prepare() { apt_sources_out = d.getVar("APTSRCS", True) apt_sources_list = (d.getVar("DISTRO_APT_SOURCES", True) or "").split() - aggregate_files(d, apt_sources_list, apt_sources_out) + aggregate_aptsources_list(d, apt_sources_list, apt_sources_out) } addtask apt_config_prepare before do_build after do_generate_keyring do_bootstrap[stamp-extra-info] = "${DISTRO}-${DISTRO_ARCH}" do_bootstrap[vardeps] += "DISTRO_APT_SOURCES" +do_bootstrap[vardeps] += "DISTRO_APT_PREMIRRORS" do_bootstrap() { if [ -e "${ROOTFSDIR}" ]; then sudo umount -l "${ROOTFSDIR}/dev" || true -- 2.16.3