[arch-projects] [mkinitcpio][PATCH 00/26] patchbomb (maybe some bug fixes)
I'd like to get a mkinitcpio release out the door in the next few weeks, but first we need actual patches to do that, so... here we go. The majority of this is style tweaks and bug fixes, but there are a few small new features I'll point out: 1) Allowing soft failures on modules -- if a module ends with a '?' character and the module isn't found, this won't trigger an error. Folks building custom kernel and building in modules like ext4 or sd_mod will find this useful. 2) busybox is installed during the build process rather than doing the install at bootstrap. Tom and I thought this made sense since the initcpio should be a "build once, use many" sort of scenario. Do the repetitive work up front where feasible. 3) Allow the 'break' variable on the cmdline to provide a pre or post-mount shell prompt. The behavior of 'break' or 'break=y' remains untouched. 4) Better support for keymap/consolefont in non-sysvinit environments. This stems from FS#24685. Basically, I went with a middle ground and we now source /etc/rc.conf in these hooks which means a systemd user can simple source /etc/vconsole.conf, /etc/locale.conf and then remap the variables to the names expected under normal circumstances. sysvinit users should notice absolutely no change in behavior here. I'll be testing this throughout the week as I have time, but anyone who has feedback or wants to mention that I broke everything is more than welcome to. Easiest way to get all of this is pull from my 'for-thomas' branch on github: git://github.com/falconindy/mkinitcpio.git cheers! d Dave Reisner (25): install/consolefont: cleanup and refactor keymap/consolefont: source rc.conf properly from $BASEDIR keymap: simplify unicode detection cleanup and bashify install hooks base: remove superfluous leading / functions: allow ignoring errors on module addition functions: refactor get_{base,dir}name functions: perform path lookup for binaries if needed functions: specify the delimiter to xargs ensure local scoping of variables mkinitcpio: simplify setting of SKIPHOOKS mkinitcpio: fix whitespace errors in error messages mkinitcpio: explicitly create $BUILDROOT mkinitcpio: keep going even when a hook isn't found mkinitcpio: insist that /dev be mounted init: support breaks before and after mounting root init: allow /run to be mounted with exec perms init: extend PATH to include /usr/local bins init: pass PATH to real PID 1's environment setup busybox during image creation instead of runtime lsinitcpio: disable color when stdout isn't a tty lsinitcpio: follow symlinks only when necessary functions: fix output order in _add_symlink use correct variable to reference compression method init_functions: use constants on LHS of tests Florian Pritz (1): harden version generation Makefile | 7 ++- PKGBUILD | 4 +- functions | 77 ++++++++++++++++----- hooks/keymap | 11 +-- init | 19 +++--- init_functions | 6 +- install/base | 7 ++- install/btrfs | 15 ++-- install/consolefont | 56 ++++++++------- install/dsdt | 21 ++---- install/filesystems | 2 +- install/fw | 29 +++----- install/ide | 30 +++----- install/keymap | 24 ++++--- install/memdisk | 19 +++--- install/net | 195 +++++++++++++++++++++++++-------------------------- install/pata | 4 +- install/pcmcia | 29 ++++---- install/resume | 19 ++--- install/sata | 4 +- install/scsi | 4 +- install/sleep | 27 +++---- install/udev | 33 ++++----- install/usb | 32 ++++----- install/usbinput | 30 +++----- lsinitcpio | 8 ++- mkinitcpio | 26 ++++--- 27 files changed, 373 insertions(+), 365 deletions(-) -- 1.7.6.4
* Provide support for uncompressed font files as well as compressed
* Avoiding using an unnecessary temp file
* Support $BASEDIR
* Warn when no font is found
* Only add the runtime hook if a font is added
Signed-off-by: Dave Reisner
This is partially in response to FS#24685, which should hopefully cut
back on configuration duplication on non-sysvinit systems. This does,
however, also fix a bug with keymap/consolefont pulling the wrong
rc.conf when BASEDIR is not '/' or unset.
Signed-off-by: Dave Reisner
On Tue, Sep 27, 2011 at 3:22 AM, Dave Reisner
This is partially in response to FS#24685, which should hopefully cut back on configuration duplication on non-sysvinit systems. This does, however, also fix a bug with keymap/consolefont pulling the wrong rc.conf when BASEDIR is not '/' or unset.
Signed-off-by: Dave Reisner
Looks much nicer to me now, regardless of the FS you mentioned.
Acked-by: Tom Gundersen
Signed-off-by: Dave Reisner
On Tue, Sep 27, 2011 at 3:22 AM, Dave Reisner
Signed-off-by: Dave Reisner
--- hooks/keymap | 11 +++-------- install/keymap | 8 +++----- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/hooks/keymap b/hooks/keymap index 3593168..14f20a1 100644 --- a/hooks/keymap +++ b/hooks/keymap @@ -3,14 +3,9 @@ run_hook () { if [ -e /keymap.bin ]; then msg -n ":: Loading keymap..." - . /keymap.utf8 - if [ "${UTF8}" = "yes" ]; then - kbd_mode -u -C /dev/console - printf "\033%%G" >> /dev/console - else - kbd_mode -a -C /dev/console - printf "\033%%@" >> /dev/console - fi + [ -f /keymap.utf8 ] && mode=-u || mode=-a + kbd_mode $mode -C /dev/console + printf "\033%%G" >> /dev/console
Why is this unconditional now? Should it not be %%@ in the non-unicode case? If not please explain in the commit message.
loadkmap < /keymap.bin msg "done." fi diff --git a/install/keymap b/install/keymap index 2cf4d15..2880f15 100644 --- a/install/keymap +++ b/install/keymap @@ -7,12 +7,10 @@ build() { . "$BASEDIR/etc/rc.conf" if [[ $KEYMAP ]]; then if [[ $LOCALE = *[Uu][Tt][Ff]-8 ]]; then - printf '%s\n' "UTF8=yes" > "$BUILDROOT/keymap.utf8" - /bin/loadkeys -q -u $KEYMAP -b > "$BUILDROOT/keymap.bin" - else - printf '%s\n' "UTF8=no" > "$BUILDROOT/keymap.utf8" - /bin/loadkeys -q $KEYMAP -b > "$BUILDROOT/keymap.bin" + touch "$BUILDROOT/keymap.utf8" + uc=-u fi + /bin/loadkeys -q $uc $KEYMAP -b > "$BUILDROOT/keymap.bin" fi )
-- 1.7.6.4
On Tue, Sep 27, 2011 at 11:31:53AM +0200, Tom Gundersen wrote:
On Tue, Sep 27, 2011 at 3:22 AM, Dave Reisner
wrote: Signed-off-by: Dave Reisner
--- hooks/keymap | 11 +++-------- install/keymap | 8 +++----- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/hooks/keymap b/hooks/keymap index 3593168..14f20a1 100644 --- a/hooks/keymap +++ b/hooks/keymap @@ -3,14 +3,9 @@ run_hook () { if [ -e /keymap.bin ]; then msg -n ":: Loading keymap..." - . /keymap.utf8 - if [ "${UTF8}" = "yes" ]; then - kbd_mode -u -C /dev/console - printf "\033%%G" >> /dev/console - else - kbd_mode -a -C /dev/console - printf "\033%%@" >> /dev/console - fi + [ -f /keymap.utf8 ] && mode=-u || mode=-a + kbd_mode $mode -C /dev/console + printf "\033%%G" >> /dev/console
Why is this unconditional now? Should it not be %%@ in the non-unicode case? If not please explain in the commit message.
Not intentional -- too greedy on the refactor. Thanks for the catch. d
loadkmap < /keymap.bin msg "done." fi diff --git a/install/keymap b/install/keymap index 2cf4d15..2880f15 100644 --- a/install/keymap +++ b/install/keymap @@ -7,12 +7,10 @@ build() { . "$BASEDIR/etc/rc.conf" if [[ $KEYMAP ]]; then if [[ $LOCALE = *[Uu][Tt][Ff]-8 ]]; then - printf '%s\n' "UTF8=yes" > "$BUILDROOT/keymap.utf8" - /bin/loadkeys -q -u $KEYMAP -b > "$BUILDROOT/keymap.bin" - else - printf '%s\n' "UTF8=no" > "$BUILDROOT/keymap.utf8" - /bin/loadkeys -q $KEYMAP -b > "$BUILDROOT/keymap.bin" + touch "$BUILDROOT/keymap.utf8" + uc=-u fi + /bin/loadkeys -q $uc $KEYMAP -b > "$BUILDROOT/keymap.bin" fi )
-- 1.7.6.4
This introduces no logical code changes -- this is purely a syntactical
cleanup and standardization across the build hooks. All hooks get the
same treatment, adhering to the following style:
#!/bin/bash
build() {
COMMANDS
}
help() {
cat <
On Mon, Sep 26, 2011 at 8:22 PM, Dave Reisner
This introduces no logical code changes -- this is purely a syntactical cleanup and standardization across the build hooks. All hooks get the same treatment, adhering to the following style:
#!/bin/bash
build() { COMMANDS }
help() { cat <
# vim: set ft=sh ts=4 sw=4 et:
Signed-off-by: Dave Reisner
--- install/btrfs | 15 ++-- install/dsdt | 21 ++---- install/filesystems | 2 +- install/fw | 29 +++----- install/ide | 30 +++----- install/keymap | 2 +- install/memdisk | 19 +++--- install/net | 195 +++++++++++++++++++++++++-------------------------- install/pata | 2 +- install/pcmcia | 28 ++++---- install/resume | 19 ++--- install/sata | 2 +- install/scsi | 2 +- install/sleep | 27 +++---- install/udev | 33 ++++----- install/usb | 30 ++++----- install/usbinput | 30 +++----- 17 files changed, 220 insertions(+), 266 deletions(-) -help () -{ -cat <
-Dan
The doubled up leading slashes annoy me in the verbose output.
Signed-off-by: Dave Reisner
We conditionally, but naively, add modules in some of our install hooks,
but the kernel may not have these. Note that these modules can fail
silently by detecting a '?' suffix on the module name. In conjunction with
this, the add_module function now takes a flag, -t or --try, which will
ignore module not found errors from modinfo. The config file will also
support this syntax.
Signed-off-by: Dave Reisner
On Monday, September 26, 2011, Dave Reisner
We conditionally, but naively, add modules in some of our install hooks, but the kernel may not have these. Note that these modules can fail silently by detecting a '?' suffix on the module name. In conjunction with this, the add_module function now takes a flag, -t or --try, which will ignore module not found errors from modinfo. The config file will also support this syntax.
Signed-off-by: Dave Reisner
--- functions | 20 ++++++++++++++++---- install/base | 2 +- install/fw | 2 +- install/ide | 2 +- install/pata | 2 +- install/pcmcia | 5 ++--- install/sata | 2 +- install/scsi | 2 +- install/usb | 4 +++- install/usbinput | 4 +--- 10 files changed, 28 insertions(+), 17 deletions(-) diff --git a/functions b/functions index 3c0cd89..c7e167e 100644 --- a/functions +++ b/functions @@ -137,6 +137,13 @@ add_module() { # $1: module name
local module path dep deps field value + local -i ign_errors=0 + + if [[ $1 = -@(t|-try) ]]; then Wouldn't @(-t|--try) be a lot clearer? Or is just my eyes that cringe at this cuteness. I spent a good 15 seconds trying to figure out how -try got translated to --try here. + ign_errors=1 + shift + fi + module=${1%.ko*}
# skip expensive stuff if this module has already been added
From: Dave Reisner
On Mon, Sep 26, 2011 at 8:22 PM, Dave Reisner
From: Dave Reisner
Make sure these are completely safe for user input. Use the same three step process in both cases:
1) Strip any trailing slash 2) Trim the string according to base/dir request 3) Print the result, defaulting to / if step 2 yielded an empty string
Signed-off-by: Dave Reisner
--- functions | 15 ++++++++------- 1 files changed, 8 insertions(+), 7 deletions(-) diff --git a/functions b/functions index c7e167e..2f5797a 100644 --- a/functions +++ b/functions @@ -30,15 +30,16 @@ die() { cleanup 1 }
-get_dirname() { - # strip any trailing slash first... - local dir="${1%/}" - # then get the directory portion - echo "${dir%/*}" +get_basename() { + local base=${1%/} + base=${base##*/} + printf '%s' "${base:-/}" }
-get_basename() { - echo "${1##*/}" +get_dirname() { + local dir=${1%/} + dir=${dir%/*} + printf '%s' "${dir:-/}" }
Did you flip the order of the functions just to make the diff trickier? Otherwise this looks OK.
in_array() { -- 1.7.6.4
We used to do this, but it was lost somewhere along the way in fixing up
basedir support. Add in a 'pathlookup' function which can do a search
within any given basedir.
Signed-off-by: Dave Reisner
Without specifying this, xargs will split arguments on whitespace as
well as newlines, and will interpret quoting and backslashes. When the
delimiter is specified, every character is taken literally and only the
given delimiter in honored.
This sidesteps issues with broken modalias files as evidenced by a
MacBookAir3,1 or the bbs thread below:
https://bbs.archlinux.org/viewtopic.php?pid=971853
Also fixes FS#25450.
Signed-off-by: Dave Reisner
On Mon, Sep 26, 2011 at 8:22 PM, Dave Reisner
Without specifying this, xargs will split arguments on whitespace as well as newlines, and will interpret quoting and backslashes. When the delimiter is specified, every character is taken literally and only the given delimiter in honored.
This sidesteps issues with broken modalias files as evidenced by a MacBookAir3,1 or the bbs thread below:
https://bbs.archlinux.org/viewtopic.php?pid=971853
Also fixes FS#25450.
Signed-off-by: Dave Reisner
--- functions | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/functions b/functions index 8ce24ea..7f9202f 100644 --- a/functions +++ b/functions @@ -117,7 +117,7 @@ auto_modules() {
IFS=$'\n' read -rd '' -a mods < \ <(find /sys/devices -name modalias -exec sort -u {} + | - xargs modprobe -d "$BASEDIR" -aRS "$KERNELVERSION" | + xargs -d $'\n' modprobe -d "$BASEDIR" -aRS "$KERNELVERSION" | Dollar sign what? /me doesn't follow this at all, a comment would be great.
sort -u)
printf "%s\n" "${mods[@]//-/_}" -- 1.7.6.4
On Mon, Sep 26, 2011 at 10:46:57PM -0500, Dan McGee wrote:
On Mon, Sep 26, 2011 at 8:22 PM, Dave Reisner
wrote: Without specifying this, xargs will split arguments on whitespace as well as newlines, and will interpret quoting and backslashes. When the delimiter is specified, every character is taken literally and only the given delimiter in honored.
This sidesteps issues with broken modalias files as evidenced by a MacBookAir3,1 or the bbs thread below:
https://bbs.archlinux.org/viewtopic.php?pid=971853
Also fixes FS#25450.
Signed-off-by: Dave Reisner
--- functions | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/functions b/functions index 8ce24ea..7f9202f 100644 --- a/functions +++ b/functions @@ -117,7 +117,7 @@ auto_modules() {
IFS=$'\n' read -rd '' -a mods < \ <(find /sys/devices -name modalias -exec sort -u {} + | - xargs modprobe -d "$BASEDIR" -aRS "$KERNELVERSION" | + xargs -d $'\n' modprobe -d "$BASEDIR" -aRS "$KERNELVERSION" | Dollar sign what? /me doesn't follow this at all, a comment would be great.
consult your manual, sir! Words of the form $'string' are treated specially. The word expands to string, with backslash-escaped characters replaced as specified by the ANSI C standard. Backslash escape sequences, if present, are decoded. In other words, its expanded in place. Yeah, this seems elementary to me, but I suppose its comment worthy.
sort -u)
printf "%s\n" "${mods[@]//-/_}" -- 1.7.6.4
On Mon, Sep 26, 2011 at 10:48 PM, Dave Reisner
On Mon, Sep 26, 2011 at 10:46:57PM -0500, Dan McGee wrote:
On Mon, Sep 26, 2011 at 8:22 PM, Dave Reisner
wrote: Without specifying this, xargs will split arguments on whitespace as well as newlines, and will interpret quoting and backslashes. When the delimiter is specified, every character is taken literally and only the given delimiter in honored.
This sidesteps issues with broken modalias files as evidenced by a MacBookAir3,1 or the bbs thread below:
https://bbs.archlinux.org/viewtopic.php?pid=971853
Also fixes FS#25450.
Signed-off-by: Dave Reisner
--- functions | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/functions b/functions index 8ce24ea..7f9202f 100644 --- a/functions +++ b/functions @@ -117,7 +117,7 @@ auto_modules() {
IFS=$'\n' read -rd '' -a mods < \ <(find /sys/devices -name modalias -exec sort -u {} + | - xargs modprobe -d "$BASEDIR" -aRS "$KERNELVERSION" | + xargs -d $'\n' modprobe -d "$BASEDIR" -aRS "$KERNELVERSION" | Dollar sign what? /me doesn't follow this at all, a comment would be great.
consult your manual, sir!
Words of the form $'string' are treated specially. The word expands to string, with backslash-escaped characters replaced as specified by the ANSI C standard. Backslash escape sequences, if present, are decoded.
In other words, its expanded in place. Yeah, this seems elementary to me, but I suppose its comment worthy.
Well when you say "consult your man page", I thought to myself, "Damn, did I really miss that? Let's read again." --delimiter=delim -d delim Input items are terminated by the specified character. Quotes and backslash are not special; every character in the input is taken literally. Disables the end-of-file string, which is treated like any other argument. This can be used when the in‐ put consists of simply newline-separated items, although it is almost always better to design your program to use --null where this is possible. The specified delimiter may be a single char‐ acter, a C-style character escape such as \n, or an octal or hexadecimal escape code. Octal and hexadecimal escape codes are understood as for the printf command. Multibyte characters are not supported. Nope! Nothing there. Then I realized "Oh! He is talking about some bash feature and THAT is the manpage I'm supposed to be reading." It isn't elementary to those of us that don't use shell as much as you, and RTFM on a 5439 line gargantuan manpage is not my idea of fun, not to mention the 118 lines of hits for the literal '$' character (because I would have no idea in hell how else to find it). -Dan
Also make sure that simple variables are declared as null strings.
Signed-off-by: Dave Reisner
Signed-off-by: Dave Reisner
Signed-off-by: Dave Reisner
Avoids explosions if a user has no HOOKS in their config, as seen:
https://bbs.archlinux.org/viewtopic.php?pid=966344
Signed-off-by: Dave Reisner
Instead of bailing entirely, throw an error, and ensure that we exit
with a non-zero status. The user might do something as simple as
misspell a hook name which may or may not prevent a useful image from
being created.
Signed-off-by: Dave Reisner
This avoids errors with process substitutions in chroots, among other
things.
Signed-off-by: Dave Reisner
Add in 'premount' and 'postmount' as trigger conditions, but also leave
in the old 'y' value as a synonym for premount.
Signed-off-by: Dave Reisner
Add in 'premount' and 'postmount' as trigger conditions, but also leave in the old 'y' value as a synonym for premount. Might be worth a code comment for the next guy that comes and looks at
On Mon, Sep 26, 2011 at 8:22 PM, Dave Reisner
Signed-off-by: Dave Reisner
--- init | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-) diff --git a/init b/init index 8c8709c..a0e082e 100644 --- a/init +++ b/init @@ -74,8 +74,8 @@ if [ -e "/hooks" ]; then done fi
-if [ "${break}" = "y" ]; then - echo ":: Break requested, type 'exit' to resume operation" +if [ "${break}" = "y" ] || [ "${break}" = "premount" ]; then + echo ":: Pre-mount break requested, type 'exit' to resume operation" launch_interactive_shell fi
@@ -100,6 +100,11 @@ elif [ ! -x "/new_root${init}" ]; then launch_interactive_shell --exec fi
+if [ "${break}" = "postmount" ]; then + echo ":: Post-mount break requested, type 'exit' to resume operation" + launch_interactive_shell +fi + # Stop udevd if is running if [ "${udevd_running}" -eq 1 ]; then udevadm control --exit -- 1.7.6.4
This is already done in initscripts so we mirror it here.
Signed-off-by: Dave Reisner
On Tue, Sep 27, 2011 at 3:22 AM, Dave Reisner
This is already done in initscripts so we mirror it here.
Signed-off-by: Dave Reisner
Acked-by: Tom Gundersen
--- init | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/init b/init index a0e082e..ff4917a 100644 --- a/init +++ b/init @@ -22,7 +22,7 @@ else # /dev/mem is needed if we want to load uvesafb before triggering uevents mknod /dev/mem c 1 1 fi -mount -t tmpfs run /run -o nosuid,noexec,nodev,mode=755,size=10M +mount -t tmpfs run /run -o nosuid,nodev,mode=755,size=10M
echo "/sbin/modprobe" > /proc/sys/kernel/modprobe
-- 1.7.6.4
This allows a user to provide their own binaries and override anything
that might be provided by busybox.
Signed-off-by: Dave Reisner
On Mon, Sep 26, 2011 at 8:22 PM, Dave Reisner
This allows a user to provide their own binaries and override anything that might be provided by busybox.
Signed-off-by: Dave Reisner
--- init | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/init b/init index ff4917a..e8f70a1 100644 --- a/init +++ b/init @@ -1,6 +1,6 @@ #!/bin/busybox ash # Install busybox's applets as symlinks -PATH=/usr/sbin:/usr/bin:/sbin:/bin +PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin This is totally nitpicking, but we have this order by default in /etc/profile: PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin"
Shouldn't we try to be consistent? Or at least figure out what normal is? Of course, from a CentOS box... $ echo $PATH /usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin:/home/dan/bin -Dan
On Mon, Sep 26, 2011 at 08:54:28PM -0500, Dan McGee wrote:
On Mon, Sep 26, 2011 at 8:22 PM, Dave Reisner
wrote: This allows a user to provide their own binaries and override anything that might be provided by busybox.
Signed-off-by: Dave Reisner
--- init | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/init b/init index ff4917a..e8f70a1 100644 --- a/init +++ b/init @@ -1,6 +1,6 @@ #!/bin/busybox ash # Install busybox's applets as symlinks -PATH=/usr/sbin:/usr/bin:/sbin:/bin +PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin This is totally nitpicking, but we have this order by default in /etc/profile: PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin"
Shouldn't we try to be consistent? Or at least figure out what normal is?
Maybe it's another case of not being clear enough in the commit msg. We're sort of peeing all over /usr/bin on the busybox --install, so we need to be able to let the user have some control. We do that by letting them override binaries in /usr/local/bin and putting this bin above the rest. An extremely rare use case, but a use case none the less. I could, also, be talked out of this patch along with the busybox on build rather than run if it seems insane. mkinitcpio is sort of longer overdue for some documentation regarding the rules and regulations of hook writing. Merging this would sort of reinforce that point.
Of course, from a CentOS box... $ echo $PATH /usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin:/home/dan/bin
-Dan
Yeah, CentOS and RHEL both leave the /sbin's out of non root profiles. Not a concern here, for obvious reasons. d
On Mon, Sep 26, 2011 at 9:07 PM, Dave Reisner
On Mon, Sep 26, 2011 at 08:54:28PM -0500, Dan McGee wrote:
On Mon, Sep 26, 2011 at 8:22 PM, Dave Reisner
wrote: This allows a user to provide their own binaries and override anything that might be provided by busybox.
Signed-off-by: Dave Reisner
--- init | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/init b/init index ff4917a..e8f70a1 100644 --- a/init +++ b/init @@ -1,6 +1,6 @@ #!/bin/busybox ash # Install busybox's applets as symlinks -PATH=/usr/sbin:/usr/bin:/sbin:/bin +PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin This is totally nitpicking, but we have this order by default in /etc/profile: PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin"
Shouldn't we try to be consistent? Or at least figure out what normal is?
Maybe it's another case of not being clear enough in the commit msg. We're sort of peeing all over /usr/bin on the busybox --install, so we need to be able to let the user have some control. We do that by letting them override binaries in /usr/local/bin and putting this bin above the rest. An extremely rare use case, but a use case none the less. I could, also, be talked out of this patch along with the busybox on build rather than run if it seems insane. I think you misinterpreted me. Note the order difference in yours vs. what I pasted from the stock Arch /etc/profile. Of course /local/ has to come first, but I was simply pointing out the "all /bin/ first" vs "all /local/ first" and other odd ordering choices.
mkinitcpio is sort of longer overdue for some documentation regarding the rules and regulations of hook writing. Merging this would sort of reinforce that point.
Of course, from a CentOS box... $ echo $PATH /usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin:/home/dan/bin
-Dan
Yeah, CentOS and RHEL both leave the /sbin's out of non root profiles. Not a concern here, for obvious reasons. Also not what I meant to point out- here, /sbin/ takes preference over /bin/, always, including local. So another totally different take.
And for some more orderings... $ pacman -Qlq initscripts | xargs grep PATH= /etc/rc.d/functions:export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" /sbin/rc.d: ENV=("PATH=/bin:/usr/bin:/sbin:/usr/sbin" -Dan
On Mon, Sep 26, 2011 at 10:54:16PM -0500, Dan McGee wrote:
On Mon, Sep 26, 2011 at 9:07 PM, Dave Reisner
wrote: On Mon, Sep 26, 2011 at 08:54:28PM -0500, Dan McGee wrote:
On Mon, Sep 26, 2011 at 8:22 PM, Dave Reisner
wrote: This allows a user to provide their own binaries and override anything that might be provided by busybox.
Signed-off-by: Dave Reisner
--- init | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/init b/init index ff4917a..e8f70a1 100644 --- a/init +++ b/init @@ -1,6 +1,6 @@ #!/bin/busybox ash # Install busybox's applets as symlinks -PATH=/usr/sbin:/usr/bin:/sbin:/bin +PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin This is totally nitpicking, but we have this order by default in /etc/profile: PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin"
Shouldn't we try to be consistent? Or at least figure out what normal is?
Maybe it's another case of not being clear enough in the commit msg. We're sort of peeing all over /usr/bin on the busybox --install, so we need to be able to let the user have some control. We do that by letting them override binaries in /usr/local/bin and putting this bin above the rest. An extremely rare use case, but a use case none the less. I could, also, be talked out of this patch along with the busybox on build rather than run if it seems insane. I think you misinterpreted me. Note the order difference in yours vs. what I pasted from the stock Arch /etc/profile. Of course /local/ has to come first, but I was simply pointing out the "all /bin/ first" vs "all /local/ first" and other odd ordering choices.
Yep, I see it now. This is all somewhat suspect now anyways, and I probably can throw this out, as it was "needed" for the patchwork that installs busybox in the build, not the boot.
mkinitcpio is sort of longer overdue for some documentation regarding the rules and regulations of hook writing. Merging this would sort of reinforce that point.
Of course, from a CentOS box... $ echo $PATH /usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin:/home/dan/bin
-Dan
Yeah, CentOS and RHEL both leave the /sbin's out of non root profiles. Not a concern here, for obvious reasons. Also not what I meant to point out- here, /sbin/ takes preference over /bin/, always, including local. So another totally different take.
Also, I apparently can't read properly at 11pm. At least what I said about RHEL is true, but it clearly has no bearing here...
And for some more orderings... $ pacman -Qlq initscripts | xargs grep PATH= /etc/rc.d/functions:export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" /sbin/rc.d: ENV=("PATH=/bin:/usr/bin:/sbin:/usr/sbin"
Yay!!! We probably had a reason for this, but I believe ordering the /usr/local bins first has caused us pain with a user at least once. d
We don't know what processes will be run by the new init, but they
should at least inherit a basic PATH to avoid any problems locating
binaries.
Signed-off-by: Dave Reisner
This is a constant which will never vary based on setup. Do it during
the build to save the forks at runtime.
Signed-off-by: Dave Reisner
On Mon, Sep 26, 2011 at 8:22 PM, Dave Reisner
This is a constant which will never vary based on setup. Do it during the build to save the forks at runtime. And why does/how can new_root get the same treatment? I'm speaking as one trying to be unfamiliar with the guts here, but worth at least mentioning in the commit message so it doesn't look unintentional.
Signed-off-by: Dave Reisner
--- init | 4 ---- install/base | 5 ++++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/init b/init index f14261d..8891a69 100644 --- a/init +++ b/init @@ -1,12 +1,8 @@ #!/bin/busybox ash -# Install busybox's applets as symlinks PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
-busybox --install -s - . /init_functions
-mkdir -p /new_root mount -t proc proc /proc -o nosuid,noexec,nodev mount -t sysfs sys /sys -o nosuid,noexec,nodev if grep -q devtmpfs /proc/filesystems 2>/dev/null; then diff --git a/install/base b/install/base index e85551c..9135ced 100644 --- a/install/base +++ b/install/base @@ -1,10 +1,13 @@ #!/bin/bash
build() { - for dir in proc sys dev run usr/{bin,sbin}; do + for dir in proc sys dev run usr/{bin,sbin} new_root; do add_dir "/$dir" done
+ # install busybox's applets as symlinks + /lib/initcpio/busybox --install -s "$BUILDROOT/usr/bin" + add_binary /lib/initcpio/busybox /bin/busybox add_binary /sbin/modprobe add_binary /sbin/blkid -- 1.7.6.4
On Tue, Sep 27, 2011 at 3:22 AM, Dave Reisner
This is a constant which will never vary based on setup. Do it during the build to save the forks at runtime.
Signed-off-by: Dave Reisner
Acked-by: Tom Gundersen
--- init | 4 ---- install/base | 5 ++++- 2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/init b/init index f14261d..8891a69 100644 --- a/init +++ b/init @@ -1,12 +1,8 @@ #!/bin/busybox ash -# Install busybox's applets as symlinks PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
-busybox --install -s - . /init_functions
-mkdir -p /new_root mount -t proc proc /proc -o nosuid,noexec,nodev mount -t sysfs sys /sys -o nosuid,noexec,nodev if grep -q devtmpfs /proc/filesystems 2>/dev/null; then diff --git a/install/base b/install/base index e85551c..9135ced 100644 --- a/install/base +++ b/install/base @@ -1,10 +1,13 @@ #!/bin/bash
build() { - for dir in proc sys dev run usr/{bin,sbin}; do + for dir in proc sys dev run usr/{bin,sbin} new_root; do add_dir "/$dir" done
+ # install busybox's applets as symlinks + /lib/initcpio/busybox --install -s "$BUILDROOT/usr/bin" + add_binary /lib/initcpio/busybox /bin/busybox add_binary /sbin/modprobe add_binary /sbin/blkid -- 1.7.6.4
On Tue, Sep 27, 2011 at 11:41:31AM +0200, Tom Gundersen wrote:
On Tue, Sep 27, 2011 at 3:22 AM, Dave Reisner
wrote: This is a constant which will never vary based on setup. Do it during the build to save the forks at runtime.
Signed-off-by: Dave Reisner
Acked-by: Tom Gundersen
BUT:
Not that this might cause issues with the next release of busybox. They have changed things in evil ways and don't seem to want to revert it.
A foolproof way to solve the problem is to loop over the list of apps (which busybox will give you) and create the symlinks manually.
The downside of that is that all links will end up in the same dir, but the distinctions between {,/usr}/{,s}bin don't make any sense in an initramfs anyway, so that should be fine.
Yeah, I recall you mentioning this. I don't want to make a change that's going to potentially break in the future because of upstream. I'm inclined to sit on this bit of patchwork and push it to my working branch until busybox figures out wtf it is they're going to mangle next. We're not making any radical changes here -- what we have right now works, and this is really only to avoid a few forks at bootstrap. Regardless, you're right that looping over the included applet list is a better way to do this. I think that it's also advantageous because then we can symlink everything into /bin and let user overrides take place in /usr, without having to involve /usr/local (which is a bit odd, imo). d
Signed-off-by: Dave Reisner
On Mon, Sep 26, 2011 at 8:22 PM, Dave Reisner
Signed-off-by: Dave Reisner
Why were we using stderr before? Did something else change?
--- lsinitcpio | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lsinitcpio b/lsinitcpio index ca2b224..95c0500 100755 --- a/lsinitcpio +++ b/lsinitcpio @@ -62,7 +62,7 @@ shift $(( OPTIND - 1 ))
declare image=$1
-if [[ -t 2 ]] && (( color )); then +if [[ -t 1 ]] && (( color )); then # prefer terminal safe colored and bold text when tput is supported if tput setaf 0 &>/dev/null; then NC="$(tput sgr0)" -- 1.7.6.4
On Mon, Sep 26, 2011 at 08:57:40PM -0500, Dan McGee wrote:
On Mon, Sep 26, 2011 at 8:22 PM, Dave Reisner
wrote: Signed-off-by: Dave Reisner
Why were we using stderr before? Did something else change?
You really wanna know? Copy/paste job from makepkg. We should fix this over in makepkg as well. I'm not sure why it's used there either.
--- lsinitcpio | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lsinitcpio b/lsinitcpio index ca2b224..95c0500 100755 --- a/lsinitcpio +++ b/lsinitcpio @@ -62,7 +62,7 @@ shift $(( OPTIND - 1 ))
declare image=$1
-if [[ -t 2 ]] && (( color )); then +if [[ -t 1 ]] && (( color )); then # prefer terminal safe colored and bold text when tput is supported if tput setaf 0 &>/dev/null; then NC="$(tput sgr0)" -- 1.7.6.4
On Mon, Sep 26, 2011 at 9:01 PM, Dave Reisner
On Mon, Sep 26, 2011 at 08:57:40PM -0500, Dan McGee wrote:
On Mon, Sep 26, 2011 at 8:22 PM, Dave Reisner
wrote: Signed-off-by: Dave Reisner
Why were we using stderr before? Did something else change? You really wanna know? Copy/paste job from makepkg. We should fix this over in makepkg as well. I'm not sure why it's used there either.
makepkg -g >> PKGBUILD. Now whether that is a good reason is up for some debate, but you asked. :) -Dan
On Mon, Sep 26, 2011 at 09:05:21PM -0500, Dan McGee wrote:
On Mon, Sep 26, 2011 at 9:01 PM, Dave Reisner
wrote: On Mon, Sep 26, 2011 at 08:57:40PM -0500, Dan McGee wrote:
On Mon, Sep 26, 2011 at 8:22 PM, Dave Reisner
wrote: Signed-off-by: Dave Reisner
Why were we using stderr before? Did something else change? You really wanna know? Copy/paste job from makepkg. We should fix this over in makepkg as well. I'm not sure why it's used there either.
makepkg -g >> PKGBUILD.
Now whether that is a good reason is up for some debate, but you asked. :)
-Dan
Did I say fix? I meant makepkg is wonderful. Yeah, we don't have any such need in lsinitcpio. But, people do enjoy writing the output from this program to a pastebin or a pager, so disabling color on [[ ! -t 1 ]] is the nice thing to do. d
If the image we're pointing to is a symlink, show the resolution as part
of the name in -a's output.
Signed-off-by: Dave Reisner
Signed-off-by: Dave Reisner
Signed-off-by: Dave Reisner
If we encounter a BOOT_IMAGE var taken from grub2, the first character
could be a '(' which will throw off busybox's parser and error out.
Reverse the comparison so that the LHS is always a constant, which can
be compared to anything (including nothing at all).
Fixes FS#26119.
Signed-off-by: Dave Reisner
On 09/26/2011 10:22 PM, Dave Reisner wrote:
If we encounter a BOOT_IMAGE var taken from grub2, the first character could be a '(' which will throw off busybox's parser and error out. Reverse the comparison so that the LHS is always a constant, which can be compared to anything (including nothing at all).
Fixes FS#26119.
Signed-off-by: Dave Reisner
--- init_functions | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/init_functions b/init_functions index fe29961..edaf87c 100644 --- a/init_functions +++ b/init_functions @@ -45,8 +45,8 @@ parse_cmdline() { # only export stuff that does work with ash :) *=*) rhs="$(echo "${w}" | cut -d= -f2-)" lhs="$(echo "${w}" | cut -d= -f1 | sed 's|\.|_|g;s|-|_|g;')" - if [ "${rhs:0:1}" = "\"" ]; then - if [ "${rhs:$((${#rhs}-1))}" = "\"" ]; then + if [ "\"" = "${rhs:0:1}" = ]; then + if [ "\"" = "${rhs:$((${#rhs}-1))}" ]; then rhs="${rhs:1:$((${#rhs}-2))}" else rhs="${rhs:1}" @@ -61,7 +61,7 @@ parse_cmdline() { ;; esac else - if [ "${w:$((${#w}-1))}" = "\"" ]; then + if [ "\"" = "${w:$((${#w}-1))}" ]; then rhs="${rhs} ${w:0:$((${#w}-1))}" in_quotes=0 (echo "${lhs}" | grep -qe '^[0-9]' -e '[^a-zA-Z0-9_]') || eval ${lhs}=\${rhs}
I testing the whole branch with archiso. But this patch introduced a regression: "ash: =: unknown operand" :: Starting udevd... tracing shows: + echo archisobasedir=arch + lhs=archisobasedir + [ " = a = ] ash: =: unknown operand + echo archisolabel=ARCH_201109 + lhs=archisolabel + [ " = A = ] ash: =: unknown operand + echo initrd=/arch/boot/i686/archiso.img + lhs=initrd + [ " = / = ] ash: =: unknown operand etc -- Gerardo Exequiel Pozzi \cos^2\alpha + \sin^2\alpha = 1
Am 27.09.2011 06:23, schrieb Gerardo Exequiel Pozzi:
- if [ "${rhs:0:1}" = "\"" ]; then + if [ "\"" = "${rhs:0:1}" = ]; then
I testing the whole branch with archiso. But this patch introduced a regression:
"ash: =: unknown operand" :: Starting udevd...
tracing shows:
+ echo archisobasedir=arch + lhs=archisobasedir + [ " = a = ] ash: =: unknown operand
It's typo. When you see it, you will cry.
On 09/27/2011 06:51 AM, Thomas Bächler wrote:
Am 27.09.2011 06:23, schrieb Gerardo Exequiel Pozzi:
- if [ "${rhs:0:1}" = "\"" ]; then + if [ "\"" = "${rhs:0:1}" = ]; then I testing the whole branch with archiso. But this patch introduced a regression:
"ash: =: unknown operand" :: Starting udevd...
tracing shows:
+ echo archisobasedir=arch + lhs=archisobasedir + [ " = a = ] ash: =: unknown operand It's typo. When you see it, you will cry.
haha, I see :P -- Gerardo Exequiel Pozzi \cos^2\alpha + \sin^2\alpha = 1
From: Florian Pritz
participants (5)
-
Dan McGee
-
Dave Reisner
-
Gerardo Exequiel Pozzi
-
Thomas Bächler
-
Tom Gundersen