Patchwork [1/1] busybox, mdev: Added option for disabling mdev -s in sysv-init

login
register
mail settings
Submitter Kim Bøndergaard
Date May 21, 2013, 5:54 a.m.
Message ID <e32d865b1013a1c88627d96d6b1659b84ee74505.1369115383.git.kibo@prevas.dk>
Download mbox | patch
Permalink /patch/245186/
State Changes Requested
Delegated to: Esben Haabendal
Headers show

Comments

Kim Bøndergaard - May 21, 2013, 5:54 a.m.
---
 recipes/busybox/busybox-configure.inc |  2 ++
 recipes/busybox/busybox-install.inc   | 25 +++++++++++++++++++++++++
 recipes/busybox/files/busybox-mdev    |  8 ++------
 3 files changed, 29 insertions(+), 6 deletions(-)
Esben Haabendal - May 29, 2013, 9 a.m.
Kim Bøndergaard <kibo@prevas.dk> writes:

> ---
>  recipes/busybox/busybox-configure.inc |  2 ++
>  recipes/busybox/busybox-install.inc   | 25 +++++++++++++++++++++++++
>  recipes/busybox/files/busybox-mdev    |  8 ++------
>  3 files changed, 29 insertions(+), 6 deletions(-)
>
> diff --git a/recipes/busybox/busybox-configure.inc b/recipes/busybox/busybox-configure.inc
> index 6caaf3e..0cfb779 100644
> --- a/recipes/busybox/busybox-configure.inc
> +++ b/recipes/busybox/busybox-configure.inc
> @@ -118,6 +118,8 @@ DEFAULT_USE_busybox_mdev_sysvinit_start = "10"
>  RECIPE_FLAGS += "busybox_mdev_splashutils_progress busybox_mdev_splashutils_msg"
>  SPLASHUTILS_INITSCRIPTS:>USE_busybox_mdev += " busybox_mdev"
>  DEFAULT_USE_busybox_mdev_splashutils_msg = "\"Starting Mdev\""
> +RECIPE_FLAGS += "busybox_mdev_dash_s"
> +DEFAULT_USE_busybox_mdev_dash_s = "1"
>  
>  RECIPE_FLAGS += "busybox_klogd \
>          busybox_klogd_sysvinit_start busybox_klogd_conlevel"
> diff --git a/recipes/busybox/busybox-install.inc b/recipes/busybox/busybox-install.inc
> index bfb0c11..9e4f78c 100644
> --- a/recipes/busybox/busybox-install.inc
> +++ b/recipes/busybox/busybox-install.inc
> @@ -135,3 +135,28 @@ do_install () {
>  		sysvinit_install_script ${SRCDIR}/busybox-httpd
>  	fi
>  }
> +
> +do_install[postfuncs] += "${BUSYBOX_INSTALL_POSTFUNCS}"
> +BUSYBOX_INSTALL_POSTFUNCS = ""
> +BUSYBOX_INSTALL_POSTFUNCS:>USE_busybox_mdev = " do_install_fix_mdev"
> +
> +python do_install_fix_mdev () {
> +	import os, fileinput
> +	path = d.get("D")
> +	os.chdir(path)
> +	sysconfdir=d.get("sysconfdir")
> +	for line in fileinput.FileInput("." + sysconfdir + "/init.d/busybox-mdev", inplace=1):
> +		if d.get("USE_busybox_mdev_dash_s"):
> +			line=line.replace("mdev_dash_s PLACEHOLDER_1",
> +				"# Create tmpfs for /dev\n" +
> +				"echo \"Creating tmpfs at /dev\"\n" +
> +				"mount -t tmpfs tmpfs /dev -o size=64k,mode=0755")
> +			line=line.replace("mdev_dash_s PLACEHOLDER_2",
> +				"# Populate /dev from /sys info\n" +
> +				"echo \"Populating /dev/ using mdev\"\n" +
> +				"$MDEV -s")
> +		else:
> +			line=line.replace("mdev_dash_s PLACEHOLDER_1", "")
> +			line=line.replace("mdev_dash_s PLACEHOLDER_2", "")
> +		print line,
> +}
> diff --git a/recipes/busybox/files/busybox-mdev b/recipes/busybox/files/busybox-mdev
> index c068b94..5d307dd 100755
> --- a/recipes/busybox/files/busybox-mdev
> +++ b/recipes/busybox/files/busybox-mdev
> @@ -34,16 +34,12 @@ if mountpoint -q /dev/shm/; then
>    umount -l /dev/shm/
>  fi
>  
> -# Create tmpfs for /dev
> -echo "Creating tmpfs at /dev"
> -mount -t tmpfs tmpfs /dev -o size=64k,mode=0755
> +mdev_dash_s PLACEHOLDER_1

Don't we need to remove this line also if USE_busybox_mdev is off?

>  
>  # Register mdev as hotplug event helper
>  echo "$MDEV" > /proc/sys/kernel/hotplug
>  
> -# Populate /dev from /sys info
> -echo "Populating /dev using mdev"
> -$MDEV -s
> +mdev_dash_s PLACEHOLDER_2

Same here.

>  # Touch .udev to inform scripts that /dev needs no further setup
>  touch /dev/.udev

Will you send a new version which properly handles USE_busybox_mdev off?

/Esben
Kim Bøndergaard Poulsen - May 31, 2013, 6:12 a.m.
You are right. Wouldn't the best be to simply always add do_install_fix_mdev() to the postfunc list independent of the USE_busybox_mdev flag.

Due to the fact that USE_busybox_mdev_dash_s defaults to 1 the resulting busybox-mdev files will be as it originally was. Don't you agree?

_____________________________________

Kim Bøndergaard Poulsen
Systems Architect
 
Prevas A/S
Hedeager 1
DK-8200 Århus N
 
Central +45 87 43 80 70
Direct   +45 51 54 39 61
kibo@prevas.dk 
www.prevas.dk 



> -----Original Message-----

> From: Esben Haabendal [mailto:esben.haabendal@dev.prevas.dk]

> Sent: 29. maj 2013 11:01

> To: Kim Bøndergaard Poulsen

> Cc: dev@oe-lite.org

> Subject: Re: [PATCH 1/1] busybox, mdev: Added option for disabling mdev -s

> in sysv-init

> 

> Kim Bøndergaard <kibo@prevas.dk> writes:

> 

> > ---

> >  recipes/busybox/busybox-configure.inc |  2 ++

> >  recipes/busybox/busybox-install.inc   | 25

> +++++++++++++++++++++++++

> >  recipes/busybox/files/busybox-mdev    |  8 ++------

> >  3 files changed, 29 insertions(+), 6 deletions(-)

> >

> > diff --git a/recipes/busybox/busybox-configure.inc

> > b/recipes/busybox/busybox-configure.inc

> > index 6caaf3e..0cfb779 100644

> > --- a/recipes/busybox/busybox-configure.inc

> > +++ b/recipes/busybox/busybox-configure.inc

> > @@ -118,6 +118,8 @@ DEFAULT_USE_busybox_mdev_sysvinit_start =

> "10"

> >  RECIPE_FLAGS += "busybox_mdev_splashutils_progress

> busybox_mdev_splashutils_msg"

> >  SPLASHUTILS_INITSCRIPTS:>USE_busybox_mdev += " busybox_mdev"

> >  DEFAULT_USE_busybox_mdev_splashutils_msg = "\"Starting Mdev\""

> > +RECIPE_FLAGS += "busybox_mdev_dash_s"

> > +DEFAULT_USE_busybox_mdev_dash_s = "1"

> >

> >  RECIPE_FLAGS += "busybox_klogd \

> >          busybox_klogd_sysvinit_start busybox_klogd_conlevel"

> > diff --git a/recipes/busybox/busybox-install.inc

> > b/recipes/busybox/busybox-install.inc

> > index bfb0c11..9e4f78c 100644

> > --- a/recipes/busybox/busybox-install.inc

> > +++ b/recipes/busybox/busybox-install.inc

> > @@ -135,3 +135,28 @@ do_install () {

> >  		sysvinit_install_script ${SRCDIR}/busybox-httpd

> >  	fi

> >  }

> > +

> > +do_install[postfuncs] += "${BUSYBOX_INSTALL_POSTFUNCS}"

> > +BUSYBOX_INSTALL_POSTFUNCS = ""

> > +BUSYBOX_INSTALL_POSTFUNCS:>USE_busybox_mdev = "

> do_install_fix_mdev"

> > +

> > +python do_install_fix_mdev () {

> > +	import os, fileinput

> > +	path = d.get("D")

> > +	os.chdir(path)

> > +	sysconfdir=d.get("sysconfdir")

> > +	for line in fileinput.FileInput("." + sysconfdir +

> "/init.d/busybox-mdev", inplace=1):

> > +		if d.get("USE_busybox_mdev_dash_s"):

> > +			line=line.replace("mdev_dash_s

> PLACEHOLDER_1",

> > +				"# Create tmpfs for

> /dev\n" +

> > +				"echo \"Creating

> tmpfs at /dev\"\n" +

> > +				"mount -t tmpfs

> tmpfs /dev -o size=64k,mode=0755")

> > +			line=line.replace("mdev_dash_s

> PLACEHOLDER_2",

> > +				"# Populate /dev

> from /sys info\n" +

> > +				"echo \"Populating

> /dev/ using mdev\"\n" +

> > +				"$MDEV -s")

> > +		else:

> > +			line=line.replace("mdev_dash_s

> PLACEHOLDER_1", "")

> > +			line=line.replace("mdev_dash_s

> PLACEHOLDER_2", "")

> > +		print line,

> > +}

> > diff --git a/recipes/busybox/files/busybox-mdev

> > b/recipes/busybox/files/busybox-mdev

> > index c068b94..5d307dd 100755

> > --- a/recipes/busybox/files/busybox-mdev

> > +++ b/recipes/busybox/files/busybox-mdev

> > @@ -34,16 +34,12 @@ if mountpoint -q /dev/shm/; then

> >    umount -l /dev/shm/

> >  fi

> >

> > -# Create tmpfs for /dev

> > -echo "Creating tmpfs at /dev"

> > -mount -t tmpfs tmpfs /dev -o size=64k,mode=0755

> > +mdev_dash_s PLACEHOLDER_1

> 

> Don't we need to remove this line also if USE_busybox_mdev is off?

> 

> >

> >  # Register mdev as hotplug event helper  echo "$MDEV" >

> > /proc/sys/kernel/hotplug

> >

> > -# Populate /dev from /sys info

> > -echo "Populating /dev using mdev"

> > -$MDEV -s

> > +mdev_dash_s PLACEHOLDER_2

> 

> Same here.

> 

> >  # Touch .udev to inform scripts that /dev needs no further setup

> > touch /dev/.udev

> 

> Will you send a new version which properly handles USE_busybox_mdev off?

> 

> /Esben
Esben Haabendal - June 20, 2013, 6:59 a.m.
Kim Bøndergaard Poulsen <Kim.BondergaardPoulsen@prevas.dk> writes:

> You are right. Wouldn't the best be to simply always add
> do_install_fix_mdev() to the postfunc list independent of the
> USE_busybox_mdev flag.
>
> Due to the fact that USE_busybox_mdev_dash_s defaults to 1 the
> resulting busybox-mdev files will be as it originally was. Don't you
> agree?

That should work.

Another solution would be to change the two placeholder lines to be
comment lines. The 'else' clause in do_install_fix_mdev could then be
dropped, and do_install_fix_mdev could then be changed to be run when
USE_busybox_mdev_dash_s is enabled and not based on the value of
USE_busybox_mdev.

/Esben

>
> _____________________________________
>
> Kim Bøndergaard Poulsen
> Systems Architect
>  
> Prevas A/S
> Hedeager 1
> DK-8200 Århus N
>  
> Central +45 87 43 80 70
> Direct   +45 51 54 39 61
> kibo@prevas.dk 
> www.prevas.dk 
>
>
>
>> -----Original Message-----
>> From: Esben Haabendal [mailto:esben.haabendal@dev.prevas.dk]
>> Sent: 29. maj 2013 11:01
>> To: Kim Bøndergaard Poulsen
>> Cc: dev@oe-lite.org
>> Subject: Re: [PATCH 1/1] busybox, mdev: Added option for disabling mdev -s
>> in sysv-init
>> 
>> Kim Bøndergaard <kibo@prevas.dk> writes:
>> 
>> > ---
>> >  recipes/busybox/busybox-configure.inc |  2 ++
>> >  recipes/busybox/busybox-install.inc   | 25
>> +++++++++++++++++++++++++
>> >  recipes/busybox/files/busybox-mdev    |  8 ++------
>> >  3 files changed, 29 insertions(+), 6 deletions(-)
>> >
>> > diff --git a/recipes/busybox/busybox-configure.inc
>> > b/recipes/busybox/busybox-configure.inc
>> > index 6caaf3e..0cfb779 100644
>> > --- a/recipes/busybox/busybox-configure.inc
>> > +++ b/recipes/busybox/busybox-configure.inc
>> > @@ -118,6 +118,8 @@ DEFAULT_USE_busybox_mdev_sysvinit_start =
>> "10"
>> >  RECIPE_FLAGS += "busybox_mdev_splashutils_progress
>> busybox_mdev_splashutils_msg"
>> >  SPLASHUTILS_INITSCRIPTS:>USE_busybox_mdev += " busybox_mdev"
>> >  DEFAULT_USE_busybox_mdev_splashutils_msg = "\"Starting Mdev\""
>> > +RECIPE_FLAGS += "busybox_mdev_dash_s"
>> > +DEFAULT_USE_busybox_mdev_dash_s = "1"
>> >
>> >  RECIPE_FLAGS += "busybox_klogd \
>> >          busybox_klogd_sysvinit_start busybox_klogd_conlevel"
>> > diff --git a/recipes/busybox/busybox-install.inc
>> > b/recipes/busybox/busybox-install.inc
>> > index bfb0c11..9e4f78c 100644
>> > --- a/recipes/busybox/busybox-install.inc
>> > +++ b/recipes/busybox/busybox-install.inc
>> > @@ -135,3 +135,28 @@ do_install () {
>> >  		sysvinit_install_script ${SRCDIR}/busybox-httpd
>> >  	fi
>> >  }
>> > +
>> > +do_install[postfuncs] += "${BUSYBOX_INSTALL_POSTFUNCS}"
>> > +BUSYBOX_INSTALL_POSTFUNCS = ""
>> > +BUSYBOX_INSTALL_POSTFUNCS:>USE_busybox_mdev = "
>> do_install_fix_mdev"
>> > +
>> > +python do_install_fix_mdev () {
>> > +	import os, fileinput
>> > +	path = d.get("D")
>> > +	os.chdir(path)
>> > +	sysconfdir=d.get("sysconfdir")
>> > +	for line in fileinput.FileInput("." + sysconfdir +
>> "/init.d/busybox-mdev", inplace=1):
>> > +		if d.get("USE_busybox_mdev_dash_s"):
>> > +			line=line.replace("mdev_dash_s
>> PLACEHOLDER_1",
>> > +				"# Create tmpfs for
>> /dev\n" +
>> > +				"echo \"Creating
>> tmpfs at /dev\"\n" +
>> > +				"mount -t tmpfs
>> tmpfs /dev -o size=64k,mode=0755")
>> > +			line=line.replace("mdev_dash_s
>> PLACEHOLDER_2",
>> > +				"# Populate /dev
>> from /sys info\n" +
>> > +				"echo \"Populating
>> /dev/ using mdev\"\n" +
>> > +				"$MDEV -s")
>> > +		else:
>> > +			line=line.replace("mdev_dash_s
>> PLACEHOLDER_1", "")
>> > +			line=line.replace("mdev_dash_s
>> PLACEHOLDER_2", "")
>> > +		print line,
>> > +}
>> > diff --git a/recipes/busybox/files/busybox-mdev
>> > b/recipes/busybox/files/busybox-mdev
>> > index c068b94..5d307dd 100755
>> > --- a/recipes/busybox/files/busybox-mdev
>> > +++ b/recipes/busybox/files/busybox-mdev
>> > @@ -34,16 +34,12 @@ if mountpoint -q /dev/shm/; then
>> >    umount -l /dev/shm/
>> >  fi
>> >
>> > -# Create tmpfs for /dev
>> > -echo "Creating tmpfs at /dev"
>> > -mount -t tmpfs tmpfs /dev -o size=64k,mode=0755
>> > +mdev_dash_s PLACEHOLDER_1
>> 
>> Don't we need to remove this line also if USE_busybox_mdev is off?
>> 
>> >
>> >  # Register mdev as hotplug event helper  echo "$MDEV" >
>> > /proc/sys/kernel/hotplug
>> >
>> > -# Populate /dev from /sys info
>> > -echo "Populating /dev using mdev"
>> > -$MDEV -s
>> > +mdev_dash_s PLACEHOLDER_2
>> 
>> Same here.
>> 
>> >  # Touch .udev to inform scripts that /dev needs no further setup
>> > touch /dev/.udev
>> 
>> Will you send a new version which properly handles USE_busybox_mdev off?
>> 
>> /Esben
Kim Bøndergaard Poulsen - June 25, 2013, 9:45 a.m.
After having looked into this again, I must say I prefer to stay at my last pushed commit

If USE_busybox_mdev is off we doesn't get the file 

    sysconfdir + "/init.d/busybox-mdev"

at all, so trying to manipulate it makes no sense (but introduces errors)
Esben Haabendal - July 3, 2013, 6:50 a.m.
Kim Bøndergaard Poulsen <Kim.BondergaardPoulsen@prevas.dk> writes:

> After having looked into this again, I must say I prefer to stay at my last pushed commit
>
> If USE_busybox_mdev is off we doesn't get the file 
>
>     sysconfdir + "/init.d/busybox-mdev"
>
> at all, so trying to manipulate it makes no sense (but introduces
> errors)

And we don't want to introduce errors :)

I just don't like the the trend that we are changing script source files
to not be valid scripts anymore, and that, as in this situation, part of
the script code is moved into Python code.  It makes it more difficult
to understand what the script does.

Staying with the general idea of your commit
e32d865b1013a1c88627d96d6b1659b84ee74505, but changing the
files/busybox-mdev file to include the actual script code, but append
the lines with '# USE_busybox_mdev_dash_s' and then change the inner
part of do_install_fix_mdev() with something like this:

if line.endswith("# USE_busybox_mdev_dash_s\n", 0, -1):
    if d.get("USE_busybox_mdev_dash_s"):
        line=line.replace("# USE_busybox_mdev_dash_s\n", "\n")
    else:
        continue

So, run the do_install_fix_mdev when USE_busybox_mdev is enabled, and
delete the 'mdev -s' related lines when USE_busybox_mdev_dash_s is
disabled, and just strip the '# USE_busybox_mdev_dash_s' markup comment
when USE_busybox_mdev_dash_s is enabled.

The files/busybox-mdev diff would be something like:

-# Create tmpfs for /dev
-echo "Creating tmpfs at /dev"
-mount -t tmpfs tmpfs /dev -o size=64k,mode=0755
+echo "Creating tmpfs at /dev"# USE_busybox_mdev_dash_s
+mount -t tmpfs tmpfs /dev -o size=64k,mode=0755# USE_busybox_mdev_dash_s

/Esben

Patch

diff --git a/recipes/busybox/busybox-configure.inc b/recipes/busybox/busybox-configure.inc
index 6caaf3e..0cfb779 100644
--- a/recipes/busybox/busybox-configure.inc
+++ b/recipes/busybox/busybox-configure.inc
@@ -118,6 +118,8 @@  DEFAULT_USE_busybox_mdev_sysvinit_start = "10"
 RECIPE_FLAGS += "busybox_mdev_splashutils_progress busybox_mdev_splashutils_msg"
 SPLASHUTILS_INITSCRIPTS:>USE_busybox_mdev += " busybox_mdev"
 DEFAULT_USE_busybox_mdev_splashutils_msg = "\"Starting Mdev\""
+RECIPE_FLAGS += "busybox_mdev_dash_s"
+DEFAULT_USE_busybox_mdev_dash_s = "1"
 
 RECIPE_FLAGS += "busybox_klogd \
         busybox_klogd_sysvinit_start busybox_klogd_conlevel"
diff --git a/recipes/busybox/busybox-install.inc b/recipes/busybox/busybox-install.inc
index bfb0c11..9e4f78c 100644
--- a/recipes/busybox/busybox-install.inc
+++ b/recipes/busybox/busybox-install.inc
@@ -135,3 +135,28 @@  do_install () {
 		sysvinit_install_script ${SRCDIR}/busybox-httpd
 	fi
 }
+
+do_install[postfuncs] += "${BUSYBOX_INSTALL_POSTFUNCS}"
+BUSYBOX_INSTALL_POSTFUNCS = ""
+BUSYBOX_INSTALL_POSTFUNCS:>USE_busybox_mdev = " do_install_fix_mdev"
+
+python do_install_fix_mdev () {
+	import os, fileinput
+	path = d.get("D")
+	os.chdir(path)
+	sysconfdir=d.get("sysconfdir")
+	for line in fileinput.FileInput("." + sysconfdir + "/init.d/busybox-mdev", inplace=1):
+		if d.get("USE_busybox_mdev_dash_s"):
+			line=line.replace("mdev_dash_s PLACEHOLDER_1",
+				"# Create tmpfs for /dev\n" +
+				"echo \"Creating tmpfs at /dev\"\n" +
+				"mount -t tmpfs tmpfs /dev -o size=64k,mode=0755")
+			line=line.replace("mdev_dash_s PLACEHOLDER_2",
+				"# Populate /dev from /sys info\n" +
+				"echo \"Populating /dev/ using mdev\"\n" +
+				"$MDEV -s")
+		else:
+			line=line.replace("mdev_dash_s PLACEHOLDER_1", "")
+			line=line.replace("mdev_dash_s PLACEHOLDER_2", "")
+		print line,
+}
diff --git a/recipes/busybox/files/busybox-mdev b/recipes/busybox/files/busybox-mdev
index c068b94..5d307dd 100755
--- a/recipes/busybox/files/busybox-mdev
+++ b/recipes/busybox/files/busybox-mdev
@@ -34,16 +34,12 @@  if mountpoint -q /dev/shm/; then
   umount -l /dev/shm/
 fi
 
-# Create tmpfs for /dev
-echo "Creating tmpfs at /dev"
-mount -t tmpfs tmpfs /dev -o size=64k,mode=0755
+mdev_dash_s PLACEHOLDER_1
 
 # Register mdev as hotplug event helper
 echo "$MDEV" > /proc/sys/kernel/hotplug
 
-# Populate /dev from /sys info
-echo "Populating /dev using mdev"
-$MDEV -s
+mdev_dash_s PLACEHOLDER_2
 
 # Touch .udev to inform scripts that /dev needs no further setup
 touch /dev/.udev