@@ -189,9 +189,27 @@ class Util {
189189 return null ;
190190 }
191191
192- //获取预制可执行文件路径
193- static String elf (String value) {
194- return "applib/libexec_$value .so" ;
192+ static Future <bool > isXServerReady (String host, int port, {int timeoutSeconds = 5 }) async {
193+ try {
194+ final socket = await Socket .connect (host, port, timeout: Duration (seconds: timeoutSeconds));
195+ await socket.close ();
196+ return true ;
197+ } catch (e) {
198+ return false ;
199+ }
200+ }
201+
202+ static Future <void > waitForXServer () async {
203+ const host = '127.0.0.1' ;
204+ const port = 7897 ;
205+
206+ while (true ) {
207+ bool isReady = await isXServerReady (host, port);
208+ if (isReady) {
209+ return ;
210+ }
211+ await Future .delayed (Duration (seconds: 1 ));
212+ }
195213 }
196214
197215}
@@ -613,6 +631,8 @@ export DATA_DIR=${G.dataPath}
613631export LD_LIBRARY_PATH=\$ DATA_DIR/lib
614632cd \$ DATA_DIR
615633ln -sf ../applib/libexec_busybox.so \$ DATA_DIR/bin/busybox
634+ ln -sf ../applib/libexec_busybox.so \$ DATA_DIR/bin/sh
635+ ln -sf ../applib/libexec_busybox.so \$ DATA_DIR/bin/cat
616636ln -sf ../applib/libexec_busybox.so \$ DATA_DIR/bin/xz
617637ln -sf ../applib/libexec_busybox.so \$ DATA_DIR/bin/gzip
618638ln -sf ../applib/libexec_proot.so \$ DATA_DIR/bin/proot
@@ -654,6 +674,7 @@ chmod 1777 tmp
654674 await Util .execute (
655675"""
656676export DATA_DIR=${G .dataPath }
677+ export PATH=\$ DATA_DIR/bin:\$ PATH
657678export LD_LIBRARY_PATH=\$ DATA_DIR/lib
658679export CONTAINER_DIR=\$ DATA_DIR/containers/0
659680export EXTRA_OPT=""
@@ -754,6 +775,7 @@ sed -i -E "s@^(VNC_RESOLUTION)=.*@\\1=${w}x${h}@" \$(command -v startvnc)""";
754775 );
755776 G .audioPty! .write (const Utf8Encoder ().convert ("""
756777export DATA_DIR=${G .dataPath }
778+ export PATH=\$ DATA_DIR/bin:\$ PATH
757779export LD_LIBRARY_PATH=\$ DATA_DIR/lib
758780\$ DATA_DIR/bin/busybox sed "s/4713/${Util .getGlobal ("defaultAudioPort" ) as int }/g" \$ DATA_DIR/bin/pulseaudio.conf > \$ DATA_DIR/bin/pulseaudio.conf.tmp
759781rm -rf \$ DATA_DIR/pulseaudio_tmp/*
780802 if (Util .getGlobal ("virgl" )) {
781803 Util .execute ("""
782804export DATA_DIR=${G .dataPath }
805+ export PATH=\$ DATA_DIR/bin:\$ PATH
783806export LD_LIBRARY_PATH=\$ DATA_DIR/lib
784807export CONTAINER_DIR=\$ DATA_DIR/containers/${G .currentContainer }
785808${G .dataPath }/bin/virgl_test_server ${Util .getGlobal ("defaultVirglCommand" )}""" );
@@ -799,6 +822,7 @@ ${G.dataPath}/bin/virgl_test_server ${Util.getGlobal("defaultVirglCommand")}""")
799822 Util .termWrite (
800823"""
801824export DATA_DIR=${G .dataPath }
825+ export PATH=\$ DATA_DIR/bin:\$ PATH
802826export LD_LIBRARY_PATH=\$ DATA_DIR/lib
803827export CONTAINER_DIR=\$ DATA_DIR/containers/${G .currentContainer }
804828export EXTRA_MOUNT="$extraMount "
@@ -871,6 +895,7 @@ clear""");
871895 launchCurrentContainer ();
872896 if (Util .getGlobal ("autoLaunchVnc" ) as bool ) {
873897 if (G .wasX11Enabled) {
898+ await Util .waitForXServer ();
874899 launchX11 ();
875900 return ;
876901 }
0 commit comments