From a1c8dac561bc80cd81459f50e8e17c1e1a081ecc Mon Sep 17 00:00:00 2001 From: Chris Howey Date: Tue, 5 May 2015 18:06:36 -0500 Subject: [PATCH 1/4] Add node to build on freebsd. Also note that inode is 32 bit in go freebsd stat struct. Assumed to be 64bit in restic. --- node.go | 4 ++-- node_freebsd.go | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 node_freebsd.go diff --git a/node.go b/node.go index 8f1ce8de5..c39bc4941 100644 --- a/node.go +++ b/node.go @@ -341,7 +341,7 @@ func (node *Node) isNewer(path string, fi os.FileInfo) bool { if node.ModTime != fi.ModTime() || node.ChangeTime != changeTime(extendedStat) || - node.Inode != inode || + node.Inode != uint64(inode) || node.Size != size { debug.Log("node.isNewer", "node %v is newer: timestamp, size or inode changed", path) return true @@ -396,7 +396,7 @@ func (node *Node) fillExtra(path string, fi os.FileInfo) error { return nil } - node.Inode = stat.Ino + node.Inode = uint64(stat.Ino) node.fillTimes(stat) diff --git a/node_freebsd.go b/node_freebsd.go new file mode 100644 index 000000000..31c0329aa --- /dev/null +++ b/node_freebsd.go @@ -0,0 +1,24 @@ +package restic + +import ( + "os" + "syscall" + "time" +) + +func (node *Node) OpenForReading() (*os.File, error) { + file, err := os.OpenFile(node.path, os.O_RDONLY, 0) + if os.IsPermission(err) { + return os.OpenFile(node.path, os.O_RDONLY, 0) + } + return file, err +} + +func (node *Node) fillTimes(stat *syscall.Stat_t) { + node.ChangeTime = time.Unix(stat.Ctimespec.Unix()) + node.AccessTime = time.Unix(stat.Atimespec.Unix()) +} + +func changeTime(stat *syscall.Stat_t) time.Time { + return time.Unix(stat.Ctimespec.Unix()) +} From a8be9c32d0a9567773d06078682251d2efb53ccb Mon Sep 17 00:00:00 2001 From: Chris Howey Date: Tue, 5 May 2015 20:47:02 -0500 Subject: [PATCH 2/4] Call open file once on FreeBSD. --- node_freebsd.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/node_freebsd.go b/node_freebsd.go index 31c0329aa..a757e3ec9 100644 --- a/node_freebsd.go +++ b/node_freebsd.go @@ -7,11 +7,7 @@ import ( ) func (node *Node) OpenForReading() (*os.File, error) { - file, err := os.OpenFile(node.path, os.O_RDONLY, 0) - if os.IsPermission(err) { - return os.OpenFile(node.path, os.O_RDONLY, 0) - } - return file, err + return os.OpenFile(node.path, os.O_RDONLY, 0) } func (node *Node) fillTimes(stat *syscall.Stat_t) { From 4262f68d459067f93cd3f20ed37706d19c2b0046 Mon Sep 17 00:00:00 2001 From: Chris Howey Date: Wed, 6 May 2015 13:30:43 -0500 Subject: [PATCH 3/4] travis: Add FreeBSD cross-compile --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index ed1293deb..951973aa5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,13 +17,13 @@ notifications: install: - go get github.com/mitchellh/gox - - gox -build-toolchain -os "linux darwin openbsd" + - gox -build-toolchain -os "linux darwin openbsd freebsd" - go get -v -t ./... script: - go build -ldflags "-s" ./... - go build -ldflags "-s" -o restic ./cmd/restic - - sh -c "cd cmd/restic && gox -verbose -os 'linux darwin openbsd' && ls -al" + - sh -c "cd cmd/restic && gox -verbose -os 'linux darwin openbsd freebsd' && ls -al" - go test -v ./... - ./testsuite.sh - sh -c "cd backend && go test -v -test.sftppath /usr/lib/openssh/sftp-server ./..." From acd4cd985d56395964188877fb7d4b92442aa360 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Wed, 6 May 2015 20:42:11 +0200 Subject: [PATCH 4/4] travis: Add env variable for gox cross-compilation --- .travis.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 951973aa5..e1793c187 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ language: go + go: - 1.3.3 - 1.4.2 @@ -15,15 +16,17 @@ notifications: on_success: change on_failure: change +env: GOX_OS="linux darwin openbsd freebsd" + install: - go get github.com/mitchellh/gox - - gox -build-toolchain -os "linux darwin openbsd freebsd" + - gox -build-toolchain -os "$GOX_OS" - go get -v -t ./... script: - go build -ldflags "-s" ./... - go build -ldflags "-s" -o restic ./cmd/restic - - sh -c "cd cmd/restic && gox -verbose -os 'linux darwin openbsd freebsd' && ls -al" + - sh -c 'cd cmd/restic && gox -verbose -os "$GOX_OS" && ls -al' - go test -v ./... - ./testsuite.sh - sh -c "cd backend && go test -v -test.sftppath /usr/lib/openssh/sftp-server ./..."