aboutsummaryrefslogtreecommitdiff
path: root/bpkg/pkg-unpack.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'bpkg/pkg-unpack.cxx')
-rw-r--r--bpkg/pkg-unpack.cxx80
1 files changed, 17 insertions, 63 deletions
diff --git a/bpkg/pkg-unpack.cxx b/bpkg/pkg-unpack.cxx
index 48a64ea..22ff02f 100644
--- a/bpkg/pkg-unpack.cxx
+++ b/bpkg/pkg-unpack.cxx
@@ -10,6 +10,7 @@
#include <bpkg/package-odb.hxx>
#include <bpkg/database.hxx>
#include <bpkg/checksum.hxx>
+#include <bpkg/rep-mask.hxx>
#include <bpkg/diagnostics.hxx>
#include <bpkg/manifest-utility.hxx>
@@ -162,7 +163,10 @@ namespace bpkg
optional<string> mc;
optional<string> bc;
- if (!simulate)
+ // Only calculate the manifest/subprojects and buildfiles checksums for
+ // external packages (see selected_package::external() for details).
+ //
+ if (!simulate && (rl.empty () || rl.directory_based ()))
{
mc = package_checksum (o, d, pi);
@@ -221,7 +225,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);
@@ -281,7 +289,7 @@ namespace bpkg
check_any_available (rdb, t);
- // Note that here we compare including the revision (see pkg-fetch()
+ // Note that here we compare including the revision (see pkg_fetch()
// implementation for more details).
//
shared_ptr<available_package> ap (
@@ -297,7 +305,8 @@ namespace bpkg
for (const package_location& l: ap->locations)
{
- if (l.repository_fragment.load ()->location.directory_based ())
+ if (!rep_masked_fragment (l.repository_fragment) &&
+ l.repository_fragment.load ()->location.directory_based ())
{
pl = &l;
break;
@@ -330,7 +339,6 @@ namespace bpkg
shared_ptr<selected_package>
pkg_unpack (const common_options& co,
database& db,
- database& rdb,
transaction& t,
const package_name& name,
bool simulate)
@@ -363,19 +371,17 @@ namespace bpkg
dir_path d (c / dir_path (n.string () + '-' + v.string ()));
- if (exists (d))
- fail << "package directory " << d << " already exists";
-
auto_rmdir arm;
- optional<string> mc;
- optional<string> bc;
if (!simulate)
{
+ if (exists (d))
+ fail << "package directory " << d << " already exists";
+
// If the archive path is not absolute, then it must be relative
// to the configuration.
//
- path a (p->archive->absolute () ? *p->archive : c / *p->archive);
+ path a (p->effective_archive (c));
l4 ([&]{trace << "archive: " << a;});
@@ -398,62 +404,11 @@ namespace bpkg
{
fail << "unable to extract " << a << " to " << c << ": " << e;
}
-
- mc = package_checksum (co, d, nullptr /* package_info */);
-
- // Calculate the buildfiles checksum if the package has any buildfile
- // clauses in the dependencies.
- //
- // Note that we may not have the available package (e.g., fetched as an
- // existing package archive rather than from an archive repository), in
- // which case we need to parse the manifest to retrieve the
- // dependencies. This is unfortunate, but is probably not a big deal
- // performance-wise given that this is not too common and we are running
- // an archive unpacking process anyway.
- //
- shared_ptr<available_package> ap (
- rdb.find<available_package> (available_package_id (n, v)));
-
- if (ap != nullptr)
- {
- // Note that the available package already has all the buildfiles
- // loaded.
- //
- if (has_buildfile_clause (ap->dependencies))
- bc = package_buildfiles_checksum (ap->bootstrap_build,
- ap->root_build,
- ap->buildfiles);
- }
- else
- {
- // Note that we don't need to translate the package version here since
- // the manifest comes from an archive and so has a proper version
- // already.
- //
- package_manifest m (
- pkg_verify (co,
- d,
- true /* ignore_unknown */,
- false /* ignore_toolchain */,
- false /* load_buildfiles */,
- function<package_manifest::translate_function> ()));
-
- if (has_buildfile_clause (m.dependencies))
- bc = package_buildfiles_checksum (m.bootstrap_build,
- m.root_build,
- m.buildfiles,
- d,
- m.buildfile_paths,
- m.alt_naming);
- }
}
p->src_root = d.leaf (); // For now assuming to be in configuration.
p->purge_src = true;
- p->manifest_checksum = move (mc);
- p->buildfiles_checksum = move (bc);
-
p->state = package_state::unpacked;
db.update (p);
@@ -518,7 +473,6 @@ namespace bpkg
p = v.empty ()
? pkg_unpack (o,
db /* pdb */,
- db /* rdb */,
t,
n,
false /* simulate */)