diff --git a/reinstall.bat b/reinstall.bat index feadea5..99dcb96 100644 --- a/reinstall.bat +++ b/reinstall.bat @@ -53,28 +53,38 @@ set tags=%tmp%\cygwin-installed-!pkgs! if not exist !tags! ( rem win10 arm 支持运行 x86 软件 rem win11 arm 支持运行 x86 和 x86_64 软件 - rem wmic os get osarchitecture + rem wmic os get osarchitecture 显示中文 + rem wmic ComputerSystem get SystemType 显示英文 + + for /f "tokens=2 delims==" %%a in ('wmic os get BuildNumber /format:list ^| find "BuildNumber"') do ( + set /a BuildNumber=%%a + ) + + set CygwinEOL=1 + wmic ComputerSystem get SystemType | find "ARM" > nul if not errorlevel 1 ( - for /f "tokens=2 delims==" %%a in ('wmic os get BuildNumber /format:list ^| find "BuildNumber"') do set BuildNumber=%%a if !BuildNumber! GEQ 22000 ( - set CygwinArch=x86_64 - ) else ( - set CygwinArch=x86 + set CygwinEOL=0 ) ) else ( wmic ComputerSystem get SystemType | find "x64" > nul if not errorlevel 1 ( - set CygwinArch=x86_64 - ) else ( - set CygwinArch=x86 + if !BuildNumber! GEQ 9600 ( + set CygwinEOL=0 + ) ) ) - if "!CygwinArch!" == "x86_64" ( - set dir=/sourceware/cygwin - ) else ( + rem win7/8 cygwin 已 EOL,不能用最新 cygwin 源,而要用 Cygwin Time Machine 源 + rem 但 Cygwin Time Machine 没有国内源 + rem 为了保证国内下载速度, cygwin EOL 统一使用 cygwin-archive x86 源 + if !CygwinEOL! == "1" ( + set CygwinArch=x86 set dir=/sourceware/cygwin-archive/20221123 + ) else ( + set CygwinArch=x86_64 + set dir=/sourceware/cygwin ) rem 下载 Cygwin diff --git a/reinstall.sh b/reinstall.sh index 91ae0e4..2738c88 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -856,7 +856,7 @@ is_efi() { is_secure_boot_enabled() { if is_efi; then if is_in_windows; then - reg query 'HKLM\SYSTEM\CurrentControlSet\Control\SecureBoot\State' /v UEFISecureBootEnabled | grep 0x1 + reg query 'HKLM\SYSTEM\CurrentControlSet\Control\SecureBoot\State' /v UEFISecureBootEnabled 2>/dev/null | grep 0x1 else # localhost:~# mokutil --sb-state # SecureBoot disabled @@ -1497,9 +1497,25 @@ EOF } # 脚本入口 +if is_in_windows; then + # win系统盘 + c=$(echo $SYSTEMDRIVE | cut -c1) + + # 64位系统 + 32位cmd/cygwin,需要添加 PATH,否则找不到64位系统程序,例如bcdedit + sysnative=$(cygpath -u $WINDIR\\Sysnative) + if [ -d $sysnative ]; then + PATH=$PATH:$sysnative + fi + + # 更改 windows 命令输出语言为英文 + # chcp.com 437 # 会清屏 + mode.com con cp select=437 >/dev/null +fi + # 检查 root if is_in_windows; then - if ! openfiles >/dev/null 2>&1; then + # 64位系统 + 32位cmd/cygwin,运行 openfiles 报错:目标系统必须运行 32 位的操作系统 + if ! fltmc >/dev/null 2>&1; then error_and_exit "Please run as administrator." fi else @@ -1566,15 +1582,6 @@ if is_secure_boot_enabled; then error_and_exit "Not Supported with secure boot enabled." fi -if is_in_windows; then - # win系统盘 - c=$(echo $SYSTEMDRIVE | cut -c1) - - # 更改 windows 命令输出语言为英文 - # chcp.com 437 # 会清屏 - mode.com con cp select=437 >/dev/null -fi - # 必备组件 install_pkg curl grep