[elbe-devel] [PATCH 1/2] Add optional mirror for host architecture

Torben Hohn torben.hohn at linutronix.de
Thu Jun 4 09:14:53 CEST 2020


On Wed, May 20, 2020 at 11:53:03AM +0200, Kory Maincent wrote:
> If the primary mirror does not contain the packages for both target and host
> architecture the build_host_sysroot process fails.
> 
> This patch adds support for describing in the XML configuration an additional
> optional mirror containing packages for the host architecture, like:
> <mirror>
> <host>http://archive.ubuntu.com/ubuntu bionic main universe</host>
> </mirror>

Do we have to add "bionic main universe" here ?
The primary mirrors are only needed for debootstrap.

The other mirror entries support [arch=amd64] and we should be able to
have all other mirror urls in the urllist without having problems.
If a mirror only has amd64 packages, it needs to be marked that way.


> 
> It also adds the architecture type in the sources.list file to avoid issues
> with apt-get update.
> 
> Signed-off-by: Kory Maincent <kory.maincent at bootlin.com>
> ---
>  elbepack/elbexml.py | 40 ++++++++++++++++++++++++++++++----------
>  elbepack/rfs.py     | 23 +++++++++++++----------
>  schema/dbsfed.xsd   |  7 +++++++
>  3 files changed, 50 insertions(+), 20 deletions(-)
> 
> diff --git a/elbepack/elbexml.py b/elbepack/elbexml.py
> index fa8158392..ece069706 100644
> --- a/elbepack/elbexml.py
> +++ b/elbepack/elbexml.py
> @@ -132,6 +132,13 @@ class ElbeXML(object):
>  
>          return mirror.replace("LOCALMACHINE", "10.0.2.2")
>  
> +    def get_host_mirror(self):
> +        if self.prj.has("mirror/host"):
> +            m = self.prj.node("mirror")
> +            mirror = m.text("host").strip() + "\n"
> +
> +        return mirror

errm... this fails when <host> does not exist.
lets integrate this in get_primary_mirror() 
and have a proper fallback.




> +
>      def get_primary_mirror(self, cdrompath, initvm=True):
>          if self.prj.has("mirror/primary_host"):
>              m = self.prj.node("mirror")
> @@ -146,7 +153,7 @@ class ElbeXML(object):
>          return replace_localmachine(mirror, initvm)
>  
>      # XXX: maybe add cdrom path param ?
> -    def create_apt_sources_list(self, build_sources=False, initvm=True):
> +    def create_apt_sources_list(self, build_sources=False, initvm=True, arch="default"):
>          if self.prj is None:
>              return "# No Project"
>  
> @@ -155,24 +162,37 @@ class ElbeXML(object):
>  
>          noauth = ""
>          if self.prj.has("noauth"):
> -            noauth = "[trusted=yes] "
> +            noauth = "trusted=yes "
> +
> +        if arch == "default":
> +            arch = self.text("project/buildimage/arch", key="arch")
> +
> +        arch_prj = self.text("project/buildimage/arch", key="arch")
>  
>          mirror = ""
> +        option = "[" + noauth + " arch=" + arch +"] "
>          if self.prj.has("mirror/primary_host"):
> -            mirror += "deb " + noauth + self.get_primary_mirror(None)
> -            mirror += " " + self.prj.text("suite") + " main\n"
> +            if (arch != arch_prj) and self.prj.has("mirror/host"):
> +                mirror += "deb " + option + self.get_host_mirror()
> +            else:
> +                mirror += "deb " + option + self.get_primary_mirror(None)
> +                mirror += " " + self.prj.text("suite") + " main\n"
> +

i find this logic too complex.
We really want the host and target suite to be identical, or we would
end up with different gcc versions.

I also think its too complex to decide, whether we are building a host
sysroot, based on architectures.

Please add a bool parameter "hostsdk" to get_primary_mirror() which will
make it look for <host> and fallback in the case its not there.

it just needs to be passed down from build_host_sysroot() via
BuildEnv.__init__() and BuildEnv.debootstrap() 

this will simplify this patch a lot.


>  
>              if build_sources:
> -                mirror += "deb-src " + noauth + self.get_primary_mirror(None)
> -                mirror += " " + self.prj.text("suite") + " main\n"
> +                if (arch != arch_prj) and self.prj.has("mirror/host"):
> +                    mirror += "deb-src " + option + self.get_host_mirror()
> +                else:
> +                    mirror += "deb-src " + option + self.get_primary_mirror(None)
> +                    mirror += " " + self.prj.text("suite") + " main\n"
>  
> -            if self.prj.has("mirror/url-list"):
> +            if self.prj.has("mirror/url-list") and (arch==arch_prj):
>                  for url in self.prj.node("mirror/url-list"):
>                      if url.has("binary"):
> -                        mirror += "deb " + noauth + \
> -                                   url.text("binary").strip() + "\n"
> +                        mirror += "deb " + option + \
> +                            url.text("binary").strip() + "\n"
>                      if url.has("source"):
> -                        mirror += "deb-src " + noauth + \
> +                        mirror += "deb-src " + option + \
>                              url.text("source").strip() + "\n"
>  
>          if self.prj.has("mirror/cdrom"):
> diff --git a/elbepack/rfs.py b/elbepack/rfs.py
> index 6967d2899..0a1bf5be2 100644
> --- a/elbepack/rfs.py
> +++ b/elbepack/rfs.py
> @@ -96,7 +96,7 @@ class BuildEnv (object):
>              self.fresh_debootstrap = False
>              self.need_dumpdebootstrap = False
>  
> -        self.initialize_dirs(build_sources=build_sources)
> +        self.initialize_dirs(build_sources=build_sources, arch=arch)
>          create_apt_prefs(self.xml, self.rfs)
>  
>      def cdrom_umount(self):
> @@ -161,8 +161,16 @@ class BuildEnv (object):
>          cleanup = False
>          suite = self.xml.prj.text("suite")
>  
> -        primary_mirror = self.xml.get_primary_mirror(
> -            self.rfs.fname('/cdrom/targetrepo'))
> +        if arch == "default":
> +            arch = self.xml.text("project/buildimage/arch", key="arch")
> +
> +        host_arch = get_command_out("dpkg --print-architecture").strip().decode()
> +
> +        if (arch == host_arch) and self.xml.prj.has("mirror/host"):
> +            primary_mirror = self.xml.get_host_mirror().split(' ',1)[0]
> +        else:
> +            primary_mirror = self.xml.get_primary_mirror(
> +                self.rfs.fname('/cdrom/targetrepo'))
>  
>          if self.xml.prj.has("mirror/primary_proxy"):
>              os.environ["no_proxy"] = "10.0.2.2,localhost,127.0.0.1"
> @@ -183,11 +191,6 @@ class BuildEnv (object):
>  
>          logging.info("Debootstrap log")
>  
> -        if arch == "default":
> -            arch = self.xml.text("project/buildimage/arch", key="arch")
> -
> -        host_arch = get_command_out("dpkg --print-architecture").strip().decode()
> -
>          includepkgs = None
>          strapcmd  = 'debootstrap '
>          if self.xml.has("target/debootstrapvariant"):
> @@ -297,8 +300,8 @@ class BuildEnv (object):
>                      key = "\n".join(line.strip(" \t") for line in url.text('raw-key').splitlines()[1:-1])
>                      self.add_key(key)
>  
> -    def initialize_dirs(self, build_sources=False):
> -        mirror = self.xml.create_apt_sources_list(build_sources=build_sources)
> +    def initialize_dirs(self, build_sources=False, arch="default"):
> +        mirror = self.xml.create_apt_sources_list(build_sources=build_sources, arch=arch)
>  
>          if self.rfs.lexists("etc/apt/sources.list"):
>              self.rfs.remove("etc/apt/sources.list")
> diff --git a/schema/dbsfed.xsd b/schema/dbsfed.xsd
> index 6392c41bd..59f42f5c2 100644
> --- a/schema/dbsfed.xsd
> +++ b/schema/dbsfed.xsd
> @@ -273,6 +273,13 @@
>            </documentation>
>          </annotation>
>        </element>
> +      <element name="host" type="rfs:string" minOccurs="0" maxOccurs="1">
> +        <annotation>
> +          <documentation>
> +            Url of the host mirror.
> +          </documentation>
> +        </annotation>
> +      </element>
>        <element name="url-list" type="rfs:url-list" minOccurs="0">
>          <annotation>
>            <documentation>
> -- 
> 2.17.1
> 
> 
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel

-- 
Torben Hohn
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99

Hinweise zum Datenschutz finden Sie hier (Informations on data privacy 
can be found here): https://linutronix.de/kontakt/Datenschutz.php

Linutronix GmbH | Firmensitz (Registered Office): Uhldingen-Mühlhofen | 
Registergericht (Registration Court): Amtsgericht Freiburg i.Br., HRB700 
806 | Geschäftsführer (Managing Directors): Heinz Egger, Thomas Gleixner



More information about the elbe-devel mailing list