@@ -17,7 +17,7 @@ function swoole_cli_self_update()
17
17
if (strstr ($ uname , 'x86_64 ' ) !== false ) {
18
18
$ arch = 'x64 ' ;
19
19
} elseif (strstr ($ uname , 'aarch64 ' ) !== false ) {
20
- $ arch = 'aarch64 ' ;
20
+ $ arch = 'arm64 ' ;
21
21
} else {
22
22
echo "unsupported architecture \n" ;
23
23
return ;
@@ -39,19 +39,25 @@ function swoole_cli_self_update()
39
39
echo "The current version `v " . SWOOLE_VERSION . "- {$ arch }` is already the latest \n" ;
40
40
} else {
41
41
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 );
43
46
echo `wget -O {$ tmpFile } {$ newVersion ->url }`, PHP_EOL ;
44
47
if (!is_file ($ tmpFile ) or filesize ($ tmpFile ) !== intval ($ newVersion ->size )) {
45
48
echo "Failed to download {$ newVersion ->url }\n" ;
46
49
return ;
47
50
}
48
- echo `cd /tmp && tar xvf {$ newVersion ->filename }`, PHP_EOL ;
51
+ echo `cd $ tmpDir && tar xvf {$ newVersion ->filename }`, PHP_EOL ;
49
52
50
- $ tmpBinFile = ' /tmp/ swoole-cli' ;
53
+ $ tmpBinFile = " $ tmpDir / swoole-cli" ;
51
54
if (!is_file ($ tmpBinFile ) or filesize ($ tmpBinFile ) == 0 ) {
52
55
echo "Failed to decompress archive {$ newVersion ->filename }\n" ;
53
56
return ;
54
57
}
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" ;
56
62
}
57
63
}
0 commit comments