Removing duplicates from md5sum.txt and computing new MD5 for changed files

This commit is contained in:
Thomas Schmitt 2022-06-23 18:17:41 +02:00
parent 87aab73058
commit 0bc397c02c
2 changed files with 95 additions and 6 deletions

View File

@ -434,6 +434,7 @@ do
MOUNT_LIST="$MOUNT_LIST $mount_point"
done
echo "Done." >&2
echo >&2
echo "Copying dists directory and md5sum.txt from first ISO ..." >&2
@ -473,6 +474,7 @@ else
echo "--- Could not copy /md5sum.txt from first ISO." >&2
cleanup_and_end 3
fi
echo "Done." >&2
## Helper functions
@ -516,6 +518,84 @@ extract_release_head() {
done
}
# Decide whether to re-compute MD5 and whether to put out the md5sum line
# Parameters: prev_path prev_md5
check_and_put_out_md5_grep() {
if echo "$prev_path" | grep '^\.\/pool\/' >/dev/null 2>&1
then
echo "$prev_md5 $prev_path"
return 0
fi
if echo "$prev_path" | grep '^\.\/firmware\/' >/dev/null 2>&1
then
if test "$was_multiple" = 1
then
# There is the risk that the surviving file does not match prev_md5.
# Better omit it.
dummy=dummy
else
echo "$prev_md5 $prev_path"
fi
return 0
fi
if echo "$prev_path" | grep '^\.\/dists\/' >/dev/null 2>&1
then
md5_path="$(echo -n "$prev_path" | sed -e 's/^\.\//merged_/')"
prev_md5="$(md5sum <"$md5_path" | awk '{print $1}')"
elif test "$prev_path" = ./README.txt
then
prev_md5="$(md5sum <merged_README.txt | awk '{print $1}')"
elif test "$was_multiple" = 1
then
# Unchanged file was taken from iso1
# md5sum.txt lines might be permuted though. So compute freshly
prev_md5="$(md5sum <"$mount_point_1"/"$prev_path" | awk '{print $1}')"
fi
if test -z "$prev_md5"
then
prev_md5="-"
return 1
else
echo "$prev_md5 $prev_path"
fi
return 0
}
# Put out merged_md5sum.txt while removing duplicates
# and recomputing MD5 if needed
polish_md5sum_txt() {
prev_path=
prev_md5=
was_multiple=0
cat merged_md5sum.txt | \
while read md5 path
do
if test "$path" = "$prev_path"
then
was_multiple=1
continue
fi
if test -n "$prev_path"
then
check_and_put_out_md5_grep
fi
prev_path="$path"
prev_md5="$md5"
was_multiple=0
done
if test -n "$prev_path"
then
check_and_put_out_md5_grep
fi
return 0
}
## Determine which Debian release is on iso1
echo >&2
@ -619,12 +699,6 @@ echo "Done." >&2
echo >&2
echo "Merging package description files ..." >&2
# /md5sum.txt seems to be the only overall package list
for i in $MOUNT_LIST
do
cat "$i"/md5sum.txt
done | sort -k 2 >merged_md5sum.txt
# Determine the files which are mentioned with checksum in main Release files
path_list=$(for i in $MOUNT_LIST
do
@ -677,6 +751,7 @@ continue
fi
done
echo "Done." >&2
## Update dists/"$dist"/Release
@ -720,6 +795,20 @@ mv temp_file merged_dists/"$dist"/Release
echo "Done." >&2
## Merge md5sum.txt and compute the MD5s which might have changed
echo >&2
echo "Merging md5sum.txt files ..." >&2
for i in $MOUNT_LIST
do
cat "$i"/md5sum.txt
done | sort -k 2 >merged_md5sum.txt
polish_md5sum_txt >temp_file
mv temp_file merged_md5sum.txt
echo "Done." >&2
## Produce the new ISO image
echo >&2
echo "Producing result ISO image ..." >&2

Binary file not shown.