XSDL: only binaries named like 'libXXX.so' are getting extracted by Android app manager,

so rename all binaries to libXXX.so and make a bunch of symlinks
This commit is contained in:
Sergii Pylypenko
2019-11-06 22:32:08 +02:00
parent 249f602165
commit 3926496d5f
4 changed files with 59 additions and 61 deletions

View File

@@ -20,13 +20,13 @@ AppVersionName="1.20.41"
# You can specify Google Play expansion files in the form 'obb:main.12345' or 'obb:patch.12345' where 12345 is the app version for obb file
# You can use .zip.xz archives for better compression, but you need to add 'lzma' to CompiledLibraries
# Generate .zip.xz files like this: zip -0 -r data.zip your-data/* ; xz -8 data.zip
AppDataDownloadUrl="!!Data files|:data.tar.gz:data-2.tgz^!!Data files|:DroidSansMono.ttf:DroidSansMono.ttf^Additional fonts (90Mb)|:xfonts.tar.gz:https://sourceforge.net/projects/libsdl-android/files/apk/XServer-XSDL/xfonts.tgz/download"
AppDataDownloadUrl="!!Library mapping|bin-map.zip^!!Data files|:data.tar.gz:data-2.tgz^!!Data files|:DroidSansMono.ttf:DroidSansMono.ttf^Additional fonts (90Mb)|:xfonts.tar.gz:https://sourceforge.net/projects/libsdl-android/files/apk/XServer-XSDL/xfonts.tgz/download"
# Reset SDL config when updating application to the new version (y) / (n)
ResetSdlConfigForThisVersion=n
# Delete application data files when upgrading (specify file/dir paths separated by spaces)
DeleteFilesOnUpgrade="%"
DeleteFilesOnUpgrade="libsdl-DownloadFinished-0.flag busybox usr tmp pulseaudio.conf"
# Here you may type readme text, which will be shown during startup. Format is:
# Text in English, use \\\\n to separate lines (that's four backslashes)^de:Text in Deutsch^ru:Text in Russian^button:Button that will open some URL:http://url-to-open/
@@ -269,8 +269,8 @@ APP_PLATFORM=
# Specify architectures to compile, 'all' or 'y' to compile for all architectures.
# Available architectures: armeabi-v7a arm64-v8a x86 x86_64
#MultiABI='armeabi-v7a arm64-v8a x86 x86_64'
MultiABI='arm64-v8a'
MultiABI='armeabi-v7a arm64-v8a x86 x86_64'
#MultiABI='arm64-v8a'
# Optional shared libraries to compile - removing some of them will save space
# MP3 patents are expired, but libmad license is GPL, not LGPL

View File

@@ -13,9 +13,9 @@ if [ -e pulseaudio/android-build.sh ]; then
fi
../setEnvironment-$1.sh sh -c '\
$CC $CFLAGS -Werror=format -c main.c -o main-'"$1.o" || exit 1
$CC $CFLAGS -Werror=format -c main.c -DXSDL_ARCH=\"'$1'\" -o main-'"$1.o" || exit 1
../setEnvironment-$1.sh sh -c '\
$CC $CFLAGS -Werror=format -c gfx.c -o gfx-'"$1.o" || exit 1
$CC $CFLAGS -Werror=format -c gfx.c -DXSDL_ARCH=\"'$1'\" -o gfx-'"$1.o" || exit 1
[ -e ../../../lib ] || ln -s libs ../../../lib
@@ -76,8 +76,6 @@ rm -rf $CURDIR/tmp-$1
mkdir -p $CURDIR/tmp-$1
cd $CURDIR/tmp-$1
cp -f $CURDIR/xserver/data/busybox-$1 ./busybox
cp -f $CURDIR/xserver/data/busybox-$1 ./libbusybox
cp -f $CURDIR/xserver/data/busybox-$1 ./libbusybox.so
for f in xhost xkbcomp xloadimage xsel; do cp -f $CURDIR/xserver/android/$1/$f ./$f ; done
# Statically-linked prebuilt executables, generated using Debian chroot.
@@ -90,6 +88,18 @@ cp -f $CURDIR/pulseaudio/$1/*/install/lib/*.so ./
rm -f ../AndroidData/binaries-$1.zip
rm -rf ../AndroidData/lib/$1
mkdir -p ../AndroidData/lib/$1
cp -a . ../AndroidData/lib/$1
#cp -a . ../AndroidData/lib/$1
rm -r bin-map-$1.txt
IDX=0
for BIN in *; do
echo "lib$IDX.so" >> bin-map-$1.txt
echo "$BIN" >> bin-map-$1.txt
cp ./$BIN ../AndroidData/lib/$1/lib$IDX.so
IDX="`expr $IDX \+ 1`"
done
zip ../AndroidData/bin-map.zip bin-map-$1.txt
exit 0

View File

@@ -283,41 +283,55 @@ static void * unpackFilesThread(void * unused)
return (void *)1;
}
static void symlinkBusybox(void)
{
char fname[PATH_MAX*2];
char fname2[PATH_MAX];
sprintf(fname, "%s/busybox", getenv("APPDIR"));
sprintf(fname2, "%s/busybox", getenv("LIBDIR"));
remove(fname);
symlink(fname2, fname);
__android_log_print(ANDROID_LOG_INFO, "XSDL", "ln -s %s %s", fname2, fname);
}
static void symlinkUsrBin(void)
{
char fname[PATH_MAX*2];
char fname2[PATH_MAX];
char libname[PATH_MAX];
char targetname[PATH_MAX];
char libpath[PATH_MAX];
char targetpath[PATH_MAX];
char mappingpath[PATH_MAX];
FILE *mapping;
strcpy( fname, getenv("APPDIR") );
strcat( fname, "/busybox" );
strcat( fname, " rm -rf " );
strcat( fname, getenv("APPDIR") );
strcat( fname, "/usr/bin" );
sprintf( mappingpath, "%s/bin-map-%s.txt", getenv("DATADIR"), XSDL_ARCH );
__android_log_print(ANDROID_LOG_INFO, "XSDL", "Opening %s", mappingpath);
mapping = fopen(mappingpath, "rb");
if (!mapping)
{
__android_log_print(ANDROID_LOG_INFO, "XSDL", "Opening %s failed", mappingpath);
return;
}
__android_log_print(ANDROID_LOG_INFO, "XSDL", "%s", fname);
sprintf( targetpath, "%s/usr", getenv("APPDIR") );
mkdir(targetpath, 0700);
system( fname );
sprintf( targetpath, "%s/usr/bin", getenv("APPDIR") );
mkdir(targetpath, 0700);
sprintf(fname, "%s/usr/bin", getenv("APPDIR"));
symlink(getenv("LIBDIR"), fname);
__android_log_print(ANDROID_LOG_INFO, "XSDL", "ln -s %s %s", getenv("LIBDIR"), fname);
while (fgets(libname, sizeof(libname), mapping) &&
fgets(targetname, sizeof(targetname), mapping))
{
if (strchr(libname, '\n'))
strchr(libname, '\n')[0] = 0;
if (strchr(targetname, '\n'))
strchr(targetname, '\n')[0] = 0;
sprintf( libpath, "%s/%s", getenv("LIBDIR"), libname );
sprintf( targetpath, "%s/usr/bin/%s", getenv("APPDIR"), targetname );
__android_log_print(ANDROID_LOG_INFO, "XSDL", "ln -s %s %s", libpath, targetpath);
symlink( libpath, targetpath );
}
fclose(mapping);
sprintf(targetpath, "%s/busybox", getenv("APPDIR"));
remove(targetpath);
symlink("usr/bin/busybox", targetpath);
__android_log_print(ANDROID_LOG_INFO, "XSDL", "ln -s usr/bin/busybox %s", targetpath);
remove(mappingpath);
}
void XSDL_unpackFiles(int _freeSpaceRequiredMb)
{
symlinkBusybox();
symlinkUsrBin();
pthread_t thread_id;
void * status;
@@ -430,8 +444,6 @@ void XSDL_unpackFiles(int _freeSpaceRequiredMb)
exit(1);
}
SDL_JoystickClose(j0);
symlinkUsrBin();
}
void XSDL_showConfigMenu(int * resolutionW, int * displayW, int * resolutionH, int * displayH, int * builtinKeyboard, int * ctrlAltShiftKeys, char * portStr)
@@ -876,7 +888,7 @@ void XSDL_generateBackground(const char * port, int showHelp, int resolutionW, i
sprintf (msg, "If you run Linux in chroot on this device, run:");
renderStringScaled(msg, 12 * resolutionH / VID_Y, resolutionW/2, y, 255, 255, 255, surf);
y += resolutionH * 15 / VID_Y;
sprintf (msg, "export DISPLAY=:0 PULSE_SERVER=tcp:127.0.0.1:4712");
sprintf (msg, "export DISPLAY=:0 PULSE_SERVER=tcp:127.0.0.1:4713");
renderStringScaled(msg, 12 * resolutionH / VID_Y, resolutionW/2, y, 255, 255, 255, surf);
SDL_SavePNG(surf, "background.png");

View File

@@ -173,30 +173,6 @@ int main( int argc, char* argv[] )
__android_log_print(ANDROID_LOG_INFO, "XSDL", "XSDL chdir to: %s", getenv("SECURE_STORAGE_DIR"));
chdir( getenv("SECURE_STORAGE_DIR") ); // Megahack: change /proc/self/cwd to the X.org data dir, and use /proc/self/cwd path in libX11
system("logwrapper echo =====================");
system("logwrapper ls -l .");
system("logwrapper echo ===================== usr");
system("logwrapper ls -l usr");
system("logwrapper echo ===================== usr/bin");
system("logwrapper ls -l usr/bin");
system("logwrapper echo ===================== usr/share/X11/xkb/rules");
system("logwrapper ls -l usr/share/X11/xkb/rules");
system("logwrapper echo ===================== ./busybox");
system("logwrapper ./busybox ls -l");
system("logwrapper ./busybox");
system("logwrapper ./busybox tar -h");
{
char buf[PATH_MAX];
system("logwrapper echo ===================== LIBDIR = $LIBDIR");
sprintf(buf, "logwrapper ls -l %s", getenv("LIBDIR"));
system(buf);
sprintf(buf, "logwrapper %s/busybox", getenv("LIBDIR"));
system(buf);
sprintf(buf, "logwrapper %s/busybox tar -h", getenv("LIBDIR"));
system(buf);
}
system("logwrapper echo ===================== END");
startPulseAudio();
android_main( argnum, args, envp ); // Should never exit on success, if we want to terminate we kill ourselves