Skip to content

Commit 588c1e7

Browse files
committed
checksum: Move b2sum to a standalone binary
1 parent 3adeb66 commit 588c1e7

File tree

27 files changed

+884
-343
lines changed

27 files changed

+884
-343
lines changed

Cargo.lock

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ feat_common_core = [
7676
"basenc",
7777
"cat",
7878
"cksum",
79+
"b2sum",
7980
"comm",
8081
"cp",
8182
"csplit",
@@ -431,6 +432,7 @@ chmod = { optional = true, version = "0.5.0", package = "uu_chmod", path = "src/
431432
chown = { optional = true, version = "0.5.0", package = "uu_chown", path = "src/uu/chown" }
432433
chroot = { optional = true, version = "0.5.0", package = "uu_chroot", path = "src/uu/chroot" }
433434
cksum = { optional = true, version = "0.5.0", package = "uu_cksum", path = "src/uu/cksum" }
435+
b2sum = { optional = true, version = "0.5.0", package = "uu_b2sum", path = "src/uu/b2sum" }
434436
comm = { optional = true, version = "0.5.0", package = "uu_comm", path = "src/uu/comm" }
435437
cp = { optional = true, version = "0.5.0", package = "uu_cp", path = "src/uu/cp" }
436438
csplit = { optional = true, version = "0.5.0", package = "uu_csplit", path = "src/uu/csplit" }

GNUmakefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ PROGS := \
8484
basename \
8585
cat \
8686
cksum \
87+
b2sum \
8788
comm \
8889
cp \
8990
csplit \
@@ -185,7 +186,6 @@ SELINUX_PROGS := \
185186
runcon
186187

187188
HASHSUM_PROGS := \
188-
b2sum \
189189
md5sum \
190190
sha1sum \
191191
sha224sum \
@@ -223,6 +223,7 @@ TEST_PROGS := \
223223
chmod \
224224
chown \
225225
cksum \
226+
b2sum \
226227
comm \
227228
cp \
228229
csplit \

build.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ pub fn main() {
8585
phf_map.entry("sha256sum", map_value.clone());
8686
phf_map.entry("sha384sum", map_value.clone());
8787
phf_map.entry("sha512sum", map_value.clone());
88-
phf_map.entry("b2sum", map_value.clone());
8988
}
9089
_ => {
9190
phf_map.entry(krate, map_value.clone());

src/uu/b2sum/Cargo.toml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
[package]
2+
name = "uu_b2sum"
3+
description = "b2sum ~ (uutils) Print or check the BLAKE2b checksums"
4+
repository = "https://github.com/uutils/coreutils/tree/main/src/uu/b2sum"
5+
version.workspace = true
6+
authors.workspace = true
7+
license.workspace = true
8+
homepage.workspace = true
9+
keywords.workspace = true
10+
categories.workspace = true
11+
edition.workspace = true
12+
readme.workspace = true
13+
14+
[lints]
15+
workspace = true
16+
17+
[lib]
18+
path = "src/b2sum.rs"
19+
20+
[dependencies]
21+
clap = { workspace = true }
22+
uucore = { workspace = true, features = [
23+
"checksum",
24+
"encoding",
25+
"sum",
26+
"hardware",
27+
] }
28+
fluent = { workspace = true }
29+
30+
[dev-dependencies]
31+
divan = { workspace = true }
32+
tempfile = { workspace = true }
33+
uucore = { workspace = true, features = ["benchmark"] }
34+
35+
[[bin]]
36+
name = "b2sum"
37+
path = "src/main.rs"
38+
39+
# [[bench]]
40+
# name = "b2sum_bench"
41+
# harness = false

src/uu/b2sum/LICENSE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../LICENSE

src/uu/b2sum/locales/en-US.ftl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
b2sum-about = Print or check the BLAKE2b checksums
2+
b2sum-usage = b2sum [OPTIONS] [FILE]...
3+
b2sum-after-help = With no FILE or when FILE is -, read standard input

src/uu/b2sum/locales/fr-FR.ftl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
b2sum-about = Afficher le BLAKE2b et la taille de chaque fichier
2+
b2sum-usage = b2sum [OPTION]... [FICHIER]...

src/uu/b2sum/src/b2sum.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// This file is part of the uutils coreutils package.
2+
//
3+
// For the full copyright and license information, please view the LICENSE
4+
// file that was distributed with this source code.
5+
6+
// spell-checker:ignore (ToDO) algo
7+
8+
use clap::Command;
9+
use uucore::checksum::cli::{checksum_main, options, standalone_checksum_app_with_length};
10+
use uucore::checksum::compute::OutputFormat;
11+
use uucore::checksum::{AlgoKind, calculate_blake2b_length_str};
12+
use uucore::error::UResult;
13+
use uucore::translate;
14+
15+
#[uucore::main]
16+
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
17+
let matches = uucore::clap_localization::handle_clap_result(uu_app(), args)?;
18+
let algo = Some(AlgoKind::Blake2b);
19+
20+
let length = matches
21+
.get_one::<String>(options::LENGTH)
22+
.map(String::as_str)
23+
.map(calculate_blake2b_length_str)
24+
.transpose()?
25+
.flatten();
26+
27+
let format = OutputFormat::from_standalone(std::env::args_os().into_iter());
28+
29+
checksum_main(algo, length, matches, format?)
30+
}
31+
32+
#[inline]
33+
pub fn uu_app() -> Command {
34+
standalone_checksum_app_with_length(translate!("b2sum-about"), translate!("b2sum-usage"))
35+
.after_help(translate!("b2sum-after-help"))
36+
}

src/uu/b2sum/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
uucore::bin!(uu_b2sum);

0 commit comments

Comments
 (0)