summaryrefslogtreecommitdiffstats
path: root/scripts/oe-publish-sdk
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/oe-publish-sdk')
-rwxr-xr-xscripts/oe-publish-sdk44
1 files changed, 25 insertions, 19 deletions
diff --git a/scripts/oe-publish-sdk b/scripts/oe-publish-sdk
index 1737c9f3bc..b8a652e47f 100755
--- a/scripts/oe-publish-sdk
+++ b/scripts/oe-publish-sdk
@@ -1,13 +1,10 @@
-#!/usr/bin/env python
-
+#!/usr/bin/env python3
+#
# OpenEmbedded SDK publishing tool
-
-# oe-publish-sdk publish <ext-sdk> <destination>
-# <ext-sdk>: extensible SDK to publish (path to the installer shell script)
-# <destination>: local or remote location which servers as an SDK update server
-# e.g.
-# oe-publish-sdk /path/to/sdk-ext.sh /mnt/poky/sdk-ext
-# oe-publish-sdk /path/to/sdk-ext.sh user@host:/opt/poky/sdk-ext
+#
+# Copyright (C) 2015-2016 Intel Corporation
+#
+# SPDX-License-Identifier: GPL-2.0-only
#
import sys
@@ -24,6 +21,7 @@ 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):
@@ -42,7 +40,10 @@ def publish(args):
# Ensure the SDK exists
if not os.path.exists(target_sdk):
- logger.error("%s doesn't exist" % 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:
@@ -52,6 +53,7 @@ def publish(args):
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")
@@ -83,15 +85,19 @@ def publish(args):
# Unpack the SDK
logger.info("Unpacking SDK")
if not is_remote:
- cmd = "sh %s -n -y -d %s" % (dest_sdk, destination)
+ 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 -n -y -d %s'" % (host, dest_sdk, destdir)
+ rm_or_not = " && rm -f %s" % dest_sdk
+ if args.keep_orig:
+ rm_or_not = ""
+ cmd = "ssh %s 'sh %s -p -y -d %s%s'" % (host, dest_sdk, destdir, rm_or_not)
ret = subprocess.call(cmd, shell=True)
if ret == 0:
logger.info('Successfully unpacked %s to %s' % (dest_sdk, destdir))
@@ -101,9 +107,9 @@ def publish(args):
# Setting up the git repo
if not is_remote:
- cmd = 'set -e; cd %s/layers; if [ ! -e .git ]; then git init .; mv .git/hooks/post-update.sample .git/hooks/post-update; fi; git add -A .; git commit -q -m "init repo" || true;' % destination
+ cmd = 'set -e; mkdir -p %s/layers; cd %s/layers; if [ ! -e .git ]; then git init .; cp .git/hooks/post-update.sample .git/hooks/post-commit; echo "*.pyc\n*.pyo\npyshtables.py" > .gitignore; fi; git config gc.auto 0; git add -A .; git config user.email "oe@oe.oe" && git config user.name "OE" && git commit -q -m "init repo" || true' % (destination, destination)
else:
- cmd = "ssh %s 'set -e; cd %s/layers; if [ ! -e .git ]; then git init .; mv .git/hooks/post-update.sample .git/hooks/post-update; fi; git add -A .; git commit -q -m \"init repo\" || true;'" % (host, destdir)
+ cmd = "ssh %s 'set -e; mkdir -p %s/layers; cd %s/layers; if [ ! -e .git ]; then git init .; cp .git/hooks/post-update.sample .git/hooks/post-commit; echo '*.pyc' > .gitignore; echo '*.pyo' >> .gitignore; echo 'pyshtables.py' >> .gitignore; fi; git config gc.auto 0; git add -A .; git config user.email 'oe@oe.oe' && git config user.name 'OE' && git commit -q -m \"init repo\" || true'" % (host, destdir, destdir)
ret = subprocess.call(cmd, shell=True)
if ret == 0:
logger.info('SDK published successfully')
@@ -113,13 +119,13 @@ def publish(args):
def main():
- parser = argparse.ArgumentParser(description="OpenEmbedded development tool",
- epilog="Use %(prog)s <subcommand> --help to get help on a specific command")
+ 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('-k', '--keep-orig', help='When published to a remote host, the eSDK installer gets deleted by default.', action='store_true')
- parser.add_argument('sdk', help='Extensible SDK to publish')
- parser.add_argument('dest', help='Destination to publish SDK to')
+ 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)
@@ -139,5 +145,5 @@ if __name__ == "__main__":
except Exception:
ret = 1
import traceback
- traceback.print_exc(5)
+ traceback.print_exc()
sys.exit(ret)