From b1becabe15972d3ddc7cf14e7840e03766ea9600 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 12 Dec 2022 19:47:08 +0300 Subject: Adapt to butl::b_info() API change --- bpkg/manifest-utility.cxx | 14 +++++++++----- bpkg/manifest-utility.hxx | 19 ++++++++++++------- bpkg/package.hxx | 19 ++++++++++--------- bpkg/pkg-build.cxx | 6 +++++- bpkg/pkg-unpack.cxx | 6 +++++- bpkg/rep-fetch.cxx | 9 ++++++++- tests/common/git/README | 2 +- tests/pkg-checkout.testscript | 9 ++++----- 8 files changed, 54 insertions(+), 30 deletions(-) diff --git a/bpkg/manifest-utility.cxx b/bpkg/manifest-utility.cxx index 7a431b3..76db3a7 100644 --- a/bpkg/manifest-utility.cxx +++ b/bpkg/manifest-utility.cxx @@ -24,7 +24,9 @@ namespace bpkg const path manifest_file ("manifest"); vector - package_b_info (const common_options& o, const dir_paths& ds, bool ext_mods) + package_b_info (const common_options& o, + const dir_paths& ds, + b_info_flags fl) { path b (name_b (o)); @@ -33,7 +35,7 @@ namespace bpkg { b_info (r, ds, - ext_mods, + fl, verb, [] (const char* const args[], size_t n) { @@ -309,9 +311,11 @@ namespace bpkg } package_version_infos - package_versions (const common_options& o, const dir_paths& ds) + package_versions (const common_options& o, + const dir_paths& ds, + b_info_flags fl) { - vector pis (package_b_info (o, ds, false /* ext_mods */)); + vector pis (package_b_info (o, ds, fl)); package_version_infos r; r.reserve (pis.size ()); @@ -346,7 +350,7 @@ namespace bpkg const vector& sps ( pi != nullptr ? pi->subprojects - : package_b_info (o, d, false /* ext_mods */).subprojects); + : package_b_info (o, d, b_info_flags::subprojects).subprojects); for (const package_info::subproject& sp: sps) cs.append (sp.path.string ()); diff --git a/bpkg/manifest-utility.hxx b/bpkg/manifest-utility.hxx index 85fbaee..a5ea962 100644 --- a/bpkg/manifest-utility.hxx +++ b/bpkg/manifest-utility.hxx @@ -7,6 +7,8 @@ #include #include +#include // b_info_flags + #include #include @@ -17,17 +19,19 @@ namespace bpkg extern const path signature_file; // signature.manifest extern const path manifest_file; // manifest + using butl::b_info_flags; + // Obtain build2 projects info for package source or output directories. // vector - package_b_info (const common_options&, const dir_paths&, bool ext_mods); + package_b_info (const common_options&, const dir_paths&, b_info_flags); // As above but return the info for a single package directory. // inline package_info - package_b_info (const common_options& o, const dir_path& d, bool ext_mods) + package_b_info (const common_options& o, const dir_path& d, b_info_flags fl) { - vector r (package_b_info (o, dir_paths ({d}), ext_mods)); + vector r (package_b_info (o, dir_paths ({d}), fl)); return move (r[0]); } @@ -131,14 +135,14 @@ namespace bpkg using package_version_infos = vector; package_version_infos - package_versions (const common_options&, const dir_paths&); + package_versions (const common_options&, const dir_paths&, b_info_flags); // As above but return the version of a single package. // inline package_version_info - package_version (const common_options& o, const dir_path& d) + package_version (const common_options& o, const dir_path& d, b_info_flags fl) { - package_version_infos r (package_versions (o, dir_paths ({d}))); + package_version_infos r (package_versions (o, dir_paths ({d}), fl)); return move (r[0]); } @@ -147,7 +151,8 @@ namespace bpkg // // Pass the build2 project info for the package, if available, to speed up // the call and NULL otherwise (in which case it will be queried by the - // implementation). + // implementation). In the former case it is assumed that the package info + // has been retrieved with the b_info_flags::subprojects flag. // string package_checksum (const common_options&, diff --git a/bpkg/package.hxx b/bpkg/package.hxx index 51f7219..4f4f16b 100644 --- a/bpkg/package.hxx +++ b/bpkg/package.hxx @@ -1361,21 +1361,22 @@ namespace bpkg // // Pass the build2 project info for the package, if available, to speed up // the call and NULL otherwise (in which case it will be queried by the - // implementation). + // implementation). In the former case it is assumed that the package info + // has been retrieved with the b_info_flags::subprojects flag. // // Notes: // // - The package directory is considered an iteration of the package if this // upstream version and revision is already present (selected) in the // configuration and has a source directory. If that's the case, then the - // specified directory path and the checksum of the manifest file it - // contains are compared to the ones of the package present in the - // configuration. If both match, then the present package version - // (including its iteration, if any) is returned. Otherwise (the package - // has moved and/or the packaging information has changed), the present - // package version with the incremented iteration number is returned. Note - // that the directory path is matched only for the external selected - // packages. + // specified directory path and the package checksum (see + // package_checksum() for details) are compared to the ones of the package + // present in the configuration. If both match, then the present package + // version (including its iteration, if any) is returned. Otherwise (the + // package has moved and/or the package information has changed), the + // present package version with the incremented iteration number is + // returned. Note that the directory path is matched only for the external + // selected packages. // // - Only a single package iteration is valid per version in the // configuration. This, in particular, means that a package of the diff --git a/bpkg/pkg-build.cxx b/bpkg/pkg-build.cxx index a5dd813..4e88fa1 100644 --- a/bpkg/pkg-build.cxx +++ b/bpkg/pkg-build.cxx @@ -2257,7 +2257,11 @@ namespace bpkg true /* load_buildfiles */, [&o, &d, &pvi] (version& v) { - pvi = package_version (o, d); + // Note that we also query subprojects since the package + // information will be used for the subsequent + // package_iteration() call. + // + pvi = package_version (o, d, b_info_flags::subprojects); if (pvi.version) v = move (*pvi.version); diff --git a/bpkg/pkg-unpack.cxx b/bpkg/pkg-unpack.cxx index 48a64ea..8f01a8a 100644 --- a/bpkg/pkg-unpack.cxx +++ b/bpkg/pkg-unpack.cxx @@ -221,7 +221,11 @@ namespace bpkg false /* load_buildfiles */, [&o, &d, &pvi] (version& v) { - pvi = package_version (o, d); + // Note that we also query subprojects since the package + // information will be used for the subsequent + // package_iteration() call. + // + pvi = package_version (o, d, b_info_flags::subprojects); if (pvi.version) v = move (*pvi.version); diff --git a/bpkg/rep-fetch.cxx b/bpkg/rep-fetch.cxx index 30c429f..17536da 100644 --- a/bpkg/rep-fetch.cxx +++ b/bpkg/rep-fetch.cxx @@ -331,8 +331,15 @@ namespace bpkg pds.push_back (move (d)); } + // Note that for the directory-based repositories we also query + // subprojects since the package information will be used for the + // subsequent package_iteration() call (see below). + // if (bs) - pvs = package_versions (co, pds); + pvs = package_versions (co, pds, + (rl.directory_based () + ? b_info_flags::subprojects + : b_info_flags::none)); } // Parse package manifests, fixing up their versions. diff --git a/tests/common/git/README b/tests/common/git/README index 737cd83..5b4781b 100644 --- a/tests/common/git/README +++ b/tests/common/git/README @@ -8,7 +8,7 @@ before modification, and $ ./pack -afterwrds. +afterwards. Also note that config files under .git/ subdirectory refer to the submodule repositories using absolute paths. So prior to pulling in subproject directory diff --git a/tests/pkg-checkout.testscript b/tests/pkg-checkout.testscript index 69e211c..1ec8b37 100644 --- a/tests/pkg-checkout.testscript +++ b/tests/pkg-checkout.testscript @@ -179,6 +179,7 @@ else $* links/1.0.1 2>>~%EOE% != 0 checking out links/1.0.1 distributing links/1.0.1 + %warning: skipping dangling symlink .+% %error: unable to stat .+% EOE else @@ -193,16 +194,14 @@ else # Cyclic symlinks in the repository. # + $rep_fetch "$rep/links.git#v1.0.2"; + if $posix - $rep_fetch "$rep/links.git#v1.0.2" 2>>~%EOE% != 0 + $* links/1.0.2 2>>~%EOE% != 0 %.* %error: unable to iterate over .+% - warning: repository state is now broken and will be cleaned up - info: run 'bpkg rep-fetch' to update EOE else - $rep_fetch "$rep/links.git#v1.0.2" - $* links/1.0.2 2>>~%EOE% != 0 checking out links/1.0.2 %.* -- cgit v1.1