summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2019-06-17 12:39:09 +0200
committerSimon Rettberg2019-06-17 12:39:09 +0200
commit3ce5c2a6b078ee2436f4913596d37558c5228607 (patch)
tree879845db03c793e9f7da5856b99bb09cb18346d6
parent[run-virt] Floppy (fd1)-scripts: No more display manager conf. patching, (diff)
downloadtm-scripts-3ce5c2a6b078ee2436f4913596d37558c5228607.tar.gz
tm-scripts-3ce5c2a6b078ee2436f4913596d37558c5228607.tar.xz
tm-scripts-3ce5c2a6b078ee2436f4913596d37558c5228607.zip
Make -i check if files are actually identical
-rw-r--r--server/includes/packing.inc35
1 files changed, 33 insertions, 2 deletions
diff --git a/server/includes/packing.inc b/server/includes/packing.inc
index aaa088aa..2891aeef 100644
--- a/server/includes/packing.inc
+++ b/server/includes/packing.inc
@@ -21,16 +21,47 @@ generate_initramfs() {
pinfo "Size: $(du -bsh "$3" | awk 'END {print $1}')"
}
+# <dir> <list_file>
+md5list() {
+ (
+ cd "$1" || perror "Cannot cd to $1"
+ while IFS='' read -r line || [[ -n "$line" ]]; do
+ md5sum "$line"
+ done < "$2"
+ )
+}
+
# generates squashfs of directory
# usage:
# generate_squashfs <source_dir> <destination_dir/filename> [ignore_root]
generate_squashfs() {
[ $# -lt 2 ] && perror "Sanity check failed: generate_squashfs needs at least two params, but $# were given."
[ -d "$1" ] || perror "$1 is not a directory."
- local IGNORE="${2}.ignore"
+ local IGNORE=$(mktemp)
truncate -s 0 "$IGNORE"
if [ -n "$3" ]; then
- find "$3" -type f -o -type l | cut -c "$(( ${#3} + 2 ))-" > "$IGNORE"
+ [ -d "$3" ] || perror "Ignore dir does not exist!"
+ local list_this=$(mktemp)
+ local list_other=$(mktemp)
+ local list_common=$(mktemp)
+ local hash_this=$(mktemp)
+ local hash_other=$(mktemp)
+ ( cd "$3" && find -type f | sort > "$list_other" )
+ ( cd "$1" && find -type f | sort > "$list_this" )
+ comm -12 "$list_this" "$list_other" > "$list_common"
+ echo "Common to both:"
+ cat "$list_common"
+ md5list "$3" "$list_common" | sort > "$hash_other"
+ md5list "$1" "$list_common" | sort > "$hash_this"
+ echo "Hash other:"
+ cat "$hash_other"
+ echo "Hash this:"
+ cat "$hash_this"
+ comm -12 "$hash_this" "$hash_other" > "$list_common"
+ echo "Identical:"
+ cat "$list_common"
+ awk '{gsub(/^\.?\//, "", $2); print $2}' "$list_common" > "$IGNORE"
+ rm -f -- "$list_this" "$list_other" "$hash_this" "$hash_other" "$list_common"
fi
# Detect mksquashfs xz support
local PARAMS