From b95ed10bd31d57b1ca1fac0de273bbe98903d0b8 Mon Sep 17 00:00:00 2001
From: Ron Yorston <rmy@pobox.com>
Date: Sat, 15 Aug 2020 09:37:06 +0100
Subject: busybox: create custom installation directory

If a custom installation directory is specified try to create it.
Don't worry if we can't, we'll find out when the links fail.
---
 libbb/appletlib.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/libbb/appletlib.c b/libbb/appletlib.c
index 35f577b89..77a9c3b7d 100644
--- a/libbb/appletlib.c
+++ b/libbb/appletlib.c
@@ -768,13 +768,14 @@ static void install_links(const char *busybox,
 {
 	char *fpc;
 	const char *appname = applet_names;
-	const char *sd = custom_install_dir == NULL ? get_system_drive() : NULL;
+	const char *sd = NULL;
 	int i, rc;
 
-	if (custom_install_dir && !is_directory(custom_install_dir, FALSE))
-		bb_error_msg_and_die("'%s' is not a directory", custom_install_dir);
-
-	if (custom_install_dir == NULL) {
+	if (custom_install_dir != NULL) {
+		bb_make_directory(custom_install_dir, 0755, FILEUTILS_RECUR);
+	}
+	else {
+		sd = get_system_drive();
 		for (i=1; i<ARRAY_SIZE(install_dir); ++i) {
 			fpc = xasprintf("%s%s", sd ?: "", install_dir[i]);
 			bb_make_directory(fpc, 0755, FILEUTILS_RECUR);
-- 
cgit v1.2.3-55-g6feb