All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] liblxc: lxc-debian expects missing directories
@ 2009-02-05  9:05 Matt Helsley
  2009-02-05  9:20 ` Daniel Lezcano
  0 siblings, 1 reply; 5+ messages in thread
From: Matt Helsley @ 2009-02-05  9:05 UTC (permalink / raw)
  To: Daniel Lezcano; +Cc: Containers

lxc-debian fails unless the directories a given rootfs needs already
exist. To fix this without relying on any particular function call order
we can do: mkdir -p `dirname PATH/TO/FILE`
before actually making the file.

Signed-off-by: Matt Helsley <matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
---
 scripts/lxc-debian.in |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Index: lxc/scripts/lxc-debian.in
===================================================================
--- lxc.orig/scripts/lxc-debian.in
+++ lxc/scripts/lxc-debian.in
@@ -24,13 +24,14 @@ SSHD_CONFIG="/etc/ssh/sshd_config"
 # custom selinux
 
 write_debian_selinux() {
-    mkdir $ROOTFS/selinux
+    mkdir -p $ROOTFS/selinux
     echo 0 > $ROOTFS/selinux/enforce
 }
 
 # custom fstab
 
 write_debian_fstab() {
+mkdir -p `dirname $ROOTFS/$FSTAB`
 cat <<EOF > $ROOTFS/$FSTAB
 tmpfs  /dev/shm   tmpfs  defaults  0 0
 EOF
@@ -39,6 +40,7 @@ EOF
 # custom inittab
 
 write_debian_inittab() {
+mkdir -p `dirname $ROOTFS/$INITTAB`
 cat <<EOF > $ROOTFS/$INITTAB
 id:3:initdefault:
 si::sysinit:/etc/init.d/rcS
@@ -62,6 +64,7 @@ EOF
 # custom network configuration
 
 write_debian_network() {
+mkdir -p `dirname $ROOTFS/$INTERFACES`
 cat <<EOF > $ROOTFS/$INTERFACES
 auto eth0 lo
 iface eth0 inet static
@@ -76,6 +79,7 @@ EOF
 # custom hostname
 
 write_debian_hostname() {
+mkdir -p `dirname $ROOTFS/$HOSTNAME`
 cat <<EOF > $ROOTFS/$HOSTNAME
 $UTSNAME
 EOF
@@ -84,6 +88,7 @@ EOF
 # custom sshd configuration file
 
 write_debian_sshd_config() {
+mkdir -p `dirname $ROOTFS/$SSHD_CONFIG`
 cat <<EOF > $ROOTFS/$SSHD_CONFIG
 Port 22
 Protocol 2

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

* Re: [PATCH] liblxc: lxc-debian expects missing directories
  2009-02-05  9:05 [PATCH] liblxc: lxc-debian expects missing directories Matt Helsley
@ 2009-02-05  9:20 ` Daniel Lezcano
       [not found]   ` <498AAF77.20906-GANU6spQydw@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Lezcano @ 2009-02-05  9:20 UTC (permalink / raw)
  To: Matt Helsley; +Cc: Containers

Matt Helsley wrote:
> lxc-debian fails unless the directories a given rootfs needs already
> exist. To fix this without relying on any particular function call order
> we can do: mkdir -p `dirname PATH/TO/FILE`
> before actually making the file.
>
> Signed-off-by: Matt Helsley <matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
> ---
>   
Do you have an example on how that happens ?
When the script is called for creation, the rootfs is created with 
debootstrap, making sure the expected directories are there, no ?
It is not a big deal to make sure the directories are there, but I would 
like to understand :)

>  scripts/lxc-debian.in |    7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> Index: lxc/scripts/lxc-debian.in
> ===================================================================
> --- lxc.orig/scripts/lxc-debian.in
> +++ lxc/scripts/lxc-debian.in
> @@ -24,13 +24,14 @@ SSHD_CONFIG="/etc/ssh/sshd_config"
>  # custom selinux
>  
>  write_debian_selinux() {
> -    mkdir $ROOTFS/selinux
> +    mkdir -p $ROOTFS/selinux
>      echo 0 > $ROOTFS/selinux/enforce
>  }
>  
>  # custom fstab
>  
>  write_debian_fstab() {
> +mkdir -p `dirname $ROOTFS/$FSTAB`
>  cat <<EOF > $ROOTFS/$FSTAB
>  tmpfs  /dev/shm   tmpfs  defaults  0 0
>  EOF
> @@ -39,6 +40,7 @@ EOF
>  # custom inittab
>  
>  write_debian_inittab() {
> +mkdir -p `dirname $ROOTFS/$INITTAB`
>  cat <<EOF > $ROOTFS/$INITTAB
>  id:3:initdefault:
>  si::sysinit:/etc/init.d/rcS
> @@ -62,6 +64,7 @@ EOF
>  # custom network configuration
>  
>  write_debian_network() {
> +mkdir -p `dirname $ROOTFS/$INTERFACES`
>  cat <<EOF > $ROOTFS/$INTERFACES
>  auto eth0 lo
>  iface eth0 inet static
> @@ -76,6 +79,7 @@ EOF
>  # custom hostname
>  
>  write_debian_hostname() {
> +mkdir -p `dirname $ROOTFS/$HOSTNAME`
>  cat <<EOF > $ROOTFS/$HOSTNAME
>  $UTSNAME
>  EOF
> @@ -84,6 +88,7 @@ EOF
>  # custom sshd configuration file
>  
>  write_debian_sshd_config() {
> +mkdir -p `dirname $ROOTFS/$SSHD_CONFIG`
>  cat <<EOF > $ROOTFS/$SSHD_CONFIG
>  Port 22
>  Protocol 2
>
>
>
>
>   

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

* Re: [PATCH] liblxc: lxc-debian expects missing directories
       [not found]   ` <498AAF77.20906-GANU6spQydw@public.gmane.org>
@ 2009-02-05  9:29     ` Matt Helsley
  2009-02-05  9:59       ` Matt Helsley
  0 siblings, 1 reply; 5+ messages in thread
From: Matt Helsley @ 2009-02-05  9:29 UTC (permalink / raw)
  To: Daniel Lezcano; +Cc: Containers

On Thu, 2009-02-05 at 10:20 +0100, Daniel Lezcano wrote:
> Matt Helsley wrote:
> > lxc-debian fails unless the directories a given rootfs needs already
> > exist. To fix this without relying on any particular function call order
> > we can do: mkdir -p `dirname PATH/TO/FILE`
> > before actually making the file.
> >
> > Signed-off-by: Matt Helsley <matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
> > ---
> >   
> Do you have an example on how that happens ?

Configure lxc with a non-/ prefix:

./configure --prefix=/usr

Cheers,
	-Matt

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

* Re: [PATCH] liblxc: lxc-debian expects missing directories
  2009-02-05  9:29     ` Matt Helsley
@ 2009-02-05  9:59       ` Matt Helsley
  2009-02-05 10:21         ` Daniel Lezcano
  0 siblings, 1 reply; 5+ messages in thread
From: Matt Helsley @ 2009-02-05  9:59 UTC (permalink / raw)
  To: Daniel Lezcano; +Cc: Containers

On Thu, 2009-02-05 at 01:29 -0800, Matt Helsley wrote:
> On Thu, 2009-02-05 at 10:20 +0100, Daniel Lezcano wrote:
> > Matt Helsley wrote:
> > > lxc-debian fails unless the directories a given rootfs needs already
> > > exist. To fix this without relying on any particular function call order
> > > we can do: mkdir -p `dirname PATH/TO/FILE`
> > > before actually making the file.
> > >
> > > Signed-off-by: Matt Helsley <matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
> > > ---
> > >   
> > Do you have an example on how that happens ?
> 
> Configure lxc with a non-/ prefix:
> 
> ./configure --prefix=/usr

This explanation is wrong, sorry.

The patch isn't necessary -- take a look at the one that handles
debootstrap interruption/failure. Basically debootstrap would fail
(apache doesn't exist in lenny I found out) and I'd have to go cleaning
up lxc-debian directories by hand before I could retry. If I missed
something one time then then lxc behaved oddly. This got me past some of
that odd behavior (only to fail later of course).

Cheers,
	-Matt

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

* Re: [PATCH] liblxc: lxc-debian expects missing directories
  2009-02-05  9:59       ` Matt Helsley
@ 2009-02-05 10:21         ` Daniel Lezcano
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Lezcano @ 2009-02-05 10:21 UTC (permalink / raw)
  To: Matt Helsley; +Cc: Containers

Matt Helsley wrote:
> On Thu, 2009-02-05 at 01:29 -0800, Matt Helsley wrote:
>   
>> On Thu, 2009-02-05 at 10:20 +0100, Daniel Lezcano wrote:
>>     
>>> Matt Helsley wrote:
>>>       
>>>> lxc-debian fails unless the directories a given rootfs needs already
>>>> exist. To fix this without relying on any particular function call order
>>>> we can do: mkdir -p `dirname PATH/TO/FILE`
>>>> before actually making the file.
>>>>
>>>> Signed-off-by: Matt Helsley <matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
>>>> ---
>>>>   
>>>>         
>>> Do you have an example on how that happens ?
>>>       
>> Configure lxc with a non-/ prefix:
>>
>> ./configure --prefix=/usr
>>     
>
> This explanation is wrong, sorry.
>
> The patch isn't necessary -- take a look at the one that handles
> debootstrap interruption/failure. Basically debootstrap would fail
> (apache doesn't exist in lenny I found out) and I'd have to go cleaning
> up lxc-debian directories by hand before I could retry. If I missed
> something one time then then lxc behaved oddly. This got me past some of
> that odd behavior (only to fail later of course).
>   
Ok, I understand why you tried to force the directory creation.
I will not apply this one, the next patch you sent with the partial 
debootstrap will fix this.

Thanks Matt.

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

end of thread, other threads:[~2009-02-05 10:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-05  9:05 [PATCH] liblxc: lxc-debian expects missing directories Matt Helsley
2009-02-05  9:20 ` Daniel Lezcano
     [not found]   ` <498AAF77.20906-GANU6spQydw@public.gmane.org>
2009-02-05  9:29     ` Matt Helsley
2009-02-05  9:59       ` Matt Helsley
2009-02-05 10:21         ` Daniel Lezcano

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.