All of lore.kernel.org
 help / color / mirror / Atom feed
* how to avoid that install.sh goes mad, if I am not root?
@ 2011-01-20 19:16 Harald Dunkel
  2011-01-20 21:47 ` Mikael Pettersson
  0 siblings, 1 reply; 10+ messages in thread
From: Harald Dunkel @ 2011-01-20 19:16 UTC (permalink / raw)
  To: Kernel Mailing List

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi folks,

I am trying to build my own custom Debian kernel package. Problem:
If the kernel is supposed to be installed in a temporary package
build directory, then it dies with

:
:
make[1]: Entering directory `/var/tmp/build_kernel/raw-kernel-2.6.37/linux-2.6.37'
sh /var/tmp/build_kernel/raw-kernel-2.6.37/linux-2.6.37/arch/x86/boot/install.sh 2.6.37 arch/x86/boot/bzImage \
                System.map "/var/tmp/build_kernel/raw-kernel-2.6.37/debian/raw-kernel-2.6.37/boot"
run-parts: executing /etc/kernel/postinst.d/dkms 2.6.37 /var/tmp/build_kernel/raw-kernel-2.6.37/debian/raw-kernel-2.6.37/boot/vmlinuz-2.6.37
dkms: running auto installation service for kernel 2.6.37:
      nvidia-current (260.19.29)...done.
      vboxhost (3.2.12)...done.
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 2.6.37 /var/tmp/build_kernel/raw-kernel-2.6.37/debian/raw-kernel-2.6.37/boot/vmlinuz-2.6.37
run-parts: executing /etc/kernel/postinst.d/pm-utils 2.6.37 /var/tmp/build_kernel/raw-kernel-2.6.37/debian/raw-kernel-2.6.37/boot/vmlinuz-2.6.37
touch: cannot touch `/var/run/do-not-hibernate': Permission denied
run-parts: /etc/kernel/postinst.d/pm-utils exited with return code 1
make[3]: *** [install] Error 1
make[2]: *** [install] Error 2
make[1]: *** [sub-make] Error 2
make[1]: Leaving directory `/var/tmp/build_kernel/raw-kernel-2.6.37/linux-2.6.37'


AFAICS this happens because the arch/x86/boot/install.sh script calls
/sbin/installkernel, which in turn runs all the scripts delivered
by various other packages. This is fine for a regular kernel install
as well as for an installation of the final kernel package, but for
a non-root install in a package build directory /sbin/installkernel
and all the run-parts scripts should not be run. installkernel doesn't
even know the redefined install directory.

Would it be possible to avoid that /sbin/installkernel is run by
install,sh, e.g. if the install directory has been redefined, or if
UID != 0?


Any helpful comment would be highly appreciated

Harri
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk04igIACgkQUTlbRTxpHjcO3wCcCXsb6ma4ypqQliWi8XYyFcUE
6PYAnA1JP78Bw2uZM4eyr4FHO9uBi0Ex
=zAFX
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: how to avoid that install.sh goes mad, if I am not root?
  2011-01-20 19:16 how to avoid that install.sh goes mad, if I am not root? Harald Dunkel
@ 2011-01-20 21:47 ` Mikael Pettersson
  2011-01-21 12:49   ` WANG Cong
  0 siblings, 1 reply; 10+ messages in thread
From: Mikael Pettersson @ 2011-01-20 21:47 UTC (permalink / raw)
  To: Harald Dunkel; +Cc: Kernel Mailing List

Harald Dunkel writes:
 > -----BEGIN PGP SIGNED MESSAGE-----
 > Hash: SHA1
 > 
 > Hi folks,
 > 
 > I am trying to build my own custom Debian kernel package. Problem:
 > If the kernel is supposed to be installed in a temporary package
 > build directory, then it dies with
 > 
 > :
 > :
 > make[1]: Entering directory `/var/tmp/build_kernel/raw-kernel-2.6.37/linux-2.6.37'
 > sh /var/tmp/build_kernel/raw-kernel-2.6.37/linux-2.6.37/arch/x86/boot/install.sh 2.6.37 arch/x86/boot/bzImage \
 >                 System.map "/var/tmp/build_kernel/raw-kernel-2.6.37/debian/raw-kernel-2.6.37/boot"
 > run-parts: executing /etc/kernel/postinst.d/dkms 2.6.37 /var/tmp/build_kernel/raw-kernel-2.6.37/debian/raw-kernel-2.6.37/boot/vmlinuz-2.6.37
 > dkms: running auto installation service for kernel 2.6.37:
 >       nvidia-current (260.19.29)...done.
 >       vboxhost (3.2.12)...done.
 > run-parts: executing /etc/kernel/postinst.d/initramfs-tools 2.6.37 /var/tmp/build_kernel/raw-kernel-2.6.37/debian/raw-kernel-2.6.37/boot/vmlinuz-2.6.37
 > run-parts: executing /etc/kernel/postinst.d/pm-utils 2.6.37 /var/tmp/build_kernel/raw-kernel-2.6.37/debian/raw-kernel-2.6.37/boot/vmlinuz-2.6.37
 > touch: cannot touch `/var/run/do-not-hibernate': Permission denied
 > run-parts: /etc/kernel/postinst.d/pm-utils exited with return code 1
 > make[3]: *** [install] Error 1
 > make[2]: *** [install] Error 2
 > make[1]: *** [sub-make] Error 2
 > make[1]: Leaving directory `/var/tmp/build_kernel/raw-kernel-2.6.37/linux-2.6.37'
 > 
 > 
 > AFAICS this happens because the arch/x86/boot/install.sh script calls
 > /sbin/installkernel, which in turn runs all the scripts delivered
 > by various other packages. This is fine for a regular kernel install
 > as well as for an installation of the final kernel package, but for
 > a non-root install in a package build directory /sbin/installkernel
 > and all the run-parts scripts should not be run. installkernel doesn't
 > even know the redefined install directory.
 > 
 > Would it be possible to avoid that /sbin/installkernel is run by
 > install,sh, e.g. if the install directory has been redefined, or if
 > UID != 0?
 > 
 > 
 > Any helpful comment would be highly appreciated

First, at least on x86, the kernel will look for the 'installkernel'
executable first in your own ~/bin/, so if you have that then it will
override /sbin/installkernel.

Second, you don't have to let the kernel choose; just run
/path/to/myinstallkernel $kernelversion path/to/boot/image System.map
(Disadvantage: path/to/boot/image varies depending on arch.)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: how to avoid that install.sh goes mad, if I am not root?
  2011-01-20 21:47 ` Mikael Pettersson
@ 2011-01-21 12:49   ` WANG Cong
  2011-01-21 22:08     ` Harald Dunkel
  0 siblings, 1 reply; 10+ messages in thread
From: WANG Cong @ 2011-01-21 12:49 UTC (permalink / raw)
  To: linux-kernel

On Thu, 20 Jan 2011 22:47:56 +0100, Mikael Pettersson wrote:
> 
> First, at least on x86, the kernel will look for the 'installkernel'
> executable first in your own ~/bin/, so if you have that then it will
> override /sbin/installkernel.
> 

That still doesn't look like a good solution.

/me is thinking if we should have a new Kconfig for this, e.g.
CONFIG_INSTALL_KERNEL whose default value is "/sbin/installkernel".

Cheers.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: how to avoid that install.sh goes mad, if I am not root?
  2011-01-21 12:49   ` WANG Cong
@ 2011-01-21 22:08     ` Harald Dunkel
  2011-01-24 10:21       ` [Patch] make installkernel configurable from command line (was Re: how to avoid that install.sh goes mad, if I am not root?) Américo Wang
  0 siblings, 1 reply; 10+ messages in thread
From: Harald Dunkel @ 2011-01-21 22:08 UTC (permalink / raw)
  To: linux-kernel

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 01/21/11 13:49, WANG Cong wrote:
> On Thu, 20 Jan 2011 22:47:56 +0100, Mikael Pettersson wrote:
>>
>> First, at least on x86, the kernel will look for the 'installkernel'
>> executable first in your own ~/bin/, so if you have that then it will
>> override /sbin/installkernel.
>>
> 
> That still doesn't look like a good solution.
> 

Same for me.

Obviously running /sbin/installkernel is not reasonable for
UID != 0 (or if $FAKEROOTKEY is set), so I would suggest to
skip /sbin/installkernel and the default Lilo setup in
install.sh for this case.


Only a suggestion, of course.

Regards

Harri
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk06A8oACgkQUTlbRTxpHjeuVwCeJjTgyjcIqvqrUTqxoGgAJngd
iwkAn2U/qiekItqItRBmpeEqk/dH0FKZ
=LgO3
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Patch] make installkernel configurable from command line (was Re: how to avoid that install.sh goes mad, if I am not root?)
  2011-01-21 22:08     ` Harald Dunkel
@ 2011-01-24 10:21       ` Américo Wang
  2011-01-24 11:43         ` Mikael Pettersson
  0 siblings, 1 reply; 10+ messages in thread
From: Américo Wang @ 2011-01-24 10:21 UTC (permalink / raw)
  To: Harald Dunkel; +Cc: linux-kernel, linux-kbuild

On Fri, Jan 21, 2011 at 11:08:10PM +0100, Harald Dunkel wrote:
>-----BEGIN PGP SIGNED MESSAGE-----
>Hash: SHA1
>
>On 01/21/11 13:49, WANG Cong wrote:
>> On Thu, 20 Jan 2011 22:47:56 +0100, Mikael Pettersson wrote:
>>>
>>> First, at least on x86, the kernel will look for the 'installkernel'
>>> executable first in your own ~/bin/, so if you have that then it will
>>> override /sbin/installkernel.
>>>
>> 
>> That still doesn't look like a good solution.
>> 
>
>Same for me.
>
>Obviously running /sbin/installkernel is not reasonable for
>UID != 0 (or if $FAKEROOTKEY is set), so I would suggest to
>skip /sbin/installkernel and the default Lilo setup in
>install.sh for this case.
>

Will the patch below work for you?

With this patch, you should be able to specify your own installkernel
by "make INSTALLKERNEL=/your/installkernel install".

Signed-off-by: WANG Cong <xiyou.wangcong@gmail.com>

---
diff --git a/Makefile b/Makefile
index 1f47495..44abded 100644
--- a/Makefile
+++ b/Makefile
@@ -327,7 +327,7 @@ OBJCOPY		= $(CROSS_COMPILE)objcopy
 OBJDUMP		= $(CROSS_COMPILE)objdump
 AWK		= awk
 GENKSYMS	= scripts/genksyms/genksyms
-INSTALLKERNEL  := installkernel
+INSTALLKERNEL  ?= /sbin/installkernel
 DEPMOD		= /sbin/depmod
 KALLSYMS	= scripts/kallsyms
 PERL		= perl
diff --git a/arch/x86/boot/install.sh b/arch/x86/boot/install.sh
index d13ec1c..c41f2b8 100644
--- a/arch/x86/boot/install.sh
+++ b/arch/x86/boot/install.sh
@@ -33,8 +33,7 @@ verify "$3"
 
 # User may have a custom install script
 
-if [ -x ~/bin/${INSTALLKERNEL} ]; then exec ~/bin/${INSTALLKERNEL} "$@"; fi
-if [ -x /sbin/${INSTALLKERNEL} ]; then exec /sbin/${INSTALLKERNEL} "$@"; fi
+if [ -x "${INSTALLKERNEL}" ]; then exec "${INSTALLKERNEL}" "$@"; fi
 
 # Default install - same as make zlilo
 


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [Patch] make installkernel configurable from command line (was Re: how to avoid that install.sh goes mad, if I am not root?)
  2011-01-24 10:21       ` [Patch] make installkernel configurable from command line (was Re: how to avoid that install.sh goes mad, if I am not root?) Américo Wang
@ 2011-01-24 11:43         ` Mikael Pettersson
  2011-01-25  5:48           ` Américo Wang
  0 siblings, 1 reply; 10+ messages in thread
From: Mikael Pettersson @ 2011-01-24 11:43 UTC (permalink / raw)
  To: Américo Wang; +Cc: Harald Dunkel, linux-kernel, linux-kbuild

=?utf-8?Q?Am=C3=A9rico?= Wang writes:
 > On Fri, Jan 21, 2011 at 11:08:10PM +0100, Harald Dunkel wrote:
 > >-----BEGIN PGP SIGNED MESSAGE-----
 > >Hash: SHA1
 > >
 > >On 01/21/11 13:49, WANG Cong wrote:
 > >> On Thu, 20 Jan 2011 22:47:56 +0100, Mikael Pettersson wrote:
 > >>>
 > >>> First, at least on x86, the kernel will look for the 'installkernel'
 > >>> executable first in your own ~/bin/, so if you have that then it will
 > >>> override /sbin/installkernel.
 > >>>
 > >> 
 > >> That still doesn't look like a good solution.
 > >> 
 > >
 > >Same for me.
 > >
 > >Obviously running /sbin/installkernel is not reasonable for
 > >UID != 0 (or if $FAKEROOTKEY is set), so I would suggest to
 > >skip /sbin/installkernel and the default Lilo setup in
 > >install.sh for this case.
 > >
 > 
 > Will the patch below work for you?
 > 
 > With this patch, you should be able to specify your own installkernel
 > by "make INSTALLKERNEL=/your/installkernel install".
 > 
 > Signed-off-by: WANG Cong <xiyou.wangcong@gmail.com>
 > 
 > ---
 > diff --git a/Makefile b/Makefile
 > index 1f47495..44abded 100644
 > --- a/Makefile
 > +++ b/Makefile
 > @@ -327,7 +327,7 @@ OBJCOPY		= $(CROSS_COMPILE)objcopy
 >  OBJDUMP		= $(CROSS_COMPILE)objdump
 >  AWK		= awk
 >  GENKSYMS	= scripts/genksyms/genksyms
 > -INSTALLKERNEL  := installkernel
 > +INSTALLKERNEL  ?= /sbin/installkernel
 >  DEPMOD		= /sbin/depmod
 >  KALLSYMS	= scripts/kallsyms
 >  PERL		= perl
 > diff --git a/arch/x86/boot/install.sh b/arch/x86/boot/install.sh
 > index d13ec1c..c41f2b8 100644
 > --- a/arch/x86/boot/install.sh
 > +++ b/arch/x86/boot/install.sh
 > @@ -33,8 +33,7 @@ verify "$3"
 >  
 >  # User may have a custom install script
 >  
 > -if [ -x ~/bin/${INSTALLKERNEL} ]; then exec ~/bin/${INSTALLKERNEL} "$@"; fi
 > -if [ -x /sbin/${INSTALLKERNEL} ]; then exec /sbin/${INSTALLKERNEL} "$@"; fi
 > +if [ -x "${INSTALLKERNEL}" ]; then exec "${INSTALLKERNEL}" "$@"; fi

NAK -- this breaks existing setups which rely on /root/bin/installkernel
being picked up automatically.

Can you handle 'make INSTALLKERNEL=...' without breaking that please?

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Patch] make installkernel configurable from command line (was Re: how to avoid that install.sh goes mad, if I am not root?)
  2011-01-24 11:43         ` Mikael Pettersson
@ 2011-01-25  5:48           ` Américo Wang
  2011-01-26 10:02             ` Mikael Pettersson
  0 siblings, 1 reply; 10+ messages in thread
From: Américo Wang @ 2011-01-25  5:48 UTC (permalink / raw)
  To: Mikael Pettersson
  Cc: Américo Wang, Harald Dunkel, linux-kernel, linux-kbuild

On Mon, Jan 24, 2011 at 12:43:14PM +0100, Mikael Pettersson wrote:
>NAK -- this breaks existing setups which rely on /root/bin/installkernel
>being picked up automatically.
>
>Can you handle 'make INSTALLKERNEL=...' without breaking that please?

Yes, here we go.

--------->

Signed-off-by: WANG Cong <xiyou.wangcong@gmail.com>

---
diff --git a/Makefile b/Makefile
index 1f47495..44abded 100644
--- a/Makefile
+++ b/Makefile
@@ -327,7 +327,7 @@ OBJCOPY		= $(CROSS_COMPILE)objcopy
 OBJDUMP		= $(CROSS_COMPILE)objdump
 AWK		= awk
 GENKSYMS	= scripts/genksyms/genksyms
-INSTALLKERNEL  := installkernel
+INSTALLKERNEL  ?= /sbin/installkernel
 DEPMOD		= /sbin/depmod
 KALLSYMS	= scripts/kallsyms
 PERL		= perl
diff --git a/arch/x86/boot/install.sh b/arch/x86/boot/install.sh
index d13ec1c..c8c9a92 100644
--- a/arch/x86/boot/install.sh
+++ b/arch/x86/boot/install.sh
@@ -33,8 +33,8 @@ verify "$3"
 
 # User may have a custom install script
 
-if [ -x ~/bin/${INSTALLKERNEL} ]; then exec ~/bin/${INSTALLKERNEL} "$@"; fi
-if [ -x /sbin/${INSTALLKERNEL} ]; then exec /sbin/${INSTALLKERNEL} "$@"; fi
+if [ -x ~/bin/installkernel ]; then exec ~/bin/installkernel "$@"; fi
+if [ -x "${INSTALLKERNEL}" ]; then exec "${INSTALLKERNEL}" "$@"; fi
 
 # Default install - same as make zlilo
 

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [Patch] make installkernel configurable from command line (was Re: how to avoid that install.sh goes mad, if I am not root?)
  2011-01-25  5:48           ` Américo Wang
@ 2011-01-26 10:02             ` Mikael Pettersson
  2011-01-28  7:58                 ` WANG Cong
  0 siblings, 1 reply; 10+ messages in thread
From: Mikael Pettersson @ 2011-01-26 10:02 UTC (permalink / raw)
  To: Américo Wang
  Cc: Mikael Pettersson, Harald Dunkel, linux-kernel, linux-kbuild

[cc: linux-kbuild's address corrected]

=?utf-8?Q?Am=C3=A9rico?= Wang writes:
 > On Mon, Jan 24, 2011 at 12:43:14PM +0100, Mikael Pettersson wrote:
 > >NAK -- this breaks existing setups which rely on /root/bin/installkernel
 > >being picked up automatically.
 > >
 > >Can you handle 'make INSTALLKERNEL=...' without breaking that please?
 > 
 > Yes, here we go.
 > 
 > --------->
 > 
 > Signed-off-by: WANG Cong <xiyou.wangcong@gmail.com>
 > 
 > ---
 > diff --git a/Makefile b/Makefile
 > index 1f47495..44abded 100644
 > --- a/Makefile
 > +++ b/Makefile
 > @@ -327,7 +327,7 @@ OBJCOPY		= $(CROSS_COMPILE)objcopy
 >  OBJDUMP		= $(CROSS_COMPILE)objdump
 >  AWK		= awk
 >  GENKSYMS	= scripts/genksyms/genksyms
 > -INSTALLKERNEL  := installkernel
 > +INSTALLKERNEL  ?= /sbin/installkernel
 >  DEPMOD		= /sbin/depmod
 >  KALLSYMS	= scripts/kallsyms
 >  PERL		= perl
 > diff --git a/arch/x86/boot/install.sh b/arch/x86/boot/install.sh
 > index d13ec1c..c8c9a92 100644
 > --- a/arch/x86/boot/install.sh
 > +++ b/arch/x86/boot/install.sh
 > @@ -33,8 +33,8 @@ verify "$3"
 >  
 >  # User may have a custom install script
 >  
 > -if [ -x ~/bin/${INSTALLKERNEL} ]; then exec ~/bin/${INSTALLKERNEL} "$@"; fi
 > -if [ -x /sbin/${INSTALLKERNEL} ]; then exec /sbin/${INSTALLKERNEL} "$@"; fi
 > +if [ -x ~/bin/installkernel ]; then exec ~/bin/installkernel "$@"; fi
 > +if [ -x "${INSTALLKERNEL}" ]; then exec "${INSTALLKERNEL}" "$@"; fi
 >  
 >  # Default install - same as make zlilo

Tested.  This works as far as not overriding root's ~/bin/installkernel
if it exists, but it fails to give precedence to an explicit command-line
INSTALLKERNEL=... over the built-in fallbacks.  I don't see an easy way
to fix that without first consolidating all archs' INSTALLKERNEL handling
into the top-level Makefile.

Not using make install and just invoking your own install script directly
works, so I'm not sure this is worth the trouble (unless you can unify all
archs' INSTALLKERNEL handling as a side-effect / cleanup).

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Patch] make installkernel configurable from command line (was Re: how to avoid that install.sh goes mad, if I am not root?)
  2011-01-26 10:02             ` Mikael Pettersson
@ 2011-01-28  7:58                 ` WANG Cong
  0 siblings, 0 replies; 10+ messages in thread
From: WANG Cong @ 2011-01-28  7:58 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-kbuild

On Wed, 26 Jan 2011 11:02:11 +0100, Mikael Pettersson wrote:
> 
> Tested.  This works as far as not overriding root's ~/bin/installkernel
> if it exists, but it fails to give precedence to an explicit
> command-line INSTALLKERNEL=... over the built-in fallbacks.  I don't see
> an easy way to fix that without first consolidating all archs'
> INSTALLKERNEL handling into the top-level Makefile.


Yes, exactly, I can expect this.

> 
> Not using make install and just invoking your own install script
> directly works, so I'm not sure this is worth the trouble (unless you
> can unify all archs' INSTALLKERNEL handling as a side-effect / cleanup).

Agreed, I will have a try.

Thanks!


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Patch] make installkernel configurable from command line (was Re: how to avoid that install.sh goes mad, if I am not root?)
@ 2011-01-28  7:58                 ` WANG Cong
  0 siblings, 0 replies; 10+ messages in thread
From: WANG Cong @ 2011-01-28  7:58 UTC (permalink / raw)
  To: linux-kbuild; +Cc: linux-kernel

On Wed, 26 Jan 2011 11:02:11 +0100, Mikael Pettersson wrote:
> 
> Tested.  This works as far as not overriding root's ~/bin/installkernel
> if it exists, but it fails to give precedence to an explicit
> command-line INSTALLKERNEL=... over the built-in fallbacks.  I don't see
> an easy way to fix that without first consolidating all archs'
> INSTALLKERNEL handling into the top-level Makefile.


Yes, exactly, I can expect this.

> 
> Not using make install and just invoking your own install script
> directly works, so I'm not sure this is worth the trouble (unless you
> can unify all archs' INSTALLKERNEL handling as a side-effect / cleanup).

Agreed, I will have a try.

Thanks!


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2011-01-28  8:45 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-20 19:16 how to avoid that install.sh goes mad, if I am not root? Harald Dunkel
2011-01-20 21:47 ` Mikael Pettersson
2011-01-21 12:49   ` WANG Cong
2011-01-21 22:08     ` Harald Dunkel
2011-01-24 10:21       ` [Patch] make installkernel configurable from command line (was Re: how to avoid that install.sh goes mad, if I am not root?) Américo Wang
2011-01-24 11:43         ` Mikael Pettersson
2011-01-25  5:48           ` Américo Wang
2011-01-26 10:02             ` Mikael Pettersson
2011-01-28  7:58               ` WANG Cong
2011-01-28  7:58                 ` WANG Cong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.