diff mbox

[v2,25/25] build: do not create directories at configure time

Message ID 4FCF1BCC.1090208@codemonkey.ws
State New
Headers show

Commit Message

Anthony Liguori June 6, 2012, 8:58 a.m. UTC
This results in failures to create symlinks in a new build directory.  The 
following patch seems to resolve it though.

Regards,

Anthony Liguori

On 06/06/2012 02:36 PM, Paolo Bonzini wrote:
> Signed-off-by: Paolo Bonzini<pbonzini@redhat.com>
> ---
>   configure |   35 ++---------------------------------
>   rules.mak |    1 +
>   2 files changed, 3 insertions(+), 33 deletions(-)
>
> diff --git a/configure b/configure
> index 301b574..07e3ff1 100755
> --- a/configure
> +++ b/configure
> @@ -3672,26 +3672,6 @@ if [ "$TARGET_BASE_ARCH" = "" ]; then
>     TARGET_BASE_ARCH=$TARGET_ARCH
>   fi
>
> -mkdir -p $target_dir/fpu
> -mkdir -p $target_dir/tcg
> -mkdir -p $target_dir/9pfs
> -mkdir -p $target_dir/hw
> -mkdir -p $target_dir/hw/ide
> -mkdir -p $target_dir/hw/usb
> -mkdir -p $target_dir/hw/9pfs
> -mkdir -p $target_dir/hw/kvm
> -mkdir -p $target_dir/hw/$TARGET_ARCH
> -mkdir -p $target_dir/hw/$TARGET_BASE_ARCH
> -mkdir -p $target_dir/target-$TARGET_BASE_ARCH
> -if test "$target_linux_user" = yes; then
> -  mkdir -p $target_dir/linux-user
> -fi
> -if test "$target_bsd_user" = yes; then
> -  mkdir -p $target_dir/bsd-user
> -fi
> -if test "$target" = "arm-linux-user" -o "$target" = "armeb-linux-user" -o "$target" = "arm-bsd-user" -o "$target" = "armeb-bsd-user" ; then
> -  mkdir -p $target_dir/linux-user/arm/nwfpe
> -fi
>   symlink "$source_path/Makefile.target" "$target_dir/Makefile"
>
>
> @@ -3948,12 +3928,9 @@ done # for target in $targets
>
>   # build tree in object directory in case the source is not in the current directory
>   DIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32"
> -DIRS="$DIRS slirp audio block net pc-bios/optionrom"
> -DIRS="$DIRS pc-bios/spapr-rtas"
> +DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas"
>   DIRS="$DIRS roms/seabios roms/vgabios"
> -DIRS="$DIRS fsdev ui hw hw/usb"
> -DIRS="$DIRS qapi qapi-generated"
> -DIRS="$DIRS qga trace qom"
> +DIRS="$DIRS qapi-generated"
>   DIRS="$DIRS libcacard libcacard/libcacard libcacard/trace"
>   FILES="Makefile tests/tcg/Makefile qdict-test-data.txt"
>   FILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
> @@ -3992,19 +3969,11 @@ done
>
>   for hwlib in 32 64; do
>     d=libhw$hwlib
> -  mkdir -p $d
> -  mkdir -p $d/hw
> -  mkdir -p $d/hw/ide
> -  mkdir -p $d/hw/usb
>     symlink "$source_path/Makefile.hw" "$d/Makefile"
> -  mkdir -p $d/hw/9pfs
>     echo "QEMU_CFLAGS+=-DTARGET_PHYS_ADDR_BITS=$hwlib">  $d/config.mak
>   done
>
>   d=libuser
> -mkdir -p $d
> -mkdir -p $d/trace
> -mkdir -p $d/qom
>   symlink "$source_path/Makefile.user" "$d/Makefile"
>
>   if test "$docs" = "yes" ; then
> diff --git a/rules.mak b/rules.mak
> index f65283c..4bc5e52 100644
> --- a/rules.mak
> +++ b/rules.mak
> @@ -111,4 +111,5 @@ endef
>   define unnest-vars
>   $(call unnest-vars-1)
>   $(foreach var,$(nested-vars),$(eval $(var) := $(filter-out %/, $($(var)))))
> +$(shell mkdir -p $(sort $(foreach var,$(nested-vars),$(dir $($(var))))))
>   endef

Comments

Paolo Bonzini June 6, 2012, 11:54 a.m. UTC | #1
> From e0e6e5b689cbcb782bca8f158fad89b3389e9e11 Mon Sep 17 00:00:00 2001
> From: Anthony Liguori <aliguori@us.ibm.com>
> Date: Wed, 6 Jun 2012 16:57:00 +0800
> Subject: [PATCH] configure: ensure directory exists when creating symlink
> 
> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
> ---
>  configure |    3 +--
>  1 files changed, 1 insertions(+), 2 deletions(-)
> 
> diff --git a/configure b/configure
> index 07e3ff1..4a7f027 100755
> --- a/configure
> +++ b/configure
> @@ -42,6 +42,7 @@ compile_prog() {
>  # symbolically link $1 to $2.  Portable version of "ln -sf".
>  symlink() {
>    rm -rf "$2"
> +  mkdir -p `dirname $2`

Please leave the argument quoted, like

  dir=`dirname "$2`
  mkdir -p "$dir"

Otherwise looks good.  Do we need a v3?  This can just be committed
before 25/25 or even before all my patches, and that would be just what
I send.

Paolo

>    ln -s "$1" "$2"
>  }
>  
> @@ -3454,14 +3455,12 @@ if test -f ${config_host_ld}~ ; then
>  fi
>  
>  for d in libdis libdis-user; do
> -    mkdir -p $d
>      symlink "$source_path/Makefile.dis" "$d/Makefile"
>      echo > $d/config.mak
>  done
>  
>  # use included Linux headers
>  if test "$linux" = "yes" ; then
> -  mkdir -p linux-headers
>    case "$cpu" in
>    i386|x86_64)
>      symlink "$source_path/linux-headers/asm-x86" linux-headers/asm
> -- 1.7.5.4
Peter Maydell June 6, 2012, 12:03 p.m. UTC | #2
On 6 June 2012 12:54, Paolo Bonzini <pbonzini@redhat.com> wrote:
>> From: Anthony Liguori <aliguori@us.ibm.com>
>> +  mkdir -p `dirname $2`
>
> Please leave the argument quoted, like
>
>  dir=`dirname "$2`

(missing ", obviously)

>  mkdir -p "$dir"

Can we use
 mkdir -p "$(dirname "$2")"

or are we still trying to be compatible with some non-POSIX
shell from the dawn of time?

-- PMM
Paolo Bonzini June 6, 2012, 12:16 p.m. UTC | #3
Il 06/06/2012 14:03, Peter Maydell ha scritto:
> Can we use
>  mkdir -p "$(dirname "$2")"
> 
> or are we still trying to be compatible with some non-POSIX
> shell from the dawn of time?

Looks like we can, there are other occurrences of $() in configure.

Paolo
Anthony Liguori June 7, 2012, 3:15 a.m. UTC | #4
On 06/06/2012 08:16 PM, Paolo Bonzini wrote:
> Il 06/06/2012 14:03, Peter Maydell ha scritto:
>> Can we use
>>   mkdir -p "$(dirname "$2")"
>>
>> or are we still trying to be compatible with some non-POSIX
>> shell from the dawn of time?
>
> Looks like we can, there are other occurrences of $() in configure.

I saw that too, but I thought $() was a bash-ism.

Regards,

Anthony Liguori

>
> Paolo
>
>
Anthony Liguori June 7, 2012, 3:16 a.m. UTC | #5
On 06/06/2012 07:54 PM, Paolo Bonzini wrote:
>>  From e0e6e5b689cbcb782bca8f158fad89b3389e9e11 Mon Sep 17 00:00:00 2001
>> From: Anthony Liguori<aliguori@us.ibm.com>
>> Date: Wed, 6 Jun 2012 16:57:00 +0800
>> Subject: [PATCH] configure: ensure directory exists when creating symlink
>>
>> Signed-off-by: Anthony Liguori<aliguori@us.ibm.com>
>> ---
>>   configure |    3 +--
>>   1 files changed, 1 insertions(+), 2 deletions(-)
>>
>> diff --git a/configure b/configure
>> index 07e3ff1..4a7f027 100755
>> --- a/configure
>> +++ b/configure
>> @@ -42,6 +42,7 @@ compile_prog() {
>>   # symbolically link $1 to $2.  Portable version of "ln -sf".
>>   symlink() {
>>     rm -rf "$2"
>> +  mkdir -p `dirname $2`
>
> Please leave the argument quoted, like
>
>    dir=`dirname "$2`
>    mkdir -p "$dir"
>
> Otherwise looks good.  Do we need a v3?  This can just be committed
> before 25/25 or even before all my patches, and that would be just what
> I send.

Unfortunately, this conflicts pretty badly with Andreas' QOM CPU series.  Could 
you rebase and send out a v3?

Regards,

Anthony Liguori

>
> Paolo
>
>>     ln -s "$1" "$2"
>>   }
>>
>> @@ -3454,14 +3455,12 @@ if test -f ${config_host_ld}~ ; then
>>   fi
>>
>>   for d in libdis libdis-user; do
>> -    mkdir -p $d
>>       symlink "$source_path/Makefile.dis" "$d/Makefile"
>>       echo>  $d/config.mak
>>   done
>>
>>   # use included Linux headers
>>   if test "$linux" = "yes" ; then
>> -  mkdir -p linux-headers
>>     case "$cpu" in
>>     i386|x86_64)
>>       symlink "$source_path/linux-headers/asm-x86" linux-headers/asm
>> -- 1.7.5.4
>
>
Eric Blake June 7, 2012, 3:21 a.m. UTC | #6
On 06/06/2012 09:15 PM, Anthony Liguori wrote:
> On 06/06/2012 08:16 PM, Paolo Bonzini wrote:
>> Il 06/06/2012 14:03, Peter Maydell ha scritto:
>>> Can we use
>>>   mkdir -p "$(dirname "$2")"
>>>
>>> or are we still trying to be compatible with some non-POSIX
>>> shell from the dawn of time?
>>
>> Looks like we can, there are other occurrences of $() in configure.
> 
> I saw that too, but I thought $() was a bash-ism.

$() is required by POSIX.  The problem is that Solaris' /bin/sh does not
understand $(), since it is not a POSIX shell.

If you take care to sanitize shell execution into a sane shell (yes, it
is possible to write configure scripts that re-execute themselves under
a better shell than /bin/sh), then using $() can be one of the decision
points on whether a better shell has been found.
Paolo Bonzini June 7, 2012, 5:26 a.m. UTC | #7
Il 07/06/2012 05:16, Anthony Liguori ha scritto:
> On 06/06/2012 07:54 PM, Paolo Bonzini wrote:
>>>  From e0e6e5b689cbcb782bca8f158fad89b3389e9e11 Mon Sep 17 00:00:00 2001
>>> From: Anthony Liguori<aliguori@us.ibm.com>
>>> Date: Wed, 6 Jun 2012 16:57:00 +0800
>>> Subject: [PATCH] configure: ensure directory exists when creating
>>> symlink
>>>
>>> Signed-off-by: Anthony Liguori<aliguori@us.ibm.com>
>>> ---
>>>   configure |    3 +--
>>>   1 files changed, 1 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/configure b/configure
>>> index 07e3ff1..4a7f027 100755
>>> --- a/configure
>>> +++ b/configure
>>> @@ -42,6 +42,7 @@ compile_prog() {
>>>   # symbolically link $1 to $2.  Portable version of "ln -sf".
>>>   symlink() {
>>>     rm -rf "$2"
>>> +  mkdir -p `dirname $2`
>>
>> Please leave the argument quoted, like
>>
>>    dir=`dirname "$2`
>>    mkdir -p "$dir"
>>
>> Otherwise looks good.  Do we need a v3?  This can just be committed
>> before 25/25 or even before all my patches, and that would be just what
>> I send.
> 
> Unfortunately, this conflicts pretty badly with Andreas' QOM CPU
> series.  Could you rebase and send out a v3?

No, it's the dumping series from Luiz.  I'll send a v3 as a pull request.

Paolo
Anthony Liguori June 7, 2012, 5:28 a.m. UTC | #8
On 06/07/2012 01:26 PM, Paolo Bonzini wrote:
> Il 07/06/2012 05:16, Anthony Liguori ha scritto:
>> On 06/06/2012 07:54 PM, Paolo Bonzini wrote:
>>>>    From e0e6e5b689cbcb782bca8f158fad89b3389e9e11 Mon Sep 17 00:00:00 2001
>>>> From: Anthony Liguori<aliguori@us.ibm.com>
>>>> Date: Wed, 6 Jun 2012 16:57:00 +0800
>>>> Subject: [PATCH] configure: ensure directory exists when creating
>>>> symlink
>>>>
>>>> Signed-off-by: Anthony Liguori<aliguori@us.ibm.com>
>>>> ---
>>>>    configure |    3 +--
>>>>    1 files changed, 1 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/configure b/configure
>>>> index 07e3ff1..4a7f027 100755
>>>> --- a/configure
>>>> +++ b/configure
>>>> @@ -42,6 +42,7 @@ compile_prog() {
>>>>    # symbolically link $1 to $2.  Portable version of "ln -sf".
>>>>    symlink() {
>>>>      rm -rf "$2"
>>>> +  mkdir -p `dirname $2`
>>>
>>> Please leave the argument quoted, like
>>>
>>>     dir=`dirname "$2`
>>>     mkdir -p "$dir"
>>>
>>> Otherwise looks good.  Do we need a v3?  This can just be committed
>>> before 25/25 or even before all my patches, and that would be just what
>>> I send.
>>
>> Unfortunately, this conflicts pretty badly with Andreas' QOM CPU
>> series.  Could you rebase and send out a v3?
>
> No, it's the dumping series from Luiz.  I'll send a v3 as a pull request.

Okay, thanks.

Regards,

Anthony Liguori

>
> Paolo
>
diff mbox

Patch

From e0e6e5b689cbcb782bca8f158fad89b3389e9e11 Mon Sep 17 00:00:00 2001
From: Anthony Liguori <aliguori@us.ibm.com>
Date: Wed, 6 Jun 2012 16:57:00 +0800
Subject: [PATCH] configure: ensure directory exists when creating symlink

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
 configure |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 07e3ff1..4a7f027 100755
--- a/configure
+++ b/configure
@@ -42,6 +42,7 @@  compile_prog() {
 # symbolically link $1 to $2.  Portable version of "ln -sf".
 symlink() {
   rm -rf "$2"
+  mkdir -p `dirname $2`
   ln -s "$1" "$2"
 }
 
@@ -3454,14 +3455,12 @@  if test -f ${config_host_ld}~ ; then
 fi
 
 for d in libdis libdis-user; do
-    mkdir -p $d
     symlink "$source_path/Makefile.dis" "$d/Makefile"
     echo > $d/config.mak
 done
 
 # use included Linux headers
 if test "$linux" = "yes" ; then
-  mkdir -p linux-headers
   case "$cpu" in
   i386|x86_64)
     symlink "$source_path/linux-headers/asm-x86" linux-headers/asm
-- 
1.7.5.4