summaryrefslogtreecommitdiff
path: root/tsp/scripts
diff options
context:
space:
mode:
authorAleksander Mistewicz <a.mistewicz@samsung.com>2016-10-06 14:07:03 (GMT)
committerAleksander Mistewicz <a.mistewicz@samsung.com>2017-01-09 18:46:14 (GMT)
commit56def2b80c3a4630c9c1ca20145a25c280e84637 (patch)
treedbc13ce49feec4a885cc32f9707bb04475ff037b /tsp/scripts
parent405f98976f16d2327f6611b21bbf1d187bf35e47 (diff)
downloadmajor-56def2b80c3a4630c9c1ca20145a25c280e84637.zip
major-56def2b80c3a4630c9c1ca20145a25c280e84637.tar.gz
major-56def2b80c3a4630c9c1ca20145a25c280e84637.tar.bz2
Simplify tsp/scripts/download_image.py coderefs/changes/77/95277/5
It makes it easier to add support for new target devices. Change-Id: I082686f3a55453677094b7a2559802a1bd0481d7 Signed-off-by: Aleksander Mistewicz <a.mistewicz@samsung.com>
Diffstat (limited to 'tsp/scripts')
-rwxr-xr-xtsp/scripts/download_image.py132
1 files changed, 61 insertions, 71 deletions
diff --git a/tsp/scripts/download_image.py b/tsp/scripts/download_image.py
index 8b77676..74ac03c 100755
--- a/tsp/scripts/download_image.py
+++ b/tsp/scripts/download_image.py
@@ -27,7 +27,7 @@ import urllib2
import argparse
import logging
-__version__ = "1.1.0"
+__version__ = "1.1.1"
__license__ = "APACHE-2.0"
__author__ = "Aleksander Mistewicz"
__author_email__ = "a.mistewicz@samsung.com"
@@ -111,11 +111,15 @@ class ImageDownloader:
logging.debug('snapshot number: %s', self.snap_nr)
logging.debug('version number: %s', self.ver_nr)
+ self.imgs = list()
+ self.md5sums = list()
+
if "odroid" == self.target or "artik" in self.target:
self.BASE_ARM_WAYLAND = "images/arm-wayland/"
if "odroid" == self.target:
self.BOOT_NAME = "common-boot-armv7l-odroidu3"
self.USR_NAME = "common-wayland-3parts-armv7l-odroidu3"
+ self.create_projectconf("armv7l", "Odroid U3")
elif "artik" in self.target:
if "artik5" in self.target:
self.BOOT_NAME = "common-boot-armv7l-artik5"
@@ -132,48 +136,62 @@ class ImageDownloader:
else:
self.USR_NAME = "common-wayland-3parts-armv7l-artik"
self.artik_usr_type = "wayland"
+ self.create_projectconf("armv7l", self.artik_usr_type + ' ' + self.artik_boot_type)
+ # Boot image
arm_common_boot_prefix = self.url + self.BASE_ARM_WAYLAND + self.BOOT_NAME
- self.arm_boot_path = arm_common_boot_prefix \
- + "/tizen-common_" + self.ver_nr + "_" + self.BOOT_NAME
- self.arm_boot_path_md5 = arm_common_boot_prefix + "/MD5SUMS"
+ self.imgs.append(arm_common_boot_prefix + "/tizen-common_" + self.ver_nr + "_" + self.BOOT_NAME + ".tar.gz")
+ self.md5sums.append(arm_common_boot_prefix + "/MD5SUMS")
+ # Userspace image
arm_common_usr_prefix = self.url + self.BASE_ARM_WAYLAND + self.USR_NAME
- self.arm_usr_path = arm_common_usr_prefix \
- + "/tizen-common_" + self.ver_nr + "_" + self.USR_NAME
- self.arm_usr_path_md5 = arm_common_usr_prefix + "/MD5SUMS"
- self.arm_snap_pkgs = "http://download.tizen.org/snapshots/tizen/common/tizen-common_" \
+ img_usr = arm_common_usr_prefix + "/tizen-common_" + self.ver_nr + "_" + self.USR_NAME
+ self.imgs.append(img_usr + ".tar.gz")
+ self.md5sums.append(arm_common_usr_prefix + "/MD5SUMS")
+
+ # Packages
+ self.pkgs = img_usr + ".packages"
+ self.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('arm (boot path): %s', self.arm_boot_path)
- logging.debug('arm (usr path): %s', self.arm_usr_path)
- elif "minnow" in self.target:
+ elif "minnow" in self.target:
if target == "minnow32":
self.BASE_MINNOW_WAYLAND = "images/ia32-wayland/"
self.MINNOW_NAME = "common-wayland-efi-i586"
+ self.create_projectconf("i586", "MinnowboardMax")
elif target == "minnow64":
self.BASE_MINNOW_WAYLAND = "images/x86_64-wayland/"
self.MINNOW_NAME = "common-wayland-efi-x86_64"
+ self.create_projectconf("x86_64", "MinnowboardMax")
+
+ # Userspace image
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_" \
+ img_usr = minnow_common_minnow_prefix + "/tizen-common_" + self.ver_nr + "_" + self.MINNOW_NAME
+ self.imgs.append(img_usr + "-sda.raw.bz2")
+ self.imgs.append(img_usr + "-sda.bmap")
+ self.md5sums.append(minnow_common_minnow_prefix + "/MD5SUMS")
+
+ # Packages
+ self.pkgs = img_usr + ".packages"
+ self.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)
+ return
+ # Postcondition
+ logging.debug("Files to download: %s", self.imgs)
+ logging.debug("MD5SUMS to use: %s", self.md5sums)
+ logging.debug("Package files (prerelease): %s", self.pkgs)
+ logging.debug("Package files (snapshot): %s", self.snap_pkgs)
def run(self):
- if "odroid" == self.target or "artik" in self.target:
- self.arm()
- elif "minnow" in self.target:
- self.minnow()
- else:
- logging.error("Unkonown target %s", self.target)
+ if not self.is_prerelease:
+ self.write_diff_for_snapshot()
+ elif self.check_diff(self.fetch_url(self.pkgs), self.fetch_url(self.snap_pkgs)):
+ return
+ logging.debug("Downloading images...")
+ self.get(self.imgs, self.md5sums)
def create_projectconf(self, arch, target_name):
logging.debug("Create project.conf file for: %s %s", arch, target_name)
@@ -211,21 +229,25 @@ class ImageDownloader:
with open(self.diff_report_filename, 'w') as f:
f.write('Snapshot')
- def check_md5(self, url):
- logging.debug("Checking md5sum")
- md5_file = "md5sums"
- subprocess.call(["wget", url, "-O", md5_file])
- subprocess.call(["sed", "-e", "/\(ks\|json\|log\|xml\|-default\|packages\)/d", "-i", md5_file])
- ret = subprocess.call(["md5sum", "-c", md5_file])
- if not ret:
- logging.info("Checksum OK")
- else:
- logging.warn("Checksum FAILED\nRemoving files mentioned in md5sums file")
- with open(md5_file, 'r') as f:
- for i in f:
- os.remove(re.findall(r'tizen-common_.+', i)[0])
- os.remove(md5_file)
- return ret
+ def check_md5(self, urls):
+ for url in urls:
+ logging.debug("Checking md5sum")
+ md5_file = "md5sums"
+ subprocess.call(["wget", url, "-O", md5_file])
+ subprocess.call(["sed", "-e", "/\(ks\|json\|log\|xml\|-default\|packages\)/d", "-i", md5_file])
+ ret = subprocess.call(["md5sum", "-c", md5_file])
+ if not ret:
+ logging.info("Checksum OK")
+ os.remove(md5_file)
+ continue
+ else:
+ logging.warn("Checksum FAILED\nRemoving files mentioned in md5sums file")
+ with open(md5_file, 'r') as f:
+ for i in f:
+ os.remove(re.findall(r'tizen-common_.+', i)[0])
+ os.remove(md5_file)
+ return True
+ return False
def get(self, urls, md5sum):
while True:
@@ -234,38 +256,6 @@ class ImageDownloader:
break
time.sleep(60)
- def arm(self):
- logging.debug("Downloading images for: arm")
- if "odroid" == self.target:
- self.create_projectconf("armv7l", "Odroid U3")
- elif "artik" in self.target:
- self.create_projectconf("armv7l", self.artik_usr_type + ' ' + self.artik_boot_type)
- if not self.is_prerelease:
- self.write_diff_for_snapshot()
- else:
- if self.check_diff(self.fetch_url(self.arm_usr_path + ".packages"), \
- self.fetch_url(self.arm_snap_pkgs)):
- return
- logging.debug("Downloading images...")
- self.get([self.arm_boot_path + ".tar.gz"], self.arm_boot_path_md5)
- self.get([self.arm_usr_path + ".tar.gz"], self.arm_usr_path_md5)
-
- def minnow(self):
- logging.debug("Downloading images for: minnowboard")
- 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()
- else:
- if self.check_diff(self.fetch_url(self.minnow_usr_path + ".packages"), \
- self.fetch_url(self.minnow_snap_pkgs)):
- return
- logging.debug("Downloading images...")
- self.get([self.minnow_usr_path + "-sda.raw.bz2", self.minnow_usr_path + "-sda.bmap"], \
- self.minnow_usr_path_md5)
-
def parse_arguments():
"""parse_arguments() -> args