diff options
author | Ron Yorston <rmy@pobox.com> | 2019-03-28 12:52:44 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2019-03-28 13:09:50 +0000 |
commit | 548ec7045bc7c80eaf03e92f390d1da2c9e9cd86 (patch) | |
tree | b4c0102539c8889eeeec9eef8afa863510c7592b /archival | |
parent | 215e01e70f13f28d1a4dbe297f095b25de04ee21 (diff) | |
download | busybox-w32-548ec7045bc7c80eaf03e92f390d1da2c9e9cd86.tar.gz busybox-w32-548ec7045bc7c80eaf03e92f390d1da2c9e9cd86.tar.bz2 busybox-w32-548ec7045bc7c80eaf03e92f390d1da2c9e9cd86.zip |
win32: interpret absolute paths as relative to %SYSTEMDRIVE%
BusyBox contains hardcoded references to absolute paths which
are unique in the *nix world but on Microsoft Windows are
interpreted as being on the current drive. To make these unique
again consider them to be relative to %SYSTEMDRIVE%.
Support this by adding functions to:
- determine the system drive (not using the environment variable);
- change a process's current directory to the root of the system drive;
- make relative paths absolute before changing directory (if needed).
The following applications have been modified:
- ash references /etc/profile from the system drive;
- dpkg places its data store on and installs files to the system drive;
- rpm installs files to the system drive;
- man looks for configuration files and man pages on the system drive.
See GitHub issue #158.
Diffstat (limited to 'archival')
-rw-r--r-- | archival/dpkg.c | 24 | ||||
-rw-r--r-- | archival/rpm.c | 3 |
2 files changed, 27 insertions, 0 deletions
diff --git a/archival/dpkg.c b/archival/dpkg.c index 8b25cfd47..08f15ad44 100644 --- a/archival/dpkg.c +++ b/archival/dpkg.c | |||
@@ -1752,6 +1752,10 @@ int dpkg_main(int argc UNUSED_PARAM, char **argv) | |||
1752 | int state_status; | 1752 | int state_status; |
1753 | int status_num; | 1753 | int status_num; |
1754 | int i; | 1754 | int i; |
1755 | #if ENABLE_PLATFORM_MINGW32 | ||
1756 | char **ptr, *path; | ||
1757 | int fd; | ||
1758 | #endif | ||
1755 | #if ENABLE_LONG_OPTS | 1759 | #if ENABLE_LONG_OPTS |
1756 | static const char dpkg_longopts[] ALIGN1 = | 1760 | static const char dpkg_longopts[] ALIGN1 = |
1757 | // FIXME: we use -C non-compatibly, should be: | 1761 | // FIXME: we use -C non-compatibly, should be: |
@@ -1796,6 +1800,26 @@ int dpkg_main(int argc UNUSED_PARAM, char **argv) | |||
1796 | bb_show_usage(); | 1800 | bb_show_usage(); |
1797 | } | 1801 | } |
1798 | 1802 | ||
1803 | #if ENABLE_PLATFORM_MINGW32 | ||
1804 | if (opt & OPT_install) { | ||
1805 | /* add system drive prefix to filenames, if necessary */ | ||
1806 | for (ptr = argv; *ptr; ++ptr) { | ||
1807 | *ptr = xabsolute_path(*ptr); | ||
1808 | } | ||
1809 | } | ||
1810 | |||
1811 | chdir_system_drive(); | ||
1812 | |||
1813 | /* initialise data store */ | ||
1814 | path = xstrdup("/var/lib/dpkg/info"); | ||
1815 | bb_make_directory(path, -1, FILEUTILS_RECUR); | ||
1816 | free(path); | ||
1817 | |||
1818 | fd = open("/var/lib/dpkg/status", O_RDWR|O_CREAT, 0666); | ||
1819 | if (fd >= 0) | ||
1820 | xclose(fd); | ||
1821 | #endif | ||
1822 | |||
1799 | /* puts("(Reading database ... xxxxx files and directories installed.)"); */ | 1823 | /* puts("(Reading database ... xxxxx files and directories installed.)"); */ |
1800 | index_status_file("/var/lib/dpkg/status"); | 1824 | index_status_file("/var/lib/dpkg/status"); |
1801 | 1825 | ||
diff --git a/archival/rpm.c b/archival/rpm.c index 3dd4d4777..c9e8785e2 100644 --- a/archival/rpm.c +++ b/archival/rpm.c | |||
@@ -303,6 +303,9 @@ static void extract_cpio(int fd, const char *source_rpm) | |||
303 | 303 | ||
304 | if (source_rpm != NULL) { | 304 | if (source_rpm != NULL) { |
305 | /* Binary rpm (it was built from some SRPM), install to root */ | 305 | /* Binary rpm (it was built from some SRPM), install to root */ |
306 | #if ENABLE_PLATFORM_MINGW32 | ||
307 | if (chdir_system_drive()) | ||
308 | #endif | ||
306 | xchdir("/"); | 309 | xchdir("/"); |
307 | } /* else: SRPM, install to current dir */ | 310 | } /* else: SRPM, install to current dir */ |
308 | 311 | ||