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

feat(24.10): add gzip dpkg and tar #483

Closed
wants to merge 6 commits into from
Closed
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
59 changes: 59 additions & 0 deletions slices/dpkg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package: dpkg

essential:
- dpkg_copyright

slices:
bins:
essential:
- dpkg_config
- dpkg_var
- libbz2-1.0_libs
- libc-bin_ldconfig
- libc6_libs
- liblzma5_libs
- libmd0_libs
- libselinux1_libs
- libzstd1_libs
- tar_tar
- zlib1g_libs
contents:
/usr/bin/dpkg:
/usr/bin/dpkg-deb:
/usr/bin/dpkg-divert:
/usr/bin/dpkg-maintscript-helper:
/usr/bin/dpkg-query:
/usr/bin/dpkg-realpath:
/usr/bin/dpkg-split:
/usr/bin/dpkg-statoverride:
/usr/bin/dpkg-trigger:
/usr/bin/update-alternatives:
/usr/libexec/dpkg/*:
/usr/sbin/start-stop-daemon:

copyright:
contents:
/usr/share/doc/dpkg/copyright:

config:
contents:
/etc/dpkg/dpkg.cfg:
/etc/dpkg/dpkg.cfg.d/:

locales:
essential:
- dpkg_bins
contents:
/usr/share/locale/**/dpkg.mo:

tables:
contents:
/usr/share/dpkg/*table:

var:
# Directories that are included in the tarball because they need to exist in /var
contents:
/var/lib/dpkg/alternatives/:
/var/lib/dpkg/info/:
/var/lib/dpkg/parts/:
/var/lib/dpkg/updates/:
29 changes: 29 additions & 0 deletions slices/gzip.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package: gzip

essential:
- gzip_copyright

slices:
bins:
essential:
- dpkg_bins
- libc6_libs
contents:
/usr/bin/gunzip:
/usr/bin/gzexe:
/usr/bin/gzip:
/usr/bin/uncompress:
/usr/bin/zcat:
/usr/bin/zcmp:
/usr/bin/zdiff:
/usr/bin/zegrep:
/usr/bin/zfgrep:
/usr/bin/zforce:
/usr/bin/zgrep:
/usr/bin/zless:
/usr/bin/zmore:
/usr/bin/znew:

copyright:
contents:
/usr/share/doc/gzip/copyright:
7 changes: 7 additions & 0 deletions slices/libc-bin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ slices:
contents:
/etc/nsswitch.conf: {copy: /usr/share/libc-bin/nsswitch.conf}

ldconfig:
essential:
- dash_bins
contents:
/usr/sbin/ldconfig:
/usr/sbin/ldconfig.real:

locale:
contents:
/usr/lib/locale/C.utf8/LC_ADDRESS:
Expand Down
31 changes: 31 additions & 0 deletions slices/tar.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package: tar

essential:
- tar_copyright

slices:
bins:
essential:
- tar_rmt
- tar_tar
contents:
/usr/sbin/tarcat:

copyright:
contents:
/usr/share/doc/tar/copyright:

rmt:
essential:
- libc6_libs
contents:
/etc/rmt: {symlink: /usr/sbin/rmt-tar}
/usr/sbin/rmt-tar:

tar:
essential:
- libacl1_libs
- libc6_libs
- libselinux1_libs
contents:
/usr/bin/tar:
12 changes: 12 additions & 0 deletions tests/spread/integration/dpkg/task.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
summary: Integration tests for dpkg

execute: |
# Chisel a minimum number of slices to give us a runnable system that we can
# test in.
rootfs="$(install-slices coreutils_bins diffutils_bins dpkg_bins)"

# Get a sample deb file to install. Contains no dependencies or install scripts.
wget -P "${rootfs}/" http://archive.ubuntu.com/ubuntu/pool/main/l/lsb-release-minimal/lsb-release_12.1-1_all.deb

# Run a smoke test for dpkg to ensure that it does not throw an error
chroot "${rootfs}/" dpkg --install ./lsb-release_12.1-1_all.deb
20 changes: 20 additions & 0 deletions tests/spread/integration/gzip/task.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
summary: Integration tests for gzip

systems:
- -ubuntu-24.04-ppc64le
- -ubuntu-24.04-s390x

execute: |
rootfs="$(install-slices gzip_bins)"

echo "this is a test text file that we will compress using gzip" > "${rootfs}"/test.txt
chroot "${rootfs}" gzip -k test.txt

# store original for comparison
mv "${rootfs}"/test.txt "${rootfs}"/test.original

# decompress the original file
chroot "${rootfs}" gzip -d test.txt.gz

# ensure that the files are identical
cmp "${rootfs}"/test.txt "${rootfs}"/test.original
33 changes: 33 additions & 0 deletions tests/spread/integration/tar/task.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
summary: Integration tests for tar

execute: |
# Chisel a minimum number of slices to give us a runnable system that we can
# test in.
rootfs="$(install-slices tar_tar)"

mkdir "${rootfs}/test"

echo "This is a test file" > "${rootfs}/test/test.txt"
touch --date=2020-01-01T00:00:00Z "${rootfs}/test/test.txt"
touch --date=2020-01-01T00:00:00Z "${rootfs}/test/"

# Create an uncompressed tarball and compare to a known hash.
chroot "${rootfs}/" tar -cf test.tar /test/
[[ $(sha256sum "${rootfs}/test.tar" | cut -d' ' -f1) == f5893661db55f15954c90dee860ee6c93042ea482c303f5f162c8078cdc79928 ]]

# Decompress back to a new directory and ensure the file is correct.
mkdir "${rootfs}/test-result"
chroot "${rootfs}/" tar -xf test.tar -C /test-result
[[ "$(cat ${rootfs}/test/test.txt)" == "$(cat ${rootfs}/test-result/test/test.txt)" ]]
# Check modification times
[[ $(stat -c %Y ${rootfs}/test-result/test) == 1577836800 ]]
[[ $(stat -c %Y ${rootfs}/test-result/test) == 1577836800 ]]

# Expect an error gzipping a tarball since gzip is not installed in the chroot.
! chroot "${rootfs}/" tar -czf test.tar.gz /test/ 2| grep -q "tar (child): gzip: Cannot exec: No such file or directory"

# New environment for rmt slice.
rootfs="$(install-slices tar_rmt)"

# We can't really do much with rmt, so just check that the executable works.
chroot "${rootfs}/" rmt-tar --version
Loading