]> Sergey Matveev's repositories - dsc.git/commitdiff
DSC_HASHES -> DSC_HASHERS master
authorSergey Matveev <stargrave@stargrave.org>
Sun, 15 Mar 2026 07:36:49 +0000 (10:36 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Sun, 15 Mar 2026 07:36:50 +0000 (10:36 +0300)
And also make it newline-separated with space separated key-value.
To be compatible with newest meta4ra utilities and BASS project.

CHECKSUM
dsc
t/csum.t
t/setup.rc

index 55a57dab8c8cd0144362e86061873d6a4ea1a12a81ab24e32e973c138a71a0d6..d374738b59c016755f8a140616968b966e3f35e9b2d9ace1fa89b63a3fb60629 100644 (file)
--- a/CHECKSUM
+++ b/CHECKSUM
@@ -2,10 +2,10 @@ There is ability to integrity protect the exported configuration.
 Exported txtar contains trailing ".csum" pseudo file with one or
 multiple hashes of the digested data.
 
 Exported txtar contains trailing ".csum" pseudo file with one or
 multiple hashes of the digested data.
 
-DSC_HASHES environment variables specified what hashes must be included
-and invoked. For example "blake2b-512:b2sum,skein-512:skein512" value
-means, that BLAKE2b-512 is calculated by calling "b2sum" utility, and
-Skein-512 by "skein512".
+DSC_HASHERS environment variables specified what hashers must be
+included and invoked. For example "blake2b-512 b2sum\nskein-512 skein512"
+value means, that BLAKE2b-512 is calculated by calling "b2sum" utility,
+and Skein-512 by "skein512".
 
 "dsc csum" command can be used to calculate hashes over the arbitrary
 data. "dsc import-check" can be used to verify piped in configuration
 
 "dsc csum" command can be used to calculate hashes over the arbitrary
 data. "dsc import-check" can be used to verify piped in configuration
diff --git a/dsc b/dsc
index 779367c364ab644545acd56316052925fc464f02c2b5090eb93fb394026abf66..ececf810aeb78f45fe0beb22fca36c3447d2ae870e07129fa2d20d9ebf017359 100755 (executable)
--- a/dsc
+++ b/dsc
@@ -42,8 +42,8 @@ Environmental variables:
     $DSC_SCHEMA -- path to the schema definition
     $DSC_STASH  -- path to stashed/unsaved state
     $DSC_SAVED  -- path to committed/saved state
     $DSC_SCHEMA -- path to the schema definition
     $DSC_STASH  -- path to stashed/unsaved state
     $DSC_SAVED  -- path to committed/saved state
-    $DSC_HASHES -- sha2-512:sha512 by default
-                   Comma-separated list of hash-name:cmd pairs
+    $DSC_HASHERS -- "sha2-512 sha512" by default.
+                    Newline-separated list of "hash-name cmd" pairs
 
 There are two kinds of options:
     * array/list ones, which are identified with /*/ in "list"'s
 
 There are two kinds of options:
     * array/list ones, which are identified with /*/ in "list"'s
@@ -57,17 +57,19 @@ set CopyBufLen [expr {128 * 1024}]
 if {[info exists env(DSC_SCHEMA)]} {set Schema $env(DSC_SCHEMA)} {set Schema schema}
 if {[info exists env(DSC_STASH)]} {set Stash $env(DSC_STASH)} {set Stash stash}
 if {[info exists env(DSC_SAVED)]} {set Saved $env(DSC_SAVED)} {set Saved saved}
 if {[info exists env(DSC_SCHEMA)]} {set Schema $env(DSC_SCHEMA)} {set Schema schema}
 if {[info exists env(DSC_STASH)]} {set Stash $env(DSC_STASH)} {set Stash stash}
 if {[info exists env(DSC_SAVED)]} {set Saved $env(DSC_SAVED)} {set Saved saved}
-if {[info exists env(DSC_HASHES)]} {
-    set Hashes [list]
-    foreach pair [split $env(DSC_HASHES) ,] {
-        set cols [split $pair :]
-        if {[llength $cols] != 2} {
-            error "bad DSC_HASHES"
-        }
-        lappend Hashes [lindex $cols 0] [lindex $cols 1]
+if {[info exists env(DSC_HASHERS)]} {
+    set Hashers [list]
+    foreach pair [split $env(DSC_HASHERS) "\n"] {
+        set idx [string first " " $pair]
+        if {$idx <= 0} {
+            continue
+        }
+        lappend Hashers \
+            [string range $pair 0 [expr {$idx-1}]] \
+            [string range $pair [expr {$idx+1}] end]
     }
 } {
     }
 } {
-    set Hashes [list sha2-512 sha512]
+    set Hashers [list sha2-512 sha512]
 }
 
 proc readents {root typ} {
 }
 
 proc readents {root typ} {
@@ -350,7 +352,7 @@ switch [lindex $argv 0] {
     }
     csum {
         set hsh [list]
     }
     csum {
         set hsh [list]
-        foreach {name cmd} $Hashes {
+        foreach {name cmd} $Hashers {
             lassign [pipe] r w
             set fh [open [list |$cmd >@$w] w]
             fconfigure $fh -translation binary
             lassign [pipe] r w
             set fh [open [list |$cmd >@$w] w]
             fconfigure $fh -translation binary
index 02d58499a33390c52ff575937caf6aeb2e5576cbe4321741961b05ffe1d68c03..5167224a5ee5921beca785257c78ff4f281810b76d5efb55f5b85ab2dad96b1e 100755 (executable)
--- a/t/csum.t
+++ b/t/csum.t
@@ -23,7 +23,7 @@ printf "%s\n" "-- .csum --" >>expected
 echo "whatever hash" >>expected
 test_expect_success "wrong csum" "! dsc import-check <out"
 
 echo "whatever hash" >>expected
 test_expect_success "wrong csum" "! dsc import-check <out"
 
-DSC_HASHES="sha2-512:sha512"
+DSC_HASHERS="sha2-512 sha512"
 test_expect_success "export sha512" "dsc export >out"
 cat >expected <<EOF
 -- .dirs --
 test_expect_success "export sha512" "dsc export >out"
 cat >expected <<EOF
 -- .dirs --
@@ -37,7 +37,7 @@ echo -n "sha2-512 " >>expected
 cat hsh >>expected
 test_expect_success "cmp" "test_cmp out expected"
 
 cat hsh >>expected
 test_expect_success "cmp" "test_cmp out expected"
 
-DSC_HASHES=""
+DSC_HASHERS=""
 test_expect_success "empty hashes" "dsc export >out"
 cat >expected <<EOF
 -- .dirs --
 test_expect_success "empty hashes" "dsc export >out"
 cat >expected <<EOF
 -- .dirs --
index 56d94e27212a5f69baedc6ba1cc0364344b3cec1ac1ff732e73a012d9a8fd7a0..0cd2983517fc8985a20d46de412e6e78a37817fbb33ef62b46edd10d71668bc1 100644 (file)
@@ -3,10 +3,12 @@ export DSC_STASH=stash DSC_SAVED=saved
 export JIMLIB="$SHARNESS_TEST_DIRECTORY/../jimlib:$JIMLIB"
 PATH="$SHARNESS_TEST_DIRECTORY/..:$PATH"
 mkdir saved
 export JIMLIB="$SHARNESS_TEST_DIRECTORY/../jimlib:$JIMLIB"
 PATH="$SHARNESS_TEST_DIRECTORY/..:$PATH"
 mkdir saved
-export DSC_HASHES="sha2-512:sha512"
+export DSC_HASHERS="sha2-512 sha512"
 if command -v skein512 2>/dev/null >/dev/null ; then
 if command -v skein512 2>/dev/null >/dev/null ; then
-    DSC_HASHES="skein-512:skein512,$DSC_HASHES"
+    DSC_HASHERS="skein-512 skein512
+$DSC_HASHERS"
 fi
 if command -v b2sum 2>/dev/null >/dev/null ; then
 fi
 if command -v b2sum 2>/dev/null >/dev/null ; then
-    DSC_HASHES="blake2b-512:b2sum,$DSC_HASHES"
+    DSC_HASHERS="blake2b-512 b2sum
+$DSC_HASHERS"
 fi
 fi