core: 不重要的优化

This commit is contained in:
bin456789
2026-04-25 23:30:22 +08:00
parent e7deea5b0f
commit 1a1f8ea124
5 changed files with 54 additions and 23 deletions

View File

@ -331,7 +331,7 @@ bash reinstall.sh netboot.xyz
- If remote login fails, try using the username `.\administrator`.
- The machine with a static IP will automatically configure the IP. It may take a few minutes to take effect on the first boot.
- Supports ISO images in any language.
- Supports bypassing Windows 11 hardware requirements.
- Automatically bypassing Windows 11 hardware requirements.
#### Supported Systems
@ -582,12 +582,14 @@ bash reinstall.sh reset
According to the Law of Bug Conservation, fixing old bugs often introduces new ones.
If a new bug occurs, try using an older version to see if it works.
If a bug occurs, try using an older version to see if it works.
Go to <https://github.com/bin456789/reinstall/commits/main> and find the old versions `commit_id` on the right side.
Replace `xxxxxxxx` in the script below with the `commit_id` of an older version and run the script.
```bash
commit_id=xxxxxxx
commit_id=xxxxxxxx
curl -O https://raw.githubusercontent.com/bin456789/reinstall/$commit_id/reinstall.sh || wget -O ${_##*/} $_
sed -i "/^confhome.*main$/s/main/$commit_id/" reinstall.sh
bash reinstall.sh ...
@ -598,6 +600,7 @@ bash reinstall.sh ...
1. Fork this repository.
2. Modify the `confhome` and `confhome_cn` at the beginning of `reinstall.sh` and `reinstall.bat`.
3. Make changes to the other code.
4. Download and run your `reinstall.sh` or `reinstall.bat`."
## Thanks

View File

@ -331,7 +331,7 @@ bash reinstall.sh netboot.xyz
- 如果远程登录失败,可以尝试使用用户名 `.\administrator`
- 静态机器会自动配置好 IP可能首次开机几分钟后才生效
- 支持任意语言的 ISO
- 支持绕过 Windows 11 硬件限制
- 自动绕过 Windows 11 硬件限制
#### 支持的系统
@ -582,12 +582,14 @@ bash reinstall.sh reset
根据 Bug 守恒定律,修复旧 Bug 的同时会引入新的 Bug
如果遇到新的 Bug,可以试下旧版本是否正常
如果脚本出现问题,可以试下旧版本是否正常
<https://github.com/bin456789/reinstall/commits/main> 右侧找到旧版本的 `commit_id`
将下面脚本的 `xxxxxxxx` 替换成旧版本的 `commit_id` 并运行脚本
```bash
commit_id=xxxxxxx
commit_id=xxxxxxxx
curl -O https://raw.githubusercontent.com/bin456789/reinstall/$commit_id/reinstall.sh || wget -O ${_##*/} $_
sed -i "/^confhome.*main$/s/main/$commit_id/" reinstall.sh
bash reinstall.sh ...
@ -598,6 +600,7 @@ bash reinstall.sh ...
1. Fork 本仓库
2. 修改 `reinstall.sh``reinstall.bat` 开头的 `confhome``confhome_cn`
3. 修改其它代码
4. 下载并运行你的 `reinstall.sh``reinstall.bat`
## 感谢

View File

@ -702,12 +702,6 @@ is_virt() {
$_is_virt
}
is_absolute_path() {
# 检查路径是否以/开头
# 注意语法和 ash 不同
[[ "$1" = /* ]]
}
is_cpu_supports_x86_64_v3() {
# 用 ld.so/cpuid/coreinfo.exe 更准确
# centos 7 /usr/lib64/ld-linux-x86-64.so.2 没有 --help
@ -3229,7 +3223,7 @@ build_cmdline() {
# 脚本可能多次运行,先清理之前的残留
mkdir_clear() {
dir=$1
local dir=$1
if [ -z "$dir" ] || [ "$dir" = / ]; then
return
@ -3892,6 +3886,7 @@ This script is outdated, please download reinstall.sh again.
if [ "$hold" = 0 ]; then
info 'hold 0'
echo "Edit $tmp if needed."
read -r -p 'Press Enter to continue...'
fi

View File

@ -5738,10 +5738,15 @@ get_filesize_mb() {
du -m "$1" | awk '{print $1}'
}
is_absolute_path() {
# 检查路径是否以/开头
# 注意语法和 bash 不同
[[ "$1" = "/*" ]]
mkdir_clear() {
local dir=$1
if [ -z "$dir" ] || [ "$dir" = / ]; then
return
fi
rm -rf "$dir"
mkdir -p "$dir"
}
# 注意使用方法是 list=$(list_add "$list" "$item_to_add")
@ -6014,7 +6019,7 @@ install_windows() {
# 检测 sac 和 nvme
{
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
find_file_ignore_case /wim/Windows/System32/drivers/stornvme.sys && has_stornvme=true || has_stornvme=false
} >/dev/null 2>&1
# 检测是否支持 sha256 签名的驱动
@ -6234,8 +6239,9 @@ install_windows() {
add_drivers() {
info "Add drivers"
# 驱动下载临时文件夹
drv=/os/drivers
mkdir -p "$drv" # 驱动下载临时文件夹
mkdir_clear "$drv"
# 这里有坑
# $(get_cloud_vendor) 调用了 cache_dmi_and_virt
@ -6743,8 +6749,7 @@ EOF
cp_drivers $drv/virtio -ipath "*/$virtio_sys/$arch/*" "$@"
fi
else
# coreutils 的 cp mv rm 才有 -v 参数
apk add 7zip file coreutils
apk add 7zip file
download $baseurl/$dir/virtio-win-gt-$arch_xdd.msi $drv/virtio.msi
match="FILE_*_${virtio_sys}_${arch}*"
7z x $drv/virtio.msi -o$drv/virtio -i!$match -y -bb1

View File

@ -1,6 +1,6 @@
#!/bin/ash
# shellcheck shell=dash
# shellcheck disable=SC3001,SC3003,SC3010
# shellcheck disable=SC3001,SC3003,SC3010,SC3015
# reinstall.sh / trans.sh 共用此文件
# grep 无法处理 UTF-16LE 编码的 inf有以下几种解决方法
@ -239,6 +239,27 @@ list_files_from_inf() {
done < <(echo "$inf_txts")
}
is_x_starts_with_y() {
[[ "$1" =~ ^"$2" ]]
}
is_x_ends_with_y() {
[[ "$1" =~ "$2"$ ]]
}
is_absolute_path() {
# 检查路径是否以/开头
# alpine ash 可用
# [[ "$1" = "/*" ]]
# bash 可用
# [[ "$1" = /* ]]
# 都可用
is_x_starts_with_y "$1" /
}
# windows 安装驱动时,只会安装相同架构的驱动文件到系统,即使 inf 里有列出其它架构的驱动
# 因此 DISM 导出驱动时,也就没有包含其它架构的驱动文件
@ -284,7 +305,11 @@ get_path_in_correct_case() {
output="$output$part/"
else
# 最后 part
output="$output$part"
if is_x_ends_with_y "$path" /; then
output="$output$part/"
else
output="$output$part"
fi
fi
shift
done