Skip to content

Commit 8824943

Browse files
committed
b2sum: introduce standalone binary
1 parent 36fee22 commit 8824943

19 files changed

Lines changed: 414 additions & 6 deletions

File tree

Cargo.lock

Lines changed: 13 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
@@ -86,6 +86,7 @@ feat_common_core = [
8686
"basenc",
8787
"cat",
8888
"cksum",
89+
"b2sum",
8990
"md5sum",
9091
"comm",
9192
"cp",
@@ -435,6 +436,7 @@ chmod = { optional = true, version = "0.5.0", package = "uu_chmod", path = "src/
435436
chown = { optional = true, version = "0.5.0", package = "uu_chown", path = "src/uu/chown" }
436437
chroot = { optional = true, version = "0.5.0", package = "uu_chroot", path = "src/uu/chroot" }
437438
cksum = { optional = true, version = "0.5.0", package = "uu_cksum", path = "src/uu/cksum" }
439+
b2sum = { optional = true, version = "0.5.0", package = "uu_b2sum", path = "src/uu/b2sum" }
438440
md5sum = { optional = true, version = "0.5.0", package = "uu_md5sum", path = "src/uu/md5sum" }
439441
comm = { optional = true, version = "0.5.0", package = "uu_comm", path = "src/uu/comm" }
440442
cp = { optional = true, version = "0.5.0", package = "uu_cp", path = "src/uu/cp" }

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
md5sum \
8889
comm \
8990
cp \
@@ -186,7 +187,6 @@ SELINUX_PROGS := \
186187
runcon
187188

188189
HASHSUM_PROGS := \
189-
b2sum \
190190
sha1sum \
191191
sha224sum \
192192
sha256sum \
@@ -223,6 +223,7 @@ TEST_PROGS := \
223223
chmod \
224224
chown \
225225
cksum \
226+
b2sum \
226227
md5sum \
227228
comm \
228229
cp \

build.rs

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

src/common/validation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fn get_canonical_util_name(util_name: &str) -> &str {
5151
"[" => "test",
5252

5353
// hashsum aliases - all these hash commands are aliases for hashsum
54-
"sha1sum" | "sha224sum" | "sha256sum" | "sha384sum" | "sha512sum" | "b2sum" => "hashsum",
54+
"sha1sum" | "sha224sum" | "sha256sum" | "sha384sum" | "sha512sum" => "hashsum",
5555

5656
"dir" => "ls", // dir is an alias for ls
5757

src/uu/b2sum/Cargo.toml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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/md5sum"
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+
uu_checksum_common = { workspace = true }
23+
uucore = { workspace = true, features = [
24+
"checksum",
25+
"encoding",
26+
"sum",
27+
"hardware",
28+
] }
29+
fluent = { workspace = true }
30+
31+
[dev-dependencies]
32+
divan = { workspace = true }
33+
tempfile = { workspace = true }
34+
uucore = { workspace = true, features = ["benchmark"] }
35+
36+
[[bin]]
37+
name = "b2sum"
38+
path = "src/main.rs"
39+
40+
# [[bench]]
41+
# name = "b2sum_bench"
42+
# 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+
md5sum-about = Print or check the BLAKE2b checksums
2+
md5sum-usage = b2sum [OPTIONS] [FILE]...
3+
md5sum-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+
md5sum-about = Afficher le BLAKE2b et la taille de chaque fichier
2+
md5sum-usage = b2sum [OPTION]... [FICHIER]...

src/uu/b2sum/src/b2sum.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
10+
use uu_checksum_common::{standalone_checksum_app_with_length, standalone_with_length_main};
11+
12+
use uucore::checksum::{AlgoKind, calculate_blake2b_length_str};
13+
use uucore::error::UResult;
14+
use uucore::translate;
15+
16+
#[uucore::main]
17+
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
18+
standalone_with_length_main(
19+
AlgoKind::Blake2b,
20+
uu_app(),
21+
args,
22+
calculate_blake2b_length_str,
23+
)
24+
}
25+
26+
#[inline]
27+
pub fn uu_app() -> Command {
28+
standalone_checksum_app_with_length(translate!("md5sum-about"), translate!("md5sum-usage"))
29+
}

0 commit comments

Comments
 (0)