core: windows 下使用 curl 下载 reinstall.sh

This commit is contained in:
bin456789 2024-10-19 00:42:29 +08:00
parent 7070e7f678
commit a45aa86b7d
No known key found for this signature in database
GPG Key ID: EE301B386DE6C11B

View File

@ -117,10 +117,15 @@ if not exist "%tags%" (
&& type nul >"%tags%"
)
rem 在c盘根目录下执行 cygpath -ua . 会得到 /cygdrive/c因此末尾要有 /
for /f %%a in ('%SystemDrive%\cygwin\bin\cygpath -ua ./') do set thisdir=%%a
rem 下载 reinstall.sh
if not exist reinstall.sh (
call :download %confhome%/reinstall.sh %~dp0reinstall.sh
rem call :download %confhome%/reinstall.sh %~dp0reinstall.sh
call :download_with_curl %confhome%/reinstall.sh %thisdir%reinstall.sh
if errorlevel 1 goto :download_failed
call :chmod a+x %thisdir%reinstall.sh
)
rem 为每个参数添加引号,使参数正确传递到 bash
@ -128,9 +133,6 @@ for %%a in (%*) do (
set "param=!param! "%%~a""
)
rem 在c盘根目录下执行 cygpath -ua . 会得到 /cygdrive/c因此末尾要有 /
for /f %%a in ('%SystemDrive%\cygwin\bin\cygpath -ua ./') do set thisdir=%%a
rem 方法1
%SystemDrive%\cygwin\bin\dos2unix -q '%thisdir%reinstall.sh'
%SystemDrive%\cygwin\bin\bash -l -c '%thisdir%reinstall.sh !param!'
@ -157,6 +159,15 @@ if not exist "%~2" certutil -urlcache -split "%~1" "%~2" >nul
if not exist "%~2" exit /b 1
exit /b
:download_with_curl
echo Download: %~1 %~2
%SystemDrive%\cygwin\bin\curl -L "%~1" -o "%~2"
exit /b
:chmod
%SystemDrive%\cygwin\bin\chmod "%~1" "%~2"
exit /b
:download_failed
echo Download failed.
exit /b 1