-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #198 from vbatts/incorporate_subcommand
*: begin incorporating the "validate" subcommand
- Loading branch information
Showing
3 changed files
with
50 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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} |