Stop Using Static QEMU

This commit is contained in:
TheBrokenRail 2021-12-17 21:04:05 -05:00
parent 4c3fefae89
commit e3a4cabf61
4 changed files with 21 additions and 5 deletions

2
debian/client-amd64 vendored
View File

@ -4,4 +4,4 @@ Maintainer: TheBrokenRail <connor24nolan@live.com>
Description: Fun with Blocks Description: Fun with Blocks
Homepage: https://www.minecraft.net/en-us/edition/pi Homepage: https://www.minecraft.net/en-us/edition/pi
Architecture: amd64 Architecture: amd64
Depends: libc6, libstdc++6, libc6-armhf-cross, libstdc++6-armhf-cross, zenity, libgles1, libegl1, libglfw3 | libglfw3-wayland, libfreeimage3, libopenal1, qemu-user-static Depends: libc6, libstdc++6, libc6-armhf-cross, libstdc++6-armhf-cross, zenity, libgles1, libegl1, libglfw3 | libglfw3-wayland, libfreeimage3, libopenal1, qemu-user

2
debian/server-amd64 vendored
View File

@ -4,4 +4,4 @@ Maintainer: TheBrokenRail <connor24nolan@live.com>
Description: Fun with Blocks Description: Fun with Blocks
Homepage: https://www.minecraft.net/en-us/edition/pi Homepage: https://www.minecraft.net/en-us/edition/pi
Architecture: amd64 Architecture: amd64
Depends: libc6, libstdc++6, libc6-armhf-cross, libstdc++6-armhf-cross, qemu-user-static Depends: libc6, libstdc++6, libc6-armhf-cross, libstdc++6-armhf-cross, qemu-user

View File

@ -28,7 +28,7 @@
## Runtime Dependencies ## Runtime Dependencies
* Non-ARM Host Architectures * Non-ARM Host Architectures
* QEMU User-Mode Static * QEMU User-Mode
* Host Architecture Dependencies * Host Architecture Dependencies
* CLient Mode Only * CLient Mode Only
* OpenGL ES 1.1 * OpenGL ES 1.1

View File

@ -42,6 +42,19 @@ static void set_and_print_env(const char *name, char *value) {
// Set The Value // Set The Value
setenv(name, value, 1); setenv(name, value, 1);
} }
#ifndef __ARM_ARCH
#define PASS_ENVIRONMENTAL_VARIABLE_TO_QEMU(name) \
{ \
char *old_value = getenv("QEMU_SET_ENV"); \
char *new_value = NULL; \
/* Pass Variable */ \
safe_asprintf(&new_value, "%s%s%s=%s", old_value == NULL ? "" : old_value, old_value == NULL ? "" : ",", name, getenv(name)); \
setenv("QEMU_SET_ENV", new_value, 1); \
free(new_value); \
/* Reset Variable */ \
RESET_ENVIRONMENTAL_VARIABLE(name); \
}
#endif
// Get Environmental Variable // Get Environmental Variable
static char *get_env_safe(const char *name) { static char *get_env_safe(const char *name) {
@ -202,8 +215,11 @@ void bootstrap(int argc, char *argv[]) {
// Run // Run
safe_execvpe(full_path, argv, environ); safe_execvpe(full_path, argv, environ);
#else #else
// Use Static QEMU So It Isn't Affected By LD_* Variables // Prevent QEMU From Being Modded
#define EXE_INTERPRETER "qemu-arm-static" PASS_ENVIRONMENTAL_VARIABLE_TO_QEMU("LD_LIBRARY_PATH");
PASS_ENVIRONMENTAL_VARIABLE_TO_QEMU("LD_PRELOAD");
// Use QEMU
#define EXE_INTERPRETER "qemu-arm"
// Create Arguments List // Create Arguments List
char *new_argv[argc + 2]; char *new_argv[argc + 2];
for (int i = 1; i <= argc; i++) { for (int i = 1; i <= argc; i++) {