@@ -17,7 +17,7 @@ function swoole_cli_self_update()
1717 if (strstr ($ uname , 'x86_64 ' ) !== false ) {
1818 $ arch = 'x64 ' ;
1919 } elseif (strstr ($ uname , 'aarch64 ' ) !== false ) {
20- $ arch = 'aarch64 ' ;
20+ $ arch = 'arm64 ' ;
2121 } else {
2222 echo "unsupported architecture \n" ;
2323 return ;
@@ -39,19 +39,25 @@ function swoole_cli_self_update()
3939 echo "The current version `v " . SWOOLE_VERSION . "- {$ arch }` is already the latest \n" ;
4040 } else {
4141 echo "Upgrading to version v {$ match [1 ]}\n" ;
42- $ tmpFile = "/tmp/ {$ newVersion ->filename }" ;
42+ $ taskId = uniqid ('swoole-cli-update- ' );
43+ $ tmpDir = "/tmp/ {$ taskId }" ;
44+ $ tmpFile = $ tmpDir . "/ {$ newVersion ->filename }" ;
45+ mkdir ($ tmpDir , 0755 , true );
4346 echo `wget -O {$ tmpFile } {$ newVersion ->url }`, PHP_EOL ;
4447 if (!is_file ($ tmpFile ) or filesize ($ tmpFile ) !== intval ($ newVersion ->size )) {
4548 echo "Failed to download {$ newVersion ->url }\n" ;
4649 return ;
4750 }
48- echo `cd /tmp && tar xvf {$ newVersion ->filename }`, PHP_EOL ;
51+ echo `cd $ tmpDir && tar xvf {$ newVersion ->filename }`, PHP_EOL ;
4952
50- $ tmpBinFile = ' /tmp/ swoole-cli' ;
53+ $ tmpBinFile = " $ tmpDir / swoole-cli" ;
5154 if (!is_file ($ tmpBinFile ) or filesize ($ tmpBinFile ) == 0 ) {
5255 echo "Failed to decompress archive {$ newVersion ->filename }\n" ;
5356 return ;
5457 }
55- echo `mv /tmp/swoole-cli $ binFile `;
58+ echo `mv $ tmpBinFile $ binFile `;
59+ echo `rm -rf $ tmpDir `;
60+ echo `chmod +x $ binFile `;
61+ echo "Upgrade completed \n" ;
5662 }
5763}
0 commit comments