summaryrefslogtreecommitdiff
path: root/tsp/scripts
diff options
context:
space:
mode:
authorAleksander Mistewicz <a.mistewicz@samsung.com>2016-07-28 10:29:46 (GMT)
committerAleksander Mistewicz <a.mistewicz@samsung.com>2016-12-06 15:37:14 (GMT)
commit361c4a60c3a7fa1915052cfa545b3eff1831bdeb (patch)
tree0e7296f8bfe300a2a2b8ea16cae111543c8835ab /tsp/scripts
parent3c2c585fa2bdc13586d3ffc7314289f2eec642e7 (diff)
downloadmajor-361c4a60c3a7fa1915052cfa545b3eff1831bdeb.zip
major-361c4a60c3a7fa1915052cfa545b3eff1831bdeb.tar.gz
major-361c4a60c3a7fa1915052cfa545b3eff1831bdeb.tar.bz2
New version of tsp/scripts/download_image.pyrefs/changes/33/81833/12
It breaks backward-compatibility with arguments and results. TSP scripts are adjusted. Supported target configurations (unchanged): odroid, minnow32, minnow64 Changes: * now uses target name for project-$target.conf and diff-$target.report * old arguments are replaced by one "-t TARGET" Change-Id: I0d503717c09073d72cb742fcc024247ec807896a Signed-off-by: Aleksander Mistewicz <a.mistewicz@samsung.com>
Diffstat (limited to 'tsp/scripts')
-rwxr-xr-xtsp/scripts/download_image.py160
1 files changed, 75 insertions, 85 deletions
diff --git a/tsp/scripts/download_image.py b/tsp/scripts/download_image.py
index 895ea5c..33e3158 100755
--- a/tsp/scripts/download_image.py
+++ b/tsp/scripts/download_image.py
@@ -27,7 +27,7 @@ import urllib2
import argparse
import logging
-__version__ = "0.2.2"
+__version__ = "1.0.0"
__license__ = "APACHE-2.0"
__author__ = "Aleksander Mistewicz"
__author_email__ = "a.mistewicz@samsung.com"
@@ -97,56 +97,70 @@ class ImageVersion(object):
class ImageDownloader:
- BASE_ARM_WAYLAND = "images/arm-wayland/"
- BOOT_NAME = "common-boot-armv7l-odroidu3"
- USR_NAME = "common-wayland-3parts-armv7l-odroidu3"
-
- def __init__(self, url, arch):
- if not arch or "i586" in arch:
- self.BASE_MINNOW_WAYLAND = "images/ia32-wayland/"
- self.MINNOW_NAME = "common-wayland-efi-i586"
- else:
- self.BASE_MINNOW_WAYLAND = "images/x86_64-wayland/"
- self.MINNOW_NAME = "common-wayland-efi-x86_64"
+ def __init__(self, url, target):
self.url = url
+ self.target = target
img_ver = ImageVersion(url)
self.snap_nr = img_ver.get_snapshot()
self.ver_nr = img_ver.get_version()
self.is_prerelease = img_ver.is_prerelease()
-
- odroid_common_boot_prefix = self.url + self.BASE_ARM_WAYLAND + self.BOOT_NAME
- self.odroid_boot_path = odroid_common_boot_prefix \
- + "/tizen-common_" + self.ver_nr + "_" + self.BOOT_NAME
- self.odroid_boot_path_md5 = odroid_common_boot_prefix + "/MD5SUMS"
-
- odroid_common_usr_prefix = self.url + self.BASE_ARM_WAYLAND + self.USR_NAME
- self.odroid_usr_path = odroid_common_usr_prefix \
- + "/tizen-common_" + self.ver_nr + "_" + self.USR_NAME
- self.odroid_usr_path_md5 = odroid_common_usr_prefix + "/MD5SUMS"
- self.odroid_snap_pkgs = "http://download.tizen.org/snapshots/tizen/common/tizen-common_" \
- + self.snap_nr + "/" + self.BASE_ARM_WAYLAND + self.USR_NAME \
- + "/tizen-common_" + self.snap_nr + "_" + self.USR_NAME + ".packages"
-
- minnow_common_minnow_prefix = self.url + self.BASE_MINNOW_WAYLAND + self.MINNOW_NAME
- self.minnow_usr_path = minnow_common_minnow_prefix \
- + "/tizen-common_" + self.ver_nr + "_" + self.MINNOW_NAME
- self.minnow_usr_path_md5 = minnow_common_minnow_prefix + "/MD5SUMS"
- self.minnow_snap_pkgs = "http://download.tizen.org/snapshots/tizen/common/tizen-common_" \
- + self.snap_nr + "/" + self.BASE_MINNOW_WAYLAND + self.MINNOW_NAME \
- + "/tizen-common_" + self.snap_nr + "_" + self.MINNOW_NAME + ".packages"
+ self.diff_report_filename = "diff-" + self.target + ".report"
logging.debug('snapshot number: %s', self.snap_nr)
logging.debug('version number: %s', self.ver_nr)
- logging.debug('odroid (boot path): %s', self.odroid_boot_path)
- logging.debug('odroid (usr path): %s', self.odroid_usr_path)
- logging.debug('minnow (usr path): %s', self.minnow_usr_path)
-
- def create_projectconf(self, filename, arch, target):
- logging.debug("Create project.conf file for: %s %s", arch, target)
- prjconf = [ "tizen-common_" + self.ver_nr, arch, target ]
- with open(filename, 'w') as f:
+
+ if "odroid" == self.target:
+ self.BASE_ARM_WAYLAND = "images/arm-wayland/"
+ self.BOOT_NAME = "common-boot-armv7l-odroidu3"
+ self.USR_NAME = "common-wayland-3parts-armv7l-odroidu3"
+
+ odroid_common_boot_prefix = self.url + self.BASE_ARM_WAYLAND + self.BOOT_NAME
+ self.odroid_boot_path = odroid_common_boot_prefix \
+ + "/tizen-common_" + self.ver_nr + "_" + self.BOOT_NAME
+ self.odroid_boot_path_md5 = odroid_common_boot_prefix + "/MD5SUMS"
+
+ odroid_common_usr_prefix = self.url + self.BASE_ARM_WAYLAND + self.USR_NAME
+ self.odroid_usr_path = odroid_common_usr_prefix \
+ + "/tizen-common_" + self.ver_nr + "_" + self.USR_NAME
+ self.odroid_usr_path_md5 = odroid_common_usr_prefix + "/MD5SUMS"
+ self.odroid_snap_pkgs = "http://download.tizen.org/snapshots/tizen/common/tizen-common_" \
+ + self.snap_nr + "/" + self.BASE_ARM_WAYLAND + self.USR_NAME \
+ + "/tizen-common_" + self.snap_nr + "_" + self.USR_NAME + ".packages"
+ logging.debug('odroid (boot path): %s', self.odroid_boot_path)
+ logging.debug('odroid (usr path): %s', self.odroid_usr_path)
+ elif "minnow" in self.target:
+ if target == "minnow32":
+ self.BASE_MINNOW_WAYLAND = "images/ia32-wayland/"
+ self.MINNOW_NAME = "common-wayland-efi-i586"
+ elif target == "minnow64":
+ self.BASE_MINNOW_WAYLAND = "images/x86_64-wayland/"
+ self.MINNOW_NAME = "common-wayland-efi-x86_64"
+ minnow_common_minnow_prefix = self.url + self.BASE_MINNOW_WAYLAND + self.MINNOW_NAME
+ self.minnow_usr_path = minnow_common_minnow_prefix \
+ + "/tizen-common_" + self.ver_nr + "_" + self.MINNOW_NAME
+ self.minnow_usr_path_md5 = minnow_common_minnow_prefix + "/MD5SUMS"
+ self.minnow_snap_pkgs = "http://download.tizen.org/snapshots/tizen/common/tizen-common_" \
+ + self.snap_nr + "/" + self.BASE_MINNOW_WAYLAND + self.MINNOW_NAME \
+ + "/tizen-common_" + self.snap_nr + "_" + self.MINNOW_NAME + ".packages"
+
+ logging.debug('minnow (usr path): %s', self.minnow_usr_path)
+ else:
+ logging.error("Unkonown target %s", self.target)
+
+ def run(self):
+ if "odroid" == self.target:
+ self.odroid()
+ elif "minnow" in self.target:
+ self.minnow()
+ else:
+ logging.error("Unkonown target %s", self.target)
+
+ def create_projectconf(self, arch, target_name):
+ logging.debug("Create project.conf file for: %s %s", arch, target_name)
+ prjconf = [ "tizen-common_" + self.ver_nr, arch, target_name ]
+ with open("project-" + self.target + ".conf", 'w') as f:
f.write('\n'.join(prjconf) + '\n')
def fetch_url(self, url):
@@ -159,12 +173,12 @@ class ImageDownloader:
f = target.fetch()
return f
- def check_diff(self, filename, snap_pkgs, pre_pkgs):
+ def check_diff(self, snap_pkgs, pre_pkgs):
logging.debug("Checking diff")
set_snap_pkgs = set(snap_pkgs.splitlines())
set_pre_pkgs = set(pre_pkgs.splitlines())
diff = set_pre_pkgs - set_snap_pkgs
- with open(filename, 'w') as f:
+ with open(self.diff_report_filename, 'w') as f:
ret = (len(diff) == 0)
if ret:
s = 'Images are identical'
@@ -174,9 +188,9 @@ class ImageDownloader:
f.write(s)
return ret
- def write_diff_for_snapshot(self, filename):
+ def write_diff_for_snapshot(self):
logging.debug("Write diff for snapshot image")
- with open(filename, 'w') as f:
+ with open(self.diff_report_filename, 'w') as f:
f.write('Snapshot')
def check_md5(self, url):
@@ -204,29 +218,30 @@ class ImageDownloader:
def odroid(self):
logging.debug("Downloading images for: odroid")
- self.create_projectconf("project-odroid.conf", "armv7l", "Odroid U3")
- diff_report_filename="diff-odroid.report"
+ self.create_projectconf("armv7l", "Odroid U3")
if not self.is_prerelease:
- self.write_diff_for_snapshot(diff_report_filename)
+ self.write_diff_for_snapshot()
else:
- if self.check_diff(diff_report_filename, self.fetch_url(self.odroid_usr_path + ".packages"), \
+ if self.check_diff(self.fetch_url(self.odroid_usr_path + ".packages"), \
self.fetch_url(self.odroid_snap_pkgs)):
return
- logging.debug("Downloading prerelease images...")
+ logging.debug("Downloading images...")
self.get([self.odroid_boot_path + ".tar.gz"], self.odroid_boot_path_md5)
self.get([self.odroid_usr_path + ".tar.gz"], self.odroid_usr_path_md5)
def minnow(self):
logging.debug("Downloading images for: minnowboard")
- self.create_projectconf("project-minnow.conf", "i586/x86_64", "MinnowboardMax")
- diff_report_filename="diff-minnow.report"
+ if self.target == "minnow32":
+ self.create_projectconf("i586", "MinnowboardMax")
+ else:
+ self.create_projectconf("x86_64", "MinnowboardMax")
if not self.is_prerelease:
- self.write_diff_for_snapshot(diff_report_filename)
+ self.write_diff_for_snapshot()
else:
- if self.check_diff(diff_report_filename, self.fetch_url(self.minnow_usr_path + ".packages"), \
+ if self.check_diff(self.fetch_url(self.minnow_usr_path + ".packages"), \
self.fetch_url(self.minnow_snap_pkgs)):
return
- logging.debug("Downloading prerelease images...")
+ logging.debug("Downloading images...")
self.get([self.minnow_usr_path + "-sda.raw.bz2", self.minnow_usr_path + "-sda.bmap"], \
self.minnow_usr_path_md5)
@@ -241,25 +256,10 @@ def parse_arguments():
parser.add_argument("url", metavar='<url>', type=str,
help='URL of prerelease or snapshot to download images from.')
- parser.add_argument("-m", "--minnow",
- action="store_true", default=False, dest="minnow",
- help="Download images for minnowboard")
-
- parser.add_argument("--minnow32",
- action="store_true", default=False, dest="minnow32",
- help="Download images for minnowboard i586")
-
- parser.add_argument("--minnow64",
- action="store_true", default=False, dest="minnow64",
- help="Download images for minnowboard x86_64")
-
- parser.add_argument("-o", "--odroid",
- action="store_true", default=False, dest="odroid",
- help="Download images for odroid")
- parser.add_argument("-a", "--arch",
- action="store", dest="arch",
- help="Choose architecture of minnowboard images")
+ parser.add_argument("-t", "--target",
+ action="store", dest="target",
+ help="Choose target device (odroid, minnow32, minnow64) to download images for")
parser.add_argument("-l", "--log",
action="store", dest="loglevel",
@@ -277,18 +277,8 @@ def main():
raise ValueError('Invalid log level: %s' % args.loglevel)
logging.basicConfig(format='%(asctime)s %(message)s',level=numeric_level)
logging.debug("Begin")
- if args.minnow64:
- downloader = ImageDownloader(args.url, 'x86_64')
- args.minnow = True
- elif args.minnow32:
- downloader = ImageDownloader(args.url, 'i586')
- args.minnow = True
- else:
- downloader = ImageDownloader(args.url, args.arch)
- if args.odroid:
- downloader.odroid()
- if args.minnow:
- downloader.minnow()
+ downloader = ImageDownloader(args.url, args.target)
+ downloader.run()
logging.debug("End")
if __name__ == '__main__':