FS#70234 - [mkinitcpio][deps]`mkinitcpio` actually requires `sed`, which is not in dependency list.

Attached to Project: Arch Linux
Opened by yw662 (yw662) - Tuesday, 30 March 2021, 14:12 GMT
Last edited by Giancarlo Razzolini (grazzolini) - Wednesday, 31 March 2021, 13:23 GMT
Task Type Bug Report
Category Packages: Core
Status Closed
Assigned To Giancarlo Razzolini (grazzolini)
Architecture x86_64
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:
If `mkinitcpio` is installed without `sed`, preset files will not be generated correctly, due to [libalpm/scripts/mkinitcpio-install](https://git.archlinux.org/mkinitcpio.git/tree/libalpm/scripts/mkinitcpio-install) requires sed at line 25, which is used to generate preset files:

```bash
sed "s|%PKGBASE%|${pkgbase}|g" /usr/share/mkinitcpio/hook.preset \
| install -Dm644 /dev/stdin "$preset"
```

This is not sever in most cases since sed is required by `base`, which is usually installed before `mkinitcpio`.
But if a user decide to not install `base`, this can be a problem.


Additional info:
* package version(s)
* config and/or log files etc.
* link to upstream bug report, if any

Steps to reproduce:
* When installing archlinux, do not install `base` or `sed` on pacstrap, or, on a device without `sed` and `mkinitcpio` installed,
* install (or pacstrap) `mkinitcpio` (and linux)
* Take a look at `/etc/mkinitcpio.d/linux.preset` (or /mnt/etc/mkinitcpio.d/linux.preset), it will be empty.
This task depends upon

Closed by  Giancarlo Razzolini (grazzolini)
Wednesday, 31 March 2021, 13:23 GMT
Reason for closing:  Won't implement
Comment by yw662 (yw662) - Tuesday, 30 March 2021, 14:20 GMT
Will gladly do a git push or somehow pull request if I am allowed. But I don't know how to.

The fix is simple though:

At /PKGBUILD, line 11 or 12, add 'sed' somewhere.
Comment by Giancarlo Razzolini (grazzolini) - Tuesday, 30 March 2021, 16:07 GMT
The base metapackage is a requirement for any Arch installation. Even though I'm inclined to list sed as a dependency on the PKGBUILD (I'm all for explicit deps), we can't support installations not using base.
Comment by yw662 (yw662) - Tuesday, 30 March 2021, 19:41 GMT
That is why I say it is not severe, otherwise that would be a big problem :-).
I am just using it as an example, without any implication that arch should support it or not.
However, mkinitcpio does require sed anyway :-).
Comment by Eli Schwartz (eschwartz) - Tuesday, 30 March 2021, 22:12 GMT
For the record, sed is also a POSIX requirement. Not only that, it is a deeply practical requirement, fulfilling needs that script authors commonly cannot do without.

I absolutely promise you in very certain terms that you'll be deeply unhappy in the long run if you try to actually use a system without it installed and that system is something other than a customized embedded OS with your handpicked, stripped down software on a read-only image baked onto an appliance, which you know a priori does not and *will not ever in the future* introduce local administrator scripts which assume POSIX.

The portability assumptions of "sed is installed on all Linux and Unix-like systems" has well thought out roots, and there is a reason it is included in the (mandatory for support, if you don't like it you pick up the pieces) base metapackage. Is there something wrong with the base metapackage that you don't want to use it?


Furthermore, sed is a requirement of glibc, due to /usr/bin/locale-gen, but for obvious reasons cannot both depend on glibc and have glibc depend on it.

Nevertheless, glibc does indeed invisibly depend on it (via base), so you cannot just assume that if you uninstall mkinitcpio it is safe to uninstall sed. You will end up with every glibc update deleting all locales on your system, then failing to create new ones with the error message

en_US.UTF-8...locale-gen: line 38: sed: command not found

and immediate exit due to set -e, otherwise the next line would be:

[error] cannot open locale definition file `-c': No such file or directory

Might I ask why you are intentionally pacstrap'ing systems with deliberately broken locales?
Comment by Eli Schwartz (eschwartz) - Tuesday, 30 March 2021, 22:14 GMT
That being said, adding even more dependency nodes forcing sed to be installed won't really hurt aside for maybe making the output of pacman -Qi mkinitcpio less human readable (which is subjective and not a huge deal).
Comment by Giancarlo Razzolini (grazzolini) - Wednesday, 31 March 2021, 01:03 GMT
I *think*, without revisiting the code, that some (if not all) the substitutions we do on the mkinitcpio hooks can be done purely in bash. I'll revisit that when I plan to make a new mkinitcpio release.
Comment by Eli Schwartz (eschwartz) - Wednesday, 31 March 2021, 03:06 GMT
Doing file read/substitute/write in bash isn't an enthralling job (I have experience in this). I would not bother; the dep is fine from a mkinitcpio source code perspective and so is whichever side of the explicit deps bikeshed you implement in the PKGBUILD.
Comment by Giancarlo Razzolini (grazzolini) - Wednesday, 31 March 2021, 13:12 GMT
Yes, I don't want to have to list half of base on mkinitcpio's PKGBUILD.

This is mkinitcpio's pactree today:

mkinitcpio
├─gawk provides awk
│ ├─bash provides sh
│ │ ├─readline
│ │ │ ├─glibc
│ │ │ │ ├─linux-api-headers provides linux-api-headers>=4.10
│ │ │ │ ├─tzdata
│ │ │ │ └─filesystem
│ │ │ │ └─iana-etc
│ │ │ ├─ncurses
│ │ │ │ ├─glibc
│ │ │ │ └─gcc-libs
│ │ │ │ └─glibc provides glibc>=2.27
│ │ │ └─ncurses provides libncursesw.so=6-64
│ │ ├─readline provides libreadline.so=8-64
│ │ ├─glibc
│ │ └─ncurses
│ ├─glibc
│ └─mpfr
│ └─gmp provides gmp>=5.0
│ ├─gcc-libs
│ └─bash provides sh
├─mkinitcpio-busybox provides mkinitcpio-busybox>=1.19.4-2
│ ├─glibc
│ └─libxcrypt
│ └─glibc
├─kmod
│ ├─glibc
│ ├─zlib
│ │ └─glibc
│ ├─openssl
│ │ └─glibc
│ ├─xz
│ │ └─bash provides sh
│ └─zstd
│ ├─glibc
│ ├─gcc-libs
│ ├─zlib
│ ├─xz
│ └─lz4
│ └─glibc
├─util-linux provides util-linux>=2.23
│ ├─pam
│ │ ├─glibc
│ │ ├─libtirpc
│ │ │ └─krb5
│ │ │ ├─glibc
│ │ │ ├─e2fsprogs
│ │ │ │ ├─bash provides sh
│ │ │ │ └─util-linux-libs
│ │ │ ├─e2fsprogs provides libss.so=2-64
│ │ │ ├─e2fsprogs provides libcom_err.so=2-64
│ │ │ ├─libldap
│ │ │ │ ├─libsasl
│ │ │ │ │ └─openssl
│ │ │ │ └─e2fsprogs
│ │ │ └─keyutils
│ │ │ ├─glibc
│ │ │ └─bash provides sh
│ │ ├─pambase
│ │ ├─audit
│ │ │ ├─glibc
│ │ │ ├─krb5
│ │ │ └─libcap-ng
│ │ │ └─glibc
│ │ ├─audit provides libaudit.so=1-64
│ │ ├─libxcrypt
│ │ └─libxcrypt provides libcrypt.so=2-64
│ ├─shadow
│ │ ├─pam
│ │ ├─acl
│ │ │ ├─attr
│ │ │ │ └─glibc
│ │ │ └─attr provides libattr.so
│ │ ├─acl provides libacl.so=1-64
│ │ ├─audit
│ │ ├─audit provides libaudit.so=1-64
│ │ ├─libcap-ng
│ │ ├─libcap-ng provides libcap-ng.so
│ │ ├─libxcrypt
│ │ └─libxcrypt provides libcrypt.so=2-64
│ ├─coreutils
│ │ ├─glibc
│ │ ├─acl
│ │ ├─attr
│ │ ├─gmp
│ │ ├─libcap
│ │ │ ├─glibc
│ │ │ └─pam
│ │ └─openssl
│ ├─systemd-libs
│ │ ├─glibc
│ │ ├─libcap
│ │ ├─libgcrypt
│ │ │ └─libgpg-error
│ │ │ ├─glibc
│ │ │ └─bash provides sh
│ │ ├─libp11-kit
│ │ │ ├─glibc
│ │ │ ├─libtasn1
│ │ │ │ └─glibc
│ │ │ └─libffi
│ │ │ └─glibc
│ │ ├─lz4
│ │ ├─xz
│ │ └─zstd
│ ├─systemd-libs provides libsystemd.so=0-64
│ ├─systemd-libs provides libudev.so=1-64
│ ├─libcap-ng
│ ├─libxcrypt
│ ├─libxcrypt provides libcrypt.so=2-64
│ ├─util-linux-libs
│ ├─file provides libmagic.so=1-64
│ │ ├─glibc
│ │ ├─zlib
│ │ ├─xz
│ │ ├─bzip2
│ │ │ ├─glibc
│ │ │ └─bash provides sh
│ │ ├─libseccomp
│ │ │ └─glibc
│ │ └─libseccomp provides libseccomp.so=2-64
│ ├─ncurses provides libncursesw.so=6-64
│ └─readline provides libreadline.so=8-64
├─libarchive
│ ├─acl
│ ├─acl provides libacl.so=1-64
│ ├─bzip2
│ ├─expat
│ │ └─glibc
│ ├─lz4
│ ├─openssl
│ ├─xz
│ ├─zlib
│ └─zstd
├─coreutils
├─bash
├─diffutils
│ ├─glibc
│ └─bash
├─findutils
│ ├─glibc
│ └─bash provides sh
├─grep
│ ├─glibc
│ └─pcre
│ ├─gcc-libs
│ ├─readline
│ ├─zlib
│ ├─bzip2
│ └─bash
├─filesystem provides filesystem>=2011.10-1
├─zstd
└─systemd
├─acl
├─acl provides libacl.so=1-64
├─bash
├─cryptsetup
│ ├─device-mapper
│ │ ├─glibc
│ │ ├─systemd-libs
│ │ └─systemd-libs provides libudev.so=1-64
│ ├─device-mapper provides libdevmapper.so=1.02-64
│ ├─openssl
│ ├─popt
│ │ └─glibc
│ ├─util-linux-libs
│ ├─util-linux-libs provides libuuid.so=1-64
│ ├─json-c
│ │ └─glibc
│ ├─json-c provides libjson-c.so=5-64
│ ├─argon2
│ │ └─glibc
│ └─argon2 provides libargon2.so=1-64
├─cryptsetup provides libcryptsetup.so=12-64
├─dbus
│ ├─systemd-libs
│ ├─expat
│ ├─audit
│ ├─systemd-libs provides libsystemd.so=0-64
│ └─audit provides libaudit.so=1-64
├─iptables
│ ├─libnftnl
│ │ └─libmnl
│ │ └─glibc
│ ├─libpcap
│ │ ├─glibc
│ │ ├─libnl
│ │ │ └─glibc
│ │ ├─bash provides sh
│ │ └─dbus provides libdbus-1.so=3-64
│ ├─libnfnetlink
│ │ └─glibc
│ ├─libnetfilter_conntrack
│ │ ├─libnfnetlink
│ │ └─libmnl
│ └─bash
├─kbd
│ ├─glibc
│ └─pam
├─kmod
├─kmod provides libkmod.so=2-64
├─hwids
├─libcap
├─libcap provides libcap.so=2-64
├─libgcrypt
├─libxcrypt
├─libxcrypt provides libcrypt.so=2-64
├─systemd-libs
├─libidn2
│ └─libunistring
│ └─glibc
├─lz4
├─pam
├─libelf
│ ├─gcc-libs
│ ├─bzip2 provides libbz2.so=1.0-64
│ ├─curl provides libcurl.so=4-64
│ │ ├─ca-certificates
│ │ │ └─ca-certificates-mozilla
│ │ │ └─ca-certificates-utils provides ca-certificates-utils>=20181109-3
│ │ │ ├─bash
│ │ │ ├─coreutils
│ │ │ ├─findutils
│ │ │ └─p11-kit provides p11-kit>=0.23.19
│ │ │ ├─libp11-kit provides libp11-kit=0.23.22-1
│ │ │ ├─coreutils
│ │ │ ├─libp11-kit provides libp11-kit.so=0-64
│ │ │ └─systemd-libs provides libsystemd.so=0-64
│ │ ├─krb5
│ │ ├─libssh2
│ │ │ ├─openssl
│ │ │ └─zlib
│ │ ├─libssh2 provides libssh2.so=1-64
│ │ ├─openssl
│ │ ├─zlib
│ │ ├─libpsl
│ │ │ ├─libidn2
│ │ │ ├─libidn2 provides libidn2.so=0-64
│ │ │ └─libunistring
│ │ ├─libpsl provides libpsl.so=5-64
│ │ ├─libnghttp2
│ │ │ └─glibc
│ │ ├─libidn2
│ │ ├─libidn2 provides libidn2.so=0-64
│ │ └─zstd
│ ├─xz
│ ├─zlib
│ └─zstd
├─libseccomp
├─libseccomp provides libseccomp.so=2-64
├─util-linux
├─util-linux-libs provides libblkid.so=1-64
├─util-linux-libs provides libmount.so=1-64
├─xz
├─pcre2
│ ├─gcc-libs
│ ├─readline
│ ├─zlib
│ ├─bzip2
│ └─bash
├─audit
├─audit provides libaudit.so=1-64
├─libp11-kit
├─libp11-kit provides libp11-kit.so=0-64
└─openssl

Loading...