On Wed, Sep 03, 2008 at 08:51:38PM +0200, Denys Vlasenko wrote:
>On Monday 01 September 2008 19:55, Vladimir Dronnikov wrote:
>> And -D option for install, please :^) I can't compile buildroot using
>> BB coreutils...
>
>Try this.
>--
>vda
>@@ -161,6 +161,16 @@ int install_main(int argc, char **argv)
> } else {
> if (isdir)
> dest = concat_path_file(last, basename(arg));
>+ if (opts & OPT_MKDIR_LEADING) {
>+ char *slash = strrchr(dest, '/');
>+ if (slash) {
>+ *slash = '\0';
>+ bb_make_directory(dest, 0755,
>FILEUTILS_RECUR);
>+ /* errors are not checked. copy_file
>+ * will fail if dir is not created. */
>+ *slash = '/';
>+ }
>+ }
What about something like the attached, which is smaller for me?
$ size coreutils/install.o*
text data bss dec hex filename
706 0 0 706 2c2 coreutils/install.o.oorig
798 0 0 798 31e coreutils/install.o.vda
787 0 0 787 313 coreutils/install.o.attached
Perhaps it would be handy not to touch the path in bb_make_directory but
return NULL on error or the trimmed path on success?
Index: coreutils/install.c
===================================================================
--- coreutils/install.c (revision 23319)
+++ coreutils/install.c (working copy)
@@ -159,6 +159,7 @@ int install_main(int argc, char **argv)
goto next;
}
} else {
+# if 0
if (isdir)
dest = concat_path_file(last, basename(arg));
if (opts & OPT_MKDIR_LEADING) {
@@ -171,6 +172,18 @@ int install_main(int argc, char **argv)
*slash = '/';
}
}
+#else
+ if (opts & OPT_MKDIR_LEADING) {
+ char *ddir = xstrdup(dest);
+ if (bb_make_directory(dirname(ddir), 0755, FILEUTILS_RECUR)) {
+ ret = EXIT_FAILURE;
+ goto next;
+ }
+ free(ddir);
+ }
+ if (isdir)
+ dest = concat_path_file(last, basename(arg));
+#endif
if (copy_file(arg, dest, copy_flags)) {
/* copy is not made */
ret = EXIT_FAILURE;
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox