diff options
author | Ron Yorston <rmy@pobox.com> | 2016-04-06 10:26:27 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2016-04-06 10:50:19 +0100 |
commit | 98b290e9b8221b7d7ffbf47da1e8ecce62a75369 (patch) | |
tree | c27be593d3fd3525b515c7d7643ba0db59afe2bb | |
parent | 57f63917f08a8f6b042f8e223c6a6746ea2b6d01 (diff) | |
download | busybox-w32-98b290e9b8221b7d7ffbf47da1e8ecce62a75369.tar.gz busybox-w32-98b290e9b8221b7d7ffbf47da1e8ecce62a75369.tar.bz2 busybox-w32-98b290e9b8221b7d7ffbf47da1e8ecce62a75369.zip |
mingw: enable busybox --install by default
Allow FEATURE_INSTALLER to be configured and enable it in the
default configuration.
The behaviour is slightly different from upstream BusyBox:
symbolic links are not permitted;
if no target directory is provided the directory containing
the busybox binary is used as the target.
-rw-r--r-- | applets/applet_tables.c | 2 | ||||
-rw-r--r-- | configs/mingw32_defconfig | 2 | ||||
-rw-r--r-- | configs/mingw64_defconfig | 2 | ||||
-rw-r--r-- | libbb/appletlib.c | 42 |
4 files changed, 43 insertions, 5 deletions
diff --git a/applets/applet_tables.c b/applets/applet_tables.c index 843f2ec08..7894b2c33 100644 --- a/applets/applet_tables.c +++ b/applets/applet_tables.c | |||
@@ -177,7 +177,7 @@ int main(int argc, char **argv) | |||
177 | printf("};\n\n"); | 177 | printf("};\n\n"); |
178 | #endif | 178 | #endif |
179 | 179 | ||
180 | #if ENABLE_FEATURE_INSTALLER | 180 | #if ENABLE_FEATURE_INSTALLER && !ENABLE_PLATFORM_MINGW32 |
181 | printf("const uint8_t applet_install_loc[] ALIGN1 = {\n"); | 181 | printf("const uint8_t applet_install_loc[] ALIGN1 = {\n"); |
182 | i = 0; | 182 | i = 0; |
183 | while (i < NUM_APPLETS) { | 183 | while (i < NUM_APPLETS) { |
diff --git a/configs/mingw32_defconfig b/configs/mingw32_defconfig index c06369b2e..ae07ca620 100644 --- a/configs/mingw32_defconfig +++ b/configs/mingw32_defconfig | |||
@@ -25,7 +25,7 @@ CONFIG_FEATURE_BUFFERS_USE_MALLOC=y | |||
25 | CONFIG_SHOW_USAGE=y | 25 | CONFIG_SHOW_USAGE=y |
26 | CONFIG_FEATURE_VERBOSE_USAGE=y | 26 | CONFIG_FEATURE_VERBOSE_USAGE=y |
27 | CONFIG_FEATURE_COMPRESS_USAGE=y | 27 | CONFIG_FEATURE_COMPRESS_USAGE=y |
28 | # CONFIG_FEATURE_INSTALLER is not set | 28 | CONFIG_FEATURE_INSTALLER=y |
29 | # CONFIG_INSTALL_NO_USR is not set | 29 | # CONFIG_INSTALL_NO_USR is not set |
30 | # CONFIG_LOCALE_SUPPORT is not set | 30 | # CONFIG_LOCALE_SUPPORT is not set |
31 | # CONFIG_UNICODE_SUPPORT is not set | 31 | # CONFIG_UNICODE_SUPPORT is not set |
diff --git a/configs/mingw64_defconfig b/configs/mingw64_defconfig index 04e6ac070..60788ab83 100644 --- a/configs/mingw64_defconfig +++ b/configs/mingw64_defconfig | |||
@@ -25,7 +25,7 @@ CONFIG_FEATURE_BUFFERS_USE_MALLOC=y | |||
25 | CONFIG_SHOW_USAGE=y | 25 | CONFIG_SHOW_USAGE=y |
26 | CONFIG_FEATURE_VERBOSE_USAGE=y | 26 | CONFIG_FEATURE_VERBOSE_USAGE=y |
27 | CONFIG_FEATURE_COMPRESS_USAGE=y | 27 | CONFIG_FEATURE_COMPRESS_USAGE=y |
28 | # CONFIG_FEATURE_INSTALLER is not set | 28 | CONFIG_FEATURE_INSTALLER=y |
29 | # CONFIG_INSTALL_NO_USR is not set | 29 | # CONFIG_INSTALL_NO_USR is not set |
30 | # CONFIG_LOCALE_SUPPORT is not set | 30 | # CONFIG_LOCALE_SUPPORT is not set |
31 | # CONFIG_UNICODE_SUPPORT is not set | 31 | # CONFIG_UNICODE_SUPPORT is not set |
diff --git a/libbb/appletlib.c b/libbb/appletlib.c index b71f2dd7e..4a9d363dd 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c | |||
@@ -662,6 +662,7 @@ static void check_suid(int applet_no) | |||
662 | 662 | ||
663 | 663 | ||
664 | # if ENABLE_FEATURE_INSTALLER | 664 | # if ENABLE_FEATURE_INSTALLER |
665 | # if !ENABLE_PLATFORM_MINGW32 | ||
665 | static const char usr_bin [] ALIGN1 = "/usr/bin/"; | 666 | static const char usr_bin [] ALIGN1 = "/usr/bin/"; |
666 | static const char usr_sbin[] ALIGN1 = "/usr/sbin/"; | 667 | static const char usr_sbin[] ALIGN1 = "/usr/sbin/"; |
667 | static const char *const install_dir[] = { | 668 | static const char *const install_dir[] = { |
@@ -706,6 +707,29 @@ static void install_links(const char *busybox, int use_symbolic_links, | |||
706 | continue; | 707 | continue; |
707 | } | 708 | } |
708 | } | 709 | } |
710 | # else /* ENABLE_PLATFORM_MINGW32 */ | ||
711 | static void install_links(const char *busybox, | ||
712 | int use_symbolic_links UNUSED_PARAM, char *custom_install_dir) | ||
713 | { | ||
714 | char *fpc; | ||
715 | const char *appname = applet_names; | ||
716 | int rc; | ||
717 | |||
718 | if (!is_directory(custom_install_dir, FALSE)) | ||
719 | bb_error_msg_and_die("'%s' is not a directory", custom_install_dir); | ||
720 | |||
721 | while (*appname) { | ||
722 | fpc = xasprintf("%s/%s.exe", custom_install_dir, appname); | ||
723 | rc = link(busybox, fpc); | ||
724 | if (rc != 0 && errno != EEXIST) { | ||
725 | bb_simple_perror_msg(fpc); | ||
726 | } | ||
727 | free(fpc); | ||
728 | while (*appname++ != '\0') | ||
729 | continue; | ||
730 | } | ||
731 | } | ||
732 | # endif | ||
709 | # else | 733 | # else |
710 | static void install_links(const char *busybox UNUSED_PARAM, | 734 | static void install_links(const char *busybox UNUSED_PARAM, |
711 | int use_symbolic_links UNUSED_PARAM, | 735 | int use_symbolic_links UNUSED_PARAM, |
@@ -743,9 +767,14 @@ static int busybox_main(char **argv) | |||
743 | "copyright notices.\n" | 767 | "copyright notices.\n" |
744 | "\n" | 768 | "\n" |
745 | "Usage: busybox [function [arguments]...]\n" | 769 | "Usage: busybox [function [arguments]...]\n" |
770 | IF_NOT_PLATFORM_MINGW32( | ||
746 | " or: busybox --list"IF_FEATURE_INSTALLER("[-full]")"\n" | 771 | " or: busybox --list"IF_FEATURE_INSTALLER("[-full]")"\n" |
772 | ) | ||
773 | IF_PLATFORM_MINGW32( | ||
774 | " or: busybox --list\n" | ||
775 | ) | ||
747 | IF_FEATURE_INSTALLER( | 776 | IF_FEATURE_INSTALLER( |
748 | " or: busybox --install [-s] [DIR]\n" | 777 | " or: busybox --install "IF_NOT_PLATFORM_MINGW32("[-s] ")"[DIR]\n" |
749 | ) | 778 | ) |
750 | " or: function [arguments]...\n" | 779 | " or: function [arguments]...\n" |
751 | "\n" | 780 | "\n" |
@@ -799,7 +828,7 @@ static int busybox_main(char **argv) | |||
799 | const char *a = applet_names; | 828 | const char *a = applet_names; |
800 | dup2(1, 2); | 829 | dup2(1, 2); |
801 | while (*a) { | 830 | while (*a) { |
802 | # if ENABLE_FEATURE_INSTALLER | 831 | # if ENABLE_FEATURE_INSTALLER && !ENABLE_PLATFORM_MINGW32 |
803 | if (argv[1][6]) /* --list-full? */ | 832 | if (argv[1][6]) /* --list-full? */ |
804 | full_write2_str(install_dir[APPLET_INSTALL_LOC(i)] + 1); | 833 | full_write2_str(install_dir[APPLET_INSTALL_LOC(i)] + 1); |
805 | # endif | 834 | # endif |
@@ -812,6 +841,7 @@ static int busybox_main(char **argv) | |||
812 | } | 841 | } |
813 | 842 | ||
814 | if (ENABLE_FEATURE_INSTALLER && strcmp(argv[1], "--install") == 0) { | 843 | if (ENABLE_FEATURE_INSTALLER && strcmp(argv[1], "--install") == 0) { |
844 | #if !ENABLE_PLATFORM_MINGW32 | ||
815 | int use_symbolic_links; | 845 | int use_symbolic_links; |
816 | const char *busybox; | 846 | const char *busybox; |
817 | 847 | ||
@@ -832,6 +862,14 @@ static int busybox_main(char **argv) | |||
832 | */ | 862 | */ |
833 | use_symbolic_links = (argv[2] && strcmp(argv[2], "-s") == 0 && ++argv); | 863 | use_symbolic_links = (argv[2] && strcmp(argv[2], "-s") == 0 && ++argv); |
834 | install_links(busybox, use_symbolic_links, argv[2]); | 864 | install_links(busybox, use_symbolic_links, argv[2]); |
865 | #else | ||
866 | /* busybox --install [DIR] | ||
867 | * where DIR is the directory to install to. If DIR is not | ||
868 | * provided put the links in the same directory as busybox. | ||
869 | */ | ||
870 | install_links(bb_busybox_exec_path, FALSE, argv[2] ? argv[2] : | ||
871 | dirname(xstrdup(bb_busybox_exec_path))); | ||
872 | #endif | ||
835 | return 0; | 873 | return 0; |
836 | } | 874 | } |
837 | 875 | ||