diff options
author | Lars Wirzenius <liw@liw.fi> | 2013-08-25 11:49:58 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2013-08-25 11:49:58 +0100 |
commit | 6cf9b0c9a41139163b32201dc902e53c296aaffa (patch) | |
tree | 169fafba60787d65a3451d51a5e9e39e87d4d24f | |
parent | cb7173f2ab04edea858977c9a23365efde962b1a (diff) | |
parent | 3c09c1e0974ae3ee8a43ab90efc0e38adbf0916d (diff) | |
download | obnam-6cf9b0c9a41139163b32201dc902e53c296aaffa.tar.gz |
FreeBSD portability
By Itamar Turner-Trauring of HybridCluster, plus changes by me.
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | _obnammodule.c | 81 | ||||
-rw-r--r-- | obnamlib/lockmgr.py | 4 | ||||
-rw-r--r-- | obnamlib/metadata.py | 16 | ||||
-rw-r--r-- | obnamlib/metadata_tests.py | 4 | ||||
-rw-r--r-- | obnamlib/plugins/sftp_plugin.py | 9 | ||||
-rw-r--r-- | obnamlib/vfs.py | 30 | ||||
-rw-r--r-- | obnamlib/vfs_local.py | 24 | ||||
-rw-r--r-- | obnamlib/vfs_local_tests.py | 29 | ||||
-rwxr-xr-x | sed-in-place | 16 | ||||
-rwxr-xr-x | test-many-generations | 2 | ||||
-rwxr-xr-x | tests/convert5to6.script | 3 | ||||
-rwxr-xr-x | tests/encryption-replaces-key.script | 2 | ||||
-rwxr-xr-x | tests/forget-removes-according-to-policy.script | 2 | ||||
-rwxr-xr-x | tests/forget-removes-specified-gens.script | 2 | ||||
-rwxr-xr-x | tests/logs-for-owner-only.script | 2 | ||||
-rw-r--r-- | tests/logs-for-owner-only.stdout | 2 | ||||
-rwxr-xr-x | tests/named-pipe.script | 2 | ||||
-rwxr-xr-x | tests/named-socket.script | 4 | ||||
-rwxr-xr-x | tests/pretend-time.script | 2 | ||||
-rwxr-xr-x | tests/remove-checkpoints.script | 2 | ||||
-rwxr-xr-x | tests/unreadable-dir.script | 2 | ||||
-rwxr-xr-x | tests/use-old-node-size.script | 2 | ||||
-rwxr-xr-x | tests/verify | 2 | ||||
-rwxr-xr-x | tests/verify-notices-changes.script | 2 |
25 files changed, 205 insertions, 44 deletions
@@ -12,6 +12,9 @@ Version 1.6, released UNRELEASED * `obnam-benchmark` can now use an installed version of larch. Patch by Lars Kruse. +* Obnam has been ported to FreeBSD by Itamar Turner-Trauring + of HybridCluster. + Bug fixes: * Fix "obnam list-toplevels" so it doesn't give an error when it's diff --git a/_obnammodule.c b/_obnammodule.c index f3e208bc..75cf3960 100644 --- a/_obnammodule.c +++ b/_obnammodule.c @@ -45,10 +45,17 @@ #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> -#include <sys/xattr.h> #include <unistd.h> #include <stdlib.h> +#ifdef __FreeBSD__ + #include <sys/extattr.h> + #define NO_NANOSECONDS 1 +#else + #include <sys/xattr.h> + #define NO_NANOSECONDS 0 +#endif + static PyObject * fadvise_dontneed(PyObject *self, PyObject *args) @@ -78,8 +85,11 @@ utimensat_wrapper(PyObject *self, PyObject *args) const char *filename; long atime_sec, atime_nsec; long mtime_sec, mtime_nsec; +#if NO_NANOSECONDS + struct timeval tv[2]; +#else struct timespec tv[2]; - +#endif if (!PyArg_ParseTuple(args, "sllll", &filename, &atime_sec, @@ -88,17 +98,41 @@ utimensat_wrapper(PyObject *self, PyObject *args) &mtime_nsec)) return NULL; +#if NO_NANOSECONDS + tv[0].tv_sec = atime_sec; + tv[0].tv_usec = atime_nsec / 1000; + tv[1].tv_sec = mtime_sec; + tv[1].tv_usec = mtime_nsec / 1000; + ret = lutimes(filename, tv); +#else tv[0].tv_sec = atime_sec; tv[0].tv_nsec = atime_nsec; tv[1].tv_sec = mtime_sec; tv[1].tv_nsec = mtime_nsec; ret = utimensat(AT_FDCWD, filename, tv, AT_SYMLINK_NOFOLLOW); +#endif if (ret == -1) ret = errno; return Py_BuildValue("i", ret); } +/* + * Since we can't set nanosecond mtime and atimes on some platforms, also + * don't retrieve that level of precision from lstat(), so comparisons + * work. + */ +static unsigned long long +remove_precision(unsigned long long nanoseconds) +{ +#if NO_NANOSECONDS + return nanoseconds - (nanoseconds % 1000); +#else + return nanoseconds; +#endif +} + + static PyObject * lstat_wrapper(PyObject *self, PyObject *args) { @@ -126,11 +160,11 @@ lstat_wrapper(PyObject *self, PyObject *args) (long long) st.st_blksize, (long long) st.st_blocks, (long long) st.st_atim.tv_sec, - (unsigned long long) st.st_atim.tv_nsec, + remove_precision(st.st_atim.tv_nsec), (long long) st.st_mtim.tv_sec, - (unsigned long long) st.st_mtim.tv_nsec, + remove_precision(st.st_mtim.tv_nsec), (long long) st.st_ctim.tv_sec, - (unsigned long long) st.st_ctim.tv_nsec); + remove_precision(st.st_ctim.tv_nsec)); } @@ -140,16 +174,38 @@ llistxattr_wrapper(PyObject *self, PyObject *args) const char *filename; size_t bufsize; PyObject *o; + char* buf; + ssize_t n; if (!PyArg_ParseTuple(args, "s", &filename)) return NULL; +#ifdef __FreeBSD__ + bufsize = extattr_list_link(filename, EXTATTR_NAMESPACE_USER, NULL, 0); + buf = malloc(bufsize); + n = extattr_list_link(filename, EXTATTR_NAMESPACE_USER, buf, bufsize); + if (n >= 0) { + /* Convert from length-prefixed BSD style to '\0'-suffixed + Linux style. */ + size_t i = 0; + while (i < n) { + unsigned char length = (unsigned char) buf[i]; + memmove(buf + i, buf + i + 1, length); + buf[i + length] = '\0'; + i += length + 1; + } + o = Py_BuildValue("s#", buf, (int) n); + } else { + o = Py_BuildValue("i", errno); + } + free(buf); +#else bufsize = 0; o = NULL; do { bufsize += 1024; - char *buf = malloc(bufsize); - ssize_t n = llistxattr(filename, buf, bufsize); + buf = malloc(bufsize); + n = llistxattr(filename, buf, bufsize); if (n >= 0) o = Py_BuildValue("s#", buf, (int) n); @@ -157,7 +213,7 @@ llistxattr_wrapper(PyObject *self, PyObject *args) o = Py_BuildValue("i", errno); free(buf); } while (o == NULL); - +#endif return o; } @@ -178,8 +234,11 @@ lgetxattr_wrapper(PyObject *self, PyObject *args) do { bufsize += 1024; char *buf = malloc(bufsize); +#ifdef __FreeBSD__ + int n = extattr_get_link(filename, EXTATTR_NAMESPACE_USER, attrname, buf, bufsize); +#else ssize_t n = lgetxattr(filename, attrname, buf, bufsize); - +#endif if (n >= 0) o = Py_BuildValue("s#", buf, (int) n); else if (n == -1 && errno != ERANGE) @@ -203,7 +262,11 @@ lsetxattr_wrapper(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "sss#", &filename, &name, &value, &size)) return NULL; +#ifdef __FreeBSD__ + ret = extattr_set_link(filename, EXTATTR_NAMESPACE_USER, name, value, size); +#else ret = lsetxattr(filename, name, value, size, 0); +#endif if (ret == -1) ret = errno; return Py_BuildValue("i", ret); diff --git a/obnamlib/lockmgr.py b/obnamlib/lockmgr.py index 87f148a7..0e35dd30 100644 --- a/obnamlib/lockmgr.py +++ b/obnamlib/lockmgr.py @@ -33,11 +33,11 @@ class LockManager(object): data = data + self._read_boot_id() self.data = '\r\n'.join(data) - def _read_boot_id(self): + def _read_boot_id(self): # pragma: no cover try: with open("/proc/sys/kernel/random/boot_id", "r") as f: boot_id = f.read().strip() - except: # pragma: no cover + except: return [] else: return ["boot_id=%s" % boot_id] diff --git a/obnamlib/metadata.py b/obnamlib/metadata.py index 94b87a73..c055087f 100644 --- a/obnamlib/metadata.py +++ b/obnamlib/metadata.py @@ -247,13 +247,15 @@ def set_metadata(fs, filename, metadata, getuid=None): if getuid() == 0: fs.lchown(filename, metadata.st_uid, metadata.st_gid) - if not symlink: - # If we are not the owner, and not root, do not restore setuid/setgid. - mode = metadata.st_mode - if getuid() not in (0, metadata.st_uid): # pragma: no cover - mode = mode & (~stat.S_ISUID) - mode = mode & (~stat.S_ISGID) - fs.chmod(filename, mode) + # If we are not the owner, and not root, do not restore setuid/setgid. + mode = metadata.st_mode + if getuid() not in (0, metadata.st_uid): # pragma: no cover + mode = mode & (~stat.S_ISUID) + mode = mode & (~stat.S_ISGID) + if symlink: + fs.chmod_symlink(filename, mode) + else: + fs.chmod_not_symlink(filename, mode) if metadata.xattr: # pragma: no cover set_xattrs_from_blob(fs, filename, metadata.xattr) diff --git a/obnamlib/metadata_tests.py b/obnamlib/metadata_tests.py index f77abe1b..557f2c97 100644 --- a/obnamlib/metadata_tests.py +++ b/obnamlib/metadata_tests.py @@ -18,6 +18,7 @@ import os import stat import tempfile import unittest +import platform import obnamlib @@ -175,6 +176,9 @@ class SetMetadataTests(unittest.TestCase): fd, self.filename = tempfile.mkstemp() os.close(fd) + # On some systems (e.g. FreeBSD) /tmp is apparently setgid and + # default gid of files is therefore not the user's gid. + os.chown(self.filename, os.getuid(), os.getgid()) self.fs = obnamlib.LocalFS('/') self.fs.connect() diff --git a/obnamlib/plugins/sftp_plugin.py b/obnamlib/plugins/sftp_plugin.py index 8b78f55c..576ba7e8 100644 --- a/obnamlib/plugins/sftp_plugin.py +++ b/obnamlib/plugins/sftp_plugin.py @@ -476,7 +476,14 @@ class SftpFS(obnamlib.VirtualFileSystem): self.sftp.chown(pathname, uid, gid) @ioerror_to_oserror - def chmod(self, pathname, mode): + def chmod_symlink(self, pathname, mode): + # SFTP and/or paramiko don't have lchmod at all, so we can't + # actually do this. However, we at least check that pathname + # exists. + self.lstat(pathname) + + @ioerror_to_oserror + def chmod_not_symlink(self, pathname, mode): self._delay() self.sftp.chmod(pathname, mode) diff --git a/obnamlib/vfs.py b/obnamlib/vfs.py index bf470078..680ca65e 100644 --- a/obnamlib/vfs.py +++ b/obnamlib/vfs.py @@ -160,8 +160,23 @@ class VirtualFileSystem(object): def lchown(self, pathname, uid, gid): '''Like os.lchown.''' - def chmod(self, pathname, mode): - '''Like os.chmod.''' + def chmod_symlink(self, pathname, mode): + '''Like os.lchmod, for symlinks only. + + This may fail if the pathname is not a symlink (but it may + not). If the target is a symlink, but the platform (e.g., + Linux) does not allow setting the permissions of a symlink, + the method will silently do nothing. + + ''' + + def chmod_not_symlink(self, pathname, mode): + '''Like os.chmod, for non-symlinks only. + + This may fail if pathname is a symlink (but it may not). It + MUST NOT be called for a symlink; use chmod_symlink instead. + + ''' def lutimes(self, pathname, atime_sec, atime_nsec, mtime_sec, mtime_nsec): '''Like lutimes(2). @@ -523,13 +538,16 @@ class VfsTests(object): # pragma: no cover def test_lstat_raises_oserror_for_nonexistent_entry(self): self.assertRaises(OSError, self.fs.lstat, 'notexists') - def test_chmod_sets_permissions_correctly(self): + def test_chmod_not_symlink_sets_permissions_correctly(self): self.fs.mkdir('foo') - self.fs.chmod('foo', 0777) + self.fs.chmod_not_symlink('foo', 0777) self.assertEqual(self.fs.lstat('foo').st_mode & 0777, 0777) - def test_chmod_raises_oserror_for_nonexistent_entry(self): - self.assertRaises(OSError, self.fs.chmod, 'notexists', 0) + def test_chmod_not_symlink_raises_oserror_for_nonexistent_entry(self): + self.assertRaises(OSError, self.fs.chmod_not_symlink, 'notexists', 0) + + def test_chmod_symlink_raises_oserror_for_nonexistent_entry(self): + self.assertRaises(OSError, self.fs.chmod_symlink, 'notexists', 0) def test_lutimes_sets_times_correctly(self): self.fs.mkdir('foo') diff --git a/obnamlib/vfs_local.py b/obnamlib/vfs_local.py index 639f4451..70a550f8 100644 --- a/obnamlib/vfs_local.py +++ b/obnamlib/vfs_local.py @@ -29,6 +29,10 @@ import tracing import obnamlib +# O_NOATIME is Linux specific: +EXTRA_OPEN_FLAGS = getattr(os, "O_NOATIME", 0) + + class LocalFSFile(file): def read(self, amount=-1): @@ -67,6 +71,9 @@ class LocalFS(obnamlib.VirtualFileSystem): self.crash_limit = None self.crash_counter = 0 + # Do we have lchmod? + self.got_lchmod = hasattr(os, 'lchmod') + def maybe_crash(self): # pragma: no cover if self.crash_limit is not None: self.crash_counter += 1 @@ -191,8 +198,19 @@ class LocalFS(obnamlib.VirtualFileSystem): tracing.trace('lchown %s %d %d', pathname, uid, gid) os.lchown(self.join(pathname), uid, gid) - def chmod(self, pathname, mode): - tracing.trace('chmod %s %o', pathname, mode) + # This method is excluded from test coverage because the platform + # either has lchmod or doesn't, and accordingly either branch of + # the if statement is taken, and the other branch shows up as not + # being tested by the unit tests. + def chmod_symlink(self, pathname, mode): # pragma: no cover + tracing.trace('chmod_symlink %s %o', pathname, mode) + if self.got_lchmod: + os.lchmod(self.join(pathname), mode) + else: + self.lstat(pathname) + + def chmod_not_symlink(self, pathname, mode): + tracing.trace('chmod_not_symlink %s %o', pathname, mode) os.chmod(self.join(pathname), mode) def lutimes(self, pathname, atime_sec, atime_nsec, mtime_sec, mtime_nsec): @@ -228,7 +246,7 @@ class LocalFS(obnamlib.VirtualFileSystem): tracing.trace('opened %s', pathname) try: flags = fcntl.fcntl(f.fileno(), fcntl.F_GETFL) - flags |= os.O_NOATIME + flags |= EXTRA_OPEN_FLAGS fcntl.fcntl(f.fileno(), fcntl.F_SETFL, flags) except IOError, e: # pragma: no cover tracing.trace('fcntl F_SETFL failed: %s', repr(e)) diff --git a/obnamlib/vfs_local_tests.py b/obnamlib/vfs_local_tests.py index f654eb81..071ebae8 100644 --- a/obnamlib/vfs_local_tests.py +++ b/obnamlib/vfs_local_tests.py @@ -14,7 +14,7 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - +import platform import errno import os import shutil @@ -22,6 +22,7 @@ import tempfile import unittest import obnamlib +from obnamlib import _obnam class LocalFSTests(obnamlib.VfsTests, unittest.TestCase): @@ -45,5 +46,29 @@ class LocalFSTests(obnamlib.VfsTests, unittest.TestCase): self.assertEqual(self.fs.get_username(0), 'root') def test_get_groupname_returns_root_for_zero(self): - self.assertEqual(self.fs.get_groupname(0), 'root') + root = 'wheel' if platform.system() == 'FreeBSD' else 'root' + self.assertEqual(self.fs.get_groupname(0), root) + + +class XAttrTests(unittest.TestCase): + '''Tests for extended attributes.''' + + def setUp(self): + fd, self.filename = tempfile.mkstemp() + os.close(fd) + + def test_empty_list(self): + '''A new file has no extended attributes.''' + self.assertEqual(_obnam.llistxattr(self.filename), "") + + def test_lsetxattr(self): + '''lsetxattr() sets an attribute on a file.''' + _obnam.lsetxattr(self.filename, "user.key", "value") + _obnam.lsetxattr(self.filename, "user.hello", "world") + self.assertEqual(sorted(_obnam.llistxattr(self.filename).strip("\0").split("\0")), + ["user.hello", "user.key"]) + def test_lgetxattr(self): + '''lgetxattr() gets the value of an attribute set on the file.''' + _obnam.lsetxattr(self.filename, "user.hello", "world") + self.assertEqual(_obnam.lgetxattr(self.filename, "user.hello"), "world") diff --git a/sed-in-place b/sed-in-place new file mode 100755 index 00000000..13e6258b --- /dev/null +++ b/sed-in-place @@ -0,0 +1,16 @@ +#!/bin/sh +# +# Do a sed in place for a set of files. This is like GNU sed -i, but +# we can't assume GNU sed. + +set -eu + +sedcmd="$1" +shift + +for filename in "$@" +do + temp="$(mktemp)" + sed "$sedcmd" "$filename" > "$temp" + mv "$temp" "$filename" +done
\ No newline at end of file diff --git a/test-many-generations b/test-many-generations index 741f67c4..bec9e6d4 100755 --- a/test-many-generations +++ b/test-many-generations @@ -55,7 +55,7 @@ seq "$N" | while read gen do genbackupdata --quiet --create="$amount" "$root" --seed="$RANDOM" - find "$root" -exec touch --date="1970-01-01 00:00:$gen" '{}' ';' + find "$root" -exec touch -d "1970-01-01 00:00:$gen" '{}' ';' ./verification-test backup "$repopath" "$root" "$conf" \ >> "$client-verif.output" 2>&1 || exit 1 done || exit 1 diff --git a/tests/convert5to6.script b/tests/convert5to6.script index c4936043..92627d34 100755 --- a/tests/convert5to6.script +++ b/tests/convert5to6.script @@ -32,7 +32,8 @@ tar -xf "$SRCDIR/test-data/repo-format-5-encrypted-gzipped.tar.gz" # Not all filesystems support nanosecond timestamps, but that doesn't # matter for us. So we remove the sub-second timestamps from both # summain files. -sed -i '/^Mtime:/s/\.[0-9]* /.IGNORED /' data.summain restored.summain +"$SRCDIR/sed-in-place" '/^Mtime:/s/\.[0-9]* /.IGNORED /' \ + data.summain restored.summain diff -u data.summain restored.summain diff --git a/tests/encryption-replaces-key.script b/tests/encryption-replaces-key.script index d2f31321..afc89778 100755 --- a/tests/encryption-replaces-key.script +++ b/tests/encryption-replaces-key.script @@ -33,7 +33,7 @@ $SRCDIR/tests/obnam --encrypt-with="$gpgkey2" remove-key --keyid="$gpgkey" \ # Remove the old key from the gpg keyring. export GNUPGHOME="$DATADIR/gpg" -gpg --batch --delete-secret-key "$fingerprint" +gpg --batch --delete-secret-key "$fingerprint" 2>/dev/null # Verify that the backup is still readable, now with the new key. $SRCDIR/tests/restore --encrypt-with="$gpgkey2" diff --git a/tests/forget-removes-according-to-policy.script b/tests/forget-removes-according-to-policy.script index 12d5ab0f..ab702cb3 100755 --- a/tests/forget-removes-according-to-policy.script +++ b/tests/forget-removes-according-to-policy.script @@ -24,7 +24,7 @@ $SRCDIR/tests/backup $SRCDIR/tests/obnam genids > "$DATADIR/genids-1" $SRCDIR/tests/obnam forget --keep=1d -sed -i 1d "$DATADIR/genids-1" +$SRCDIR/sed-in-place 1d "$DATADIR/genids-1" $SRCDIR/tests/obnam genids > "$DATADIR/genids-2" diff -u "$DATADIR/genids-1" "$DATADIR/genids-2" diff --git a/tests/forget-removes-specified-gens.script b/tests/forget-removes-specified-gens.script index 2565590e..424ce284 100755 --- a/tests/forget-removes-specified-gens.script +++ b/tests/forget-removes-specified-gens.script @@ -24,7 +24,7 @@ $SRCDIR/tests/backup $SRCDIR/tests/obnam genids > "$DATADIR/genids-1" $SRCDIR/tests/obnam forget $(head -n1 "$DATADIR/genids-1") -sed -i 1d "$DATADIR/genids-1" +$SRCDIR/sed-in-place 1d "$DATADIR/genids-1" $SRCDIR/tests/obnam genids > "$DATADIR/genids-2" diff -u "$DATADIR/genids-1" "$DATADIR/genids-2" diff --git a/tests/logs-for-owner-only.script b/tests/logs-for-owner-only.script index 920620c0..9e665f54 100755 --- a/tests/logs-for-owner-only.script +++ b/tests/logs-for-owner-only.script @@ -19,5 +19,5 @@ set -e $SRCDIR/tests/backup --log="$DATADIR/obnam.log" # Print out the permissions. -stat --printf '%A\n' "$DATADIR/obnam.log" +python -c "import sys, os; print os.lstat(sys.argv[1]).st_mode" "$DATADIR/obnam.log" diff --git a/tests/logs-for-owner-only.stdout b/tests/logs-for-owner-only.stdout index 2bdc0369..7bd2e962 100644 --- a/tests/logs-for-owner-only.stdout +++ b/tests/logs-for-owner-only.stdout @@ -1 +1 @@ --rw------- +33152 diff --git a/tests/named-pipe.script b/tests/named-pipe.script index 0f2ccd35..a0f0d09c 100755 --- a/tests/named-pipe.script +++ b/tests/named-pipe.script @@ -23,7 +23,7 @@ then fi # Create a named pipe. -mknod "$DATADIR/data/pipe" p +mkfifo "$DATADIR/data/pipe" $SRCDIR/tests/backup $SRCDIR/tests/restore diff --git a/tests/named-socket.script b/tests/named-socket.script index 7f87a321..1d4d08e1 100755 --- a/tests/named-socket.script +++ b/tests/named-socket.script @@ -24,6 +24,10 @@ fi # Create a named socket. python -c ' +import platform +if platform.system() == "FreeBSD": + # Cannot mknod sockets on FreeBSD. + raise SystemExit(0) import os, stat filename = os.path.join(os.environ["DATADIR"], "data", "socket") os.mknod(filename, 0600 | stat.S_IFSOCK) diff --git a/tests/pretend-time.script b/tests/pretend-time.script index 8296b157..ac616e44 100755 --- a/tests/pretend-time.script +++ b/tests/pretend-time.script @@ -20,4 +20,4 @@ $SRCDIR/tests/backup --pretend-time='2007-08-12 01:02:03' # Print out the generation timestamp. $SRCDIR/tests/obnam $opts generations | - sed 's/([0-9]\+ files/(xx files/' + sed 's/([0-9]* files/(xx files/' diff --git a/tests/remove-checkpoints.script b/tests/remove-checkpoints.script index 1a70921c..d61c7e06 100755 --- a/tests/remove-checkpoints.script +++ b/tests/remove-checkpoints.script @@ -19,5 +19,5 @@ set -e $SRCDIR/tests/backup --checkpoint=1k # Check that there's only one generation. -$SRCDIR/tests/obnam genids | wc -l +$SRCDIR/tests/obnam genids | wc -l | sed 's/ *//' diff --git a/tests/unreadable-dir.script b/tests/unreadable-dir.script index 7533b589..71fe28aa 100755 --- a/tests/unreadable-dir.script +++ b/tests/unreadable-dir.script @@ -17,7 +17,7 @@ set -e echo aaa > "$DATADIR/data/aaa" -mkdir --mode=0 "$DATADIR/data/bbb" +mkdir -m 0 "$DATADIR/data/bbb" echo ccc > "$DATADIR/data/ccc" if $SRCDIR/tests/backup diff --git a/tests/use-old-node-size.script b/tests/use-old-node-size.script index 7c905182..a540db10 100755 --- a/tests/use-old-node-size.script +++ b/tests/use-old-node-size.script @@ -20,5 +20,5 @@ $SRCDIR/tests/backup --node-size=4k $SRCDIR/tests/backup --node-size=16k # Check that there's two generations. -$SRCDIR/tests/obnam $opts genids | wc -l +$SRCDIR/tests/obnam $opts genids | wc -l | sed 's/ *//' diff --git a/tests/verify b/tests/verify index d064a98b..a4bfe602 100755 --- a/tests/verify +++ b/tests/verify @@ -25,7 +25,7 @@ summain -r "$DATADIR/restored/$DATADIR/data" > "$DATADIR/restored.summain" # summain output to remove sub-second timestamps. if [ "$OBNAM_TEST_SFTP_ROOT" = yes ] then - sed -i '/^Mtime:/s/\.[[:digit:]]\+ / /' \ + "$SRCDIR/sed-in-place" '/^Mtime:/s/\.[[:digit:]]\+ / /' \ "$DATADIR/data.summain" \ "$DATADIR/restored.summain" fi diff --git a/tests/verify-notices-changes.script b/tests/verify-notices-changes.script index 45e01e2b..6443c0c0 100755 --- a/tests/verify-notices-changes.script +++ b/tests/verify-notices-changes.script @@ -21,7 +21,7 @@ echo ccc > "$DATADIR/data/ccc" $SRCDIR/tests/backup -touch --date="1970-01-02 03:04:05" "$DATADIR/data/aaa" +touch -d "1970-01-02 03:04:05" "$DATADIR/data/aaa" $SRCDIR/tests/obnam verify "$(cat $DATADIR/rooturl)" 2>&1 | sed "s,$DATADIR,TMP,g" | |