Compare commits

..

No commits in common. "103ef84f92bd051af0078517cfb58176e932f284" and "770000ea9d807dcf8e9c61785041337aba02787b" have entirely different histories.

4 changed files with 42 additions and 138 deletions

View File

@ -30,25 +30,15 @@ if errorlevel 1 (
rem 有时 %tmp% 带会话 id且文件夹不存在
rem https://learn.microsoft.com/troubleshoot/windows-server/shell-experience/temp-folder-with-logon-session-id-deleted
rem if not exist %tmp% (
rem md %tmp%
rem )
if not exist %tmp% (
md %tmp%
)
rem 下载 geoip
rem 检查是否国内
if not exist geoip (
rem www.cloudflare.com/dash.cloudflare.com 国内访问的是美国服务器,而且部分地区被墙
call :download http://www.qualcomm.cn/cdn-cgi/trace %~dp0geoip || goto :download_failed
)
rem 判断是否有 loc=
findstr /c:"loc=" geoip >nul
if errorlevel 1 (
echo Invalid geoip file
del geoip
exit /b 1
)
rem 检查是否国内
findstr /c:"loc=CN" geoip >nul
if not errorlevel 1 (
rem mirrors.tuna.tsinghua.edu.cn 会强制跳转 https
@ -70,49 +60,37 @@ if not errorlevel 1 (
call :check_cygwin_installed || (
rem win10 arm 支持运行 x86 软件
rem win11 arm 支持运行 x86 和 x86_64 软件
rem windows 11 24h2 没有 wmic
rem wmic os get osarchitecture 显示中文,即使设置了 mode con cp select=437
rem wmic os get osarchitecture 显示中文
rem wmic ComputerSystem get SystemType 显示英文
rem for /f "tokens=*" %%a in ('wmic ComputerSystem get SystemType ^| find /i "based"') do (
rem set "SystemType=%%a"
rem )
rem SystemType
rem windows 11 24h2 没有 wmic
rem 有的系统精简了 powershell
rem for /f "delims=" %%a in ('powershell -NoLogo -NoProfile -NonInteractive -Command "(Get-WmiObject win32_computersystem).SystemType"') do (
rem set "SystemType=%%a"
rem )
rem SystemArch
for /f "tokens=3" %%a in ('reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v PROCESSOR_ARCHITECTURE') do (
set SystemArch=%%a
where wmic >nul 2>&1
if not errorlevel 1 (
for /f "tokens=*" %%a in ('wmic ComputerSystem get SystemType ^| find /i "based"') do (
set "SystemType=%%a"
)
) else (
for /f "delims=" %%a in ('powershell -NoLogo -NoProfile -NonInteractive -Command "(Get-WmiObject win32_computersystem).SystemType"') do (
set "SystemType=%%a"
)
)
rem 也可以用 PROCESSOR_ARCHITEW6432 和 PROCESSOR_ARCHITECTURE 判断
rem ARM64 win11 PROCESSOR_ARCHITEW6432 PROCESSOR_ARCHITECTURE
rem 原生cmd 未定义 ARM64
rem 32位cmd ARM64 x86
rem if defined PROCESSOR_ARCHITEW6432 (
rem set "SystemArch=%PROCESSOR_ARCHITEW6432%"
rem ) else (
rem set "SystemArch=%PROCESSOR_ARCHITECTURE%"
rem )
rem BuildNumber
for /f "tokens=3" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v CurrentBuildNumber') do (
set /a BuildNumber=%%a
set /a BuildNumber=%%a
)
set CygwinEOL=1
echo !SystemArch! | find "ARM" > nul
echo !SystemType! | find "ARM" > nul
if not errorlevel 1 (
if !BuildNumber! GEQ 22000 (
set CygwinEOL=0
)
) else (
echo !SystemArch! | find "AMD64" > nul
echo !SystemType! | find "x64" > nul
if not errorlevel 1 (
if !BuildNumber! GEQ 9600 (
set CygwinEOL=0
@ -136,14 +114,6 @@ call :check_cygwin_installed || (
call :download http://www.cygwin.com/setup-!CygwinArch!.exe %~dp0setup-!CygwinArch!.exe || goto :download_failed
)
rem 少于 1M 视为无效
rem 有的 IP 被官网拉黑,无法下载 exe下载得到 html
for %%A in (setup-!CygwinArch!.exe) do if %%~zA LSS 1048576 (
echo Invalid Cgywin installer
del setup-!CygwinArch!.exe
exit /b 1
)
rem 安装 Cygwin
set site=!mirror!!dir!
start /wait setup-!CygwinArch!.exe ^

View File

@ -4002,24 +4002,16 @@ redhat | centos | almalinux | rocky | fedora | ubuntu)
;;
esac
# 检查内存
check_ram
# 检查硬件架构
if is_in_windows; then
# x86-based PC
# x64-based PC
# ARM-based PC
# ARM64-based PC
if false; then
# 如果机器没有 wmic 则需要下载 wmic.ps1但此时未判断国内外还是用国外源
basearch=$(wmic ComputerSystem get SystemType | grep '=' | cut -d= -f2 | cut -d- -f1)
elif true; then
# 可以用
basearch=$(reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v PROCESSOR_ARCHITECTURE |
grep . | tail -1 | awk '{print $NF}')
else
# 也可以用
basearch=$(cmd /c "if defined PROCESSOR_ARCHITEW6432 (echo %PROCESSOR_ARCHITEW6432%) else (echo %PROCESSOR_ARCHITECTURE%)")
fi
basearch=$(wmic ComputerSystem get SystemType | grep '=' | cut -d= -f2 | cut -d- -f1)
else
# archlinux 云镜像没有 arch 命令
# https://en.wikipedia.org/wiki/Uname
@ -4053,7 +4045,6 @@ if false && [[ "$confhome" = http*://raw.githubusercontent.com/* ]]; then
fi
# 设置国内代理
# 要在使用 wmic 前设置,否则国内机器会从国外源下载 wmic.ps1
# gitee 不支持ipv6
# jsdelivr 有12小时缓存
# https://github.com/XIU2/UserScript/blob/master/GithubEnhanced-High-Speed-Download.user.js#L31
@ -4066,10 +4057,6 @@ if is_in_china; then
fi
fi
# 检查内存
# 会用到 wmic因此要在设置国内 confhome 后使用
check_ram
# 以下目标系统不需要两步安装
# alpine
# debian

View File

@ -2328,10 +2328,6 @@ get_disk_logic_sector_size() {
blockdev --getss "$1"
}
is_4kn() {
[ "$(blockdev --getss "$1")" = 4096 ]
}
is_xda_gt_2t() {
disk_size=$(get_disk_size /dev/$xda)
disk_2t=$((2 * 1024 * 1024 * 1024 * 1024))
@ -5355,29 +5351,13 @@ hivexget() {
ash "$(which hivexget)" "$@"
}
get_windows_type_from_windows_drive() {
get_installation_type_from_windows_drive() {
local os_dir=$1
apk add hivex
software_hive=$(find_file_ignore_case $os_dir/Windows/System32/config/SOFTWARE)
system_hive=$(find_file_ignore_case $os_dir/Windows/System32/config/SYSTEM)
installation_type=$(hivexget $software_hive '\Microsoft\Windows NT\CurrentVersion' InstallationType || true)
product_type=$(hivexget $system_hive '\ControlSet001\Control\ProductOptions' ProductType || true)
hive=$(find_file_ignore_case $os_dir/Windows/System32/config/SOFTWARE)
hivexget $hive '\Microsoft\Windows NT\CurrentVersion' InstallationType
apk del hivex
# 根据 win11 multi-session 的情况
# InstallationType 比 ProductType 准确
# Vista wim 和注册表都没有 InstallationType
case "$installation_type" in
Client | Embedded) echo client ;;
Server | 'Server Core') echo server ;;
*) case "$product_type" in
WinNT) echo client ;;
ServerNT) echo server ;;
*) error_and_exit "Unknown Windows Type" ;;
esac ;;
esac
}
get_windows_arch_from_windows_drive() {
@ -5526,7 +5506,7 @@ install_windows() {
# 用内核版本号筛选驱动
# 使得可以安装 Hyper-V Server / Azure Stack HCI 等 Windows Server 变种
# 7601.24214.180801-1700.win7sp1_ldr_escrow_CLIENT_ULTIMATE_x64FRE_en-us.iso wim 没有 Installation Type
# Vista wim 和 注册表 都没有 InstallationType
# 因此改成从注册表获取
if false; then
nt_ver=$(get_selected_image_prop "Major Version").$(get_selected_image_prop "Minor Version")
build_ver=$(get_selected_image_prop "Build")
@ -5541,7 +5521,7 @@ install_windows() {
wimmount "$iso_install_wim" "$image_index" /wim/
ntoskrnl_exe=$(find_file_ignore_case /wim/Windows/System32/ntoskrnl.exe)
get_windows_version_from_dll "$ntoskrnl_exe"
windows_type=$(get_windows_type_from_windows_drive /wim)
installation_type=$(get_installation_type_from_windows_drive /wim)
{
find_file_ignore_case /wim/Windows/System32/sacsess.exe && has_sac=true || has_sac=false
find_file_ignore_case /wim/Windows/INF/stornvme.inf && has_stornvme=true || has_stornvme=false
@ -5560,12 +5540,17 @@ install_windows() {
support_sha256=true
fi
product_ver=$(
case "$windows_type" in
client) get_client_name_by_build_ver "$build_ver" ;;
server) get_server_name_by_build_ver "$build_ver" ;;
esac
)
case "$installation_type" in
Client | Embedded)
windows_type=client
product_ver=$(get_client_name_by_build_ver "$build_ver")
;;
Server | 'Server Core')
windows_type=server
product_ver=$(get_server_name_by_build_ver "$build_ver")
;;
*) error_and_exit "Unknown Installation Type: $installation_type" ;;
esac
info "Selected image info"
echo "Image Name: $image_name"
@ -5936,39 +5921,15 @@ EOF
apk add msitools
# 8.4.3 的 xenbus 挑创建实例时的初始系统
# 初始系统为 windows 的实例支持 8.4.3
# 初始系统为 linux 的实例不支持 8.4.3
# 初始系统为 linux + 安装 8.4.3
# 如果用 msi 安装,则不会启用 xenbus结果是能启动但无法上网
# 如果通过 inf 安装,则会启用 xenbus结果是无法启动
apk add lscpu
hypervisor_vendor=$(lscpu | grep 'Hypervisor vendor:' | awk '{print $3}')
apk del lscpu
aws_pv_ver=$(
case "$nt_ver" in
6.1) $support_sha256 && echo 8.3.5 || echo 8.3.2 ;;
6.2 | 6.3)
case "$hypervisor_vendor" in
Microsoft) echo 8.4.3 ;; # 实例初始系统为 Windows能使用 8.4.3
Xen) echo 8.3.5 ;; # 实例初始系统为 Linux不能使用 8.4.3
esac
;;
6.2 | 6.3) echo 8.4.3 ;;
*) echo Latest ;;
esac
)
url=$(
case "$aws_pv_ver" in
8.3.2) echo https://web.archive.org/web/20221016194548/https://s3.amazonaws.com/ec2-windows-drivers-downloads/AWSPV/$aws_pv_ver/AWSPVDriver.zip ;; # win7 sha1
*) echo "$(get_aws_repo)/AWSPV/$aws_pv_ver/AWSPVDriver.zip" ;;
esac
)
download "$url" $drv/AWSPVDriver.zip
download "$(get_aws_repo)/AWSPV/$aws_pv_ver/AWSPVDriver.zip" $drv/AWSPVDriver.zip
unzip -o -d $drv $drv/AWSPVDriver.zip
mkdir -p $drv/xen/
@ -6531,12 +6492,6 @@ EOF
sed -i 's/EnableEMS=0/EnableEMS=1/i' $startnet_cmd
fi
# 4kn EFI 分区最少要 260M
# https://learn.microsoft.com/windows-hardware/manufacture/desktop/hard-drives-and-partitions
if is_4kn /dev/$xda; then
sed -i 's/is4kn=0/is4kn=1/i' $startnet_cmd
fi
# Windows Thin PC 有 Windows\System32\winpeshl.ini
# [LaunchApps]
# %SYSTEMDRIVE%\windows\system32\drvload.exe, %SYSTEMDRIVE%\windows\inf\sdbus.inf

View File

@ -93,14 +93,6 @@ for /f "tokens=3" %%a in (X:\disk.txt) do (
)
del X:\disk.txt
rem 这个变量会被 trans.sh 修改
set is4kn=0
if "%is4kn%"=="1" (
set EFISize=260
) else (
set EFISize=100
)
rem 重新分区/格式化
(if "%BootType%"=="efi" (
echo select disk %DiskIndex%
@ -112,7 +104,7 @@ rem 重新分区/格式化
echo select part 3
echo delete part override
echo create part efi size=%EFISize%
echo create part efi size=100
echo format fs=fat32 quick
echo create part msr size=16