From 6911da5c8713c3e33e8e43c6707a2c871bf79375 Mon Sep 17 00:00:00 2001 From: Michael Pyne Date: Wed, 16 Jul 2014 01:00:55 -0400 Subject: [PATCH] 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 --- doc/index.docbook | 33 ++++++++++++++-- doc/man-kdesrc-build.1.docbook | 14 +++++++ modules/ksb/Application.pm | 72 +++++++++++++++++++++++----------- 3 files changed, 92 insertions(+), 27 deletions(-) diff --git a/doc/index.docbook b/doc/index.docbook index 449ca0d..2395886 100644 --- a/doc/index.docbook +++ b/doc/index.docbook @@ -1078,7 +1078,11 @@ included with the &kdesrc-build; source. You can pretend to do the operations. If you pass or 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 kdesrc-build + +command first in order for to work. For an even more verbose description of what &kdesrc-build; is doing, try using the 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.). -Note: Simple read-only commands (such as reading file information) may +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). - + + +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 kdesrc-build + to download the required metadata +first. + + @@ -2820,6 +2833,15 @@ Only perform the install process. + +--metadata-only + +Only perform the metadata download process. &kdesrc-build; normally handles this +automatically, but you might manually use this to allow the command line option to work. + + + --ignore-modules @@ -2854,7 +2876,10 @@ The source updates for the modules themselves will still occur unless you pass --no-src as well. 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 --metadata-only option +one time and then using this option for subsequent runs. diff --git a/doc/man-kdesrc-build.1.docbook b/doc/man-kdesrc-build.1.docbook index ac39e92..440967c 100644 --- a/doc/man-kdesrc-build.1.docbook +++ b/doc/man-kdesrc-build.1.docbook @@ -251,6 +251,20 @@ combining short options into one at this point. (E.g. running + + + + + + + + Only updates the build metadata needed for KDE modules, then exits. This is + useful to allow the option to work if you've never + run kdesrc-build. See also . + + + + diff --git a/modules/ksb/Application.pm b/modules/ksb/Application.pm index b560465..0324002 100644 --- a/modules/ksb/Application.pm +++ b/modules/ksb/Application.pm @@ -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