summaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorMarius Storm-Olsen <marius.storm-olsen@nokia.com>2012-04-08 22:25:26 -0500
committerQt by Nokia <qt-info@nokia.com>2012-04-20 18:51:50 +0200
commit8ddc280393f942c8d684c78ec2b34ee13c284e80 (patch)
treec4221cd3e5c4deb34fa4a0524f226e4a7e3fed29 /build
parent9fa0f5ddf47b0ab06e50fad0799f328cc9ca3b61 (diff)
Clean up exit/die/return mess for exe*()
The exe*() functions were inconsistent of where they exited. So, make sure that all exe*() confesses upon errors, and let the calling functions use eval{} to avoid the exception when needed. Change-Id: Ia6e4edb22a83ac32d924b792e8a2eea657a6a149 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
Diffstat (limited to 'build')
-rwxr-xr-xbuild29
1 files changed, 16 insertions, 13 deletions
diff --git a/build b/build
index a4fd74fd..2649c9c1 100755
--- a/build
+++ b/build
@@ -155,11 +155,10 @@ sub exe
print "+ @cmd\n" unless ($self->{quiet});
+ # dry-run > 1 means run sub-processes with dry-run too
if ($self->{'dry-run'} != 1) {
confess "@cmd exited with status $CHILD_ERROR" if (system(@cmd) != 0);
}
-
- return 0;
}
sub dropPrivileges()
@@ -189,29 +188,33 @@ sub dropPrivileges()
sub exeHighPriv()
{
my ($self, @cmd) = @_;
- return $self->exe(@cmd);
+ # confesses upon system() failure
+ $self->exe(@cmd);
}
sub exeLowPriv()
{
my ($self, @cmd) = @_;
- if ("$Config{osname}" =~ /mswin/i) {
- # Just like exeHighPriv for now
- return $self->exe(@cmd);
- } else {
+ if ("$Config{osname}" !~ /mswin/i) {
my $ret;
my $pid = fork();
die "Couldn't fork" unless defined $pid;
if ($pid == 0) {
$self->dropPrivileges;
- $self->exe(@cmd);
- exit 0;
+ # just exit on error, exception propagated below
+ eval { $self->exe(@cmd); };
+ exit $?;
} else {
waitpid($pid, 0);
- return $?;
+ # propagate exception upon system() failure in fork
+ die if ($? != 0);
+ return;
}
}
+
+ # Just like exeHighPriv for now, and confesses upon failure
+ $self->exe(@cmd);
}
sub which {
@@ -422,15 +425,15 @@ sub build_project
my $install_command = $self->{'instcmds'}->{$module};
if (!defined $build_command) {
if (!-e "$module/Makefile") {
- $self->exeLowPriv("cd $module && qmake -r") && die "'cd $module && qmake -r' failed: $?";
+ $self->exeLowPriv("cd $module && qmake -r");
}
$build_command = "$self->{MAKE} $self->{MAKEOPTS}";
}
- $self->exeLowPriv("cd $module && $build_command") && die "'cd $module && $build_command' failed: $?";
+ $self->exeLowPriv("cd $module && $build_command");
$install_command = "$self->{MAKE} install" if (!defined $install_command);
### TODO: Should be fixed after the alpha
unless ("$Config{osname}" =~ /(dar|ms)win/i) {
- $self->exeHighPriv("cd $module && $install_command") && die "'cd $module && $install_command failed: $?";
+ $self->exeHighPriv("cd $module && $install_command");
}
$self->mark_as_finished($module);
return 0;