소스 검색

isar-bootstrap: Consolidate common host and target bits

Avoids duplicating too much identical logic.

The key element is introducing DISTRO_VARS_PREFIX that adds "HOST_" for
the buildchroot-host case.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Jan Kiszka 3 년 전
부모
커밋
3c7d43aa8c

+ 2 - 29
meta/recipes-core/isar-bootstrap/isar-bootstrap-host.bb

@@ -9,42 +9,15 @@ Description = "Minimal host Debian root file system"
 
 DEPLOY_ISAR_BOOTSTRAP = "${DEPLOY_DIR_BOOTSTRAP}/${HOST_DISTRO}-host_${DISTRO}-${DISTRO_ARCH}"
 
+DISTRO_VARS_PREFIX = "HOST_"
+
 require isar-bootstrap.inc
 
 HOST_DISTRO_BOOTSTRAP_KEYS ?= ""
 DISTRO_BOOTSTRAP_KEYS = "${HOST_DISTRO_BOOTSTRAP_KEYS}"
 
-do_apt_config_prepare[dirs] = "${WORKDIR}"
-do_apt_config_prepare[vardeps] += "\
-                                   APTPREFS \
-                                   HOST_DISTRO_APT_PREFERENCES \
-                                   DEBDISTRONAME \
-                                   APTSRCS \
-                                   HOST_DISTRO_APT_SOURCES \
-                                   DEPLOY_ISAR_BOOTSTRAP \
-                                  "
-python do_apt_config_prepare() {
-    apt_preferences_out = d.getVar("APTPREFS", True)
-    apt_preferences_list = (
-        d.getVar("HOST_DISTRO_APT_PREFERENCES", True) or ""
-    ).split()
-    aggregate_files(d, apt_preferences_list, apt_preferences_out)
-
-    apt_sources_out = d.getVar("APTSRCS", True)
-    apt_sources_init_out = d.getVar("APTSRCS_INIT", True)
-    apt_sources_list = (
-        d.getVar("HOST_DISTRO_APT_SOURCES", True) or ""
-    ).split()
-
-    aggregate_files(d, apt_sources_list, apt_sources_init_out)
-    aggregate_aptsources_list(d, apt_sources_list, apt_sources_out)
-}
-addtask apt_config_prepare before do_bootstrap after do_unpack
-
 OVERRIDES_append = ":${@get_distro_needs_https_support(d, True)}"
 
-do_bootstrap[vardeps] += "HOST_DISTRO_APT_SOURCES"
 do_bootstrap() {
     isar_bootstrap --host
 }
-addtask bootstrap before do_build after do_generate_keyrings

+ 0 - 27
meta/recipes-core/isar-bootstrap/isar-bootstrap-target.bb

@@ -11,35 +11,8 @@ DEPLOY_ISAR_BOOTSTRAP = "${DEPLOY_DIR_BOOTSTRAP}/${DISTRO}-${DISTRO_ARCH}"
 
 require isar-bootstrap.inc
 
-do_apt_config_prepare[dirs] = "${WORKDIR}"
-do_apt_config_prepare[vardeps] += "\
-                                   APTPREFS \
-                                   DISTRO_APT_PREFERENCES \
-                                   DEBDISTRONAME \
-                                   APTSRCS \
-                                   DISTRO_APT_SOURCES \
-                                   DEPLOY_ISAR_BOOTSTRAP \
-                                  "
-python do_apt_config_prepare() {
-    apt_preferences_out = d.getVar("APTPREFS", True)
-    apt_preferences_list = (
-        d.getVar("DISTRO_APT_PREFERENCES", True) or ""
-    ).split()
-    aggregate_files(d, apt_preferences_list, apt_preferences_out)
-
-    apt_sources_out = d.getVar("APTSRCS", True)
-    apt_sources_init_out = d.getVar("APTSRCS_INIT", True)
-    apt_sources_list = (d.getVar("DISTRO_APT_SOURCES", True) or "").split()
-
-    aggregate_files(d, apt_sources_list, apt_sources_init_out)
-    aggregate_aptsources_list(d, apt_sources_list, apt_sources_out)
-}
-addtask apt_config_prepare before do_bootstrap after do_unpack
-
 OVERRIDES_append = ":${@get_distro_needs_https_support(d, False)}"
 
-do_bootstrap[vardeps] += "DISTRO_APT_SOURCES"
 do_bootstrap() {
     isar_bootstrap
 }
-addtask bootstrap before do_build after do_generate_keyrings

+ 36 - 1
meta/recipes-core/isar-bootstrap/isar-bootstrap.inc

@@ -27,6 +27,8 @@ DISTRO_BOOTSTRAP_BASE_PACKAGES = "locales"
 DISTRO_BOOTSTRAP_BASE_PACKAGES_append_gnupg = ",gnupg"
 DISTRO_BOOTSTRAP_BASE_PACKAGES_append_https-support = "${@https_support(d)}"
 
+DISTRO_VARS_PREFIX ?= ""
+
 inherit deb-dl-dir
 
 python () {
@@ -220,15 +222,48 @@ do_generate_keyrings() {
 }
 addtask generate_keyrings before do_build after do_unpack
 
+do_apt_config_prepare[dirs] = "${WORKDIR}"
+do_apt_config_prepare[vardeps] += " \
+    APTPREFS \
+    ${DISTRO_VARS_PREFIX}DISTRO_APT_PREFERENCES \
+    DEBDISTRONAME \
+    APTSRCS \
+    ${DISTRO_VARS_PREFIX}DISTRO_APT_SOURCES \
+    DEPLOY_ISAR_BOOTSTRAP \
+    "
+python do_apt_config_prepare() {
+    apt_preferences_out = d.getVar("APTPREFS", True)
+    apt_preferences_list = (
+        d.getVar(d.getVar("DISTRO_VARS_PREFIX") + "DISTRO_APT_PREFERENCES", True) or ""
+    ).split()
+    aggregate_files(d, apt_preferences_list, apt_preferences_out)
+
+    apt_sources_out = d.getVar("APTSRCS", True)
+    apt_sources_init_out = d.getVar("APTSRCS_INIT", True)
+    apt_sources_list = (
+        d.getVar(d.getVar("DISTRO_VARS_PREFIX") + "DISTRO_APT_SOURCES", True) or ""
+    ).split()
+
+    aggregate_files(d, apt_sources_list, apt_sources_init_out)
+    aggregate_aptsources_list(d, apt_sources_list, apt_sources_out)
+}
+addtask apt_config_prepare before do_bootstrap after do_unpack
+
 def get_host_release():
     import platform
     rel = platform.release()
     return rel
 
-do_bootstrap[vardeps] += "DISTRO_APT_PREMIRRORS ISAR_ENABLE_COMPAT_ARCH"
+do_bootstrap[vardeps] += " \
+    DISTRO_APT_PREMIRRORS \
+    ISAR_ENABLE_COMPAT_ARCH \
+    ${DISTRO_VARS_PREFIX}DISTRO_APT_SOURCES \
+    "
 do_bootstrap[dirs] = "${DEPLOY_DIR_BOOTSTRAP}"
 do_bootstrap[depends] = "base-apt:do_cache isar-apt:do_cache_config"
 
+addtask bootstrap before do_build after do_generate_keyrings
+
 isar_bootstrap() {
     IS_HOST=""
     while true; do