aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2022-06-09 08:57:53 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2022-06-10 07:15:52 +0200
commit843627b2d3f801a7e9e45af0cc2cd4654077fac8 (patch)
tree5c588297539bc0b41997c2490cbc0b5173b7a8e4
parent450d6159206501dd69c3e8877ad37eeb3cd15049 (diff)
Add butl::sha256 to types.hxx
-rw-r--r--bpkg/auth.cxx1
-rw-r--r--bpkg/checksum.cxx2
-rw-r--r--bpkg/checksum.hxx6
-rw-r--r--bpkg/database.cxx4
-rw-r--r--bpkg/fetch-pkg.cxx10
-rw-r--r--bpkg/manifest-utility.cxx1
-rw-r--r--bpkg/pkg-build.cxx1
-rw-r--r--bpkg/pkg-fetch.cxx6
-rw-r--r--bpkg/rep-create.cxx6
-rw-r--r--bpkg/rep-info.cxx1
-rw-r--r--bpkg/types.hxx7
11 files changed, 22 insertions, 23 deletions
diff --git a/bpkg/auth.cxx b/bpkg/auth.cxx
index 85cf5fa..663054d 100644
--- a/bpkg/auth.cxx
+++ b/bpkg/auth.cxx
@@ -7,7 +7,6 @@
#include <limits> // numeric_limits
#include <iterator> // ostreambuf_iterator
-#include <libbutl/sha256.hxx>
#include <libbutl/base64.hxx>
#include <libbutl/openssl.hxx>
#include <libbutl/timestamp.hxx>
diff --git a/bpkg/checksum.cxx b/bpkg/checksum.cxx
index 65ed377..b761d0b 100644
--- a/bpkg/checksum.cxx
+++ b/bpkg/checksum.cxx
@@ -331,7 +331,7 @@ namespace bpkg
}
string
- sha256 (const common_options& o, const path& f)
+ sha256sum (const common_options& o, const path& f)
{
if (!exists (f))
fail << "file " << f << " does not exist";
diff --git a/bpkg/checksum.hxx b/bpkg/checksum.hxx
index 73f52e8..54e5b3c 100644
--- a/bpkg/checksum.hxx
+++ b/bpkg/checksum.hxx
@@ -4,8 +4,6 @@
#ifndef BPKG_CHECKSUM_HXX
#define BPKG_CHECKSUM_HXX
-#include <libbutl/sha256.hxx>
-
#include <bpkg/types.hxx>
#include <bpkg/utility.hxx>
@@ -16,7 +14,7 @@ namespace bpkg
// Calculate SHA256 sum of the specified memory buffer in binary mode.
//
inline string
- sha256 (const char* buf, size_t n) {return butl::sha256 (buf, n).string ();}
+ sha256sum (const char* buf, size_t n) {return sha256 (buf, n).string ();}
// The same but for a file. Issue diagnostics and throw failed if anything
// goes wrong.
@@ -26,7 +24,7 @@ namespace bpkg
// optimized for the platform.
//
string
- sha256 (const common_options&, const path& file);
+ sha256sum (const common_options&, const path& file);
}
#endif // BPKG_CHECKSUM_HXX
diff --git a/bpkg/database.cxx b/bpkg/database.cxx
index b0a673e..d96c53b 100644
--- a/bpkg/database.cxx
+++ b/bpkg/database.cxx
@@ -10,8 +10,6 @@
#include <odb/schema-catalog.hxx>
#include <odb/sqlite/exceptions.hxx>
-#include <libbutl/sha256.hxx>
-
#include <bpkg/package.hxx>
#include <bpkg/package-odb.hxx>
#include <bpkg/diagnostics.hxx>
@@ -706,7 +704,7 @@ namespace bpkg
//
std::string schema;
{
- butl::sha256 h (d.string ());
+ sha256 h (d.string ());
for (size_t n (4);; ++n)
{
diff --git a/bpkg/fetch-pkg.cxx b/bpkg/fetch-pkg.cxx
index 64abb43..ca4767f 100644
--- a/bpkg/fetch-pkg.cxx
+++ b/bpkg/fetch-pkg.cxx
@@ -52,7 +52,7 @@ namespace bpkg
is.close ();
string s (bs.str ());
- string sha256sum (sha256 (s.c_str (), s.size ()));
+ string cs (sha256sum (s.c_str (), s.size ()));
istringstream ts (s); // Text mode.
@@ -60,7 +60,7 @@ namespace bpkg
M m (mp, ignore_unknown);
if (pr.wait ())
- return make_pair (move (m), move (sha256sum));
+ return make_pair (move (m), move (cs));
// Child existed with an error, fall through.
}
@@ -146,14 +146,14 @@ namespace bpkg
// and reading the manifest. The file should be opened in the binary
// mode for the first operation and in the text mode for the second one.
//
- string sha256sum;
+ string cs;
if (o != nullptr)
- sha256sum = sha256 (*o, f); // Read file in the binary mode.
+ cs = sha256sum (*o, f); // Read file in the binary mode.
ifdstream ifs (f); // Open file in the text mode.
manifest_parser mp (ifs, f.string ());
- return make_pair (M (mp, ignore_unknown), move (sha256sum));
+ return make_pair (M (mp, ignore_unknown), move (cs));
}
catch (const manifest_parsing& e)
{
diff --git a/bpkg/manifest-utility.cxx b/bpkg/manifest-utility.cxx
index f690a40..d205c2d 100644
--- a/bpkg/manifest-utility.cxx
+++ b/bpkg/manifest-utility.cxx
@@ -6,7 +6,6 @@
#include <cstring> // strcspn()
#include <libbutl/b.hxx>
-#include <libbutl/sha256.hxx>
#include <bpkg/package.hxx> // wildcard_version
#include <bpkg/diagnostics.hxx>
diff --git a/bpkg/pkg-build.cxx b/bpkg/pkg-build.cxx
index 90e2d70..63bbc36 100644
--- a/bpkg/pkg-build.cxx
+++ b/bpkg/pkg-build.cxx
@@ -12,7 +12,6 @@
#include <functional> // ref()
#include <forward_list>
-#include <libbutl/sha256.hxx>
#include <libbutl/standard-version.hxx>
#include <bpkg/package.hxx>
diff --git a/bpkg/pkg-fetch.cxx b/bpkg/pkg-fetch.cxx
index 531bf84..d065ff1 100644
--- a/bpkg/pkg-fetch.cxx
+++ b/bpkg/pkg-fetch.cxx
@@ -256,12 +256,12 @@ namespace bpkg
//
assert (ap->sha256sum);
- const string& sha256sum (sha256 (co, a));
- if (sha256sum != *ap->sha256sum)
+ const string& cs (sha256sum (co, a));
+ if (cs != *ap->sha256sum)
{
fail << "checksum mismatch for " << n << " " << v <<
info << pl->repository_fragment->name << " has " << *ap->sha256sum <<
- info << "fetched archive has " << sha256sum <<
+ info << "fetched archive has " << cs <<
info << "consider re-fetching package list and trying again" <<
info << "if problem persists, consider reporting this to "
<< "the repository maintainer";
diff --git a/bpkg/rep-create.cxx b/bpkg/rep-create.cxx
index 13ffbf1..c9ee924 100644
--- a/bpkg/rep-create.cxx
+++ b/bpkg/rep-create.cxx
@@ -106,7 +106,7 @@ namespace bpkg
// Calculate its checksum.
//
- m.sha256sum = sha256 (o, a);
+ m.sha256sum = sha256sum (o, a);
l4 ([&]{trace << m.name << " " << m.version << " in " << a
<< " sha256sum " << *m.sha256sum;});
@@ -183,7 +183,7 @@ namespace bpkg
collect (o, pm, d, d);
pkg_package_manifests manifests;
- manifests.sha256sum = sha256 (o, path (d / repositories_file));
+ manifests.sha256sum = sha256sum (o, path (d / repositories_file));
for (auto& p: pm)
{
@@ -235,7 +235,7 @@ namespace bpkg
info << "run 'bpkg help rep-create' for more information";
signature_manifest m;
- m.sha256sum = sha256 (o, p);
+ m.sha256sum = sha256sum (o, p);
m.signature = sign_repository (o, m.sha256sum, key, *cert, d);
p = path (d / signature_file);
diff --git a/bpkg/rep-info.cxx b/bpkg/rep-info.cxx
index 5184048..7d78173 100644
--- a/bpkg/rep-info.cxx
+++ b/bpkg/rep-info.cxx
@@ -5,7 +5,6 @@
#include <iostream> // cout
-#include <libbutl/sha256.hxx> // sha256_to_fingerprint()
#include <libbutl/manifest-serializer.hxx>
#include <libbpkg/manifest.hxx>
diff --git a/bpkg/types.hxx b/bpkg/types.hxx
index a8cd0f4..2b6a1f8 100644
--- a/bpkg/types.hxx
+++ b/bpkg/types.hxx
@@ -26,6 +26,7 @@
#include <libbutl/path.hxx>
#include <libbutl/uuid.hxx>
#include <libbutl/uuid-io.hxx>
+#include <libbutl/sha256.hxx>
#include <libbutl/process.hxx>
#include <libbutl/utility.hxx> // icase_compare_string,
// compare_reference_target
@@ -103,6 +104,12 @@ namespace bpkg
//
using butl::url;
+ // <libbutl/sha256.hxx>
+ //
+ using butl::sha256;
+ using butl::sha256_to_fingerprint;
+ using butl::fingerprint_to_sha256;
+
// <libbutl/process.hxx>
//
using butl::process;