From c7cdffd11386c898cd8e1d0a9cb14547d296f092 Mon Sep 17 00:00:00 2001 From: z4yx Date: Thu, 31 Oct 2019 10:45:14 +0800 Subject: [PATCH] use awk to parse the record (fix #43) --- helpers/apt-download | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/helpers/apt-download b/helpers/apt-download index 2c58c1c..df6c578 100644 --- a/helpers/apt-download +++ b/helpers/apt-download @@ -129,8 +129,12 @@ function apt-download-binary() { ERROR=0 + awk_script='BEGIN{FS="\n";RS="\n\n"}{for(i=1;i<=NF;i++){if($i ~ /^Filename/){fn=$i;gsub(/^.+: /,"",fn)}else if($i ~ /^Size/){sz=$i;gsub(/^.+: /,"",sz)}else if($i ~ /' + awk_script+="${checksum_regex}" + awk_script+='/){hash=$i;gsub(/^.+: /,"",hash)}}print fn;print sz;print hash }' + # Download packages - (echo -e "${pkgidx_content}" | grep -e '^Filename' -e '^Size' -e ${checksum_regex} | cut -d' ' -f 2) | \ + (echo -e "${pkgidx_content}" | awk "$awk_script") | \ while read pkg_filename; read pkg_size; read pkg_checksum; do echo ${pkg_filename} >> $filelist dest_filename="${dest_base_dir}/${pkg_filename}"