Bugzilla – Bug 1225197
util-linux depends on libmagic
Last modified: 2024-06-11 09:25:01 UTC
util-linux has a hard dependency on libmagic1 and thus file-magic, which is rather big (~9MiB). It's only pulled in because /usr/bin/more links against it. Can this dependency be avoided for instance by removing libmagic support from more? That's what Debian, Fedora and Ubuntu do as well.
Is it a problem of Ring 0 bootstrap build loop size or a problem of a cut down image size? more uses libmagic to identify binary files. In the first case, move of more from util-linux to util-linux systemd could help. In the second case, I would suggest to create a new sub-package containing feature stripped binaries: more without libmagic support findmnt, lsblk without libudev logger, lslogins, uuidd without libsystemd It could help to create minimal images for the non bootable containers.
(In reply to Stanislav Brabec from comment #1) > Is it a problem of Ring 0 bootstrap build loop size or a problem of a cut > down image size? Size is a problem, especially on low level hard required tools. > more uses libmagic to identify binary files. Yes, but as Fabian wrote: no other big distribution compiles more with this dependency, and people normally use less since >> 25 years. more is only the last fallback if less is not there, e.g. in containers. > In the second case, I would suggest to create a new sub-package containing > feature stripped binaries: > more without libmagic support > findmnt, lsblk without libudev > logger, lslogins, uuidd without libsystemd > > It could help to create minimal images for the non bootable containers. It's not only about containers, it's also about the default install size of our system. We have some projects with partners, were size is all what matters for various reasons. E.g. limited size in ROM. So your sub-package solution will not help here, as we need the other tools with that dependencies. And currently it's really just about more.
it doesn't actually use the magic "features" for anything other than refusing to show a file if it is considered binary. here's the code in question: /* check_magic -- check for file magic numbers. */ static int check_magic(struct more_control *ctl, char *fs) { #ifdef HAVE_MAGIC ⇥ const int fd = fileno(ctl->current_file); ⇥ const char *mime_encoding = magic_descriptor(ctl->magic, fd); ⇥ const char *magic_error_msg = magic_error(ctl->magic); ⇥ if (magic_error_msg) { ⇥ ⇥ printf("%s: %s: %s\n", program_invocation_short_name, ⇥ ⇥ ⇥ _("magic failed"), magic_error_msg); ⇥ ⇥ return 0; ⇥ } ⇥ if (!mime_encoding || !(strcmp("binary", mime_encoding))) { ⇥ ⇥ printf(_("\n******** %s: Not a text file ********\n\n"), fs); ⇥ ⇥ return 1; ⇥ } #else ⇥ signed char twobytes[2]; ⇥ /* don't try to look ahead if the input is unseekable */ ⇥ if (fseek(ctl->current_file, 0L, SEEK_SET)) ⇥ ⇥ return 0; ⇥ if (fread(twobytes, 2, 1, ctl->current_file) == 1) { ⇥ ⇥ switch (twobytes[0] + (twobytes[1] << 8)) { ⇥ ⇥ case 0407:⇥ /* a.out obj */ ⇥ ⇥ case 0410:⇥ /* a.out exec */ ⇥ ⇥ case 0413:⇥ /* a.out demand exec */ ⇥ ⇥ case 0405: ⇥ ⇥ case 0411: ⇥ ⇥ case 0177545: ⇥ ⇥ case 0x457f:⇥ /* simple ELF detection */ ⇥ ⇥ ⇥ printf(_("\n******** %s: Not a text file ********\n\n"), ⇥ ⇥ ⇥ fs); ⇥ ⇥ ⇥ return 1; ⇥ ⇥ } ⇥ } ⇥ fseek(ctl->current_file, 0L, SEEK_SET);⇥/* rewind() not necessary */ #endif ⇥ return 0; so it does implement the same feature without it, just maybe in a less correct way. but it could easily be extended should there be a regression report coming in.
https://build.opensuse.org/request/show/1179681
This is an autogenerated message for OBS integration: This bug (1225197) was mentioned in https://build.opensuse.org/request/show/1179694 Factory / util-linux
OK, makes sense. You submit is on the way fo Factory. The subpackage could make sense as well, especially if there will be a need for a util-linux-systemd variant that does not depend on libsystemd.so.0. (We do not want such binaries on a regular system, but for containers that don't contain systemd it could be OK.)
This is an autogenerated message for OBS integration: This bug (1225197) was mentioned in https://build.opensuse.org/request/show/1179952 Factory / util-linux