summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2016-03-06 22:30:00 +0200
committerLars Wirzenius <liw@liw.fi>2016-03-06 22:30:00 +0200
commiteea74e591fd26c6fc231d6447a8f273a82063276 (patch)
tree157918ecf420da17cf30b36af4e5a13e6775ef67
parent1d5c6fef9dbb28a8b28b3a26e00d115e7e13a46b (diff)
downloadick-eea74e591fd26c6fc231d6447a8f273a82063276.tar.gz
Move shell-command running steps into a module
-rw-r--r--icklib/__init__.py1
-rw-r--r--icklib/project.py51
-rw-r--r--icklib/step_run_shell.py68
-rw-r--r--without-tests1
4 files changed, 72 insertions, 49 deletions
diff --git a/icklib/__init__.py b/icklib/__init__.py
index 793ac4b..e954315 100644
--- a/icklib/__init__.py
+++ b/icklib/__init__.py
@@ -33,6 +33,7 @@ from .step_find_new_commit import (
from .step_find_tags_debian_release import FindTagsToBuildForDebianRelease
from .step_git_clone import CloneGits
from .step_project_info import LoadProjectInfo, SaveProjectInfo
+from .step_run_shell import RunShellCommandsOnEachTarget, RunLocalShellCommands
from .project import create_projects_from_ick
from .git import GitClone
from .info import InformationStore
diff --git a/icklib/project.py b/icklib/project.py
index 46043a6..58f25f1 100644
--- a/icklib/project.py
+++ b/icklib/project.py
@@ -223,53 +223,6 @@ class Project(object):
remote_git_dir)
-class RunShellCommandsOnEachTarget(icklib.BuildStep):
-
- def build(self):
- if self.run_state.build_using_shell:
- for target in self.targets:
- self._build_on_target(self.project, target, self.run_state)
-
- def _build_on_target(self, project, target, run_state):
- run_state.progress['target'] = target.name
- run_state.logger.important(
- 'Building {project_name} on {target_name}',
- project_name=project.name, target_name=target.name)
- with run_state.logger:
- remote_git_dir = target.mkdtemp()
- target.sync_to_target(
- run_state.clones[0].dirname, remote_git_dir, '.')
- try:
- for command in project.commands:
- project.run_argv_on_target(
- target, ['sh', '-euxc', command], command,
- remote_git_dir)
- except cliapp.AppException:
- target.remove_all([remote_git_dir])
- raise
- target.remove_all([remote_git_dir])
- run_state.progress['target'] = ''
-
-
-class RunLocalShellCommands(icklib.BuildStep):
-
- def build(self):
- if self.run_state.build_using_local_shell:
- self.build_locally(self.project, self.run_state)
-
- def build_locally(self, project, run_state):
- run_state.progress['target'] = 'local'
- run_state.logger.important(
- 'Building {project_name} locally',
- project_name=project.name)
- git_dir = run_state.clones[0].dirname
- with run_state.logger:
- for command in project.local_commands:
- project.run_locally(
- ['sh', '-euxc', command], command, git_dir)
- run_state.progress['target'] = ''
-
-
class CollectDebianInfoAboutTargets(icklib.BuildStep):
def build(self):
@@ -881,7 +834,7 @@ def create_projects_from_ick(ick, wanted_names):
icklib.FindCurrentGitCommits,
icklib.FindNewCommitToBuildForShell,
icklib.CreateBuildInfo,
- RunShellCommandsOnEachTarget,
+ icklib.RunShellCommandsOnEachTarget,
icklib.FinishBuildInfo,
icklib.SaveProjectInfo,
],
@@ -891,7 +844,7 @@ def create_projects_from_ick(ick, wanted_names):
icklib.FindCurrentGitCommits,
icklib.FindNewCommitToBuildForLocalShell,
icklib.CreateBuildInfo,
- RunLocalShellCommands,
+ icklib.RunLocalShellCommands,
icklib.FinishBuildInfo,
icklib.SaveProjectInfo,
],
diff --git a/icklib/step_run_shell.py b/icklib/step_run_shell.py
new file mode 100644
index 0000000..2751beb
--- /dev/null
+++ b/icklib/step_run_shell.py
@@ -0,0 +1,68 @@
+# Copyright 2016 Lars Wirzenius
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# =*= License: GPL-3+ =*=
+
+
+import cliapp
+
+import icklib
+
+
+class RunShellCommandsOnEachTarget(icklib.BuildStep):
+
+ def build(self):
+ if self.run_state.build_using_shell:
+ for target in self.targets:
+ self._build_on_target(self.project, target, self.run_state)
+
+ def _build_on_target(self, project, target, run_state):
+ run_state.progress['target'] = target.name
+ run_state.logger.important(
+ 'Building {project_name} on {target_name}',
+ project_name=project.name, target_name=target.name)
+ with run_state.logger:
+ remote_git_dir = target.mkdtemp()
+ target.sync_to_target(
+ run_state.clones[0].dirname, remote_git_dir, '.')
+ try:
+ for command in project.commands:
+ project.run_argv_on_target(
+ target, ['sh', '-euxc', command], command,
+ remote_git_dir)
+ except cliapp.AppException:
+ target.remove_all([remote_git_dir])
+ raise
+ target.remove_all([remote_git_dir])
+ run_state.progress['target'] = ''
+
+
+class RunLocalShellCommands(icklib.BuildStep):
+
+ def build(self):
+ if self.run_state.build_using_local_shell:
+ self.build_locally(self.project, self.run_state)
+
+ def build_locally(self, project, run_state):
+ run_state.progress['target'] = 'local'
+ run_state.logger.important(
+ 'Building {project_name} locally',
+ project_name=project.name)
+ git_dir = run_state.clones[0].dirname
+ with run_state.logger:
+ for command in project.local_commands:
+ project.run_locally(
+ ['sh', '-euxc', command], command, git_dir)
+ run_state.progress['target'] = ''
diff --git a/without-tests b/without-tests
index 7c321f2..dbd9af4 100644
--- a/without-tests
+++ b/without-tests
@@ -10,3 +10,4 @@ icklib/step_find_new_commit.py
icklib/step_find_tags_debian_release.py
icklib/step_git_clone.py
icklib/step_project_info.py
+icklib/step_run_shell.py