summaryrefslogtreecommitdiff
path: root/tests/libtest.sh
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2017-06-12 13:59:33 -0400
committerAtomic Bot <atomic-devel@projectatomic.io>2017-06-13 12:02:12 +0000
commit74e3581ed674746d03e8a0e0af332b10de26963f (patch)
tree600183fec1b040b1561dae4d4abf7a597357ed3d /tests/libtest.sh
parentb614c65eabc416458dc7d27f8339f84091f68ad2 (diff)
downloadostree-74e3581ed674746d03e8a0e0af332b10de26963f.tar.gz
lib/repo: Support hardlink conversions from bare-user to bu-only
Thinking about the problem of flatpak converting from `bare-user` to `bare-user-only` "in place" by creating a new repo and doing a `pull-local`, I realized that we can optimize this process by doing hardlinks for both metadata and regular files. The repo formats are *almost* compatible, the exception being symlinks. An earlier patch caused us to do hardlinks for metadata, this patch takes things to the next step and special cases this specific conversion. In this case we need to parse the source object to determine whether or not it's a symlink. Closes: #922 Approved by: alexlarsson
Diffstat (limited to 'tests/libtest.sh')
-rwxr-xr-xtests/libtest.sh30
1 files changed, 23 insertions, 7 deletions
diff --git a/tests/libtest.sh b/tests/libtest.sh
index 1774a7b6..15802dfd 100755
--- a/tests/libtest.sh
+++ b/tests/libtest.sh
@@ -116,10 +116,16 @@ else
fi
fi
+files_are_hardlinked() {
+ f1=$(stat -c %i $1)
+ f2=$(stat -c %i $2)
+ [ "$f1" == "$f2" ]
+}
+
assert_files_hardlinked() {
f1=$(stat -c %i $1)
f2=$(stat -c %i $2)
- if [ "$f1" != "$f2" ]; then
+ if ! files_are_hardlinked "$f1" "$f2"; then
fatal "Files '$1' and '$2' are not hardlinked"
fi
}
@@ -512,12 +518,22 @@ ostree_file_path_to_checksum() {
$CMD_PREFIX ostree --repo=$repo ls -C $ref $path | awk '{ print $5 }'
}
+# Given a path to a file in a repo for a ref, print the (relative) path to its
+# object
+ostree_file_path_to_relative_object_path() {
+ repo=$1
+ ref=$2
+ path=$3
+ checksum=$(ostree_file_path_to_checksum $repo $ref $path)
+ test -n "${checksum}"
+ echo objects/${checksum:0:2}/${checksum:2}.file
+}
+
# Given a path to a file in a repo for a ref, print the path to its object
ostree_file_path_to_object_path() {
- repo=$1
- ref=$2
- path=$3
- checksum=$(ostree_file_path_to_checksum $repo $ref $path)
- test -n "${checksum}"
- echo ${repo}/objects/${checksum:0:2}/${checksum:2}.file
+ repo=$1
+ ref=$2
+ path=$3
+ relpath=$(ostree_file_path_to_relative_object_path $repo $ref $path)
+ echo ${repo}/${relpath}
}