diff --git a/apt/private/dpkg_status.sh b/apt/private/dpkg_status.sh index 866545d..1dc689f 100755 --- a/apt/private/dpkg_status.sh +++ b/apt/private/dpkg_status.sh @@ -8,19 +8,17 @@ shift 2 tmp_out=$(mktemp) while (( $# > 0 )); do - control="$($bsdtar -xf "$1" --to-stdout ./control)" - echo "$control" | head -n 1 >> $tmp_out - echo "Status: install ok installed" >> $tmp_out - echo "$control" | tail -n +2 >> $tmp_out - echo "" >> $tmp_out + $bsdtar -xf "$1" --to-stdout ./control | + awk '{ + print $0; + if (NR == 1) { print "Status: install ok installed"}; + } END { print "" } + ' >> $tmp_out shift done -mtree_out=$(mktemp) echo "#mtree ./var/lib/dpkg/status type=file uid=0 gid=0 mode=0644 contents=$tmp_out -" > $mtree_out +" | "$bsdtar" $@ -cf "$out" "@-" -"$bsdtar" $@ -cf "$out" "@$mtree_out" - -rm $tmp_out $mtree_out \ No newline at end of file +rm $tmp_out \ No newline at end of file diff --git a/apt/private/dpkg_statusd.sh b/apt/private/dpkg_statusd.sh index e2e1fb5..c9a4c8a 100755 --- a/apt/private/dpkg_statusd.sh +++ b/apt/private/dpkg_statusd.sh @@ -16,8 +16,14 @@ tmp=$(mktemp -d) awk -v pkg="$package_name" '{ if ($1=="#mtree") { print $1; next - }; + }; + # strip leading ./ prefix sub(/^\.?\//, "", $1); - $1 = "./var/lib/dpkg/status.d/" pkg "/" $1 " contents=./" $1; + + if ($1 ~ /^control/) { + $1 = "./var/lib/dpkg/status.d/" pkg " contents=./" $1; + } else if ($1 ~ /^md5sums/) { + $1 = "./var/lib/dpkg/status.d/" pkg ".md5sums contents=./" $1; + } print $0 -}' | "$bsdtar" $@ -cf "$out" -C "$tmp/" @- +}' | "$bsdtar" $@ -cf "$out" -C "$tmp/" @- diff --git a/examples/statusd/BUILD.bazel b/examples/statusd/BUILD.bazel index c389d5b..4e2b4e9 100644 --- a/examples/statusd/BUILD.bazel +++ b/examples/statusd/BUILD.bazel @@ -13,7 +13,7 @@ assert_tar_listing( actual = "statusd", expected = """\ #mtree -./var/lib/dpkg/status.d/ca-certificates/control time=1611051064.0 mode=644 gid=0 uid=0 type=file size=793 sha1digest=214a8bc9b7e7ce33fbd2e08b0b01aa5e2b717495 -./var/lib/dpkg/status.d/ca-certificates/md5sums time=1611051064.0 mode=644 gid=0 uid=0 type=file size=14644 sha1digest=80ae4d6a7dbfeefd6e16ccab344671c6f7426422 +./var/lib/dpkg/status.d/ca-certificates time=1611051064.0 mode=644 gid=0 uid=0 type=file size=793 sha1digest=214a8bc9b7e7ce33fbd2e08b0b01aa5e2b717495 +./var/lib/dpkg/status.d/ca-certificates.md5sums time=1611051064.0 mode=644 gid=0 uid=0 type=file size=14644 sha1digest=80ae4d6a7dbfeefd6e16ccab344671c6f7426422 """, )