1
This commit is contained in:
1 parent
59125d185c
commit
5ac164b407
18 files changed
+2249
-43
No files matched your search
@@ -51,24 +51,37 @@ enum DistroFamily {
|
||||
class HeadlessCancelToken {
|
||||
Process? _process;
|
||||
bool _cancelled = false;
|
||||
Directory? _rootDir;
|
||||
|
||||
bool get isCancelled => _cancelled;
|
||||
|
||||
void _attach(Process process) {
|
||||
void _attach(Process process, {Directory? rootDir}) {
|
||||
_process = process;
|
||||
_rootDir = rootDir;
|
||||
if (_cancelled) {
|
||||
try {
|
||||
process.kill(ProcessSignal.sigkill);
|
||||
} catch (_) {}
|
||||
if (rootDir != null) {
|
||||
DistroManager().cleanStaleLocks(rootDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// 取消:标记状态并杀掉当前子进程(若有)
|
||||
/// 取消:标记状态并先尝试发送 SIGINT 优雅退出,随后超时强杀并清理陈旧锁
|
||||
void cancel() {
|
||||
_cancelled = true;
|
||||
try {
|
||||
_process?.kill(ProcessSignal.sigkill);
|
||||
_process?.kill(ProcessSignal.sigint);
|
||||
} catch (_) {}
|
||||
Future<void>.delayed(const Duration(milliseconds: 300), () {
|
||||
try {
|
||||
_process?.kill(ProcessSignal.sigkill);
|
||||
} catch (_) {}
|
||||
if (_rootDir != null) {
|
||||
DistroManager().cleanStaleLocks(_rootDir!);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -373,6 +386,7 @@ class DistroManager {
|
||||
String? workspacePath,
|
||||
String prootPath = 'proot',
|
||||
String? customCommand,
|
||||
Directory? customRootDir,
|
||||
}) async {
|
||||
// 1. 本地 Shell 特殊处理
|
||||
if (systemName == 'host') {
|
||||
@@ -393,7 +407,7 @@ class DistroManager {
|
||||
}
|
||||
|
||||
// 2. Linux 容器 (PRoot 隔离环境)
|
||||
final rootDir = await getSystemRootDir(systemName);
|
||||
final rootDir = customRootDir ?? await getSystemRootDir(systemName);
|
||||
// 前置守卫:rootfs 必须先真实存在。否则下方一系列 ensure*(DNS/CA 证书/shm/l2s/sysdata)
|
||||
// 会 recursive 地创建出一套空壳目录,把"并不存在的系统"伪造成系统选择器里的已安装项。
|
||||
if (!rootDir.existsSync()) {
|
||||
@@ -419,13 +433,13 @@ class DistroManager {
|
||||
await DistroInstaller.ensureJavaConfiguration(rootDir);
|
||||
|
||||
// 确保独立的 /dev/shm 目录存在(对标 proot-distro shm.py,解决 POSIX 共享内存缺失)
|
||||
final shmDir = await _ensureShmDir(systemName);
|
||||
final shmDir = await _ensureShmDir(systemName, customBaseDir: customRootDir?.parent);
|
||||
|
||||
// 确保独立的 .l2s 硬链接目录存在(对标 proot-distro --link2symlink 规范)
|
||||
final l2sDir = await _ensureL2sDir(systemName);
|
||||
final l2sDir = await _ensureL2sDir(systemName, customBaseDir: customRootDir?.parent);
|
||||
|
||||
// 确保独立的 sysdata 桩目录存在(对标 proot-distro sysdata.py,提供 SELinux 与 Proc 补充数据)
|
||||
final sysdataDir = await _ensureSysdataDir(systemName);
|
||||
final sysdataDir = await _ensureSysdataDir(systemName, customBaseDir: customRootDir?.parent);
|
||||
|
||||
String tmpPath = '/tmp';
|
||||
try {
|
||||
@@ -610,9 +624,9 @@ class DistroManager {
|
||||
}
|
||||
|
||||
/// 确保容器实例拥有独立的 POSIX 共享内存目录(对标 proot-distro shm.py)
|
||||
Future<Directory?> _ensureShmDir(String systemName) async {
|
||||
Future<Directory?> _ensureShmDir(String systemName, {Directory? customBaseDir}) async {
|
||||
try {
|
||||
final baseDir = await getBaseDistrosDir();
|
||||
final baseDir = customBaseDir ?? await getBaseDistrosDir();
|
||||
final shmDir = Directory(p.join(baseDir.path, systemName, 'shm'));
|
||||
if (!shmDir.existsSync()) {
|
||||
shmDir.createSync(recursive: true);
|
||||
@@ -625,9 +639,9 @@ class DistroManager {
|
||||
}
|
||||
|
||||
/// 确保容器实例拥有独立的 .l2s 硬链接跟踪目录(对标 proot-distro login/__init__.py)
|
||||
Future<Directory?> _ensureL2sDir(String systemName) async {
|
||||
Future<Directory?> _ensureL2sDir(String systemName, {Directory? customBaseDir}) async {
|
||||
try {
|
||||
final baseDir = await getBaseDistrosDir();
|
||||
final baseDir = customBaseDir ?? await getBaseDistrosDir();
|
||||
final l2sDir = Directory(p.join(baseDir.path, systemName, '.l2s'));
|
||||
if (!l2sDir.existsSync()) {
|
||||
l2sDir.createSync(recursive: true);
|
||||
@@ -640,9 +654,9 @@ class DistroManager {
|
||||
}
|
||||
|
||||
/// 确保容器实例拥有独立的 sysdata 桩目录与 SELinux 覆盖节点(对标 proot-distro sysdata.py)
|
||||
Future<Directory?> _ensureSysdataDir(String systemName) async {
|
||||
Future<Directory?> _ensureSysdataDir(String systemName, {Directory? customBaseDir}) async {
|
||||
try {
|
||||
final baseDir = await getBaseDistrosDir();
|
||||
final baseDir = customBaseDir ?? await getBaseDistrosDir();
|
||||
final sysdataDir = Directory(p.join(baseDir.path, systemName, 'sysdata'));
|
||||
if (!sysdataDir.existsSync()) {
|
||||
sysdataDir.createSync(recursive: true);
|
||||
@@ -824,9 +838,14 @@ class DistroManager {
|
||||
}
|
||||
}
|
||||
|
||||
/// 清理此前异常崩溃或中断留下的陈旧锁文件(防止 groupadd/useradd 等报 /etc/*.lock 锁占用或找不到)
|
||||
/// 清理此前异常崩溃或中断留下的陈旧锁文件(防止 groupadd/useradd 等报 /etc/*.lock 锁占用,以及 APT/APK 包管理器死锁)
|
||||
void cleanStaleLocks(Directory rootDir) {
|
||||
_cleanStaleLocks(rootDir);
|
||||
}
|
||||
|
||||
void _cleanStaleLocks(Directory rootDir) {
|
||||
try {
|
||||
// 1. /etc 目录下的陈旧锁文件与备份文件(防止 groupadd/useradd 等报 /etc/*.lock 锁占用或找不到)
|
||||
final etcDir = Directory(p.join(rootDir.path, 'etc'));
|
||||
if (etcDir.existsSync()) {
|
||||
for (final entry in etcDir.listSync(followLinks: false)) {
|
||||
@@ -843,6 +862,41 @@ class DistroManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Debian / Ubuntu (APT / dpkg) 核心锁文件
|
||||
final dpkgLockFiles = [
|
||||
p.join(rootDir.path, 'var', 'lib', 'dpkg', 'lock'),
|
||||
p.join(rootDir.path, 'var', 'lib', 'dpkg', 'lock-frontend'),
|
||||
p.join(rootDir.path, 'var', 'lib', 'apt', 'lists', 'lock'),
|
||||
p.join(rootDir.path, 'var', 'cache', 'apt', 'archives', 'lock'),
|
||||
];
|
||||
for (final filePath in dpkgLockFiles) {
|
||||
final f = File(filePath);
|
||||
if (f.existsSync()) {
|
||||
try {
|
||||
f.deleteSync();
|
||||
debugPrint('[DistroManager] 清理 APT/dpkg 陈旧锁文件: $filePath');
|
||||
} catch (_) {}
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Alpine Linux (APK) 锁文件
|
||||
final apkLock = File(p.join(rootDir.path, 'lib', 'apk', 'db', 'lock'));
|
||||
if (apkLock.existsSync()) {
|
||||
try {
|
||||
apkLock.deleteSync();
|
||||
debugPrint('[DistroManager] 清理 APK 陈旧锁文件: ${apkLock.path}');
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
// 4. Fedora / RPM 锁文件
|
||||
final rpmLock = File(p.join(rootDir.path, 'var', 'lib', 'rpm', '.rpm.lock'));
|
||||
if (rpmLock.existsSync()) {
|
||||
try {
|
||||
rpmLock.deleteSync();
|
||||
debugPrint('[DistroManager] 清理 RPM 陈旧锁文件: ${rpmLock.path}');
|
||||
} catch (_) {}
|
||||
}
|
||||
} catch (e) {
|
||||
debugPrint('[DistroManager] 清理陈旧锁文件异常 (非阻塞): $e');
|
||||
}
|
||||
@@ -862,12 +916,15 @@ class DistroManager {
|
||||
Duration timeout = const Duration(seconds: 120),
|
||||
HeadlessCancelToken? cancelToken,
|
||||
void Function(String chunk)? onStdout,
|
||||
Directory? customRootDir,
|
||||
}) async {
|
||||
try {
|
||||
final rootDir = customRootDir ?? (await getSystemRootDir(systemName));
|
||||
final config = await buildLaunchConfig(
|
||||
systemName: systemName,
|
||||
workspacePath: workspacePath,
|
||||
customCommand: command,
|
||||
customRootDir: customRootDir,
|
||||
);
|
||||
|
||||
final process = await Process.start(
|
||||
@@ -876,11 +933,12 @@ class DistroManager {
|
||||
environment: config.environment,
|
||||
workingDirectory: config.workingDirectory,
|
||||
);
|
||||
cancelToken?._attach(process);
|
||||
cancelToken?._attach(process, rootDir: rootDir);
|
||||
if (cancelToken?.isCancelled ?? false) {
|
||||
try {
|
||||
process.kill(ProcessSignal.sigkill);
|
||||
} catch (_) {}
|
||||
_cleanStaleLocks(rootDir);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -903,6 +961,7 @@ class DistroManager {
|
||||
try {
|
||||
process.kill(ProcessSignal.sigkill);
|
||||
} catch (_) {}
|
||||
_cleanStaleLocks(rootDir);
|
||||
return -1;
|
||||
},
|
||||
);
|
||||
@@ -913,6 +972,7 @@ class DistroManager {
|
||||
);
|
||||
|
||||
if (cancelToken?.isCancelled ?? false) {
|
||||
_cleanStaleLocks(rootDir);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,176 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart' show rootBundle;
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
import '../l10n/app_localizations.dart';
|
||||
import '../models/distro_manifest.dart';
|
||||
import '../widgets/distro_extract_dialog.dart';
|
||||
import 'distro_installer.dart';
|
||||
import 'distro_manager.dart';
|
||||
|
||||
/// 内部私有代码智能引擎服务 (files/internal_engine/alpine)
|
||||
class InternalEngineService extends ChangeNotifier {
|
||||
static final InternalEngineService instance = InternalEngineService._();
|
||||
InternalEngineService._();
|
||||
|
||||
/// 测试自定义引擎根目录
|
||||
@visibleForTesting
|
||||
Directory? customEngineDir;
|
||||
|
||||
bool _isChecking = false;
|
||||
bool get isChecking => _isChecking;
|
||||
|
||||
/// 获取引擎主目录: `<files>/internal_engine/alpine`
|
||||
Future<Directory> getEngineDir() async {
|
||||
if (customEngineDir != null) {
|
||||
return customEngineDir!;
|
||||
}
|
||||
final appDir = await getApplicationSupportDirectory();
|
||||
final rootPath = p.basename(appDir.path) == 'files'
|
||||
? appDir.path
|
||||
: p.join(appDir.path, 'files');
|
||||
final engineDir = Directory(p.join(rootPath, 'internal_engine', 'alpine'));
|
||||
if (!engineDir.existsSync()) {
|
||||
engineDir.createSync(recursive: true);
|
||||
}
|
||||
return engineDir;
|
||||
}
|
||||
|
||||
/// 获取 rootfs 目录: `<files>/internal_engine/alpine/rootfs`
|
||||
Future<Directory> getRootfsDir() async {
|
||||
final engineDir = await getEngineDir();
|
||||
return Directory(p.join(engineDir.path, 'rootfs'));
|
||||
}
|
||||
|
||||
/// 检查内置 Alpine 引擎是否已完整安装
|
||||
Future<bool> isEngineInstalled() async {
|
||||
try {
|
||||
final engineDir = await getEngineDir();
|
||||
final marker = File(p.join(engineDir.path, '.installed'));
|
||||
if (!marker.existsSync()) return false;
|
||||
|
||||
final rootfs = await getRootfsDir();
|
||||
if (!rootfs.existsSync()) return false;
|
||||
|
||||
final binDir = Directory(p.join(rootfs.path, 'bin'));
|
||||
final etcDir = Directory(p.join(rootfs.path, 'etc'));
|
||||
return binDir.existsSync() && etcDir.existsSync();
|
||||
} catch (e) {
|
||||
debugPrint('检查内置引擎异常: $e');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// 确保内置引擎已准备完毕;若未安装,弹出模态解压弹窗进行解压
|
||||
Future<bool> ensureEngineReady(BuildContext context) async {
|
||||
if (await isEngineInstalled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!context.mounted) return false;
|
||||
final l10n = AppLocalizations.of(context);
|
||||
|
||||
_isChecking = true;
|
||||
notifyListeners();
|
||||
|
||||
try {
|
||||
final success = await DistroExtractDialog.show(
|
||||
context: context,
|
||||
systemName: l10n?.internalEngineTitle ?? '内部代码智能引擎 (Alpine)',
|
||||
task: (onProgress, isCancelled) async {
|
||||
await extractEngine(
|
||||
onProgress: onProgress,
|
||||
isCancelled: isCancelled,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
_isChecking = false;
|
||||
notifyListeners();
|
||||
return success;
|
||||
} catch (e) {
|
||||
_isChecking = false;
|
||||
notifyListeners();
|
||||
debugPrint('解压内部引擎失败: $e');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// 解压 Asset 中的 Alpine minirootfs 到私有引擎目录
|
||||
Future<void> extractEngine({
|
||||
InstallProgressCallback? onProgress,
|
||||
bool Function()? isCancelled,
|
||||
}) async {
|
||||
final assetPath = DistroRepository.builtinAlpineAssetPath;
|
||||
onProgress?.call(0.02, '正在读取应用内置 Alpine 系统资源包...');
|
||||
|
||||
final byteData = await rootBundle.load(assetPath);
|
||||
final bytes = byteData.buffer.asUint8List();
|
||||
|
||||
final rootfsDir = await getRootfsDir();
|
||||
if (!rootfsDir.existsSync()) {
|
||||
rootfsDir.createSync(recursive: true);
|
||||
}
|
||||
|
||||
await DistroInstaller.installFromBytes(
|
||||
tarGzBytes: bytes,
|
||||
targetDir: rootfsDir,
|
||||
onProgress: onProgress,
|
||||
isCancelled: isCancelled,
|
||||
);
|
||||
|
||||
// 写入安装完成标记文件
|
||||
final engineDir = await getEngineDir();
|
||||
final marker = File(p.join(engineDir.path, '.installed'));
|
||||
await marker.writeAsString('ready');
|
||||
}
|
||||
|
||||
/// 检查某命令(如 clangd, rust-analyzer)是否在内置 Alpine 中已安装
|
||||
Future<bool> isCommandInstalled(String command) async {
|
||||
if (!await isEngineInstalled() || command.trim().isEmpty) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
final rootfs = await getRootfsDir();
|
||||
final res = await DistroManager().runHeadlessCommand(
|
||||
systemName: 'alpine_internal',
|
||||
customRootDir: rootfs,
|
||||
command: 'command -v ${command.trim()} >/dev/null 2>&1 && echo CE_OK',
|
||||
timeout: const Duration(seconds: 15),
|
||||
);
|
||||
return res?.stdout.toString().contains('CE_OK') ?? false;
|
||||
} catch (e) {
|
||||
debugPrint('检查内置引擎命令异常: $e');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// 在内置 Alpine 中安装指定 apk 软件包
|
||||
Future<bool> installPackage(
|
||||
String apkPackage, {
|
||||
void Function(String chunk)? onOutput,
|
||||
}) async {
|
||||
if (!await isEngineInstalled() || apkPackage.trim().isEmpty) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
final rootfs = await getRootfsDir();
|
||||
final res = await DistroManager().runHeadlessCommand(
|
||||
systemName: 'alpine_internal',
|
||||
customRootDir: rootfs,
|
||||
command: 'apk add --no-cache ${apkPackage.trim()}',
|
||||
timeout: const Duration(minutes: 5),
|
||||
onStdout: onOutput,
|
||||
);
|
||||
return res != null && res.exitCode == 0;
|
||||
} catch (e) {
|
||||
debugPrint('安装内置引擎软件包异常: $e');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import '../models/lsp_language_config.dart';
|
||||
|
||||
/// 语言服务器配置管理器
|
||||
class LspConfigService extends ChangeNotifier {
|
||||
static final LspConfigService instance = LspConfigService._();
|
||||
LspConfigService._();
|
||||
|
||||
/// 测试自定义存储目录
|
||||
@visibleForTesting
|
||||
Directory? customBaseDir;
|
||||
|
||||
List<LspLanguageConfig> _configs = [];
|
||||
bool _isLoaded = false;
|
||||
|
||||
List<LspLanguageConfig> get configs => List.unmodifiable(_configs);
|
||||
bool get isLoaded => _isLoaded;
|
||||
|
||||
/// 获取配置文件路径: `<files>/internal_engine/lsp_languages.json`
|
||||
Future<File> getConfigFile() async {
|
||||
final Directory baseDir;
|
||||
if (customBaseDir != null) {
|
||||
baseDir = customBaseDir!;
|
||||
} else {
|
||||
final appDir = await getApplicationSupportDirectory();
|
||||
final rootPath = p.basename(appDir.path) == 'files'
|
||||
? appDir.path
|
||||
: p.join(appDir.path, 'files');
|
||||
baseDir = Directory(p.join(rootPath, 'internal_engine'));
|
||||
}
|
||||
|
||||
if (!baseDir.existsSync()) {
|
||||
baseDir.createSync(recursive: true);
|
||||
}
|
||||
return File(p.join(baseDir.path, 'lsp_languages.json'));
|
||||
}
|
||||
|
||||
/// 加载配置,若缺失预设语言则自动增量追加合并并回写
|
||||
Future<List<LspLanguageConfig>> loadConfigs({bool forceReload = false}) async {
|
||||
if (_isLoaded && !forceReload) {
|
||||
return _configs;
|
||||
}
|
||||
|
||||
final file = await getConfigFile();
|
||||
List<LspLanguageConfig> loaded = [];
|
||||
bool needSave = false;
|
||||
|
||||
if (!file.existsSync()) {
|
||||
loaded = List.from(LspLanguageConfig.defaultPresets);
|
||||
needSave = true;
|
||||
} else {
|
||||
try {
|
||||
final content = file.readAsStringSync();
|
||||
final dynamic raw = jsonDecode(content);
|
||||
if (raw is List) {
|
||||
loaded = raw
|
||||
.map((e) => e is Map<String, dynamic>
|
||||
? LspLanguageConfig.fromJson(e)
|
||||
: null)
|
||||
.whereType<LspLanguageConfig>()
|
||||
.toList();
|
||||
}
|
||||
} catch (e) {
|
||||
debugPrint('读取 lsp_languages.json 异常: $e,使用默认预设');
|
||||
loaded = List.from(LspLanguageConfig.defaultPresets);
|
||||
needSave = true;
|
||||
}
|
||||
|
||||
// 动态增量合并:对比官方预设,若预设中某项 id 本地缺失,则追加进去,默认 enabled: true
|
||||
final existingIds = loaded.map((e) => e.id).toSet();
|
||||
for (final preset in LspLanguageConfig.defaultPresets) {
|
||||
if (!existingIds.contains(preset.id)) {
|
||||
loaded.add(preset.copyWith(enabled: true));
|
||||
needSave = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_configs = loaded;
|
||||
_isLoaded = true;
|
||||
|
||||
if (needSave) {
|
||||
await _writeToDisk();
|
||||
}
|
||||
|
||||
notifyListeners();
|
||||
return _configs;
|
||||
}
|
||||
|
||||
/// 保存完整配置列表到本地 JSON
|
||||
Future<void> saveConfigs(List<LspLanguageConfig> newConfigs) async {
|
||||
_configs = List.from(newConfigs);
|
||||
_isLoaded = true;
|
||||
await _writeToDisk();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// 更新或新增某项语言配置
|
||||
Future<void> updateConfig(LspLanguageConfig config) async {
|
||||
final index = _configs.indexWhere((e) => e.id == config.id);
|
||||
if (index >= 0) {
|
||||
_configs[index] = config;
|
||||
} else {
|
||||
_configs.add(config);
|
||||
}
|
||||
await _writeToDisk();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// 删除某项语言配置
|
||||
Future<void> deleteConfig(String id) async {
|
||||
_configs.removeWhere((e) => e.id == id);
|
||||
await _writeToDisk();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// 恢复官方默认预设
|
||||
Future<void> resetToDefaults() async {
|
||||
_configs = List.from(LspLanguageConfig.defaultPresets);
|
||||
await _writeToDisk();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// 根据文件扩展名查找匹配的已启用语言配置
|
||||
LspLanguageConfig? findByExtension(String ext) {
|
||||
if (ext.isEmpty) return null;
|
||||
final normalized = ext.startsWith('.') ? ext.toLowerCase() : '.$ext'.toLowerCase();
|
||||
|
||||
for (final config in _configs) {
|
||||
if (!config.enabled) continue;
|
||||
for (final item in config.fileExtensions) {
|
||||
final itemNorm = item.startsWith('.') ? item.toLowerCase() : '.$item'.toLowerCase();
|
||||
if (itemNorm == normalized) {
|
||||
return config;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<void> _writeToDisk() async {
|
||||
try {
|
||||
final file = await getConfigFile();
|
||||
final encoder = const JsonEncoder.withIndent(' ');
|
||||
final jsonString = encoder.convert(_configs.map((e) => e.toJson()).toList());
|
||||
file.writeAsStringSync(jsonString, flush: true);
|
||||
} catch (e) {
|
||||
debugPrint('保存 lsp_languages.json 失败: $e');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,8 +19,15 @@ class ToolchainRequirement {
|
||||
required this.installCommands,
|
||||
});
|
||||
|
||||
/// 获取指定发行版家族下的安装命令
|
||||
String? getInstallCommand(DistroFamily family) => installCommands[family];
|
||||
/// 获取指定发行版家族下的安装命令(对于 Ubuntu/Debian 自动前置 dpkg 自愈修复,防止前序中断报错)
|
||||
String? getInstallCommand(DistroFamily family) {
|
||||
final cmd = installCommands[family];
|
||||
if (cmd == null) return null;
|
||||
if (family == DistroFamily.ubuntu || family == DistroFamily.debian) {
|
||||
return 'DEBIAN_FRONTEND=noninteractive dpkg --configure -a 2>/dev/null || true; $cmd';
|
||||
}
|
||||
return cmd;
|
||||
}
|
||||
}
|
||||
|
||||
/// 预编译软件源与工具链检测/安装适配服务
|
||||
|
||||
Reference in new issue
Block a user