[elbe-devel] [PATCH 13/13] elbeproject/sdk: encode project details into sdk

Manuel Traut manut at linutronix.de
Mon Jan 29 14:02:43 CET 2018


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.

Signed-off-by: Manuel Traut <manut 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 01e7e9b6..2107e21c 100644
--- a/elbepack/elbeproject.py
+++ b/elbepack/elbeproject.py
@@ -67,26 +67,32 @@ class AptCacheCommitError(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')
@@ -96,6 +102,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__(
             self,
@@ -158,6 +166,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:
@@ -284,13 +295,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




More information about the elbe-devel mailing list