Message ID | 20240907165104.1825446-2-kumar.rakesh@siemens.com |
---|---|
State | New |
Headers | show |
Series | [1/2] initramfs-fsck-hook: bump version, rename package and files | expand |
On Sat, 2024-09-07 at 22:21 +0530, Rakesh Kumar wrote: > * Used hook_error() function to improve error handling during > copy_exec calls in the initramfs hook script. Rather than paraphrasing each copy_exec call, I would mimic what Debian hooks such as /usr/share/initramfs-tools/hooks/{fuse,plymouth} do: have the hook use "set -e" towards the beginning of the script to simply abort as soon as a command fail. set -e copy_exec ... copy_exec ... > * Corrected the path for fsck from /sbin/fsck to /usr/sbin/fsck. I am sorry but /sbin/fsck is correct # dpkg -S /usr/sbin/fsck dpkg-query: no path found matching pattern /usr/sbin/fsck # dpkg -S /sbin/fsck util-linux: /sbin/fsck > > Signed-off-by: Rakesh Kumar <kumar.rakesh@siemens.com> > --- > .../files/initramfs-fsck-ext4.hook | 21 +++++++---------- > -- > 1 file changed, 7 insertions(+), 14 deletions(-) > > diff --git a/meta/recipes-support/initramfs-fsck- > hook/files/initramfs-fsck-ext4.hook b/meta/recipes-support/initramfs- > fsck-hook/files/initramfs-fsck-ext4.hook > index 259b73b4..4762c805 100644 > --- a/meta/recipes-support/initramfs-fsck-hook/files/initramfs-fsck- > ext4.hook > +++ b/meta/recipes-support/initramfs-fsck-hook/files/initramfs-fsck- > ext4.hook > @@ -5,8 +5,6 @@ > > #!/bin/sh > > -set -e > - > PREREQ="" > > prereqs() > @@ -24,16 +22,11 @@ esac > . /usr/share/initramfs-tools/scripts/functions > . /usr/share/initramfs-tools/hook-functions > > -if [ ! -x /sbin/fsck ]; then > - echo "Warning: couldn't find /sbin/fsck!" > - exit 0 > -fi > - > -copy_exec /sbin/fsck > -copy_exec /sbin/logsave > +hook_error() { > + echo "(ERROR): $1" >&2 > + exit 1 > +} > > -if prog="$(command -v fsck.ext4)"; then > - copy_exec "$prog" > -else > - echo "Warning: /sbin/fsck.ext4 doesn't exist, can't install to > initramfs, ignoring." > -fi > +copy_exec /sbin/fsck || hook_error "Unable to copy /usr/sbin/fsck" > +copy_exec /sbin/logsave || hook_error "Unable to copy > /usr/sbin/logsave" > +copy_exec /usr/sbin/fsck.ext4 || hook_error "Unable to copy > /usr/sbin/fsck.ext4"
diff --git a/meta/recipes-support/initramfs-fsck-hook/files/initramfs-fsck-ext4.hook b/meta/recipes-support/initramfs-fsck-hook/files/initramfs-fsck-ext4.hook index 259b73b4..4762c805 100644 --- a/meta/recipes-support/initramfs-fsck-hook/files/initramfs-fsck-ext4.hook +++ b/meta/recipes-support/initramfs-fsck-hook/files/initramfs-fsck-ext4.hook @@ -5,8 +5,6 @@ #!/bin/sh -set -e - PREREQ="" prereqs() @@ -24,16 +22,11 @@ esac . /usr/share/initramfs-tools/scripts/functions . /usr/share/initramfs-tools/hook-functions -if [ ! -x /sbin/fsck ]; then - echo "Warning: couldn't find /sbin/fsck!" - exit 0 -fi - -copy_exec /sbin/fsck -copy_exec /sbin/logsave +hook_error() { + echo "(ERROR): $1" >&2 + exit 1 +} -if prog="$(command -v fsck.ext4)"; then - copy_exec "$prog" -else - echo "Warning: /sbin/fsck.ext4 doesn't exist, can't install to initramfs, ignoring." -fi +copy_exec /sbin/fsck || hook_error "Unable to copy /usr/sbin/fsck" +copy_exec /sbin/logsave || hook_error "Unable to copy /usr/sbin/logsave" +copy_exec /usr/sbin/fsck.ext4 || hook_error "Unable to copy /usr/sbin/fsck.ext4"
* Used hook_error() function to improve error handling during copy_exec calls in the initramfs hook script. * Corrected the path for fsck from /sbin/fsck to /usr/sbin/fsck. Signed-off-by: Rakesh Kumar <kumar.rakesh@siemens.com> --- .../files/initramfs-fsck-ext4.hook | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-)