Improve first-run behavior with build metadata.

This commit makes the kde-build-metadata module a requirement instead of
an option, since the vast majority of runs will require this module now.

Additionally the --metadata-only option is added and documented to allow
for downloading the kde-build-metadata module alone (and make the
--pretend option work afterwards), and kdesrc-build recommends using it
if you run with --pretend and without metadata.

This should hopefully make the first-run use case easier for users.

BUG:337446
FIXED-IN:1.16
wilder
Michael Pyne 12 years ago
parent 848f035ace
commit 6911da5c87
  1. 33
      doc/index.docbook
  2. 14
      doc/man-kdesrc-build.1.docbook
  3. 72
      modules/ksb/Application.pm

@ -1078,7 +1078,11 @@ included with the &kdesrc-build; source.</para>
You can <quote>pretend</quote> to do the operations. If you pass
<option>--pretend</option> or <option>-p</option> on the
command line, the script will give a verbose description of the commands
it is about to execute, without actually executing it.
it is about to execute, without actually executing it. However if you've never
run &kdesrc-build;, you would want to run the <command>kdesrc-build
<option><link
linkend="cmdline-metadata-only">--metadata-only</link></option></command>
command first in order for <option>--pretend</option> to work.
<tip><para>For an even more verbose description of what &kdesrc-build; is
doing, try using the <option>--debug</option> option.
@ -2770,10 +2774,19 @@ performing any actions to update or build, will instead output what the
script would have done (e.g. what commands to run, general steps being taken,
etc.).</para>
<para>Note: Simple read-only commands (such as reading file information) may
<note><para>Simple read-only commands (such as reading file information) may
still be run to make the output more relevant (such as correctly simulating
whether source code would be checked out or updated).
</para></listitem>
</para></note>
<important><para>This option requires that some needed metadata is available,
which is normally automatically downloaded, but downloads are disabled in
pretend mode. If you've never run &kdesrc-build; (and therefore, don't have
this metadata), you should run <command>kdesrc-build
<option>--metadata-only</option></command> to download the required metadata
first.
</para></important>
</listitem>
</varlistentry>
<varlistentry id="cmdline-quiet">
@ -2820,6 +2833,15 @@ Only perform the install process.
</para></listitem>
</varlistentry>
<varlistentry id="cmdline-metadata-only">
<term><parameter>--metadata-only</parameter></term>
<listitem><para>
Only perform the metadata download process. &kdesrc-build; normally handles this
automatically, but you might manually use this to allow the <option><link
linkend="cmdline-pretend">--pretend</link></option> command line option to work.
</para></listitem>
</varlistentry>
<varlistentry id="cmdline-ignore-modules">
<term><parameter>--ignore-modules</parameter></term>
<listitem><para>
@ -2854,7 +2876,10 @@ The source updates for the modules themselves will still occur unless you pass
<link linkend="cmdline-no-src">--no-src</link> as well.
</para><para>
This can be useful if you are frequently re-running &kdesrc-build; since the
metadata does not change very often.
metadata does not change very often. But note that many other features require
the metadata to be available. You might want to consider running &kdesrc-build;
with the <link linkend="cmdline-metadata-only">--metadata-only</link> option
one time and then using this option for subsequent runs.
</para></listitem>
</varlistentry>

@ -251,6 +251,20 @@ combining short options into one at this point. (E.g. running
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--metadata-only</option>
</term>
<listitem>
<para>
Only updates the build metadata needed for KDE modules, then exits. This is
useful to allow the <option>--pretend</option> option to work if you've never
run kdesrc-build. See also <option>--no-metadata</option>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--refresh-build</option>

@ -67,6 +67,11 @@ sub new
my @moduleList = $self->generateModuleList(@options);
$self->{modules} = \@moduleList;
if (!@moduleList) {
print "No modules to build, exiting.\n";
exit 0;
}
$self->context()->setupOperatingEnvironment(); # i.e. niceness, ulimits, etc.
# After this call, we must run the finish() method
@ -274,6 +279,7 @@ DONE
'revision=i', 'resume-from=s', 'resume-after=s',
'resume', 'stop-on-failure',
'stop-after=s', 'stop-before=s', 'set-module-option-value=s',
'metadata-only',
# Special sub used (see above), but have to tell Getopt::Long to look
# for strings
@ -580,6 +586,18 @@ sub generateModuleList
_executeCommandLineProgram(@startProgramArgs); # noreturn
}
# Selecting modules or module sets would require having the KDE build
# metadata available. This used to be optional, but now everything needs
# it, so download it unilaterally.
$ctx->setKDEProjectMetadataModuleNeeded();
$self->_downloadKDEProjectMetadata();
# The user might only want metadata to update to allow for a later
# --pretend run, check for that here.
if (exists $pendingGlobalOptions->{'metadata-only'}) {
return;
}
# At this point we have our list of candidate modules / module-sets (as read in
# from rc-file). The module sets have not been expanded into modules.
# We also might have cmdline "selectors" to determine which modules or
@ -641,6 +659,7 @@ sub _downloadKDEProjectMetadata
{
my $self = shift;
my $ctx = $self->context();
my $updateNeeded;
my $metadataModule = $ctx->getKDEProjectMetadataModule();
eval {
@ -648,13 +667,19 @@ sub _downloadKDEProjectMetadata
super_mkdir($sourceDir);
my $updateDesired = !$ctx->getOption('no-metadata') && $ctx->phases()->has('update');
my $updateNeeded = (! -e "$sourceDir/dependency-data-common");
$updateNeeded = (! -e "$sourceDir/dependency-data-common");
my $lastUpdate = $ctx->getPersistentOption('global', 'last-metadata-update') // 0;
if (!$updateDesired && $updateNeeded && (time - ($lastUpdate)) >= 7200) {
warning (" r[b[*] Skipping build metadata update, but it hasn't been updated recently!");
}
if ($updateNeeded && pretending() && ! -e $sourceDir) {
croak_runtime("\n\tCan't use --pretend without having metadata
available, and can't download it in pretend mode. Try running
\"kdesrc-build --metadata-only\" first and try again.");
}
if ($updateDesired && (!pretending() || $updateNeeded)) {
$metadataModule->scm()->updateInternal();
$ctx->setPersistentOption('global', 'last-metadata-update', time);
@ -662,9 +687,14 @@ sub _downloadKDEProjectMetadata
};
if ($@) {
warning (" b[r[*] Unable to download required metadata for build process");
warning (" b[r[*] Will attempt to press onward...");
warning (" b[r[*] Exception message: $@");
if (!$updateNeeded) {
warning (" b[r[*] Unable to download required metadata for build process");
warning (" b[r[*] Will attempt to press onward...");
warning (" b[r[*] Exception message: $@");
}
else {
die;
}
}
}
@ -710,6 +740,7 @@ sub _resolveModuleDependencies
# Runs all update, build, install, etc. phases. Basically this *is* the
# script.
# The metadata module must already have performed its update by this point.
sub runAllModulePhases
{
my $self = shift;
@ -717,28 +748,23 @@ sub runAllModulePhases
my $metadataModule = $ctx->getKDEProjectMetadataModule();
my @modules = $self->modules();
# If we have kde-build-metadata we must process it first, ASAP.
if ($metadataModule) {
$self->_downloadKDEProjectMetadata();
$ctx->addToIgnoreList($metadataModule->scm()->ignoredModules());
$ctx->addToIgnoreList($metadataModule->scm()->ignoredModules());
# Remove modules that are explicitly blanked out in their branch-group
# i.e. those modules where they *have* a branch-group, and it's set to
# be empty ("").
my $resolver = $ctx->moduleBranchGroupResolver();
my $branchGroup = $ctx->effectiveBranchGroup();
# Remove modules that are explicitly blanked out in their branch-group
# i.e. those modules where they *have* a branch-group, and it's set to
# be empty ("").
my $resolver = $ctx->moduleBranchGroupResolver();
my $branchGroup = $ctx->effectiveBranchGroup();
@modules = grep {
my $branch = $_->isKDEProject()
? $resolver->findModuleBranch($_->fullProjectPath(), $branchGroup)
: 1; # Just a placeholder truthy value
whisper ("Removing $_ due to branch-group") if (defined $branch and !$branch);
(!defined $branch or $branch); # This is the actual test
} (@modules);
@modules = grep {
my $branch = $_->isKDEProject()
? $resolver->findModuleBranch($_->fullProjectPath(), $branchGroup)
: 1; # Just a placeholder truthy value
whisper ("Removing $_ due to branch-group") if (defined $branch and !$branch);
(!defined $branch or $branch); # This is the actual test
} (@modules);
@modules = $self->_resolveModuleDependencies(@modules);
}
@modules = $self->_resolveModuleDependencies(@modules);
# Filter --resume-foo options. This might be a second pass, but that should
# be OK since there's nothing different going on from the first pass (in

Loading…
Cancel
Save