diff options
Diffstat (limited to 'server/includes/packing.inc')
-rw-r--r-- | server/includes/packing.inc | 35 |
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 |