Bug 473

Summary: memstat_0.5.tar.gz has install with -D and that fails "make" (last buildroot git)
Product: buildroot Reporter: Etienne Lorrain <etienne_lorrain>
Component: OtherAssignee: unassigned
Status: RESOLVED FIXED    
Severity: minor CC: buildroot, jacmet
Priority: P5    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Host: i386-pc-linux-gnu Target: powerpc-unknown-linux-gnu
Build: i386-pc-linux-gnu
Attachments: main config file

Description Etienne Lorrain 2009-07-20 13:53:23 UTC
make
...
gzip -d -c /home/elorrain/buildroot/dl/memstat_0.5.tar.gz | tar -C /home/elorrain/buildroot/build_powerpc   -xf -
toolchain/patch-kernel.sh /home/elorrain/buildroot/build_powerpc/memstat-0.5 package/memstat/ memstat-0.5\*.patch
touch /home/elorrain/buildroot/build_powerpc/memstat-0.5/.unpacked
touch /home/elorrain/buildroot/build_powerpc/memstat-0.5/.configured
/home/elorrain/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -pipe -Os  -I/home/elorrain/buildroot/build_powerpc/staging_dir/usr/include -I/home/elorrain/buildroot/build_powerpc/staging_dir/include --sysroot=/home/elorrain/buildroot/build_powerpc/staging_dir/ -isysroot /home/elorrain/buildroot/build_powerpc/staging_dir -mtune=440fp -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -L/home/elorrain/buildroot/build_powerpc/staging_dir/lib -L/home/elorrain/buildroot/build_powerpc/staging_dir/usr/lib --sysroot=/home/elorrain/buildroot/build_powerpc/staging_dir/ /home/elorrain/buildroot/build_powerpc/memstat-0.5/memstat.c -o /home/elorrain/buildroot/build_powerpc/memstat-0.5/memstat
[ -e /home/elorrain/buildroot/project_build_powerpc/Eqam4G/root/etc/memstat.conf ] || \
        /usr/bin/install -m 0644 -D /home/elorrain/buildroot/build_powerpc/memstat-0.5/memstat.conf /home/elorrain/buildroot/project_build_powerpc/Eqam4G/root/etc
/usr/bin/install: cannot overwrite directory `/home/elorrain/buildroot/project_build_powerpc/Eqam4G/root/etc' with non-directory
make: *** [/home/elorrain/buildroot/project_build_powerpc/Eqam4G/root/usr/bin/memstat] Error 1

[elorrain@cobra buildroot]$ /usr/bin/install -m 0644  /home/elorrain/buildroot/build_powerpc/memstat-0.5/memstat.conf /home/elorrain/buildroot/project_build_powerpc/Eqam4G/root/etc/
[elorrain@cobra buildroot]$
Comment 1 Thomas Petazzoni 2009-07-20 14:52:43 UTC
I'm sorry, but I'm not able to reproduce here (with a cross-compilation to ARM, but the problem isn't architecture-related apparently).

Could you attach your .config ?
Comment 2 Etienne Lorrain 2009-07-20 16:25:55 UTC
Created attachment 485 [details]
main config file

 I attach my .comfig, but the problem seems more like that directory:
/home/elorrain/buildroot/project_build_powerpc/Eqam4G/root/etc
 should exist before trying to install.
 Isn't that the target device /etc ? (just begining with buildroot...)
Comment 3 Thomas Petazzoni 2009-07-20 17:03:13 UTC
Indeed this directory is $(TARGET_DIR), which contains the filesystem as it will be on the target (with a few differences, like missing device files, not created in this directory since device files can only be created by the root user).

The etc/ directory in $(TARGET_DIR) is supposed to be created because the target root filesystem is initially filled with the contents of target/generic/target_skeleton/.

So, not sure what's happening in your case. Nothing looks odd in your .config. Can you run a full build from scratch, and send the corresponding log ?

Something like :

rm -rf build_powerpc
rm -rf toolchain_build_powerpc
rm -rf project_build_powerpc
rm -rf binaries
make 2>&1 | tee /tmp/buildroot.log

and send us the buildroot.log file.
Comment 4 Peter Korsgaard 2009-07-20 20:28:08 UTC
(In reply to comment #0)
>         /usr/bin/install -m 0644 -D
> /home/elorrain/buildroot/build_powerpc/memstat-0.5/memstat.conf
> /home/elorrain/buildroot/project_build_powerpc/Eqam4G/root/etc
> /usr/bin/install: cannot overwrite directory
> `/home/elorrain/buildroot/project_build_powerpc/Eqam4G/root/etc' with
> non-directory

So your host install program doesn't seem to like doing install -D <file> <dir> - What version/distribution are you using?

On my Debian machine it works:

mkdir /tmp/blah
touch /tmp/blih
install -m 0644 -D /tmp/blih /tmp/blah
ls -lah /tmp/blih
-rw-r--r-- 1 peko peko 0 2009-07-20 22:24 /tmp/blih
install --version
install (GNU coreutils) 7.4
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by David MacKenzie.
Comment 5 Etienne Lorrain 2009-07-21 09:59:15 UTC
 I do not know why, but it is entirely reproduceable, "install" needs the
target filename and not only the directory where to put the source
filename. This is on a quite old centos machine, I do not have the root password.
 I can add the full log if you want, but this screen dump should describe
the problem:


gzip -d -c /home/elorrain/buildroot/dl/memstat_0.5.tar.gz | tar -C /home/elorrain/buildroot/build_powerpc   -xf -
toolchain/patch-kernel.sh /home/elorrain/buildroot/build_powerpc/memstat-0.5 package/memstat/ memstat-0.5\*.patch
touch /home/elorrain/buildroot/build_powerpc/memstat-0.5/.unpacked
touch /home/elorrain/buildroot/build_powerpc/memstat-0.5/.configured
/home/elorrain/buildroot/build_powerpc/staging_dir/usr/bin/powerpc-linux-uclibc-gcc -Os -pipe -Os  -I/home/elorrain/buildroot/build_powerpc/staging_dir/usr/include -I/home/elorrain/buildroot/build_powerpc/staging_dir/include --sysroot=/home/elorrain/buildroot/build_powerpc/staging_dir/ -isysroot /home/elorrain/buildroot/build_powerpc/staging_dir -mtune=440fp -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -L/home/elorrain/buildroot/build_powerpc/staging_dir/lib -L/home/elorrain/buildroot/build_powerpc/staging_dir/usr/lib --sysroot=/home/elorrain/buildroot/build_powerpc/staging_dir/ /home/elorrain/buildroot/build_powerpc/memstat-0.5/memstat.c -o /home/elorrain/buildroot/build_powerpc/memstat-0.5/memstat
[ -e /home/elorrain/buildroot/project_build_powerpc/Eqam4G/root/etc/memstat.conf ] || \
        /usr/bin/install -m 0644 -D /home/elorrain/buildroot/build_powerpc/memstat-0.5/memstat.conf /home/elorrain/buildroot/project_build_powerpc/Eqam4G/root/etc
/usr/bin/install: cannot overwrite directory `/home/elorrain/buildroot/project_build_powerpc/Eqam4G/root/etc' with non-directory
make: *** [/home/elorrain/buildroot/project_build_powerpc/Eqam4G/root/usr/bin/memstat] Error 1
[elorrain@cobra buildroot]$ ls -ld /home/elorrain/buildroot/project_build_powerpc/Eqam4G/root/etc
drwxrwxr-x  5 elorrain elorrain 4096 Jul 21 10:21 /home/elorrain/buildroot/project_build_powerpc/Eqam4G/root/etc
[elorrain@cobra buildroot]$ ls /home/elorrain/buildroot/project_build_powerpc/Eqam4G/root/etc
br-version  group     hosts   inittab  issue         mtab     passwd   protocols    resolv.conf  services  TZ
fstab       hostname  init.d  inputrc  ld.so.conf.d  network  profile  random-seed  securetty    shadow
[elorrain@cobra buildroot]$ /usr/bin/install -m 0644 -D /home/elorrain/buildroot/build_powerpc/memstat-0.5/memstat.conf /home/elorrain/buildroot/project_build_powerpc/Eqam4G/root/etc
/usr/bin/install: cannot overwrite directory `/home/elorrain/buildroot/project_build_powerpc/Eqam4G/root/etc' with non-directory
[elorrain@cobra buildroot]$ /usr/bin/install -m 0644 -D /home/elorrain/buildroot/build_powerpc/memstat-0.5/memstat.conf /home/elorrain/buildroot/project_build_powerpc/Eqam4G/root/etc/
/usr/bin/install: cannot overwrite directory `/home/elorrain/buildroot/project_build_powerpc/Eqam4G/root/etc/' with non-directory
[elorrain@cobra buildroot]$ /usr/bin/install -m 0644 -D /home/elorrain/buildroot/build_powerpc/memstat-0.5/memstat.conf /home/elorrain/buildroot/project_build_powerpc/Eqam4G/root/etc/memstat.conf
[elorrain@cobra buildroot]$ install --version
install (coreutils) 5.2.1
Written by David MacKenzie.

Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[elorrain@cobra buildroot]$ cat /etc/redhat-release
Red Hat Enterprise Linux ES release 4
[elorrain@cobra buildroot]$ cat /proc/version
Linux version 2.6.9-67.0.15.plus.c4smp (mockbuild@builder10.centos.org) (gcc version 3.4.6 20060404 (Red Hat 3.4.6-9)) #1 SMP Fri May 9 10:17:50 EDT 2008
[elorrain@cobra buildroot]$

I do not know if it has to be fixed, this centos is too old. But it seems
the only place where "install" is used with a target directory in building
the whole buildroot.

 Thanks for your help,
 Etienne.
Comment 6 Bernhard Reutner-Fischer 2009-07-21 10:19:03 UTC
can you verify if install thefile /there/dir/ works (i.e. with trailing slash)?
Comment 7 Etienne Lorrain 2009-07-21 10:30:31 UTC
Last slash try already in the screen dump, doesn't work...
Comment 8 Etienne Lorrain 2009-07-21 10:44:40 UTC
Note that the install man page seems to imply that install can be used with a
target directory only if there is multiple input files:
NAME
       ginstall - copy files and set attributes

SYNOPSIS
       install [OPTION]... SOURCE DEST           (1st format)
       install [OPTION]... SOURCE... DIRECTORY   (2nd format)
       install -d [OPTION]... DIRECTORY...       (3rd format)

DESCRIPTION
       In the first two formats, copy SOURCE to DEST or multiple SOURCE(s) to
       the  existing  DIRECTORY,   while   setting   permission   modes   and
       owner/group.   In the third format, create all components of the given
       DIRECTORY(ies).

Comment 9 Bernhard Reutner-Fischer 2009-07-21 10:45:17 UTC
Right, sorry.

diff --git a/package/memstat/memstat.mk b/package/memstat/memstat.mk
index 7220aee..a54509a 100644
--- a/package/memstat/memstat.mk
+++ b/package/memstat/memstat.mk
@@ -21,15 +21,17 @@ $(MEMSTAT_DIR)/.configured: $(MEMSTAT_DIR)/.unpacked
 	touch $@
 
 $(MEMSTAT_DIR)/memstat: $(MEMSTAT_DIR)/.configured
-	$(TARGET_CC) $(TARGET_CFLAGS) $(TARGET_LDFLAGS) $(@D)/memstat.c -o $@
+	$(TARGET_CC) $(TARGET_CFLAGS) $(TARGET_LDFLAGS) \
+		$(CFLAGS_WHOLE_PROGRAM) $(@D)/memstat.c -o $@
 
 $(TARGET_DIR)/usr/bin/memstat: $(MEMSTAT_DIR)/memstat
 	[ -e $(TARGET_DIR)/etc/memstat.conf ] || \
-		$(INSTALL) -m 0644 -D $(^D)/memstat.conf $(TARGET_DIR)/etc
+		$(INSTALL) -m 0644 -D $(^D)/memstat.conf \
+			$(TARGET_DIR)/etc/memstat.conf
 	$(INSTALL) -m 0755 -D $^ $@
 	$(STRIPCMD) $(STRIP_STRIP_ALL) $@
 
-memstat: uclibc $(TARGET_DIR)/usr/bin/memstat
+memstat: $(TARGET_DIR)/usr/bin/memstat
 
 memstat-source: $(DL_DIR)/$(MEMSTAT_SOURCE)
 

Better?
Comment 10 Etienne Lorrain 2009-07-21 12:10:34 UTC
Yes, GIT tree fixed, thanks.