aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2023-03-06 09:47:07 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2023-03-06 09:47:07 +0200
commit2ae552a8c064653130d5ecdbe7a9175988268402 (patch)
treefc71d5c7ba57f1fb999704a11f6fef6a5a03bb90
parentd7014bd5a0bc3c09d175140641d1d8ad95e27559 (diff)
Add --debian-build-meta to override build metadata
-rw-r--r--bpkg/pkg-bindist.cli10
-rw-r--r--bpkg/system-package-manager-debian.cxx43
-rw-r--r--bpkg/system-package-manager-debian.hxx3
3 files changed, 44 insertions, 12 deletions
diff --git a/bpkg/pkg-bindist.cli b/bpkg/pkg-bindist.cli
index 7c686bf..abf578b 100644
--- a/bpkg/pkg-bindist.cli
+++ b/bpkg/pkg-bindist.cli
@@ -77,6 +77,16 @@ namespace bpkg
options, if any, are used as configured."
}
+ string --debian-build-meta
+ {
+ "<data>",
+ "Alternative build metadata to include in the binary package version.
+ If empty value is specified, then no build metadata is included. By
+ default, the build metadata is the \cb{ID} and \cb{VERSION_ID}
+ components from \cb{os-release(5)}, for example, \cb{debian10} in
+ version \cb{1.2.3-0~debian10}."
+ }
+
string --debian-section
{
"<v>",
diff --git a/bpkg/system-package-manager-debian.cxx b/bpkg/system-package-manager-debian.cxx
index f012d6c..92a32f9 100644
--- a/bpkg/system-package-manager-debian.cxx
+++ b/bpkg/system-package-manager-debian.cxx
@@ -1499,7 +1499,8 @@ namespace bpkg
package_status system_package_manager_debian::
map_package (const package_name& pn,
const version& pv,
- const available_packages& aps)
+ const available_packages& aps,
+ const optional<string>& build_metadata)
{
// We should only have one available package corresponding to this package
// name/version.
@@ -1672,6 +1673,8 @@ namespace bpkg
//
string& sv (r.system_version);
+ bool no_build_metadata (build_metadata && build_metadata->empty ());
+
if (optional<string> ov = system_package_version (ap,
rf,
os_release.name_id,
@@ -1711,19 +1714,21 @@ namespace bpkg
// Add revision copying over the bpkg version value if empty.
//
+ // Omit the default -0 revision if we have no build metadata.
+ //
if (rp != string::npos)
{
if (size_t rn = n - (rp + 1))
{
sv.append (dv, rp, rn + 1);
}
- else
+ else if (pv.revision || !no_build_metadata)
{
sv += '-';
sv += to_string (pv.revision ? *pv.revision : 0);
}
}
- else
+ else if (!no_build_metadata)
sv += "-0"; // Default revision (for build metadata; see below).
}
else
@@ -1767,15 +1772,26 @@ namespace bpkg
// Add revision.
//
- sv += '-';
- sv += to_string (pv.revision ? *pv.revision : 0);
+ if (pv.revision || !no_build_metadata)
+ {
+ sv += '-';
+ sv += to_string (pv.revision ? *pv.revision : 0);
+ }
}
// Add build matadata.
//
- sv += '~';
- sv += os_release.name_id;
- sv += os_release.version_id; // Could be empty.
+ if (!no_build_metadata)
+ {
+ sv += '~';
+ if (build_metadata)
+ sv += *build_metadata;
+ else
+ {
+ sv += os_release.name_id;
+ sv += os_release.version_id; // Could be empty.
+ }
+ }
return r;
}
@@ -1870,6 +1886,10 @@ namespace bpkg
const dir_path& out (ops_->output_root ()); // Cannot be empty.
+ optional<string> build_metadata;
+ if (ops_->debian_build_meta_specified ())
+ build_metadata = ops_->debian_build_meta ();
+
const shared_ptr<selected_package>& sp (pkgs.front ().selected);
const package_name& pn (sp->name);
const version& pv (sp->version);
@@ -1907,7 +1927,7 @@ namespace bpkg
// Note that there should be no duplicate dependencies and we can sidestep
// the status cache.
//
- package_status st (map_package (pn, pv, aps));
+ package_status st (map_package (pn, pv, aps, build_metadata));
vector<package_status> sdeps;
sdeps.reserve (deps.size ());
@@ -1943,7 +1963,7 @@ namespace bpkg
s = move (*os);
}
else
- s = map_package (sp->name, sp->version, aps);
+ s = map_package (sp->name, sp->version, aps, build_metadata);
sdeps.push_back (move (s));
}
@@ -2245,7 +2265,8 @@ namespace bpkg
// ~debian10). While it may be tempting to strip it, we cannot since
// the order is inverse. We could just make it empty `~`, though
// that will look a bit strange. But keeping it shouldn't cause any
- // issues.
+ // issues. Also note that the build metadata is part of the revision
+ // so we could strip the whole thing.
//
depends += st.main + " (>= " + st.system_version + ')';
}
diff --git a/bpkg/system-package-manager-debian.hxx b/bpkg/system-package-manager-debian.hxx
index bba3f04..429b14f 100644
--- a/bpkg/system-package-manager-debian.hxx
+++ b/bpkg/system-package-manager-debian.hxx
@@ -212,7 +212,8 @@ namespace bpkg
package_status
map_package (const package_name&,
const version&,
- const available_packages&);
+ const available_packages&,
+ const optional<string>&);
// If simulate is not NULL, then instead of executing the actual apt-cache
// and apt-get commands simulate their execution: (1) for apt-cache by