[elbe-devel] [PATCH v2 23/24] elbeproject/sdk: encode project details into sdk

Torben Hohn torben.hohn at linutronix.de
Thu Feb 8 17:19:59 CET 2018


On Thu, Feb 08, 2018 at 02:17:09PM +0100, Manuel Traut wrote:
> default-path:
> Instead of suggesting always install to /opt/elbe-sdk encode some
> project details into the default path
> 
> filename of the installer:
> including project arch, name and version and the filename of the
> installer script makes it easier for users to distinguish between
> different installers.

Also renames __gen_sdk_scripts to gen_sdk_scripts

> 
> Signed-off-by: Manuel Traut <manut at linutronix.de>

Reviewed-by: Torben Hohn <torben.hohn at linutronix.de>

> ---
>  elbepack/db.py          |  6 +++++-
>  elbepack/elbeproject.py | 44 ++++++++++++++++++++++++++++++++------------
>  2 files changed, 37 insertions(+), 13 deletions(-)
> 
> diff --git a/elbepack/db.py b/elbepack/db.py
> index 9ba0c58c..ef54fd16 100644
> --- a/elbepack/db.py
> +++ b/elbepack/db.py
> @@ -21,6 +21,7 @@ from __future__ import print_function
>  import os
>  import errno
>  import re
> +import glob
>  
>  from datetime import datetime
>  from shutil import (rmtree, copyfile, copyfileobj)
> @@ -839,7 +840,10 @@ class ElbeDB(object):
>                                        "application/x-xz-compressed-tar",
>                                        "sysroot for cross-toolchains")
>  
> -            self._update_project_file(s, p.builddir, "setup-sdk.sh",
> +            sdk = glob.glob(os.path.join(p.builddir, "setup-elbe-sdk-*.sh"))
> +            sdkname = sdk[0].split('/')[-1]
> +
> +            self._update_project_file(s, p.builddir, sdkname,
>                                        "application/x-shellscript",
>                                        "SDK Installer")
>  
> diff --git a/elbepack/elbeproject.py b/elbepack/elbeproject.py
> index 4704ba02..01fac01a 100644
> --- a/elbepack/elbeproject.py
> +++ b/elbepack/elbeproject.py
> @@ -72,26 +72,32 @@ class UnsupportedSDKException(Exception):
>  
>  def test_gen_sdk_scripts():
>      os.system("mkdir -p /tmp/test/sdk")
> -    __gen_sdk_scripts('armhf-linux-gnueabihf',
> -                      'testproject',
> -                      '08.15',
> -                      '/tmp/test',
> -                      '/tmp/test/sdk')
> +    gen_sdk_scripts('armhf-linux-gnueabihf',
> +                    'testproject',
> +                    '08.15',
> +                    '/tmp/test',
> +                    '/tmp/test/sdk')
>  
>  
> -def __gen_sdk_scripts(triplet, prj_name, prj_version, builddir, sdkpath):
> +def gen_sdk_scripts(triplet, prj_name, prj_version, builddir, sdkpath):
> +
> +    prj_name = prj_name.replace(" ", "_")
> +    prj_version = prj_version.replace(" ", "_")
>  
>      # generate the setup script
>      sdkvalues = { 'sdk_arch': 'x86_64',
>                    'sdk_gcc_ver': '',
> -                  'sdk_path': '/opt/elbe-sdk',
> +                  'sdk_path': '/opt/elbe-sdk-%s-%s-%s' % (triplet,
> +                                                          prj_name,
> +                                                          prj_version),
>                    'sdk_ext_path': '~/elbe-sdk',
>                    'real_multimach_target_sys': triplet,
>                    'sdk_title': 'ELBE %s' % prj_name,
>                    'sdk_version': prj_version,
>                  }
>      t = os.path.join(mako_template_dir, 'toolchain-shar-extract.sh.mako')
> -    with open(os.path.join(builddir, 'setup-sdk.sh'), 'w') as f:
> +    sdkname = 'setup-elbe-sdk-%s-%s-%s.sh' % (triplet, prj_name, prj_version)
> +    with open(os.path.join(builddir, sdkname), 'w') as f:
>          f.write(template(t, sdkvalues))
>  
>      t = os.path.join(mako_template_dir, 'environment-setup-elbe.mako')
> @@ -101,6 +107,8 @@ def __gen_sdk_scripts(triplet, prj_name, prj_version, builddir, sdkpath):
>      with open(os.path.join(sdkpath, envname), 'w') as f:
>          f.write(template(t, sdkvalues))
>  
> +    return sdkname
> +
>  
>  class ElbeProject (object):
>      def __init__(
> @@ -164,6 +172,9 @@ class ElbeProject (object):
>          self.arch = self.xml.text("project/arch", key="arch")
>          self.codename = self.xml.text("project/suite")
>  
> +        if not self.name:
> +            self.name = self.xml.text("project/name")
> +
>          # If logpath is given, use an AsciiDocLog instance, otherwise log
>          # to stdout
>          if logpath:
> @@ -295,13 +306,22 @@ class ElbeProject (object):
>                      'amd64',
>                      True)
>  
> -        __gen_sdk_scripts(triplet, prj_name, prj_version,
> -                          self.builddir, self.sdkpath)
> +        # remove files that are also in the target sysroot
> +        self.log.do('rm -rf "%s"' % os.path.join(hostsysrootpath,
> +                                                 'usr', triplet))
> +
> +        n = gen_sdk_scripts(triplet,
> +                            self.name,
> +                            self.xml.text("project/version"),
> +                            self.builddir,
> +                            self.sdkpath)
>  
>          # create sdk tar and append it to setup script
>          self.log.do("cd %s; tar cJf ../sdk.txz ." % self.sdkpath)
> -        self.log.do("cd %s; cat sdk.txz >> setup-sdk.sh" % self.builddir)
> -        self.log.do("cd %s; chmod +x setup-sdk.sh" % self.builddir)
> +        self.log.do("cd %s; rm -rf sdk" % self.builddir)
> +        self.log.do("cd %s; cat sdk.txz >> %s" % (self.builddir, n))
> +        self.log.do("cd %s; chmod +x %s" % (self.builddir, n))
> +        self.log.do("cd %s; rm sdk.txz" % self.builddir)
>  
>  
>      def pbuild(self, p):
> -- 
> 2.15.1
> 

-- 
Mit freundlichen Grüßen
Torben Hohn

Linutronix GmbH

Standort: Bremen

Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99

Firmensitz / Registered Office: D-88690 Uhldingen, Bahnhofstr. 3
Registergericht / Local District Court: Amtsgericht Freiburg i. Br.; HRB
Nr. / Trade register no.: 700 806

Geschäftsführer / Managing Directors: Heinz Egger, Thomas Gleixner

Eine Bitte von uns: Sollten Sie diese E-Mail irrtümlich erhalten haben,
benachrichtigen Sie uns in diesem Falle bitte sobald wie es Ihnen
möglich ist, durch Antwort-Mail. Vielen Dank!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.linutronix.de/pipermail/elbe-devel/attachments/20180208/4a7643cc/attachment-0001.sig>


More information about the elbe-devel mailing list