Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ feat_common_core = [
"basenc",
"cat",
"cksum",
"b2sum",
"comm",
"cp",
"csplit",
Expand Down Expand Up @@ -431,6 +432,7 @@ chmod = { optional = true, version = "0.5.0", package = "uu_chmod", path = "src/
chown = { optional = true, version = "0.5.0", package = "uu_chown", path = "src/uu/chown" }
chroot = { optional = true, version = "0.5.0", package = "uu_chroot", path = "src/uu/chroot" }
cksum = { optional = true, version = "0.5.0", package = "uu_cksum", path = "src/uu/cksum" }
b2sum = { optional = true, version = "0.5.0", package = "uu_b2sum", path = "src/uu/b2sum" }
comm = { optional = true, version = "0.5.0", package = "uu_comm", path = "src/uu/comm" }
cp = { optional = true, version = "0.5.0", package = "uu_cp", path = "src/uu/cp" }
csplit = { optional = true, version = "0.5.0", package = "uu_csplit", path = "src/uu/csplit" }
Expand Down
3 changes: 2 additions & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ PROGS := \
basename \
cat \
cksum \
b2sum \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why b2sum only? Just forgot other bins?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No no, it's the reason it's still in draft

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hasusum.rs is still remain. But we remove it later and totail size of source code is reduced. Right?

comm \
cp \
csplit \
Expand Down Expand Up @@ -185,7 +186,6 @@ SELINUX_PROGS := \
runcon

HASHSUM_PROGS := \
b2sum \
md5sum \
sha1sum \
sha224sum \
Expand Down Expand Up @@ -223,6 +223,7 @@ TEST_PROGS := \
chmod \
chown \
cksum \
b2sum \
comm \
cp \
csplit \
Expand Down
1 change: 0 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ pub fn main() {
phf_map.entry("sha256sum", map_value.clone());
phf_map.entry("sha384sum", map_value.clone());
phf_map.entry("sha512sum", map_value.clone());
phf_map.entry("b2sum", map_value.clone());
}
_ => {
phf_map.entry(krate, map_value.clone());
Expand Down
41 changes: 41 additions & 0 deletions src/uu/b2sum/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[package]
name = "uu_b2sum"
description = "b2sum ~ (uutils) Print or check the BLAKE2b checksums"
repository = "https://github.com/uutils/coreutils/tree/main/src/uu/b2sum"
version.workspace = true
authors.workspace = true
license.workspace = true
homepage.workspace = true
keywords.workspace = true
categories.workspace = true
edition.workspace = true
readme.workspace = true

[lints]
workspace = true

[lib]
path = "src/b2sum.rs"

[dependencies]
clap = { workspace = true }
uucore = { workspace = true, features = [
"checksum",
"encoding",
"sum",
"hardware",
] }
fluent = { workspace = true }

[dev-dependencies]
divan = { workspace = true }
tempfile = { workspace = true }
uucore = { workspace = true, features = ["benchmark"] }

[[bin]]
name = "b2sum"
path = "src/main.rs"

# [[bench]]
# name = "b2sum_bench"
# harness = false
1 change: 1 addition & 0 deletions src/uu/b2sum/LICENSE
3 changes: 3 additions & 0 deletions src/uu/b2sum/locales/en-US.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
b2sum-about = Print or check the BLAKE2b checksums
b2sum-usage = b2sum [OPTIONS] [FILE]...
b2sum-after-help = With no FILE or when FILE is -, read standard input
2 changes: 2 additions & 0 deletions src/uu/b2sum/locales/fr-FR.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
b2sum-about = Afficher le BLAKE2b et la taille de chaque fichier
b2sum-usage = b2sum [OPTION]... [FICHIER]...
36 changes: 36 additions & 0 deletions src/uu/b2sum/src/b2sum.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// This file is part of the uutils coreutils package.
//
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.

// spell-checker:ignore (ToDO) algo

use clap::Command;
use uucore::checksum::cli::{checksum_main, options, standalone_checksum_app_with_length};
use uucore::checksum::compute::OutputFormat;
use uucore::checksum::{AlgoKind, calculate_blake2b_length_str};
use uucore::error::UResult;
use uucore::translate;

#[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let matches = uucore::clap_localization::handle_clap_result(uu_app(), args)?;
let algo = Some(AlgoKind::Blake2b);

let length = matches
.get_one::<String>(options::LENGTH)
.map(String::as_str)
.map(calculate_blake2b_length_str)
.transpose()?
.flatten();

let format = OutputFormat::from_standalone(std::env::args_os().into_iter());

checksum_main(algo, length, matches, format?)
}

#[inline]
pub fn uu_app() -> Command {
standalone_checksum_app_with_length(translate!("b2sum-about"), translate!("b2sum-usage"))
.after_help(translate!("b2sum-after-help"))
}
1 change: 1 addition & 0 deletions src/uu/b2sum/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uucore::bin!(uu_b2sum);
16 changes: 0 additions & 16 deletions src/uu/cksum/locales/en-US.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,3 @@ cksum-after-help = DIGEST determines the digest algorithm and default output for
- sha3: (only available through cksum)
- blake2b: (equivalent to b2sum)
- sm3: (only available through cksum)

# Help messages
cksum-help-algorithm = select the digest type to use. See DIGEST below
cksum-help-untagged = create a reversed style checksum, without digest type
cksum-help-tag = create a BSD style checksum, undo --untagged (default)
cksum-help-length = digest length in bits; must not exceed the max for the blake2 algorithm and must be a multiple of 8
cksum-help-raw = emit a raw binary digest, not hexadecimal
cksum-help-strict = exit non-zero for improperly formatted checksum lines
cksum-help-check = read hashsums from the FILEs and check them
cksum-help-base64 = emit a base64 digest, not hexadecimal
cksum-help-warn = warn about improperly formatted checksum lines
cksum-help-status = don't output anything, status code shows success
cksum-help-quiet = don't print OK for each successfully verified file
cksum-help-ignore-missing = don't fail or report status for missing files
cksum-help-zero = end each output line with NUL, not newline, and disable file name escaping
cksum-help-debug = print CPU hardware capability detection info used by cksum
16 changes: 0 additions & 16 deletions src/uu/cksum/locales/fr-FR.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,3 @@ cksum-after-help = DIGEST détermine l'algorithme de condensé et le format de s
- sha3 : (disponible uniquement via cksum)
- blake2b : (équivalent à b2sum)
- sm3 : (disponible uniquement via cksum)

# Messages d'aide
cksum-help-algorithm = sélectionner le type de condensé à utiliser. Voir DIGEST ci-dessous
cksum-help-untagged = créer une somme de contrôle de style inversé, sans type de condensé
cksum-help-tag = créer une somme de contrôle de style BSD, annuler --untagged (par défaut)
cksum-help-length = longueur du condensé en bits ; ne doit pas dépasser le maximum pour l'algorithme blake2 et doit être un multiple de 8
cksum-help-raw = émettre un condensé binaire brut, pas hexadécimal
cksum-help-strict = sortir avec un code non-zéro pour les lignes de somme de contrôle mal formatées
cksum-help-check = lire les sommes de hachage des FICHIERs et les vérifier
cksum-help-base64 = émettre un condensé base64, pas hexadécimal
cksum-help-warn = avertir des lignes de somme de contrôle mal formatées
cksum-help-status = ne rien afficher, le code de statut indique le succès
cksum-help-quiet = ne pas afficher OK pour chaque fichier vérifié avec succès
cksum-help-ignore-missing = ne pas échouer ou signaler le statut pour les fichiers manquants
cksum-help-zero = terminer chaque ligne de sortie avec NUL, pas un saut de ligne, et désactiver l'échappement des noms de fichiers
cksum-help-debug = afficher les informations de débogage sur la détection de la prise en charge matérielle du processeur
Loading
Loading