Skip to content

Commit

Permalink
fix: incorrect statusd paths (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
thesayyn authored Apr 1, 2024
1 parent 53cd286 commit 1447931
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
18 changes: 8 additions & 10 deletions apt/private/dpkg_status.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
rm $tmp_out
12 changes: 9 additions & 3 deletions apt/private/dpkg_statusd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/" @-
4 changes: 2 additions & 2 deletions examples/statusd/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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
""",
)

0 comments on commit 1447931

Please sign in to comment.