diff options
author | Tomás Touceda <chiiph@leap.se> | 2014-09-11 14:35:43 -0300 |
---|---|---|
committer | Tomás Touceda <chiiph@leap.se> | 2014-09-11 14:35:43 -0300 |
commit | a244174d377f5b9ebe889078f51511f45f47fe54 (patch) | |
tree | d159f52156f52fb672f38216b30c231574261007 | |
parent | 4d08978c2d45099cd47496a883b954f2ad0aa7bb (diff) | |
parent | 6f82fe5991d616bad0e0caf9340544ed7cdc2099 (diff) |
Merge remote-tracking branch 'refs/remotes/meskio/feature/6044_diferenciate_linux32_64' into develop
-rw-r--r-- | changes/feature_6044_diferenciate_linux32_64 | 2 | ||||
-rw-r--r-- | src/launcher.py | 41 |
2 files changed, 30 insertions, 13 deletions
diff --git a/changes/feature_6044_diferenciate_linux32_64 b/changes/feature_6044_diferenciate_linux32_64 new file mode 100644 index 0000000..6aa8d12 --- /dev/null +++ b/changes/feature_6044_diferenciate_linux32_64 @@ -0,0 +1,2 @@ +- Add support for multiple archs in the same platform. Closes #6044 +- Stop updater if platform is not defined. Closes #6052 diff --git a/src/launcher.py b/src/launcher.py index a47d697..fbd0368 100644 --- a/src/launcher.py +++ b/src/launcher.py @@ -12,9 +12,8 @@ from leap.common.events import events_pb2 as proto import tuf.client.updater bundles_per_platform = { - "Windows": "windows", - "Darwin": "darwin", - "Linux": "linux", + "Linux-i386": "linux-i368", + "Linux-x86_64": "linux-x86_64", } GENERAL_SECTION = "General" @@ -24,7 +23,8 @@ DELAY_KEY = "updater_delay" class TUF(threading.Thread): def __init__(self, config): """ - Initialize the list of mirrors, paths and other TUF dependencies from the config file + Initialize the list of mirrors, paths and other TUF dependencies from + the config file """ if config.has_section(GENERAL_SECTION) and \ config.has_option(GENERAL_SECTION, DELAY_KEY): @@ -34,7 +34,8 @@ class TUF(threading.Thread): self._load_mirrors(config) if not self.mirrors: - print "ERROR: No updater mirrors found (missing or not well formed launcher.conf)" + print("ERROR: No updater mirrors found (missing or not well " + "formed launcher.conf)") self.bundle_path = os.getcwd() self.source_path = self.bundle_path @@ -52,13 +53,16 @@ class TUF(threading.Thread): while True: try: - tuf.conf.repository_directory = os.path.join(self.bundle_path, 'repo') + tuf.conf.repository_directory = os.path.join(self.bundle_path, + 'repo') - updater = tuf.client.updater.Updater('leap-updater', self.mirrors) + updater = tuf.client.updater.Updater('leap-updater', + self.mirrors) updater.refresh() targets = updater.all_targets() - updated_targets = updater.updated_targets(targets, self.source_path) + updated_targets = updater.updated_targets(targets, + self.source_path) for target in updated_targets: updater.download_target(target, self.dest_path) self._set_permissions(target) @@ -66,9 +70,13 @@ class TUF(threading.Thread): if os.path.isdir(self.update_path): shutil.rmtree(self.update_path) shutil.move(self.dest_path, self.update_path) + filepath = sorted([f['filepath'] for f in updated_targets]) signal(proto.UPDATER_NEW_UPDATES, - content=", ".join(sorted([f['filepath'] for f in updated_targets]))) + content=", ".join(filepath)) return + except NotImplemented as e: + print "NotImplemented: ", e + return except Exception as e: print "ERROR:", e finally: @@ -80,20 +88,27 @@ class TUF(threading.Thread): if section[:6] != 'Mirror': continue url_prefix = config.get(section, 'url_prefix') - metadata_path = bundles_per_platform[platform.system()] + '/metadata' - targets_path = bundles_per_platform[platform.system()] + '/targets' + metadata_path = self._repo_path() + '/metadata' + targets_path = self._repo_path() + '/targets' self.mirrors[section[7:]] = {'url_prefix': url_prefix, 'metadata_path': metadata_path, 'targets_path': targets_path, 'confined_target_dirs': ['']} def _set_permissions(self, target): - file_permisions = int(target["fileinfo"]["custom"]["file_permissions"], 8) + file_permissions_str = target["fileinfo"]["custom"]["file_permissions"] + file_permissions = int(file_permissions_str, 8) filepath = target['filepath'] if filepath[0] == '/': filepath = filepath[1:] file_path = os.path.join(self.dest_path, filepath) - os.chmod(file_path, file_permisions) + os.chmod(file_path, file_permissions) + + def _repo_path(self): + system = platform.system() + "-" + platform.machine() + if system not in bundles_per_platform: + raise NotImplemented("Platform %s not supported" % (system,)) + return bundles_per_platform[system] if __name__ == "__main__": |