Hello all! В Thu, 11 Dec 2014 15:46:08 +0100 Thomas Renninger <trenn@xxxxxxx> пишет: > From: Thorsten Behrens <tbehrens@xxxxxxxx> > > Add more corner cases from systemd's > unit_name_from_path_instance() C function. > > Signed-off-by: Thorsten Behrens <tbehrens@xxxxxxxx> > Signed-off-by: Thomas Renninger <trenn@xxxxxxx> > --- > modules.d/99base/dracut-lib.sh | 24 ++++++++++++++++++------ > 1 file changed, 18 insertions(+), 6 deletions(-) > > diff --git a/modules.d/99base/dracut-lib.sh > b/modules.d/99base/dracut-lib.sh index f7cffc4..5c1504f 100755 > --- a/modules.d/99base/dracut-lib.sh > +++ b/modules.d/99base/dracut-lib.sh > @@ -866,18 +866,30 @@ wait_for_mount() > } >> "$hookdir/emergency/90-${_name}.sh" > } > > +# get a systemd-compatible unit name from a path > +# (mimicks unit_name_from_path_instance()) > dev_unit_name() > { > + local dev="$1" > + > if command -v systemd-escape >/dev/null; then > - systemd-escape -p "$1" > + systemd-escape -p "$dev" > return > fi > > - _name="${1%%/}" > - _name="${_name##/}" > - _name="$(str_replace "$_name" '-' '\x2d')" > - _name="$(str_replace "$_name" '/' '-')" > - echo "$_name" > + if [ "$dev" = "/" -o -z "$dev" ]; then > + printf -- "-" > + exit 0 > + fi > + > + dev="${1%%/}" > + dev="${dev##/}" > + dev="$(str_replace "$dev" '\' '\x5c')" > + dev="$(str_replace "$dev" '-' '\x2d')" > + dev=${dev/#\./\\x2e} The above string substitution works only in bash. With dash it gives the following warnings: $ grep 'Bad subst' rdsosreport.txt [ 2.493678] laptop dracut-cmdline[121]: /bin/dracut-cmdline: 889: //lib/dracut/hooks/cmdline/30-parse-lvm.sh: Bad substitution [ 2.537849] laptop dracut-cmdline[121]: /bin/dracut-cmdline: 889: //lib/dracut/hooks/cmdline/30-parse-lvm.sh: Bad substitution [ 2.578491] laptop dracut-cmdline[121]: /bin/dracut-cmdline: 889: //lib/dracut/hooks/cmdline/30-parse-lvm.sh: Bad substitution [ 3.854089] laptop dracut-initqueue[250]: /bin/dracut-initqueue: 889: /lib/dracut/hooks/initqueue/settled/systemd-cryptsetup-sda3.sh: Bad substitution Harald, is dash is still supported by dracut and do you accept patches to remove bashisms? > + dev="$(str_replace "$dev" '/' '-')" > + > + printf -- "%s" "$dev" > } > > # wait_for_dev <dev> -- Alexander Tsoy -- To unsubscribe from this list: send the line "unsubscribe initramfs" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html