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.04): add util-linux #330

Open
wants to merge 11 commits into
base: ubuntu-24.04
Choose a base branch
from

Conversation

Meulengracht
Copy link
Member

@Meulengracht Meulengracht commented Sep 3, 2024

Proposed changes

Proposing the util-linux package

Forward porting

Will open for 24.10 once this is approved.

Related issue

Closes #260

Checklist

Copy link

github-actions bot commented Sep 3, 2024

Diff of dependencies:

slices/util-linux.yaml
@@ -1,8 +1,11 @@
+base-files
 libblkid1
 libc6
 libcap-ng0
 libcrypt1
 libmount1
+libpam-modules
+libpam-runtime
 libpam0g
 libselinux1
 libsmartcols1

@linostar linostar added the Priority Look at me first label Sep 24, 2024
@linostar linostar requested review from linostar and a team September 24, 2024 13:03
slices/util-linux.yaml Show resolved Hide resolved
tests/spread/integration/util-linux/task.yaml Show resolved Hide resolved
Copy link
Member

@rebornplusplus rebornplusplus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall. Just a couple of comments.

slices/util-linux.yaml Outdated Show resolved Hide resolved
slices/util-linux.yaml Show resolved Hide resolved
@linostar linostar mentioned this pull request Oct 16, 2024
2 tasks
slices/util-linux.yaml Outdated Show resolved Hide resolved
cjdcordeiro and others added 2 commits November 18, 2024 15:11
This commit adds a new slice su-support, which segregates the su and
runuser binaries to that slice for granularity. It also modifies the
tests a bit.
linostar

This comment was marked as outdated.

@rebornplusplus rebornplusplus marked this pull request as draft November 26, 2024 14:26
@linostar linostar self-requested a review November 26, 2024 14:39
Copy link
Collaborator

@zhijie-yang zhijie-yang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With these changes applied, spread tests should pass, and the functionality of util-linux should be fulfilled. The spread tests will pass only when this PR is rebased upon the newest ubuntu-24.04 branch, where PR #306 is already merged.

slices/util-linux.yaml Show resolved Hide resolved
slices/util-linux.yaml Show resolved Hide resolved
slices/util-linux.yaml Show resolved Hide resolved
tests/spread/integration/util-linux/task.yaml Outdated Show resolved Hide resolved
tests/spread/integration/util-linux/task.yaml Outdated Show resolved Hide resolved
tests/spread/integration/util-linux/task.yaml Outdated Show resolved Hide resolved
Co-authored-by: zhijie-yang <zhijie.yang@canonical.com>
Co-authored-by: Linostar <linux.anas@gmail.com>
Copy link
Collaborator

@zhijie-yang zhijie-yang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix linting and wrong slice name.

slices/util-linux.yaml Outdated Show resolved Hide resolved
slices/util-linux.yaml Outdated Show resolved Hide resolved
Co-authored-by: zhijie-yang <zhijie.yang@canonical.com>
Copy link
Collaborator

@zhijie-yang zhijie-yang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good to me now. Thanks!

@cjdcordeiro cjdcordeiro marked this pull request as ready for review January 8, 2025 15:32
Copy link
Member

@rebornplusplus rebornplusplus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

- util-linux_pam-profiles
- util-linux_su-support
- zlib1g_libs
contents:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sry I have to throw one more request here, but to follow our own practices, we should test every binary in the slice.

Comment on lines +23 to +27
# smoke test a couple of the bundled applications
chroot "${rootfs}" lsblk | grep "loop0"
chroot "${rootfs}" lsipc | grep "MSGMNI"
chroot "${rootfs}" lsmem | grep "Total online memory"
chroot "${rootfs}" whereis lsblk | grep "/usr/bin/lsblk"
Copy link
Collaborator

@zhijie-yang zhijie-yang Jan 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# smoke test a couple of the bundled applications
chroot "${rootfs}" lsblk | grep "loop0"
chroot "${rootfs}" lsipc | grep "MSGMNI"
chroot "${rootfs}" lsmem | grep "Total online memory"
chroot "${rootfs}" whereis lsblk | grep "/usr/bin/lsblk"
# Binaries involving disk, partition and device operations are only tested with
# the `--help` command as the smoke test.
# Some of the binaries are not possible to be tested with their functionalities
# due to the limitation of the spread test environment.
# Some of the binaries neither changes the status of the system, nor have
# deterministic outputs across different systems. They are tested without
# assertions.
chroot "${rootfs}" addpart --help
chroot "${rootfs}" choom -p 1
chroot "${rootfs}" chrt -p 1
chroot "${rootfs}" delpart --help
# Accessing kernel dmesg is not permitted in LXD.
chroot "${rootfs}" dmesg --help
chroot "${rootfs}" fallocate -l 1M /tmp/fallocate-test
test -f "${rootfs}"/tmp/fallocate-test
chroot "${rootfs}" findmnt | grep "/dev"
chroot "${rootfs}" flock /tmp/bash.lock -c "exit 0"
chroot "${rootfs}" getopt Hello world | grep " -- world"
mkdir -p "${rootfs}"/tmp/hardlink-test
echo "Hello world" > "${rootfs}"/tmp/hardlink-test/file1
cp "${rootfs}"/tmp/hardlink-test/file1 "${rootfs}"/tmp/hardlink-test/file2
chroot "${rootfs}" hardlink /tmp/hardlink-test/ | grep 'Saved:[[:blank:]]*12 B'
chroot "${rootfs}" ionice -P 1 | grep "best-effort: prio"
ipcmk_out=$(chroot "${rootfs}" ipcmk -M 1)
shm_id=$(echo "${ipcmk_out}" | grep -oP '\d+')
chroot "${rootfs}" ipcs -m | grep "${shm_id}"
chroot "${rootfs}" ipcrm shm "${shm_id}"
cp /var/log/wtmp "${rootfs}"/var/log/wtmp
chroot "${rootfs}" last | grep "wtmp begins"
chroot "${rootfs}" lsblk | grep "loop0"
chroot "${rootfs}" lscpu | grep "Architecture"
chroot "${rootfs}" lsipc | grep "MSGMNI"
chroot "${rootfs}" lsmem | grep "Total online memory"
chroot "${rootfs}" lsns | grep "init"
chroot "${rootfs}" mcookie | grep -E '^[0-9a-f]{32}$'
chroot "${rootfs}" mesg --help
chroot "${rootfs}" more /usr/share/doc/util-linux/copyright | grep "format"
chroot "${rootfs}" mountpoint /dev | grep "/dev is a mountpoint"
chroot "${rootfs}" namei /bin/bash | grep "l bin -> usr/bin"
chroot "${rootfs}" nsenter bash -c "exit 0"
chroot "${rootfs}" partx --help
chroot "${rootfs}" prlimit | grep "CPU"
chroot "${rootfs}" rename.ul copyright copyright2 /usr/share/doc/util-linux/copyright
test -f "${rootfs}"/usr/share/doc/util-linux/copyright2
chroot "${rootfs}" resizepart --help
echo "Hello" | chroot "${rootfs}" rev | grep "olleH"
# i386, ppc, ppc32, ppc64, s390, s390x and x86_64 are symlinks to setarch.
chroot "${rootfs}" setarch --list | grep "linux32"
chroot "${rootfs}" setpriv bash -c "exit 0"
chroot "${rootfs}" setsid bash -c "exit 0"
chroot "${rootfs}" setterm --help
chroot "${rootfs}" taskset -p 1 | grep "pid 1's current affinity mask:"
chroot "${rootfs}" uclampset -p 1 | grep "util_clamp: min: "
chroot "${rootfs}" unshare bash -c "exit 0"
chroot "${rootfs}" utmpdump --help
chroot "${rootfs}" wdctl --help
chroot "${rootfs}" whereis lsblk | grep "/usr/bin/lsblk"
chroot "${rootfs}" agetty --help
chroot "${rootfs}" blkdiscard --help
fallocate -l 1M "${rootfs}"/test.img
mkfs.ext4 -F "${rootfs}"/test.img
chroot "${rootfs}" blkid /test.img | grep "ext4"
rm "${rootfs}"/test.img
chroot "${rootfs}" blkzone --help
chroot "${rootfs}" blockdev --help
chroot "${rootfs}" chcpu --help
chroot "${rootfs}" chmem --help
chroot "${rootfs}" ctrlaltdel | grep -P '[soft|hard]'
chroot "${rootfs}" findfs --help
# Dry run, outputs differ across different system configurations
chroot "${rootfs}" fsck -N
# fsck.cramfs and fsck.minix are tested together with mkfs.cramfs and mkfs.minix
chroot "${rootfs}" fsfreeze --help
chroot "${rootfs}" fstrim --help
chroot "${rootfs}" getty --help
chroot "${rootfs}" isosize --help
chroot "${rootfs}" ldattach --help
# chroot "${rootfs}" mkfs /test.img
fallocate -l 1M "${rootfs}"/test.img
chroot "${rootfs}" mkfs.bfs /test.img
file "${rootfs}"/test.img | grep "BFS"
rm "${rootfs}"/test.img
mkdir -p "${rootfs}"/test
chroot "${rootfs}" mkfs.cramfs /test /test.cramfs
file "${rootfs}"/test.cramfs | grep "Compressed ROM File System"
chroot "${rootfs}" fsck.cramfs /test.cramfs
rm "${rootfs}"/test.cramfs
rm -r "${rootfs}"/test
fallocate -l 1M "${rootfs}"/test.img
chroot "${rootfs}" mkfs.minix /test.img
file "${rootfs}"/test.img | grep "Minix"
chroot "${rootfs}" fsck.minix /test.img
chroot "${rootfs}" mkswap --help
chroot "${rootfs}" pivot_root --help
chroot "${rootfs}" readprofile --help
chroot "${rootfs}" rtcwake --help
cp /etc/passwd "${rootfs}"/etc/passwd
# sulogin expects keyboard inputs to continue or exit.
# Set timeout to let it exit without keyboard inputs after 1 second.
chroot "${rootfs}" sulogin -t 1
chroot "${rootfs}" swaplabel --help
chroot "${rootfs}" switch_root --help
chroot "${rootfs}" wipefs --help
chroot "${rootfs}" zramctl --help

We need to add tests for all the bins. Some architecture-dependent symlink-based executables are excluded here, but their linked real binary are tested.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks. can you comment the tests just so we know what's happening?

What's useful to know?

  • Some architecture-dependent symlink-based executables are excluded here, but their linked real binary are tested.

  • why some are just tested with --help
  • fix or explain why certain commands aren't being asserted (e.g fallocate , lsns...)

Copy link
Collaborator

@zhijie-yang zhijie-yang Jan 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The following binaries are symbolically linked to /usr/bin/setarch, and therefore excluded from the spread test:

  • /usr/bin/i386
  • /usr/bin/ppc
  • /usr/bin/ppc32
  • /usr/bin/ppc64
  • /usr/bin/s390
  • /usr/bin/s390x
  • /usr/bin/x86_64

For those binaries, which require complicated preparations, such as disk/block/partition operations or querying non-existing system logs, and which do not work in LXD (e.g., dmesg), are only tested with --help.

Some of the binaries are only run but not asserted since they do not change the system's status. As long as they exit with 0, they pass the smoking test.

Assertions are added for fallocate and lsns.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies if it wasn't clear, but the request is to comment the test itself, not the PR, for future reference

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority Look at me first
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants