update:#I6BT41,#I6BT42
https://gitee.com/spark-community-works-collections/oyo/issues/I6BT42 https://gitee.com/spark-community-works-collections/oyo/issues/I6BT41
This commit is contained in:
parent
4a36e72c6e
commit
963c19cc14
@ -0,0 +1,9 @@
|
|||||||
|
const List<String> ubuntuMirrorList = [
|
||||||
|
'https://mirrors.tuna.tsinghua.edu.cn/ubuntu/',
|
||||||
|
'https://mirrors.aliyun.com/ubuntu/',
|
||||||
|
'https://repo.huaweicloud.com/ubuntu/'
|
||||||
|
];
|
||||||
|
|
||||||
|
List<String> ubuntuGetMirrorList(){
|
||||||
|
return ubuntuMirrorList;
|
||||||
|
}
|
@ -7,7 +7,7 @@ Uri mirrorsUri = Uri(
|
|||||||
);
|
);
|
||||||
|
|
||||||
/// 获取镜像列表,返回一个 List<String>
|
/// 获取镜像列表,返回一个 List<String>
|
||||||
Future<List<String>> getMirrorList() async {
|
Future<List<String>> yoyoGetMirrorList() async {
|
||||||
final response = await http.get(mirrorsUri);
|
final response = await http.get(mirrorsUri);
|
||||||
final list = response.body.replaceAll('\n', ' ').trimRight().split(' ');
|
final list = response.body.replaceAll('\n', ' ').trimRight().split(' ');
|
||||||
return list;
|
return list;
|
@ -0,0 +1,7 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
File file = File('/etc/apt/sources.list.d/yoyo-os.list');
|
||||||
|
|
||||||
|
bool yoyoIsExist() {
|
||||||
|
return file.existsSync();
|
||||||
|
}
|
@ -1,19 +1,16 @@
|
|||||||
import 'package:mason_logger/mason_logger.dart';
|
import 'package:mason_logger/mason_logger.dart';
|
||||||
import 'package:yoyo_get_fast_mirror/src/commands/modules/getfastmirro/generate_apt_fast_config_file.dart';
|
import 'package:yoyo_get_fast_mirror/src/commands/modules/getfastmirro/Ubuntu/ubuntu_get_mirro_list.dart';
|
||||||
import 'package:yoyo_get_fast_mirror/src/commands/modules/getfastmirro/get_mirro_list.dart';
|
import 'package:yoyo_get_fast_mirror/src/commands/modules/getfastmirro/Ubuntu/ubuntu_sources_list_template.dart';
|
||||||
import 'package:yoyo_get_fast_mirror/src/commands/modules/getfastmirro/network_test.dart';
|
import 'package:yoyo_get_fast_mirror/src/commands/modules/getfastmirro/Yoyo/yoyo_get_mirro_list.dart';
|
||||||
import 'package:yoyo_get_fast_mirror/src/commands/modules/getfastmirro/test_mirro_speed.dart';
|
import 'package:yoyo_get_fast_mirror/src/commands/modules/getfastmirro/Yoyo/yoyo_is_exist.dart';
|
||||||
import 'package:yoyo_get_fast_mirror/src/commands/modules/getfastmirro/ubuntu_sources_list_template.dart';
|
import 'package:yoyo_get_fast_mirror/src/commands/modules/getfastmirro/Yoyo/yoyo_sources_list_template.dart';
|
||||||
import 'package:yoyo_get_fast_mirror/src/commands/modules/getfastmirro/write_mirror_into_file.dart';
|
import 'package:yoyo_get_fast_mirror/src/commands/modules/getfastmirro/utils/generate_apt_fast_config_file.dart';
|
||||||
import 'package:yoyo_get_fast_mirror/src/commands/modules/getfastmirro/yoyo_sources_list_template.dart';
|
import 'package:yoyo_get_fast_mirror/src/commands/modules/getfastmirro/utils/network_test.dart';
|
||||||
|
import 'package:yoyo_get_fast_mirror/src/commands/modules/getfastmirro/utils/test_mirro_speed.dart';
|
||||||
|
import 'package:yoyo_get_fast_mirror/src/commands/modules/getfastmirro/utils/write_mirror_into_file.dart';
|
||||||
|
|
||||||
final Map<String, dynamic> status = {};
|
final Map<String, dynamic> status = {};
|
||||||
final Logger _logger = Logger();
|
final Logger _logger = Logger();
|
||||||
const List<String> ubuntuMirrorList = [
|
|
||||||
'https://mirrors.tuna.tsinghua.edu.cn/ubuntu/',
|
|
||||||
'https://mirrors.aliyun.com/ubuntu/',
|
|
||||||
'https://repo.huaweicloud.com/ubuntu/'
|
|
||||||
];
|
|
||||||
|
|
||||||
final outputYoyo = lightGreen.wrap('Yoyo Mirrors:');
|
final outputYoyo = lightGreen.wrap('Yoyo Mirrors:');
|
||||||
final outputUbuntu = lightGreen.wrap('Ubuntu Mirrors:');
|
final outputUbuntu = lightGreen.wrap('Ubuntu Mirrors:');
|
||||||
@ -25,11 +22,19 @@ Future<Map<String, dynamic>> getFastMirror({bool onlyTest = false}) async {
|
|||||||
status['msg'] = 'NetWork Error';
|
status['msg'] = 'NetWork Error';
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
//获取Yoyo镜像地址
|
// 如果 yoyo-os.list 存在,获取Yoyo镜像地址
|
||||||
final yoYoMirrorList = await getMirrorList();
|
final yoYoMirrorList = yoyoIsExist() ? await yoyoGetMirrorList() : ['none'];
|
||||||
|
if (yoyoIsExist()) {
|
||||||
_logger.info("\n$outputYoyo\n${yoYoMirrorList.join('\n')}\n");
|
_logger.info("\n$outputYoyo\n${yoYoMirrorList.join('\n')}\n");
|
||||||
//测试Yoyo镜像并获取时间和排序后的Map
|
}
|
||||||
final sortedUrlListAndTimeYoyo = await testMirroSpeed(yoYoMirrorList);
|
// 如果 yoyo-os.list 存在,测试Yoyo镜像并获取时间和排序后的Map
|
||||||
|
final sortedUrlListAndTimeYoyo = yoyoIsExist()
|
||||||
|
? await testMirroSpeed(yoYoMirrorList)
|
||||||
|
: [
|
||||||
|
{'url': '', 'time': 'none'}
|
||||||
|
];
|
||||||
|
// 获取Ubuntua镜像地址
|
||||||
|
final ubuntuMirrorList = ubuntuGetMirrorList();
|
||||||
//测试Ubuntu镜像并获取时间和排序后的Map
|
//测试Ubuntu镜像并获取时间和排序后的Map
|
||||||
_logger.info("\n$outputUbuntu\n${ubuntuMirrorList.join('\n')}\n");
|
_logger.info("\n$outputUbuntu\n${ubuntuMirrorList.join('\n')}\n");
|
||||||
final sortedUrlListAndTimeUbuntu = await testMirroSpeed(ubuntuMirrorList);
|
final sortedUrlListAndTimeUbuntu = await testMirroSpeed(ubuntuMirrorList);
|
||||||
@ -37,7 +42,9 @@ Future<Map<String, dynamic>> getFastMirror({bool onlyTest = false}) async {
|
|||||||
if (!onlyTest) {
|
if (!onlyTest) {
|
||||||
try {
|
try {
|
||||||
generateAptFastConfigFile(
|
generateAptFastConfigFile(
|
||||||
sortedUrlListAndTimeYoyo, sortedUrlListAndTimeUbuntu,);
|
sortedUrlListAndTimeYoyo,
|
||||||
|
sortedUrlListAndTimeUbuntu,
|
||||||
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
status['success'] = false;
|
status['success'] = false;
|
||||||
status['msg'] = 'Generate Config File Error';
|
status['msg'] = 'Generate Config File Error';
|
||||||
@ -46,7 +53,8 @@ Future<Map<String, dynamic>> getFastMirror({bool onlyTest = false}) async {
|
|||||||
status['success'] = true;
|
status['success'] = true;
|
||||||
}
|
}
|
||||||
//写入镜像源文件
|
//写入镜像源文件
|
||||||
//Yoyo
|
//如果 yoyo-os.list 存在,Yoyo
|
||||||
|
if (yoyoIsExist()) {
|
||||||
final fastestYoyoMirror =
|
final fastestYoyoMirror =
|
||||||
sortedUrlListAndTimeYoyo.first.entries.first.value;
|
sortedUrlListAndTimeYoyo.first.entries.first.value;
|
||||||
final yoyoSourcesListFile = yoyoSourcesListTemplate(fastestYoyoMirror);
|
final yoyoSourcesListFile = yoyoSourcesListTemplate(fastestYoyoMirror);
|
||||||
@ -54,6 +62,7 @@ Future<Map<String, dynamic>> getFastMirror({bool onlyTest = false}) async {
|
|||||||
yoyoSourcesListFile,
|
yoyoSourcesListFile,
|
||||||
'/etc/apt/sources.list.d/yoyo-os.list',
|
'/etc/apt/sources.list.d/yoyo-os.list',
|
||||||
);
|
);
|
||||||
|
}
|
||||||
//Ubuntu
|
//Ubuntu
|
||||||
final fastestUbuntuMirror =
|
final fastestUbuntuMirror =
|
||||||
sortedUrlListAndTimeUbuntu.first.entries.first.value;
|
sortedUrlListAndTimeUbuntu.first.entries.first.value;
|
||||||
|
@ -13,15 +13,7 @@ String aptFastConfigTemplate(String yoYoMirroList,String ubuntuMirroList) {
|
|||||||
#
|
#
|
||||||
# Default: apt-get
|
# Default: apt-get
|
||||||
#
|
#
|
||||||
_APTMGR=apt
|
_APTMGR=/usr/bin/apt
|
||||||
|
|
||||||
if grep -Eqi "linuxmint" /etc/os-release;then
|
|
||||||
_APTMGR=apt-get
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -x "\$(command -v oyo)" ]; then
|
|
||||||
_APTMGR=apt-get
|
|
||||||
fi
|
|
||||||
|
|
||||||
####
|
####
|
||||||
#
|
#
|
||||||
@ -41,7 +33,7 @@ fi
|
|||||||
#
|
#
|
||||||
# Default: dialog enabled
|
# Default: dialog enabled
|
||||||
#
|
#
|
||||||
DOWNLOADBEFORE=true
|
# DOWNLOADBEFORE=true
|
||||||
|
|
||||||
|
|
||||||
# Choose mirror list to speed up downloads from same archive. To select some
|
# Choose mirror list to speed up downloads from same archive. To select some
|
@ -1,5 +1,5 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:yoyo_get_fast_mirror/src/commands/modules/getfastmirro/apt_fast_config_template.dart';
|
import 'package:yoyo_get_fast_mirror/src/commands/modules/getfastmirro/utils/apt_fast_config_template.dart';
|
||||||
|
|
||||||
final tmpDir = Directory.systemTemp.path;
|
final tmpDir = Directory.systemTemp.path;
|
||||||
final String filePath = '$tmpDir/oyo/apt-fast.conf';
|
final String filePath = '$tmpDir/oyo/apt-fast.conf';
|
@ -28,6 +28,7 @@ Future<List<Map<String, String>>> testMirroSpeed(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
spinner.updateMessage('');
|
spinner.updateMessage('');
|
||||||
|
// ignore: cascade_invocations
|
||||||
spinner.stop();
|
spinner.stop();
|
||||||
_logger.info(logMsg.toString());
|
_logger.info(logMsg.toString());
|
||||||
final resultMap = testResult.asMap();
|
final resultMap = testResult.asMap();
|
Loading…
x
Reference in New Issue
Block a user