From 8f9a80a9ac8f353ce2cdafa23f0e5163d30d5800 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 1 May 2019 22:32:11 +0300 Subject: Add support for description-type package manifest value --- load/load.cli | 5 +++++ load/load.cxx | 49 ++++++++++++++++++++++++++++++++++--------------- 2 files changed, 39 insertions(+), 15 deletions(-) (limited to 'load') diff --git a/load/load.cli b/load/load.cli index 17aba5b..74c91f2 100644 --- a/load/load.cli +++ b/load/load.cli @@ -40,6 +40,11 @@ class options { "\h|OPTIONS|" + bool --ignore-unknown + { + "Ignore unknown manifest entries." + } + bool --force { "Reload package information regardless of the repository manifest file diff --git a/load/load.cxx b/load/load.cxx index d00a1af..c5fa3cd 100644 --- a/load/load.cxx +++ b/load/load.cxx @@ -89,7 +89,7 @@ using internal_repositories = vector; // Specifically, the packages.manifest is not a pkg package manifest list. It // contains a raw list of package manifests that may contain values forbidden // for the pkg package manifest list (description-file, changes-file) and may -// omit the required ones (sha256sum). +// omit the required ones (sha256sum, description-type). // // @@ Latter, we may also want to support loading bpkg repositories using // manifest files produced by bpkg-rep-info command. This, in particular, @@ -343,6 +343,7 @@ repository_info (const options& lo, const string& rl, const cstrings& options) static void load_packages (const shared_ptr& rp, database& db, + bool ignore_unknown, const manifest_name_values& overrides) { // packages_timestamp other than timestamp_nonexistent signals the @@ -376,18 +377,17 @@ load_packages (const shared_ptr& rp, // We put no restrictions on the manifest values presence since it's not // critical for displaying and building if the packages omit some // manifest values (see libbpkg/manifest.hxx for details). Note, though, - // that we expect package dependency constraints to be complete. + // that we expect dependency constraints to be complete. // for (manifest_name_value nv (mp.next ()); !nv.empty (); nv = mp.next ()) - pms.emplace_back ( - mp, - move (nv), - false /* ignore_unknown */, - false /* complete_depends */, - package_manifest_flags::forbid_incomplete_depends); + pms.emplace_back (mp, + move (nv), + ignore_unknown, + false /* complete_depends */, + package_manifest_flags::forbid_incomplete_depends); } else - pms = pkg_package_manifests (mp); + pms = pkg_package_manifests (mp, ignore_unknown); } catch (const io_error& e) { @@ -423,6 +423,8 @@ load_packages (const shared_ptr& rp, // Create internal package object. // optional dsc; + optional dst; + if (pm.description) { // The description value should not be of the file type if the @@ -431,7 +433,18 @@ load_packages (const shared_ptr& rp, assert (!pm.description->file || cl.type () != repository_type::pkg); if (!pm.description->file) - dsc = move (pm.description->text); + { + dst = pm.effective_description_type (ignore_unknown); + + // If the description type is unknown (which may be the case for + // some "transitional" period and only if --ignore-unknown is + // specified) we just silently drop the description. + // + assert (dst || ignore_unknown); + + if (dst) + dsc = move (pm.description->text); + } } string chn; @@ -495,6 +508,7 @@ load_packages (const shared_ptr& rp, move (pm.license_alternatives), move (pm.tags), move (dsc), + move (dst), move (chn), move (pm.url), move (pm.doc_url), @@ -563,6 +577,7 @@ load_packages (const shared_ptr& rp, static void load_repositories (const shared_ptr& rp, database& db, + bool ignore_unknown, bool shallow) { // repositories_timestamp other than timestamp_nonexistent signals that @@ -592,7 +607,7 @@ load_repositories (const shared_ptr& rp, rp->repositories_timestamp = file_mtime (p); manifest_parser mp (ifs, p.string ()); - rpm = pkg_repository_manifests (mp); + rpm = pkg_repository_manifests (mp, ignore_unknown); } catch (const io_error& e) { @@ -744,8 +759,12 @@ load_repositories (const shared_ptr& rp, // We don't apply overrides to the external packages. // - load_packages (pr, db, manifest_name_values () /* overrides */); - load_repositories (pr, db, false /* shallow */); + load_packages (pr, + db, + ignore_unknown, + manifest_name_values () /* overrides */); + + load_repositories (pr, db, ignore_unknown, false /* shallow */); } db.update (rp); @@ -1248,7 +1267,7 @@ try move (cert), priority++)); - load_packages (r, db, overrides); + load_packages (r, db, ops.ignore_unknown (), overrides); } // On the second pass over the internal repositories we load their @@ -1261,7 +1280,7 @@ try db.load ( repository_id (tnt, ir.location.canonical_name ()))); - load_repositories (r, db, ops.shallow ()); + load_repositories (r, db, ops.ignore_unknown (), ops.shallow ()); } // Resolve internal packages dependencies unless this is a shallow load. -- cgit v1.1