mkinitrd unification across distributions
 help / color / mirror / Atom feed
From: Dave Young <dyoung-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: xiyou.wangcong-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Cc: initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	harald-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Subject: Re: [RFC PATCH 1/2] support adding module-specific parameters
Date: Wed, 11 Jan 2012 10:30:22 +0800	[thread overview]
Message-ID: <4F0CF43E.1020901@redhat.com> (raw)
In-Reply-To: <1326208786-24344-1-git-send-email-xiyou.wangcong-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

Hi,

Thanks for the effort, before test it I have two comments

On 01/10/2012 11:19 PM, xiyou.wangcong-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:

> From: Cong Wang <xiyou.wangcong-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> 
> ssh-client module needs a specific parameter, --ssh-key, but
> this parameter is totally useless for other modules. So, introduce
> a way to let users to pass module-specific parameters, that is,
> using colons to separate module name and its parameters, like,
> 
> 	--add ssh-client:sshkey=/root/.ssh/kdump_id_rsa.pub


Seems no way to add param to modules which is not add explicitly
such as simply run
./dracut -l

So also need to find way to add params to the implicit-added modules?

> 
> Cc: harald-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
> Signed-off-by: Cong Wang <xiyou.wangcong-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
>  dracut           |   30 ++++++++++++++++++++++++++----
>  dracut-functions |   14 ++++++++++++--
>  dracut.8.xml     |   22 ++++++++++++++++++----
>  3 files changed, 56 insertions(+), 10 deletions(-)
> 
> diff --git a/dracut b/dracut
> index 8fcdffe..f3fa257 100755
> --- a/dracut
> +++ b/dracut
> @@ -199,6 +199,13 @@ push_arg() {
>      fi
>  }
>  
> +declare -A dracut_module_args
> +read_module_args() {
> +    local _key="${1%%:*}"
> +    local _val="${1#*:}"

> +    dracut_module_args["$_key"]="$_val"

[ -z "$_key" ] above will fail

> +}
> +
>  verbosity_mod_l=0
>  
>  while (($# > 0)); do
> @@ -319,13 +326,23 @@ fi
>  # these optins add to the stuff in the config file
>  if (( ${#add_dracutmodules_l[@]} )); then
>      while pop add_dracutmodules_l val; do
> -        add_dracutmodules+=" $val "
> +        if [[ "$val" =~ ":" ]]; then
> +            add_dracutmodules+=" ${val%%:*} "
> +            read_module_args "$val"
> +        else
> +            add_dracutmodules+=" $val "
> +        fi
>      done
>  fi
>  
>  if (( ${#force_add_dracutmodules_l[@]} )); then
>      while pop force_add_dracutmodules_l val; do
> -        force_add_dracutmodules+=" $val "
> +        if [[ "$val" =~ ":" ]]; then
> +            force_add_dracutmodules+="${val%%:*} "
> +            read_module_args "$val"
> +        else
> +            force_add_dracutmodules+=" $val "
> +        fi
>      done
>  fi
>  
> @@ -364,7 +381,12 @@ fi
>  if (( ${#dracutmodules_l[@]} )); then
>      dracutmodules=''
>      while pop dracutmodules_l val; do
> -        dracutmodules+="$val "
> +        if [[ "$val" =~ ":" ]]; then
> +            dracutmodules+="${val%%:*} "
> +            read_module_args "$val"
> +        else
> +            dracutmodules+="$val "
> +        fi
>      done
>  fi
>  
> @@ -591,7 +613,7 @@ export initdir dracutbasedir dracutmodules drivers \
>      add_drivers mdadmconf lvmconf filesystems \
>      use_fstab libdir usrlibdir fscks nofscks cttyhack \
>      stdloglvl sysloglvl fileloglvl kmsgloglvl logfile \
> -    debug host_fs_types host_devs sshkey
> +    debug host_fs_types host_devs sshkey dracut_module_args
>  
>  # Create some directory structure first
>  [[ $prefix ]] && mkdir -m 0755 -p "${initdir}${prefix}"
> diff --git a/dracut-functions b/dracut-functions
> index 3dd72e9..00f8309 100755
> --- a/dracut-functions
> +++ b/dracut-functions
> @@ -690,14 +690,24 @@ module_check() {
>          # if we do not have a check script, we are unconditionally included
>          [[ -x $_moddir/check ]] || return 0
>          [ $_forced -ne 0 ] && unset hostonly
> -        $_moddir/check $hostonly
> +        if [ -n "${dracut_module_args["$1"]}" ]; then
> +            local _l="${dracut_module_args["$1"]}"
> +            eval "(${_l/:/;};$_moddir/check $hostonly;)"
> +        else
> +            $_moddir/check $hostonly
> +        fi
>          _ret=$?
>      else
>          unset check depends install installkernel
>          . $_moddir/module-setup.sh
>          is_func check || return 0
>          [ $_forced -ne 0 ] && unset hostonly
> -        check $hostonly
> +        if [ -n "${dracut_module_args["$1"]}" ]; then
> +            local _l="${dracut_module_args["$1"]}"
> +            eval "(${_l/:/;};check $hostonly;)"
> +        else
> +            check $hostonly
> +        fi
>          _ret=$?
>          unset check depends install installkernel
>      fi
> diff --git a/dracut.8.xml b/dracut.8.xml
> index 5a5df54..ea24764 100644
> --- a/dracut.8.xml
> +++ b/dracut.8.xml
> @@ -106,13 +106,14 @@ For a complete list of kernel command line options see
>              <option>-m</option>
>            </term>
>            <term>
> -            <option>--modules&nbsp;<replaceable>&lt;list of dracut modules&gt;</replaceable></option>
> +            <option>--modules&nbsp;<replaceable>&lt;module1:para1=val1:para2=val2 module2 ...&gt;</replaceable></option>
>            </term>
>            <listitem>
>              <para>specify a space-separated list of dracut modules to call
>  when building the initramfs.
>  Modules are located in
> -<filename>/usr/lib/dracut/modules.d</filename>. This parameter can be specified multiple times.</para>
> +<filename>/usr/lib/dracut/modules.d</filename>. This parameter can be specified multiple times.
> +You can also pass module specific parameters here, using colons, for example, -m ssh-client:sshkey=/root/ssh-key.</para>
>            </listitem>
>          </varlistentry>
>          <varlistentry>
> @@ -131,7 +132,7 @@ Modules are located in
>              <option>-a</option>
>            </term>
>            <term>
> -            <option>--add&nbsp;<replaceable>&lt;list of dracut modules&gt;</replaceable></option>
> +            <option>--add&nbsp;<replaceable>&lt;module1:para1=val1:para2=val2 module2 ...&gt;</replaceable></option>
>            </term>
>            <listitem>
>              <para>add a space-separated list of dracut modules to the default set of modules. This parameter can be specified multiple times.</para>
> @@ -139,7 +140,7 @@ Modules are located in
>          </varlistentry>
>          <varlistentry>
>            <term>
> -            <option>--force-add&nbsp;<replaceable>&lt;list of dracut modules&gt;</replaceable></option>
> +            <option>--force-add&nbsp;<replaceable>&lt;module1:para1=val1:para2=val2 module2 ...&gt;</replaceable></option>
>            </term>
>            <listitem>
>              <para>force to add a space-separated list of dracut modules to the default set of modules, when -H is specified. This parameter can be specified multiple times.</para>
> @@ -539,6 +540,19 @@ TARGET directory in the final initramfs. If SOURCE is a file, it will be install
>          </varlistentry>
>        </variablelist>
>      </refsect2>
> +    <refsect2>
> +     <title>Module Specific Parameters</title>
> +     <variablelist>
> +        <varlistentry>
> +          <term>
> +            <option>ssh-client</option>
> +          </term>
> +          <listitem>
> +            <para>sshkey=/path/to/sshkey (specifies the path to your ssh public key which will be used by ssh-client module)</para>
> +          </listitem>
> +       </varlistentry>
> +      </variablelist>
> +    </refsect2>
>    </refsect1>
>    <refsect1>
>      <title>Files</title>



-- 
Thanks
Dave

  parent reply	other threads:[~2012-01-11  2:30 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-10 15:19 [RFC PATCH 1/2] support adding module-specific parameters xiyou.wangcong-Re5JQEeQqe8AvxtiuMwx3w
     [not found] ` <1326208786-24344-1-git-send-email-xiyou.wangcong-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-01-10 15:19   ` [PATCH 2/2] remove the global --sshkey parameter xiyou.wangcong-Re5JQEeQqe8AvxtiuMwx3w
     [not found]     ` <1326208786-24344-2-git-send-email-xiyou.wangcong-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-01-11  2:59       ` Dave Young
     [not found]         ` <4F0CFB08.6030800-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-01-11  3:40           ` Dave Young
2012-01-11  9:54           ` Cong Wang
     [not found]             ` <4F0D5C64.1080203-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-01-12  2:15               ` Dave Young
     [not found]                 ` <4F0E4247.1010501-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-01-13  9:03                   ` Cong Wang
2012-01-11  2:30   ` Dave Young [this message]
     [not found]     ` <4F0CF43E.1020901-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-01-11  9:58       ` [RFC PATCH 1/2] support adding module-specific parameters Cong Wang
     [not found]         ` <4F0D5D57.9000804-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-01-12  2:19           ` Dave Young
     [not found]             ` <4F0E434F.9080002-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-01-13  9:01               ` Cong Wang
2012-01-23 11:14   ` Harald Hoyer
     [not found]     ` <4F1D412B.1060801-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-01-24 15:23       ` Cong Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F0CF43E.1020901@redhat.com \
    --to=dyoung-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
    --cc=harald-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=xiyou.wangcong-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox