summaryrefslogtreecommitdiff
path: root/ick
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2015-05-24 20:25:45 +0300
committerLars Wirzenius <liw@liw.fi>2015-05-24 20:27:15 +0300
commit4eef5242f9f33d128c4552d8e9be95196d0c6475 (patch)
tree0977bb4a6dc25593e4f1eebbd5fddd1b7d231884 /ick
parent433013b16d8479c21e651105655fcf5616d680be (diff)
downloadick-4eef5242f9f33d128c4552d8e9be95196d0c6475.tar.gz
Make use of icklib.Target
Diffstat (limited to 'ick')
-rwxr-xr-xick42
1 files changed, 21 insertions, 21 deletions
diff --git a/ick b/ick
index 7ff7a57..c16d4a4 100755
--- a/ick
+++ b/ick
@@ -62,9 +62,10 @@ class Ick(cliapp.Application):
self.build_project(statedir, project_name, project, targets)
def get_targets(self, ick):
- return self.pick_from_dict(
- ick.get('targets', {}),
- self.settings['target'])
+ target_dicts = ick.get('targets', {})
+ wanted_names = self.settings['target']
+ wanted_dicts = self.pick_from_dict(target_dicts, wanted_names)
+ return [self.make_target(name, x) for name, x in wanted_dicts.items()]
def pick_from_dict(self, items, names):
if names:
@@ -72,6 +73,11 @@ class Ick(cliapp.Application):
else:
return items
+ def make_target(self, target_name, target_dict):
+ t = icklib.Target(target_name)
+ t.set_address(target_dict['address'])
+ return t
+
def get_projects(self, ick):
return self.pick_from_dict(
ick.get('projects', {}),
@@ -95,9 +101,8 @@ class Ick(cliapp.Application):
return
build_dir = self.get_next_build_dir(statedir, project_name)
- for target_name, target in targets.items():
- self.build_on_target(
- project_name, project, target_name, target, git_dir)
+ for target in targets:
+ self.build_on_target(project_name, project, target, git_dir)
self.save_build_metadata(build_dir, meta)
def needs_to_be_built(self, statedir, project_name, current_commit):
@@ -147,36 +152,31 @@ class Ick(cliapp.Application):
output = cliapp.runcmd(['git', 'rev-parse', 'HEAD'], cwd=git_dir)
return output.strip()
- def build_on_target(self, project_name, project, target_name, target,
- git_dir):
+ def build_on_target(self, project_name, project, target, git_dir):
with self.logger:
self.logger.log(
'Building {project_name} on {target_name}',
- project_name=project_name, target_name=target_name)
- address = target['address']
- remote_git_dir = self.rsync_to_target(git_dir, address)
+ project_name=project_name, target_name=target.name)
+ remote_git_dir = self.rsync_to_target(git_dir, target)
try:
for command in project.get('commands', []):
- self.run_on_target(address, command, remote_git_dir)
+ self.run_on_target(target, command, remote_git_dir)
except cliapp.AppException:
cliapp.ssh_runcmd(address, ['rm', '-rf', remote_git_dir])
raise
- def rsync_to_target(self, source, address):
- output = cliapp.ssh_runcmd(address, ['mktemp', '-d'])
+ def rsync_to_target(self, source, target):
+ output = target.ssh_runcmd(['mktemp', '-d'])
remote_git_dir = output.strip()
- cliapp.runcmd(
- ['rsync', '-aHSs', source + '/.',
- '%s:%s/.' % (address, remote_git_dir)])
+ target.sync_to_target(source, remote_git_dir)
return remote_git_dir
- def run_on_target(self, address, command, remote_cwd):
+ def run_on_target(self, target, command, remote_cwd):
with self.logger:
self.logger.log(
'On {address} run {command}',
- address=address, command=command)
- output = cliapp.ssh_runcmd(
- address,
+ address=target.address, command=command)
+ output = target.ssh_runcmd(
['sh', '-euxc', command],
remote_cwd=remote_cwd,
stderr=subprocess.STDOUT)