#!/usr/bin/env python3 # OpenEmbedded Development tool # # Copyright (C) 2014-2015 Intel Corporation # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. import sys import os import argparse import glob import re import configparser import subprocess import logging basepath = '' workspace = {} config = None context = None scripts_path = os.path.dirname(os.path.realpath(__file__)) lib_path = scripts_path + '/lib' sys.path = sys.path + [lib_path] from devtool import DevtoolError, setup_tinfoil import scriptutils import argparse_oe logger = scriptutils.logger_create('devtool') plugins = [] class ConfigHandler(object): config_file = '' config_obj = None init_path = '' workspace_path = '' def __init__(self, filename): self.config_file = filename self.config_obj = configparser.ConfigParser() def get(self, section, option, default=None): try: ret = self.config_obj.get(section, option) except (configparser.NoOptionError, configparser.NoSectionError): if default != None: ret = default else: raise return ret def read(self): if os.path.exists(self.config_file): self.config_obj.read(self.config_file) if self.config_obj.has_option('General', 'init_path'): pth = self.get('General', 'init_path') self.init_path = os.path.join(basepath, pth) if not os.path.exists(self.init_path): logger.error('init_path %s specified in config file cannot be found' % pth) return False else: self.config_obj.add_section('General') self.workspace_path = self.get('General', 'workspace_path', os.path.join(basepath, 'workspace')) return True def write(self): logger.debug('writing to config file %s' % self.config_file) self.config_obj.set('General', 'workspace_path', self.workspace_path) with open(self.config_file, 'w') as f: self.config_obj.write(f) def set(self, section, option, value): if not self.config_obj.has_section(section): self.config_obj.add_section(section) self.config_obj.set(section, option, value) class Context: def __init__(self, **kwargs): self.__dict__.update(kwargs) def read_workspace(): global workspace workspace = {} if not os.path.exists(os.path.join(config.workspace_path, 'conf', 'layer.conf')): if context.fixed_setup: logger.error("workspace layer not set up") sys.exit(1) else: logger.info('Creating workspace layer in %s' % config.workspace_path) _create_workspace(config.workspace_path, config, basepath) if not context.fixed_setup: _enable_workspace_layer(config.workspace_path, config, basepath) logger.debug('Reading workspace in %s' % config.workspace_path) externalsrc_re = re.compile(r'^EXTERNALSRC(_pn-([^ =]+))? *= *"([^"]*)"$') for fn in glob.glob(os.path.join(config.workspace_path, 'appends', '*.bbappend')): with open(fn, 'r') as f: pnvalues = {} for line in f: res = externalsrc_re.match(line.rstrip()) if res: recipepn = os.path.splitext(os.path.basename(fn))[0].split('_')[0] pn = res.group(2) or recipepn # Find the recipe file within the workspace, if any bbfile = os.path.basename(fn).replace('.bbappend', '.bb').replace('%', '*') recipefile = glob.glob(os.path.join(config.workspace_path, 'recipes', recipepn, bbfile)) if recipefile: recipefile = recipefile[0] pnvalues['srctree'] = res.group(3) pnvalues['bbappend'] = fn pnvalues['recipefile'] = recipefile elif line.startswith('# srctreebase: '): pnvalues['srctreebase'] = line.split(':', 1)[1].strip() if pnvalues: if not pnvalues.get('srctreebase', None): pnvalues['srctreebase'] = pnvalues['srctree'] logger.debug('Found recipe %s' % pnvalues) workspace[pn] = pnvalues def create_workspace(args, config, basepath, workspace): if args.layerpath: workspacedir = os.path.abspath(args.layerpath) else: workspacedir = os.path.abspath(os.path.join(basepath, 'workspace')) _create_workspace(workspacedir, config, basepath) if not args.create_only: _enable_workspace_layer(workspacedir, config, basepath) def _create_workspace(workspacedir, config, basepath): import bb confdir = os.path.join(workspacedir, 'conf') if os.path.exists(os.path.join(confdir, 'layer.conf')): logger.info('Specified workspace already set up, leaving as-is') else: # Add a config file bb.utils.mkdirhier(confdir) with open(os.path.join(confdir, 'layer.conf'), 'w') as f: f.write('# ### workspace layer auto-generated by devtool ###\n') f.write('BBPATH =. "$' + '{LAYERDIR}:"\n') f.write('BBFILES += "$' + '{LAYERDIR}/recipes/*/*.bb \\\n') f.write(' $' + '{LAYERDIR}/appends/*.bbappend"\n') f.write('BBFILE_COLLECTIONS += "workspacelayer"\n') f.write('BBFILE_PATTERN_workspacelayer = "^$' + '{LAYERDIR}/"\n') f.write('BBFILE_PATTERN_IGNORE_EMPTY_workspacelayer = "1"\n') f.write('BBFILE_PRIORITY_workspacelayer = "99"\n') f.write('LAYERSERIES_COMPAT_workspacelayer = "${LAYERSERIES_COMPAT_core}"\n') # Add a README file with open(os.path.join(workspacedir, 'README'), 'w') as f: f.write('This layer was created by the OpenEmbedded devtool utility in order to\n') f.write('contain recipes and bbappends that are currently being worked on. The idea\n') f.write('is that the contents is temporary - once you have finished working on a\n') f.write('recipe you use the appropriate method to move the files you have been\n') f.write('working on to a proper layer. In most instances you should use the\n') f.write('devtool utility to manage files within it rather than modifying files\n') f.write('directly (although recipes added with "devtool add" will often need\n') f.write('direct modification.) @media only all and (prefers-color-scheme: dark) { .highlight .hll { background-color: #49483e } .highlight .c { color: #75715e } /* Comment */ .highlight .err { color: #960050; background-color: #1e0010 } /* Error */ .highlight .k { color: #66d9ef } /* Keyword */ .highlight .l { color: #ae81ff } /* Literal */ .highlight .n { color: #f8f8f2 } /* Name */ .highlight .o { color: #f92672 } /* Operator */ .highlight .p { color: #f8f8f2 } /* Punctuation */ .highlight .ch { color: #75715e } /* Comment.Hashbang */ .highlight .cm { color: #75715e } /* Comment.Multiline */ .highlight .cp { color: #75715e } /* Comment.Preproc */ .highlight .cpf { color: #75715e } /* Comment.PreprocFile */ .highlight .c1 { color: #75715e } /* Comment.Single */ .highlight .cs { color: #75715e } /* Comment.Special */ .highlight .gd { color: #f92672 } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gi { color: #a6e22e } /* Generic.Inserted */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #75715e } /* Generic.Subheading */ .highlight .kc { color: #66d9ef } /* Keyword.Constant */ .highlight .kd { color: #66d9ef } /* Keyword.Declaration */ .highlight .kn { color: #f92672 } /* Keyword.Namespace */ .highlight .kp { color: #66d9ef } /* Keyword.Pseudo */ .highlight .kr { color: #66d9ef } /* Keyword.Reserved */ .highlight .kt { color: #66d9ef } /* Keyword.Type */ .highlight .ld { color: #e6db74 } /* Literal.Date */ .highlight .m { color: #ae81ff } /* Literal.Number */ .highlight .s { color: #e6db74 } /* Literal.String */ .highlight .na { color: #a6e22e } /* Name.Attribute */ .highlight .nb { color: #f8f8f2 } /* Name.Builtin */ .highlight .nc { color: #a6e22e } /* Name.Class */ .highlight .no { color: #66d9ef } /* Name.Constant */ .highlight .nd { color: #a6e22e } /* Name.Decorator */ .highlight .ni { color: #f8f8f2 } /* Name.Entity */ .highlight .ne { color: #a6e22e } /* Name.Exception */ .highlight .nf { color: #a6e22e } /* Name.Function */ .highlight .nl { color: #f8f8f2 } /* Name.Label */ .highlight .nn { color: #f8f8f2 } /* Name.Namespace */ .highlight .nx { color: #a6e22e } /* Name.Other */ .highlight .py { color: #f8f8f2 } /* Name.Property */ .highlight .nt { color: #f92672 } /* Name.Tag */ .highlight .nv { color: #f8f8f2 } /* Name.Variable */ .highlight .ow { color: #f92672 } /* Operator.Word */ .highlight .w { color: #f8f8f2 } /* Text.Whitespace */ .highlight .mb { color: #ae81ff } /* Literal.Number.Bin */ .highlight .mf { color: #ae81ff } /* Literal.Number.Float */ .highlight .mh { color: #ae81ff } /* Literal.Number.Hex */ .highlight .mi { color: #ae81ff } /* Literal.Number.Integer */ .highlight .mo { color: #ae81ff } /* Literal.Number.Oct */ .highlight .sa { color: #e6db74 } /* Literal.String.Affix */ .highlight .sb { color: #e6db74 } /* Literal.String.Backtick */ .highlight .sc { color: #e6db74 } /* Literal.String.Char */ .highlight .dl { color: #e6db74 } /* Literal.String.Delimiter */ .highlight .sd { color: #e6db74 } /* Literal.String.Doc */ .highlight .s2 { color: #e6db74 } /* Literal.String.Double */ .highlight .se { color: #ae81ff } /* Literal.String.Escape */ .highlight .sh { color: #e6db74 } /* Literal.String.Heredoc */ .highlight .si { color: #e6db74 } /* Literal.String.Interpol */ .highlight .sx { color: #e6db74 } /* Literal.String.Other */ .highlight .sr { color: #e6db74 } /* Literal.String.Regex */ .highlight .s1 { color: #e6db74 } /* Literal.String.Single */ .highlight .ss { color: #e6db74 } /* Literal.String.Symbol */ .highlight .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #a6e22e } /* Name.Function.Magic */ .highlight .vc { color: #f8f8f2 } /* Name.Variable.Class */ .highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */ .highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */ .highlight .vm { color: #f8f8f2 } /* Name.Variable.Magic */ .highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */ } @media (prefers-color-scheme: light) { .highlight .hll { background-color: #ffffcc } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ } #!/usr/bin/env python3 # OpenEmbedded SDK publishing tool # Copyright (C) 2015-2016 Intel Corporation # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. import sys import os import argparse import glob import re import subprocess import logging import shutil import errno scripts_path = os.path.dirname(os.path.realpath(__file__)) lib_path = scripts_path + '/lib' sys.path = sys.path + [lib_path] import scriptutils import argparse_oe logger = scriptutils.logger_create('sdktool') def mkdir(d): try: os.makedirs(d) except OSError as e: if e.errno != errno.EEXIST: raise e def publish(args): logger.debug("In publish function") target_sdk = args.sdk destination = args.dest logger.debug("target_sdk = %s, update_server = %s" % (target_sdk, destination)) sdk_basename = os.path.basename(target_sdk) # Ensure the SDK exists if not os.path.exists(target_sdk): logger.error("Specified SDK %s doesn't exist" % target_sdk) return -1 if os.path.isdir(target_sdk): logger.error("%s is a directory - expected path to SDK installer file" % target_sdk) return -1 if ':' in destination: is_remote = True host, destdir = destination.split(':') dest_sdk = os.path.join(destdir, sdk_basename) else: is_remote = False dest_sdk = os.path.join(destination, sdk_basename) destdir = destination # Making sure the directory exists logger.debug("Making sure the destination directory exists") if not is_remote: mkdir(destination) else: cmd = "ssh %s 'mkdir -p %s'" % (host, destdir) ret = subprocess.call(cmd, shell=True) if ret != 0: logger.error("Making directory %s on %s failed" % (destdir, host)) return ret # Copying the SDK to the destination logger.info("Copying the SDK to destination") if not is_remote: if os.path.exists(dest_sdk): os.remove(dest_sdk) if (os.stat(target_sdk).st_dev == os.stat(destination).st_dev): os.link(target_sdk, dest_sdk) else: shutil.copy(target_sdk, dest_sdk) else: cmd = "scp %s %s" % (target_sdk, destination) ret = subprocess.call(cmd, shell=True) if ret != 0: logger.error("scp %s %s failed" % (target_sdk, destination)) return ret # Unpack the SDK logger.info("Unpacking SDK") if not is_remote: cmd = "sh %s -p -y -d %s" % (dest_sdk, destination) ret = subprocess.call(cmd, shell=True) if ret == 0: logger.info('Successfully unpacked %s to %s' % (dest_sdk, destination)) os.remove(dest_sdk) else: logger.error('Failed to unpack %s to %s' % (dest_sdk, destination)) return ret else: cmd = "ssh %s 'sh %s -p -y -d %s && rm -f %s'" % (host, dest_sdk, destdir, dest_sdk) ret = subprocess.call(cmd, shell=True) if ret == 0: logger.info('Successfully unpacked %s to %s' % (dest_sdk, destdir)) else: logger.error('Failed to unpack %s to %s' % (dest_sdk, destdir)) return ret # Setting up the git repo cmd_common = "if [ ! -e .git ]; then" cmd_common += " git init .;" cmd_common += " mv .git/hooks/post-update.sample .git/hooks/post-update;" cmd_common += " echo '*.pyc\n*.pyo\npyshtables.py' > .gitignore;" cmd_common += "fi;" cmd_common += "git add -A .;" cmd_common += "git config user.email 'oe@oe.oe' && git config user.name 'OE' && git commit -q -m 'init repo' || true;" if not is_remote: cmd = "set -e;" cmd += "mkdir -p %s/layers;" % destination cmd += "cd %s/layers;" % destination cmd += cmd_common cmd += "git update-server-info" else: cmd = "ssh %s 'set -e;" % host cmd += "mkdir -p %s/layers;" % destdir cmd += "cd %s/layers;" % destdir cmd += cmd_common cmd += "git update-server-info'" ret = subprocess.call(cmd, shell=True) if ret == 0: logger.info('SDK published successfully') else: logger.error('Failed to set up layer git repo') return ret def main(): parser = argparse_oe.ArgumentParser(description="OpenEmbedded extensible SDK publishing tool - writes server-side data to support the extensible SDK update process to a specified location") parser.add_argument('-d', '--debug', help='Enable debug output', action='store_true') parser.add_argument('-q', '--quiet', help='Print only errors', action='store_true') parser.add_argument('sdk', help='Extensible SDK to publish (path to .sh installer file)') parser.add_argument('dest', help='Destination to publish SDK to; can be local path or remote in the form of user@host:/path (in the latter case ssh/scp will be used).') parser.set_defaults(func=publish) args = parser.parse_args() if args.debug: logger.setLevel(logging.DEBUG) elif args.quiet: logger.setLevel(logging.ERROR) ret = args.func(args) return ret if __name__ == "__main__": try: ret = main() except Exception: ret = 1 import traceback traceback.print_exc() sys.exit(ret)
#!/usr/bin/env python3 # OpenEmbedded SDK publishing tool # Copyright (C) 2015-2016 Intel Corporation # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. import sys import os import argparse import glob import re import subprocess import logging import shutil import errno scripts_path = os.path.dirname(os.path.realpath(__file__)) lib_path = scripts_path + '/lib' sys.path = sys.path + [lib_path] import scriptutils import argparse_oe logger = scriptutils.logger_create('sdktool') def mkdir(d): try: os.makedirs(d) except OSError as e: if e.errno != errno.EEXIST: raise e def publish(args): logger.debug("In publish function") target_sdk = args.sdk destination = args.dest logger.debug("target_sdk = %s, update_server = %s" % (target_sdk, destination)) sdk_basename = os.path.basename(target_sdk) # Ensure the SDK exists if not os.path.exists(target_sdk): logger.error("Specified SDK %s doesn't exist" % target_sdk) return -1 if os.path.isdir(target_sdk): logger.error("%s is a directory - expected path to SDK installer file" % target_sdk) return -1 if ':' in destination: is_remote = True host, destdir = destination.split(':') dest_sdk = os.path.join(destdir, sdk_basename) else: is_remote = False dest_sdk = os.path.join(destination, sdk_basename) destdir = destination # Making sure the directory exists logger.debug("Making sure the destination directory exists") if not is_remote: mkdir(destination) else: cmd = "ssh %s 'mkdir -p %s'" % (host, destdir) ret = subprocess.call(cmd, shell=True) if ret != 0: logger.error("Making directory %s on %s failed" % (destdir, host)) return ret # Copying the SDK to the destination logger.info("Copying the SDK to destination") if not is_remote: if os.path.exists(dest_sdk): os.remove(dest_sdk) if (os.stat(target_sdk).st_dev == os.stat(destination).st_dev): os.link(target_sdk, dest_sdk) else: shutil.copy(target_sdk, dest_sdk) else: cmd = "scp %s %s" % (target_sdk, destination) ret = subprocess.call(cmd, shell=True) if ret != 0: logger.error("scp %s %s failed" % (target_sdk, destination)) return ret # Unpack the SDK logger.info("Unpacking SDK") if not is_remote: cmd = "sh %s -p -y -d %s" % (dest_sdk, destination) ret = subprocess.call(cmd, shell=True) if ret == 0: logger.info('Successfully unpacked %s to %s' % (dest_sdk, destination)) os.remove(dest_sdk) else: logger.error('Failed to unpack %s to %s' % (dest_sdk, destination)) return ret else: cmd = "ssh %s 'sh %s -p -y -d %s && rm -f %s'" % (host, dest_sdk, destdir, dest_sdk) ret = subprocess.call(cmd, shell=True) if ret == 0: logger.info('Successfully unpacked %s to %s' % (dest_sdk, destdir)) else: logger.error('Failed to unpack %s to %s' % (dest_sdk, destdir)) return ret # Setting up the git repo cmd_common = "if [ ! -e .git ]; then" cmd_common += " git init .;" cmd_common += " mv .git/hooks/post-update.sample .git/hooks/post-update;" cmd_common += " echo '*.pyc\n*.pyo\npyshtables.py' > .gitignore;" cmd_common += "fi;" cmd_common += "git add -A .;" cmd_common += "git config user.email 'oe@oe.oe' && git config user.name 'OE' && git commit -q -m 'init repo' || true;" if not is_remote: cmd = "set -e;" cmd += "mkdir -p %s/layers;" % destination cmd += "cd %s/layers;" % destination cmd += cmd_common cmd += "git update-server-info" else: cmd = "ssh %s 'set -e;" % host cmd += "mkdir -p %s/layers;" % destdir cmd += "cd %s/layers;" % destdir cmd += cmd_common cmd += "git update-server-info'" ret = subprocess.call(cmd, shell=True) if ret == 0: logger.info('SDK published successfully') else: logger.error('Failed to set up layer git repo') return ret def main(): parser = argparse_oe.ArgumentParser(description="OpenEmbedded extensible SDK publishing tool - writes server-side data to support the extensible SDK update process to a specified location") parser.add_argument('-d', '--debug', help='Enable debug output', action='store_true') parser.add_argument('-q', '--quiet', help='Print only errors', action='store_true') parser.add_argument('sdk', help='Extensible SDK to publish (path to .sh installer file)') parser.add_argument('dest', help='Destination to publish SDK to; can be local path or remote in the form of user@host:/path (in the latter case ssh/scp will be used).') parser.set_defaults(func=publish) args = parser.parse_args() if args.debug: logger.setLevel(logging.DEBUG) elif args.quiet: logger.setLevel(logging.ERROR) ret = args.func(args) return ret if __name__ == "__main__": try: ret = main() except Exception: ret = 1 import traceback traceback.print_exc() sys.exit(ret)