aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2023-01-26 16:14:14 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2023-01-26 16:14:14 +0200
commita6970597f25712821cc715a418c39404dc29c744 (patch)
treefc644b8f72f992c5e364ec8844e1f8cb7e5ed601
parent61f62a91bdf0348a73db18b95a6e9aa475aa6568 (diff)
Fix version translation in Debian implementation
-rw-r--r--bpkg/system-package-manager-debian.cxx29
-rw-r--r--bpkg/system-package-manager-debian.hxx10
2 files changed, 30 insertions, 9 deletions
diff --git a/bpkg/system-package-manager-debian.cxx b/bpkg/system-package-manager-debian.cxx
index c19ebb4..1219ebf 100644
--- a/bpkg/system-package-manager-debian.cxx
+++ b/bpkg/system-package-manager-debian.cxx
@@ -202,7 +202,7 @@ namespace bpkg
assert (n != 0 && n <= pps.size ());
- // In particular, --quite makes sure we don't get a noice (N) printed to
+ // In particular, --quiet makes sure we don't get a noice (N) printed to
// stderr if the package is unknown. It does not appear to affect error
// diagnostics (try temporarily renaming /var/lib/dpkg/status).
//
@@ -433,7 +433,7 @@ namespace bpkg
string spec (name + '=' + ver);
- // In particular, --quite makes sure we don't get noices (N) printed to
+ // In particular, --quiet makes sure we don't get noices (N) printed to
// stderr. It does not appear to affect error diagnostics (try showing
// information for an unknown package).
//
@@ -1144,10 +1144,18 @@ namespace bpkg
if (r)
{
- // Map the system version to the bpkg version.
+ // Map the Debian version to the bpkg version. But first strip the
+ // revision from Debian version ([<epoch>:]<upstream>[-<revision>]), if
+ // any.
//
+ // Note that according to deb-version(5), <upstream> may contain `:`/`-`
+ // but in these cases <epoch>/<revision> must be specified explicitly,
+ // respectively.
+ //
+ string sv (r->system_version, 0, r->system_version.rfind ('-'));
+
optional<version> v (
- downstream_package_version (r->system_version,
+ downstream_package_version (sv,
*aps,
os_release_.name_id,
os_release_.version_id,
@@ -1155,17 +1163,22 @@ namespace bpkg
if (!v)
{
- // Fallback to using system version as downstream version.
+ // Fallback to using system version as downstream version. But first
+ // strip the epoch, if any.
//
+ size_t p (sv.find (':'));
+ if (p != string::npos)
+ sv.erase (0, p + 1);
+
try
{
- v = version (r->system_version);
+ v = version (sv);
}
catch (const invalid_argument& e)
{
fail << "unable to map Debian package " << r->system_name
- << " version " << r->system_version << " to bpkg package "
- << pn << " version" <<
+ << " version " << sv << " to bpkg package " << pn
+ << " version" <<
info << "Debian version is not a valid bpkg version: " << e.what () <<
info << "consider specifying explicit mapping in " << pn
<< " package manifest";
diff --git a/bpkg/system-package-manager-debian.hxx b/bpkg/system-package-manager-debian.hxx
index 7f91d38..cbf4828 100644
--- a/bpkg/system-package-manager-debian.hxx
+++ b/bpkg/system-package-manager-debian.hxx
@@ -57,7 +57,8 @@ namespace bpkg
// -common packages. They normally have the same version.
//
// The first group is called the main group and the first package in the
- // group is called the main package.
+ // group is called the main package. Note that all the groups are consumed
+ // (installed) but only the main group is produced (packaged).
//
// We allow/recommend specifying the -dev package instead of the main
// package for libraries (the name starts with lib), seeing that we are
@@ -71,6 +72,13 @@ namespace bpkg
// as extras but in the future we may decide to sort them out like the main
// group (see parse_name_value() for details).
//
+ // The Debian package version has the [<epoch>:]<upstream>[-<revision>] form
+ // (see deb-version(5) for details). If no explicit mapping to bpkg version
+ // is specified with the debian-to-downstream-version manifest values (or
+ // alike), then we fallback to using the <upstream> part as bpkg version. If
+ // explicit mapping is specified, then we match it against the
+ // <epoch>:<upstream> parts ignoring <revision>.
+ //
struct system_package_status_debian: system_package_status
{
string main;