1
0
Fork 0
mirror of https://github.com/vbatts/go-mtree.git synced 2024-12-20 21:06:30 +00:00
Commit graph

310 commits

Author SHA1 Message Date
68a1a615b9 README: add info on running the tests
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-11-18 04:25:16 +00:00
71b81f3ced Merge pull request from vbatts/xattr_bsd
xattr: tests for non-linux
2016-11-17 23:18:44 -05:00
81e5c5c8f0 Merge pull request from vbatts/flags
Exclude non-directories
2016-11-17 22:47:36 -05:00
e76196a6d6 xattr: tests for non-linux
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-11-18 03:47:11 +00:00
c0a5cb25ec
-d: exclude non-directories
Adding flag, and supporting functionality for exluding entries that are
non-directories

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-11-17 22:43:02 -05:00
353436a031
main: group flag variables
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-11-17 22:00:23 -05:00
f51a3381de Merge pull request from vbatts/keyword
Keyword overhaul
2016-11-17 21:58:04 -05:00
21723a3974
*: fix comparison of missing keywords
Adding another test validated from the FreeBSD workflow.

Just because the keywords requested to be validated are not present in
the manifest, it is not an error.
Also, if the keywords from a new manifest are not present in a prior
manifest, then only compare the common keywords.

Fixes https://github.com/vbatts/go-mtree/issues/86

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-11-17 21:38:10 -05:00
4eec68be4b
*: make Keyword and KeyVal pervasive
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-11-17 21:38:01 -05:00
5d26726bb1
keyword: unify keyword synonyms
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-11-16 15:42:53 -05:00
627c6e9ddd
DirectoryHierarchy: UsedKeywords is a of the struct
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-11-16 14:43:05 -05:00
a8e4475c5e
*: clean up
* Get rid of the isErr func in main()
* put main() logic closer to the top

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-11-16 14:22:12 -05:00
690c85d4e8 Merge pull request from cyphar/core-manifest-diff
mtree: implement manifest comparisons
2016-11-11 12:01:49 -05:00
0fd0d3ed55 Merge pull request from cyphar/fix-symlink-keyword
keywords: safely encode symlink keywords
2016-11-11 11:54:06 -05:00
Aleksa Sarai
704d91fc7c
keywords: safely encode symlink keywords
symlink(2) is a very dumb syscall, and allows you to put any damn value
you please inside a symlink. In addition, spaces are valid path
characters which causes issues with keyword parsing. So use Vis() and
Unvis() to safely store an encoded version of the path.

This also adds a cli test for this behaviour.

Signed-off-by: Aleksa Sarai <asarai@suse.de>
2016-11-12 01:52:37 +11:00
Aleksa Sarai
3bfdecf467
gomtree: add special cases for tar generation checking
Due to several unsolveable problems in tar generation, such as the
size=... keyword, we have to special case quite a few things in the
checking code. We might want to move this to mtree properly (but I'm
hesitant about ignoring errors that only happen for tar DHes).

Signed-off-by: Aleksa Sarai <asarai@suse.de>
2016-11-10 12:41:23 +11:00
Aleksa Sarai
d214ab47e8
check: re-implement *Check() using Compare()
This removes all of the special handling code for both TarCheck() and
Check() so that everything now uses the new (generic) Compare() code. In
addition, the tests had to be modified to reflect the new classes of
errors.

Signed-off-by: Aleksa Sarai <asarai@suse.de>
2016-11-10 11:30:06 +11:00
Aleksa Sarai
c4be8dfe32
compare: implement proper testing with tar
While the full testing is broken due to bugs in the tar DH generator, we
ignore known bugs in the tar generator to at least allow us to test some
of the other semantics of Compare.

Signed-off-by: Aleksa Sarai <asarai@suse.de>
2016-11-10 11:30:06 +11:00
Aleksa Sarai
d7f49531f8
gomtree: switch to using compare
Switch the commandline to use the .Compare() API when checking
specification files against the state of a tar archive or other archive.
The main purpose is to completely remove the check.go code from being
necessary (outside of a wrapper).

Signed-off-by: Aleksa Sarai <asarai@suse.de>
2016-11-10 11:30:06 +11:00
Aleksa Sarai
26ff922da6
compare: implement mtree.DirectoryHierarchy comparisons
This is part of a patchset that refactors all of the checking logic into
comparison operations. Essentially, provide a Compare(...) function that
allows for two different manifests to be compared. Extra and missing
entries are supported in addition to the standard modified entry, and by
implementing as a manifest comparison there is no double-scanning of the
manifest source.

The main annoyance is that we have to also include tar_time handling,
which has not been abstracted inside keywords.go. This is a bit ugly
right now, but works fine for the moment.

Signed-off-by: Aleksa Sarai <asarai@suse.de>
2016-11-10 11:30:06 +11:00
Aleksa Sarai
36372dd3c8
mtree: remove use of dhCreator for iterators
Fix a bug in the parser that caused all iterators to have to handle the
/set and /unset semantics separately. In addition, provide a helper
function to correctly generate the merged set of keywords for a
particular entry.

Signed-off-by: Aleksa Sarai <asarai@suse.de>
2016-11-10 11:30:06 +11:00
30ae0132eb Merge pull request from vbatts/test
Add cli tests to the validation
2016-11-07 07:44:43 -08:00
0805fd4bb1
travis: use the whole validation
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-11-07 10:40:20 -05:00
b83c40e7f9
test: add basic cli test
tar and filesystem check

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-11-07 10:40:12 -05:00
85eacd2163
Makefile: add easy target for validation
Hopefully soon adding integration tests for the cli

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-11-05 12:43:00 -04:00
4f26a7e254 Merge pull request from cyphar/fix-keyword-nanosecond-time
keywords: correctly handle time keywords
2016-11-01 14:03:08 +00:00
Aleksa Sarai
d0f7e8cb8b
keywords: correctly handle time keywords
Previously, the time generation code would inexplicably drop parts of
the nanotime -- potentially causing validation to succeed when it should
fail. This was probably do to a bug in the remainder logic, but instead
we should be using .Nanosecond() anyway.

After changing the time of a file with a test case like this:

    // Change the time to something known with nanosec != 0.
    chtime := time.Unix(100, 987654321)
    if err := os.Chtimes("somefile", chtime, chtime); err != nil {
	// panic
    }

timeKeywordFunc() would return the wrong value (time=100.000000021).
This fixes the issue and adds a test case.

Signed-off-by: Aleksa Sarai <asarai@suse.de>
2016-11-01 17:47:06 +11:00
c5fc89d0f1 Merge pull request from vbatts/bsd_compat
keywords: BSD compat for a few keywords
2016-10-31 18:13:33 +00:00
3732fa351f Merge pull request from vbatts/bsd_flags
keywords: don't fail on presence of "flags"
2016-10-31 17:48:02 +00:00
e45837faea
keywords: don't fail on presence of "flags"
BSD file's support "flags". These have some similarity with xattr, but
for specific features, rather than general purpose key/values.

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-10-31 13:25:11 -04:00
b493e2920f keywords: BSD compat for a few keywords
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-10-31 14:10:42 +00:00
84f1e6ebc6 Merge pull request from vbatts/update_golang
travis: update versions of golang
2016-10-31 13:47:21 +00:00
8672a4bc93
travis: update versions of golang
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-10-31 09:42:23 -04:00
8c6b32c842 Merge pull request from vbatts/fix_digest_symlink
keywords: fix xattrs for broken symlinks
2016-09-01 15:54:19 -04:00
c805a855bd
keywords: fix xattrs for broken symlinks
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-09-01 15:52:24 -04:00
3aa50a7a50 Merge pull request from stephen679/tar_cleanup
tar: remove completed TODO's and dead code
2016-08-21 16:15:14 -04:00
Stephen Chung
3973da9b81 tar: remove completed TODO's and dead code
minor clean-up of some comments and code that is not used
in tar functionality

Signed-off-by: Stephen Chung <spchung@andrew.cmu.edu>
2016-08-21 15:41:28 -04:00
bc52946f8e Merge pull request from vbatts/test_cleanup
test: cleanup testdir after testing
2016-08-17 10:33:39 -04:00
fdf37fcebf test: cleanup testdir after testing
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-08-17 10:25:15 -04:00
bd52b623df Merge pull request from vbatts/version
Add versioning
2016-08-16 11:42:19 -04:00
23a95a1c97 version: bump for a dev cycle
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-08-16 11:37:47 -04:00
92b6fc1af3 main: expose the version with a flag
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-08-16 11:37:11 -04:00
475c51cbd7 version: adding a version variable
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-08-16 11:34:01 -04:00
a63446dc6f Merge pull request from stephen679/tar_test_extra_missing
tar_test: don't check for extra/missing when validating relative to "."
2016-08-12 09:04:06 -04:00
Stephen Chung
0e2cf67ac3 tar_test: don't check for extra/missing when validating relative to "."
right now, Check() doesn't check for missing/extra files. So, for the
sake of this test, we don't want to do this check for extra/missing files
when we validate the validation manifest produced from a tar against
the "." root directory (which would be /testdata).

Signed-off-by: Stephen Chung <schung@redhat.com>
2016-08-11 22:23:26 -04:00
52985ee3a5 Merge pull request from vbatts/list_used_JSON
gomtree: `-list-used` can output JSON
2016-08-11 15:00:19 -04:00
6d8cd9fe4c gomtree: -list-used can output JSON
Piggybacking on `-result-format`:

```bash
$ tar c .git/ | gomtree -c -T - > git.mtree
$ gomtree -result-format=json -list-used -f ./git.mtree
{
  "./git.mtree": [
    "type",
    "mode",
    "uid",
    "gid",
    "tar_time",
    "size"
  ]
}
$ tar c .git/ | gomtree -c -T - -K sha512digest > git.mtree
$ gomtree -result-format=json -list-used -f ./git.mtree
{
  "./git.mtree": [
    "type",
    "mode",
    "uid",
    "gid",
    "tar_time",
    "size",
    "sha512digest"
  ]
}
```

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-08-11 14:50:20 -04:00
97a2505b8b Merge pull request from vbatts/stdin_tar
gomtree: allow tar from stdin
2016-08-11 14:12:10 -04:00
90bdfb6c29 gomtree: allow tar from stdin
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-08-11 14:07:07 -04:00
232b80f320 Merge pull request from stephen679/resolve_hardlinks
tar: resolve hardlinks when streaming archive
2016-08-11 13:39:28 -04:00