Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: incorrect statusd paths #28

Merged
merged 2 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
""",
)
Loading