mirror of
https://github.com/vbatts/go-mtree.git
synced 2024-11-21 16:05:40 +00:00
*: begin incorporating the "validate" subcommand
Update the README to show the validate subcommand by default. This doesn't eliminate the default behavior of _not_ using the command, but begins the visibility of using it by default. Also copy one of the existing tests, to ensure the same behaviour works as we add more subcommands and/or global flags. Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
48e5e86700
commit
e19072ac1c
3 changed files with 50 additions and 5 deletions
10
README.md
10
README.md
|
@ -104,31 +104,31 @@ To use the command line tool, first [build it](#Building), then the following.
|
||||||
This will also include the sha512 digest of the files.
|
This will also include the sha512 digest of the files.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
gomtree -c -K sha512digest -p . > /tmp/root.mtree
|
gomtree validate -c -K sha512digest -p . > /tmp/root.mtree
|
||||||
```
|
```
|
||||||
|
|
||||||
With a tar file:
|
With a tar file:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
gomtree -c -K sha512digest -T sometarfile.tar > /tmp/tar.mtree
|
gomtree validate -c -K sha512digest -T sometarfile.tar > /tmp/tar.mtree
|
||||||
```
|
```
|
||||||
|
|
||||||
### Validate a manifest
|
### Validate a manifest
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
gomtree -p . -f /tmp/root.mtree
|
gomtree validate -p . -f /tmp/root.mtree
|
||||||
```
|
```
|
||||||
|
|
||||||
With a tar file:
|
With a tar file:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
gomtree -T sometarfile.tar -f /tmp/root.mtree
|
gomtree validate -T sometarfile.tar -f /tmp/root.mtree
|
||||||
```
|
```
|
||||||
|
|
||||||
### See the supported keywords
|
### See the supported keywords
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
gomtree -list-keywords
|
gomtree validate -list-keywords
|
||||||
Available keywords:
|
Available keywords:
|
||||||
uname
|
uname
|
||||||
sha1
|
sha1
|
||||||
|
|
|
@ -15,6 +15,7 @@ import (
|
||||||
func NewValidateCommand() *cli.Command {
|
func NewValidateCommand() *cli.Command {
|
||||||
return &cli.Command{
|
return &cli.Command{
|
||||||
Name: "validate",
|
Name: "validate",
|
||||||
|
Usage: "Create and validate a filesystem hierarchy (this is default tool behavior)",
|
||||||
Action: validateAction,
|
Action: validateAction,
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
// Flags common with mtree(8)
|
// Flags common with mtree(8)
|
||||||
|
|
44
test/cli/0001a.sh
Normal file
44
test/cli/0001a.sh
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
name=$(basename $0)
|
||||||
|
root="$(dirname $(dirname $(dirname $0)))"
|
||||||
|
gomtree=$(go run ${root}/test/realpath/main.go ${root}/gomtree)
|
||||||
|
t=$(mktemp -d -t go-mtree.XXXXXX)
|
||||||
|
|
||||||
|
echo "[${name}] Running in ${t}"
|
||||||
|
# This test is for basic running check of manifest, and check against tar and file system
|
||||||
|
#
|
||||||
|
|
||||||
|
pushd ${root}
|
||||||
|
|
||||||
|
git archive --format=tar -o "${t}/${name}.tar" HEAD^{tree}
|
||||||
|
|
||||||
|
prev_umask=$(umask)
|
||||||
|
umask 0 # this is so the tar command can set the mode's properly
|
||||||
|
mkdir -p ${t}/extract
|
||||||
|
tar -C ${t}/extract/ -xf "${t}/${name}.tar"
|
||||||
|
umask ${prev_umask}
|
||||||
|
|
||||||
|
# create manifest from tar
|
||||||
|
${gomtree} validate -K sha256digest -c -T "${t}/${name}.tar" > "${t}/${name}.mtree"
|
||||||
|
|
||||||
|
# check tar-manifest against the tar
|
||||||
|
${gomtree} validate -f ${t}/${name}.mtree -T "${t}/${name}.tar"
|
||||||
|
|
||||||
|
# check tar-manifest against the filesystem
|
||||||
|
# git archive makes the uid/gid as 0, so don't check them for this test
|
||||||
|
${gomtree} validate -k size,sha256digest,mode,type -f "${t}/${name}.mtree" -p ${t}/extract/
|
||||||
|
|
||||||
|
# create a manifest from filesystem
|
||||||
|
${gomtree} validate -K sha256digest -c -p "${t}/extract/" > "${t}/${name}.mtree"
|
||||||
|
|
||||||
|
# check filesystem-manifest against the filesystem
|
||||||
|
${gomtree} validate -f "${t}/${name}.mtree" -p "${t}/extract/"
|
||||||
|
|
||||||
|
# check filesystem-manifest against the tar
|
||||||
|
# git archive makes the uid/gid as 0, so don't check them for this test
|
||||||
|
${gomtree} validate -k size,sha256digest,mode,type -f "${t}/${name}.mtree" -T "${t}/${name}.tar"
|
||||||
|
|
||||||
|
popd
|
||||||
|
rm -rf ${t}
|
Loading…
Reference in a new issue