diff options
Diffstat (limited to 'bpkg/pkg-build-collect.cxx')
-rw-r--r-- | bpkg/pkg-build-collect.cxx | 81 |
1 files changed, 67 insertions, 14 deletions
diff --git a/bpkg/pkg-build-collect.cxx b/bpkg/pkg-build-collect.cxx index 5485672..f0e66f2 100644 --- a/bpkg/pkg-build-collect.cxx +++ b/bpkg/pkg-build-collect.cxx @@ -404,6 +404,8 @@ namespace bpkg ? override : available); + const shared_ptr<selected_package>& sp (selected); + assert (!skeleton && ap != nullptr); package_key pk (db, ap->id.name); @@ -430,11 +432,12 @@ namespace bpkg if (ap != nullptr) { - bool src_conf (selected != nullptr && - selected->state == package_state::configured && - selected->substate != package_substate::system); + bool src_conf (sp != nullptr && + sp->state == package_state::configured && + sp->substate != package_substate::system); database& pdb (db); + const dir_path& c (pdb.config); // If the package is being reconfigured, then specify {src,out}_root as // the existing source and output root directories not to create the @@ -447,26 +450,74 @@ namespace bpkg // configuration? Yes we can, since load_config_flags stays 0 in this // case and all the variables in config.build will be ignored. // - if (src_conf && ap->version == selected->version) + // Note that the failure to configure a package may result in the whole + // bunch of packages in the unpacked state but having the build2 + // configuration, potentially configured by the user (think of a being + // reconfigured external dependency package for which `b configure` has + // failed, leaving it and all it external dependent packages in the + // described state). For such packages we would prefer to preserve the + // user configuration rather than to configure them from scratch. Thus, + // here we treat them (unpacked_conf is present) similar to packages + // configured from source (src_conf is true). (Note that if this change + // causes any negative consequences, we could invent a special + // unpackged-with-configuration state/substate or some such). + // + // @@ Also note that regardless whether the packages is in the + // configured or unpacked state, we currently do not preserve the + // build2 user configuration for the package subprojects on the + // package reconfiguration (skeleton just ignores the subprojects but + // we configure passing the config.config.disfigure='config.<pkg>**' + // variable to build2). + // + optional<dir_path> unpacked_conf; + + if (src_conf && ap->version == sp->version) { - src_root = selected->effective_src_root (pdb.config); - out_root = selected->effective_out_root (pdb.config); + src_root = sp->effective_src_root (c); + out_root = sp->effective_out_root (c); } - else + else if (sp != nullptr && sp->state == package_state::unpacked) + { + // Check if the config.build file is present and, if that's the case, + // assume this package to be configured. And let's handle all packages + // uniformly, regardless if they are external or not. + // + dir_path d ( + sp->external () + ? c / dir_path (sp->name.string ()) + : c / dir_path (sp->name.string () + '-' + sp->version.string ())); + + if (exists (d / alt_config_file) || exists (d / std_config_file)) + { + unpacked_conf = move (d); + + if (ap->version == sp->version) + { + src_root = sp->effective_src_root (c); + out_root = unpacked_conf; + } + } + } + + if (!src_root) { src_root = external_dir (); if (src_root) - out_root = dir_path (pdb.config) /= name ().string (); + out_root = dir_path (c) /= name ().string (); } // Specify old_{src,out}_root paths and set load_config_flags if the old // configuration is present and is requested to be loaded. // - if (src_conf && (!disfigure || load_old_dependent_config)) + if ((src_conf || unpacked_conf) && + (!disfigure || load_old_dependent_config)) { - old_src_root = selected->effective_src_root (pdb.config); - old_out_root = selected->effective_out_root (pdb.config); + old_src_root = sp->effective_src_root (c); + + old_out_root = src_conf + ? sp->effective_out_root (c) + : move (unpacked_conf); if (!disfigure) load_config_flags |= package_skeleton::load_config_user; @@ -483,7 +534,7 @@ namespace bpkg move (ap), config_vars, // @@ Maybe make optional<strings> and move? disfigure, - (selected != nullptr ? &selected->config_variables : nullptr), + (sp != nullptr ? &sp->config_variables : nullptr), move (src_root), move (out_root), move (old_src_root), @@ -2483,7 +2534,7 @@ namespace bpkg // unsatisfied dependency constraint imposed by the dependent and // returning such constraints in the // precollect_result::unsatisfied_dependent member. If this alternative - // is get selected, then this unsatisfied dependent/constraints are + // gets selected, then this unsatisfied dependent/constraints are // recorded (see unsatisfied_dependents for details). Save both the // original dependency constraint imposed by the dependent // (dependency_constraint) and the effective dependency constraint (the @@ -3323,7 +3374,9 @@ namespace bpkg if (!aps.empty ()) { - dr << "unable to satisfy dependency constraint (" << dn; + dr << "unable to satisfy " + << (!dep_constr ? "dependency" : "command line") + << " constraint (" << dn; // We need to be careful not to print the wildcard-based // constraint. |