From 9150b2cae5ddc7827578996290379b3b878ca3fc Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Tue, 19 Sep 2023 13:01:06 +0200 Subject: [PATCH] Refactored logic to rewrite the Release file. --- .drone.yml | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/.drone.yml b/.drone.yml index a19a2b8d2..e60875e21 100644 --- a/.drone.yml +++ b/.drone.yml @@ -477,6 +477,20 @@ steps: - echo "-- Updating Release files" - | + add_hashes() { + dist_dir=$1 + hash_cmd=$2 + hash_label=$3 + + echo "$hash_label:" + find "$dist_dir" -name 'Packages*' | while read file; do + basename="$(echo "$file" | sed -r -e "s|^$dist_dir/||")" + hash="$($hash_cmd "$file" | cut -d" " -f1)" + size="$(wc -c < $file)" + echo " $hash $size $basename" + done + } + echo "stable\noldstable" | while read distro; do dist_dir="$APT_ROOT/dists/$distro" components=$(find "$dist_dir" -name Packages | awk -F '/' '{print $(NF-2)}' | uniq | tr '\n' ' ') @@ -494,23 +508,9 @@ steps: Date: $(date -Ru) EOF - echo "MD5Sum:" >> "$release_file" - find "$dist_dir" -name 'Packages*' | while read file; do - basename="$(echo "$file" | sed -r -e "s|^$dist_dir/(.*)|\1|")" - echo " $(md5sum "$file" | cut -d" " -f1) $(wc -c < $file) $basename" - done >> "$release_file" - - echo "SHA1:" >> "$release_file" - find "$dist_dir" -name 'Packages*' | while read file; do - basename="$(echo "$file" | sed -r -e "s|^$dist_dir/(.*)|\1|")" - echo " $(sha1sum "$file" | cut -d" " -f1) $(wc -c < $file) $basename" - done >> "$release_file" - - echo "SHA256:" >> "$release_file" - find "$dist_dir" -name 'Packages*' | while read file; do - basename="$(echo "$file" | sed -r -e "s|^$dist_dir/(.*)|\1|")" - echo " $(sha256sum "$file" | cut -d" " -f1) $(wc -c < $file) $basename" - done >> "$release_file" + add_hashes "$dist_dir" "md5sum" "MD5Sum" >> "$release_file" + add_hashes "$dist_dir" "sha1sum" "SHA1" >> "$release_file" + add_hashes "$dist_dir" "sha256sum" "SHA256" >> "$release_file" done ###