@ -1671,11 +1671,10 @@ sub install_module_snapshot
# branch option if specified. Otherwise the default branch for the
# module is selected (usually trunk, perhaps 4.3)
my $branch = get_option($module, 'tag');
$branch = get_option($module, 'branch') if not $branch;
# FIXME: This is broken for kdesupport (since it is default tags) but should magically
# work since there will be no snapshot available.
$branch = default_module _branch($module) if not $branch;
$branch = get_svn _branch($module) if not $branch;
my ($filename, $url, $dirName);
@ -1871,9 +1870,40 @@ sub moduleBaseName
return $module;
}
# Returns the user-selected branch for the given module, or 'master' if no
# branch was selected.
#
# First parameter is the module name.
sub get_git_branch
{
my $module = shift;
my $branch = get_option($module, 'branch');
$branch = 'master' unless $branch;
return $branch;
}
# Returns the first valid value among the following (for the given module,
# assumed to be a Subversion module):
# 1. User's selected branch option
# 2. Default branch option (if non-empty)
# 3. 'trunk'
#
# First parameter is the module name.
sub get_svn_branch
{
my $module = shift;
my $branch = get_option($module, 'branch');
$branch = default_module_branch($module) unless $branch;
$branch = 'trunk' unless $branch;
return $branch;
}
# Perform a git clone to checkout the latest branch of either the official
# Qt Software Qt 4, or the KDE-Qt repository (essentially the old qt-copy
# with patches applied).
# Assumes the __kdesvn-build-remote git remote has been setup.
#
# First parameter is the module to perform the checkout of.
# Second parameter is the repository (typically URL) to use.
@ -1887,12 +1917,35 @@ sub git_clone_module
my $result = log_command($module, 'git-clone', ['git', 'clone', '--', $git_repo, $srcdir]);
if ($result == 0) {
set_persistent_option($module, 'git-cloned-repository', $git_repo);
$result = log_command($module, 'git-remote-setup',
['git', 'remote', 'add', '__kdesvn-build-remote', $git_repo]);
}
return ($result == 0);
}
# Returns boolean true if the git checkout for the current source directory
# contains a specified branch name.
#
# First parameter is the branch name.
sub git_has_branch
{
my $branch = shift;
my @output = slurp_program_output('git', 'branch');
foreach (@output) {
chomp;
s/^\s*\*?\s*//; # Remove leading gunk
return 1 if ($_ eq $branch);
}
return 0;
}
# Updates an already existing git checkout by running git pull.
# Assumes the __kdesvn-build-remote git remote has been setup.
#
# First parameter is the module to download.
# Returns boolean true if successful, otherwise 0.
@ -1910,12 +1963,41 @@ sub git_update_module
return ($result == 0);
}
else {
warning " y[b[*] y[$module]'s repository has changed";
warning " y[b[*] from\t$old_repo";
warning " y[b[*] to\t$cur_repo,";
warning " y[b[*] but support for this has not been implemented yet.";
warning " y[b[*] No update has occurred, but proceeding anyways.";
return 1;
note " y[b[*] y[$module]'s selected repository has changed:";
note " y[b[*] from\t$old_repo";
note " y[b[*] to\t$cur_repo,";
note " y[b[*] Attempting to perform the switch";
# Ensure any existing remote is removed and recreated
# Don't log it, we don't need the output
safe_system(qw(git remote rm __kdesvn-build-remote));
my $result = log_command($module, 'git-remote-setup',
['git', 'remote', 'add', '__kdesvn-build-remote', $cur_repo]);
if ($result != 0) {
return 0;
}
my $branch = get_git_branch($module);
if (0 != log_command($module, 'git-fetch', ['git', 'fetch', '__kdesvn-build-remote'])) {
return 0;
}
# If the user doesn't already have this branch, check it out.
if (not git_has_branch($branch)) {
$result = log_command($module, 'git-checkout-branch',
['git', 'checkout', '-b', $branch, "__kdesvn-build-remote/$branch"]);
return 0 if $result != 0;
}
else {
$result = log_command($module, 'git-checkout-update',
['git', 'checkout', "__kdesvn-build-remote/$branch"]);
}
# Update what we think is the current repository on-disk.
set_persistent_option($module, 'git-cloned-repository', $cur_repo);
return $result == 0;
}
}
@ -1938,7 +2020,7 @@ sub update_module_git_checkout
my $git_repo = get_option($module, 'repository');
if (not $git_repo) {
die "Unable to checkout Qt , you must specify a repository to use.";
die "Unable to checkout $module , you must specify a repository to use.";
}
git_clone_module($module, "$git_repo") or die "Can't checkout $module: $!";
@ -2590,10 +2672,7 @@ sub default_module_branch
my $module = shift;
my $branch = get_option('global', 'branch');
my $default = 'trunk';
# Go go gadget git!
$default = 'master' if $module eq 'qt-copy';
my $default = '';
# If the module doesn't normally get branched there's not much we can do, so we'll just
# return the default. (We search against regexps instead of module names here)
@ -2633,16 +2712,12 @@ sub default_module_options
);
# Hack to support default "tags" instead of default branches for kdesupport.
my $tagname = 'branch';
if ($branch =~ /^tags\//)
{
$branch =~ s/^tags\///; # Strip tags/
$tagname = 'tag' ;
$options{'tag'} = $branch ;
}
$options{$tagname} = $branch;
if ($module eq 'qt-copy') {
# Setup default options for qt-copy
my %qtcopy_opts = (
@ -3313,6 +3388,30 @@ sub read_persistent_options
}
}
# Returns an array of lines output from a program. Use this only if you
# expect that the output will be short.
#
# Since there is no way to disambiguate no output from an error, this
# function will call die on error, wrap in eval if this bugs you.
#
# First parameter is the program to run, all remaining arguments are
# passed to the program.
sub slurp_program_output
{
my ($program, @args) = @_;
my $output;
my $pid = open3(0, $output, undef, $program, @args);
# Just read all the input in so we can safely waitpid the process
my @lines = <$output>;
close $output;
waitpid $pid, 0;
return @lines;
}
# Returns a requested parameter from 'svn info' for the given module.
#
# First parameter is the module.
@ -3334,12 +3433,7 @@ sub get_svn_info
p_chdir ($srcdir);
my $output;
local $ENV{'LC_ALL'} = 'C'; # Make the svn output untranslated
my $pid = open3(0, $output, undef, 'svn', 'info', '--non-interactive', '.');
# Just read all the input in so we can safely waitpid the process
my @lines = <$output>;
close $output;
waitpid $pid, 0;
my @lines = slurp_program_output('svn', 'info', '--non-interactive', '.');
foreach (@lines)
{