Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9604563a22 | ||
|
|
381136551f | ||
|
|
b220fc45a5 | ||
| cb8e70c6ac | |||
|
|
963c19cc14 | ||
| 4a36e72c6e |
@@ -1,9 +1,9 @@
|
||||
Package: oyo
|
||||
Version: 1.1
|
||||
Version: 1.2
|
||||
Maintainer: shenmo <shenmo@spark-app.store>
|
||||
Section: utils
|
||||
Installed-Size:10
|
||||
Depends: curl,transhell
|
||||
Depends: transhell,aria2
|
||||
Description: Aptss for Yoyo OS
|
||||
Architecture: amd64
|
||||
Homepage: https://gitee.com/spark-community-works-collections/oyo
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
#!/bin/bash
|
||||
ln -sf /opt/durapps/oyo/apt /usr/local/bin/apt
|
||||
@@ -1,2 +0,0 @@
|
||||
#!/bin/bash
|
||||
rm -f /usr/local/bin/apt
|
||||
@@ -2,5 +2,5 @@
|
||||
source /opt/durapps/transhell/transhell.sh
|
||||
load_transhell
|
||||
|
||||
echo "${TRANSHELL_CONTENT_APT_IS_PROVIDED_BY_OYO} "
|
||||
echo -e "${TRANSHELL_CONTENT_APT_IS_PROVIDED_BY_OYO} "
|
||||
oyo $@
|
||||
@@ -1,3 +1,3 @@
|
||||
#!/bin/bash
|
||||
TRANSHELL_CONTENT_APT_IS_PROVIDED_BY_OYO="In Yoyo OS, apt is provided by oyo.Please be careful when using apt in scripts"
|
||||
TRANSHELL_CONTENT_APT_IS_PROVIDED_BY_OYO="In Yoyo OS, apt is provided by oyo.Please be careful when using apt in scripts\nAlso try oyo ! You can use oyo as apt and enjoy a faster speed!\nThe original version of apt can be call by /usr/bin/apt"
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#!/bin/bash
|
||||
TRANSHELL_CONTENT_APT_IS_PROVIDED_BY_OYO="在Yoyo OS中,apt是由oyo提供的。在脚本中使用apt请小心"
|
||||
TRANSHELL_CONTENT_APT_IS_PROVIDED_BY_OYO="在Yoyo OS中,apt是由oyo提供的。在脚本中使用apt请小心\n欢迎尝试oyo!oyo的使用方法和apt类似,但是速度更快!\n如果要使用原版的apt,请使用/usr/bin/apt"
|
||||
|
||||
|
||||
233
OYO/usr/share/bash-completion/completions/oyo
Normal file
233
OYO/usr/share/bash-completion/completions/oyo
Normal file
@@ -0,0 +1,233 @@
|
||||
# Debian apt(8) completion -*- shell-script -*-
|
||||
|
||||
_oyo()
|
||||
{
|
||||
local sourcesdir="/etc/apt/sources.list.d"
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
local GENERIC_APT_GET_OPTIONS='
|
||||
-d --download-only
|
||||
-y --assume-yes
|
||||
--assume-no
|
||||
-u --show-upgraded
|
||||
-m --ignore-missing
|
||||
-t --target-release
|
||||
--download
|
||||
--fix-missing
|
||||
--ignore-hold
|
||||
--upgrade
|
||||
--only-upgrade
|
||||
--allow-change-held-packages
|
||||
--allow-remove-essential
|
||||
--allow-downgrades
|
||||
--print-uris
|
||||
--trivial-only
|
||||
--remove
|
||||
--arch-only
|
||||
--allow-unauthenticated
|
||||
--allow-insecure-repositories
|
||||
--install-recommends
|
||||
--install-suggests
|
||||
--no-install-recommends
|
||||
--no-install-suggests
|
||||
--fix-policy
|
||||
'
|
||||
|
||||
# see if the user selected a command already
|
||||
local COMMANDS=(
|
||||
"list"
|
||||
"search"
|
||||
"show" "showsrc"
|
||||
"install" "reinstall" "remove" "purge" "autoremove" "autopurge"
|
||||
"update"
|
||||
"upgrade" "full-upgrade" "dist-upgrade"
|
||||
"edit-sources"
|
||||
"help"
|
||||
"source" "build-dep"
|
||||
"clean" "autoclean"
|
||||
"download" "changelog"
|
||||
"moo"
|
||||
"depends" "rdepends"
|
||||
"policy")
|
||||
|
||||
local command i
|
||||
for (( i=1; i < ${#words[@]}; i++ )); do
|
||||
if [[ " ${COMMANDS[*]} " == *" ${words[i]} "* ]]; then
|
||||
command=${words[i]}
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Complete a -t<SPACE><TAB>
|
||||
case $prev in
|
||||
-t|--target-release)
|
||||
COMPREPLY=( $( compgen -W "$(apt-cache policy | grep -Eo 'a=[^,]*|n=[^,]*' | cut -f2- -d= | sort -u)" -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
|
||||
# When the cursor (cword) is before the command word (i), only suggest
|
||||
# options but not package or file names:
|
||||
if [[ $cur == -* || ( -v command && $cword -le $i ) ]]; then
|
||||
case ${command-} in
|
||||
install|reinstall|remove|purge|upgrade|dist-upgrade|full-upgrade|autoremove|autopurge)
|
||||
COMPREPLY=( $( compgen -W '--show-progress
|
||||
--fix-broken --purge --verbose-versions --auto-remove
|
||||
-s --simulate --dry-run
|
||||
--download
|
||||
--fix-missing
|
||||
--fix-policy
|
||||
--ignore-hold
|
||||
--force-yes
|
||||
--trivial-only
|
||||
--reinstall --solver
|
||||
-t --target-release'"$GENERIC_APT_GET_OPTIONS" -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
update)
|
||||
COMPREPLY=( $( compgen -W '--list-cleanup
|
||||
--print-uris
|
||||
--allow-insecure-repositories
|
||||
' -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
list)
|
||||
COMPREPLY=( $( compgen -W '--installed --upgradable
|
||||
--manual-installed
|
||||
-v --verbose
|
||||
-a --all-versions
|
||||
-t --target-release
|
||||
' -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
show)
|
||||
COMPREPLY=( $( compgen -W '-a --all-versions
|
||||
' -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
depends|rdepends)
|
||||
COMPREPLY=( $( compgen -W '-i
|
||||
--important
|
||||
--installed
|
||||
--pre-depends
|
||||
--depends
|
||||
--recommends
|
||||
--suggests
|
||||
--replaces
|
||||
--breaks
|
||||
--conflicts
|
||||
--enhances
|
||||
--recurse
|
||||
--implicit' -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
search)
|
||||
COMPREPLY=( $( compgen -W '
|
||||
-n --names-only
|
||||
-f --full' -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
showsrc)
|
||||
COMPREPLY=( $( compgen -W '
|
||||
--only-source' -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
source)
|
||||
COMPREPLY=( $( compgen -W '
|
||||
-s --simulate --dry-run
|
||||
-b --compile --build
|
||||
-P --build-profiles
|
||||
--diff-only --debian-only
|
||||
--tar-only
|
||||
--dsc-only
|
||||
-t --target-release
|
||||
'"$GENERIC_APT_GET_OPTIONS" -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
build-dep)
|
||||
COMPREPLY=( $( compgen -W '
|
||||
-a --host-architecture
|
||||
-s --simulate --dry-run
|
||||
-P --build-profiles
|
||||
-t --target-release
|
||||
--purge --solver
|
||||
'"$GENERIC_APT_GET_OPTIONS" -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
moo)
|
||||
COMPREPLY=( $( compgen -W '
|
||||
--color
|
||||
' -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
clean|autoclean)
|
||||
COMPREPLY=( $( compgen -W '
|
||||
-s --simulate --dry-run
|
||||
' -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
|
||||
return
|
||||
fi
|
||||
|
||||
# specific command arguments
|
||||
if [[ -v command ]]; then
|
||||
case $command in
|
||||
remove|purge|autoremove|autopurge)
|
||||
if [[ -f /etc/debian_version ]]; then
|
||||
# Debian system
|
||||
COMPREPLY=( $( \
|
||||
_xfunc dpkg _comp_dpkg_installed_packages $cur ) )
|
||||
else
|
||||
# assume RPM based
|
||||
_xfunc rpm _rpm_installed_packages
|
||||
fi
|
||||
return 0
|
||||
;;
|
||||
show|list|download|changelog|depends|rdepends)
|
||||
COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \
|
||||
2> /dev/null ) )
|
||||
return 0
|
||||
;;
|
||||
install|reinstall)
|
||||
if [[ "$cur" == .* || "$cur" == /* || "$cur" == ~* ]]; then
|
||||
_filedir "deb"
|
||||
else
|
||||
COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \
|
||||
2> /dev/null ) )
|
||||
fi
|
||||
return 0
|
||||
;;
|
||||
source|build-dep|showsrc|policy)
|
||||
if [[ "$command" == build-dep && ( "$cur" == .* || "$cur" == /* || "$cur" == ~* ) ]]; then
|
||||
_filedir "dsc"
|
||||
else
|
||||
COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \
|
||||
2> /dev/null ) $( apt-cache dumpavail | \
|
||||
command grep "^Source: $cur" | sort -u | cut -f2 -d" " ) )
|
||||
fi
|
||||
return 0
|
||||
;;
|
||||
edit-sources)
|
||||
COMPREPLY=( $( compgen -W '$( command ls $sourcesdir )' \
|
||||
-- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
moo)
|
||||
COMPREPLY=( $( compgen -W 'moo' \
|
||||
-- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
else
|
||||
# no command yet, show what commands we have
|
||||
COMPREPLY=( $( compgen -W '${COMMANDS[@]}' -- "$cur" ) )
|
||||
fi
|
||||
|
||||
return 0
|
||||
} &&
|
||||
complete -F _oyo oyo
|
||||
|
||||
# ex: ts=4 sw=4 et filetype=sh
|
||||
@@ -6,7 +6,7 @@ import 'package:yoyo_get_fast_mirror/src/version.dart';
|
||||
|
||||
const executableName = 'yoyo-getfastmirror';
|
||||
const packageName = 'yoyo_get_fast_mirror';
|
||||
const description = 'A Very Good Project created by Yoyo.';
|
||||
const description = 'A Very Good aptss created by Yoyo.';
|
||||
|
||||
class YoyoGetFastMirrorCommandRunner extends CommandRunner<int> {
|
||||
/// {@macro yoyo_get_fast_mirror_command_runner}
|
||||
|
||||
@@ -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>
|
||||
Future<List<String>> getMirrorList() async {
|
||||
Future<List<String>> yoyoGetMirrorList() async {
|
||||
final response = await http.get(mirrorsUri);
|
||||
final list = response.body.replaceAll('\n', ' ').trimRight().split(' ');
|
||||
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,14 @@
|
||||
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/get_mirro_list.dart';
|
||||
import 'package:yoyo_get_fast_mirror/src/commands/modules/getfastmirro/network_test.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/ubuntu_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/yoyo_sources_list_template.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/Yoyo/yoyo_get_mirro_list.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/utils/generate_apt_fast_config_file.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 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 outputUbuntu = lightGreen.wrap('Ubuntu Mirrors:');
|
||||
@@ -25,11 +20,19 @@ Future<Map<String, dynamic>> getFastMirror({bool onlyTest = false}) async {
|
||||
status['msg'] = 'NetWork Error';
|
||||
return status;
|
||||
}
|
||||
//获取Yoyo镜像地址
|
||||
final yoYoMirrorList = await getMirrorList();
|
||||
_logger.info("\n$outputYoyo\n${yoYoMirrorList.join('\n')}\n");
|
||||
//测试Yoyo镜像并获取时间和排序后的Map
|
||||
final sortedUrlListAndTimeYoyo = await testMirroSpeed(yoYoMirrorList);
|
||||
// 如果 yoyo-os.list 存在,获取Yoyo镜像地址
|
||||
final yoYoMirrorList = yoyoIsExist() ? await yoyoGetMirrorList() : ['none'];
|
||||
if (yoyoIsExist()) {
|
||||
_logger.info("\n$outputYoyo\n${yoYoMirrorList.join('\n')}\n");
|
||||
}
|
||||
// 如果 yoyo-os.list 存在,测试Yoyo镜像并获取时间和排序后的Map
|
||||
final sortedUrlListAndTimeYoyo = yoyoIsExist()
|
||||
? await testMirroSpeed(yoYoMirrorList)
|
||||
: [
|
||||
{'url': '', 'time': 'none'}
|
||||
];
|
||||
// 获取Ubuntua镜像地址
|
||||
final ubuntuMirrorList = ubuntuGetMirrorList();
|
||||
//测试Ubuntu镜像并获取时间和排序后的Map
|
||||
_logger.info("\n$outputUbuntu\n${ubuntuMirrorList.join('\n')}\n");
|
||||
final sortedUrlListAndTimeUbuntu = await testMirroSpeed(ubuntuMirrorList);
|
||||
@@ -37,7 +40,9 @@ Future<Map<String, dynamic>> getFastMirror({bool onlyTest = false}) async {
|
||||
if (!onlyTest) {
|
||||
try {
|
||||
generateAptFastConfigFile(
|
||||
sortedUrlListAndTimeYoyo, sortedUrlListAndTimeUbuntu,);
|
||||
sortedUrlListAndTimeYoyo,
|
||||
sortedUrlListAndTimeUbuntu,
|
||||
);
|
||||
} catch (e) {
|
||||
status['success'] = false;
|
||||
status['msg'] = 'Generate Config File Error';
|
||||
@@ -46,21 +51,20 @@ Future<Map<String, dynamic>> getFastMirror({bool onlyTest = false}) async {
|
||||
status['success'] = true;
|
||||
}
|
||||
//写入镜像源文件
|
||||
//Yoyo
|
||||
final fastestYoyoMirror =
|
||||
sortedUrlListAndTimeYoyo.first.entries.first.value;
|
||||
final yoyoSourcesListFile = yoyoSourcesListTemplate(fastestYoyoMirror);
|
||||
writeMirrorIntoFile(
|
||||
yoyoSourcesListFile,
|
||||
'/etc/apt/sources.list.d/yoyo-os.list',
|
||||
);
|
||||
//如果 yoyo-os.list 存在,Yoyo
|
||||
if (yoyoIsExist()) {
|
||||
final fastestYoyoMirror =
|
||||
sortedUrlListAndTimeYoyo.first.entries.first.value;
|
||||
writeMirrorIntoFile(
|
||||
fastestYoyoMirror,
|
||||
'/etc/apt/sources.list.d/yoyo-os.list',
|
||||
);
|
||||
}
|
||||
//Ubuntu
|
||||
final fastestUbuntuMirror =
|
||||
sortedUrlListAndTimeUbuntu.first.entries.first.value;
|
||||
final ubuntuSourcesLIstFile =
|
||||
ubuntuSourcesListTemplate(fastestUbuntuMirror);
|
||||
writeMirrorIntoFile(
|
||||
ubuntuSourcesLIstFile,
|
||||
fastestUbuntuMirror,
|
||||
'/etc/apt/sources.list',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
String ubuntuSourcesListTemplate(String ubuntuMirrorUrl) {
|
||||
return '''
|
||||
# Generate by yoyo-getfastmirror
|
||||
# Author: Github/Riceneeder
|
||||
|
||||
deb $ubuntuMirrorUrl jammy main restricted universe multiverse
|
||||
deb $ubuntuMirrorUrl jammy-updates main restricted universe multiverse
|
||||
deb $ubuntuMirrorUrl jammy-backports main restricted universe multiverse
|
||||
deb $ubuntuMirrorUrl jammy-security main restricted universe multiverse
|
||||
''';
|
||||
}
|
||||
@@ -13,15 +13,7 @@ String aptFastConfigTemplate(String yoYoMirroList,String ubuntuMirroList) {
|
||||
#
|
||||
# Default: apt-get
|
||||
#
|
||||
_APTMGR=apt
|
||||
|
||||
if grep -Eqi "linuxmint" /etc/os-release;then
|
||||
_APTMGR=apt-get
|
||||
fi
|
||||
|
||||
if [ -x "\$(command -v oyo)" ]; then
|
||||
_APTMGR=apt-get
|
||||
fi
|
||||
_APTMGR=/usr/bin/apt
|
||||
|
||||
####
|
||||
#
|
||||
@@ -41,7 +33,7 @@ fi
|
||||
#
|
||||
# Default: dialog enabled
|
||||
#
|
||||
DOWNLOADBEFORE=true
|
||||
# DOWNLOADBEFORE=true
|
||||
|
||||
|
||||
# Choose mirror list to speed up downloads from same archive. To select some
|
||||
@@ -1,5 +1,5 @@
|
||||
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 String filePath = '$tmpDir/oyo/apt-fast.conf';
|
||||
@@ -28,6 +28,7 @@ Future<List<Map<String, String>>> testMirroSpeed(
|
||||
}
|
||||
}
|
||||
spinner.updateMessage('');
|
||||
// ignore: cascade_invocations
|
||||
spinner.stop();
|
||||
_logger.info(logMsg.toString());
|
||||
final resultMap = testResult.asMap();
|
||||
@@ -3,12 +3,21 @@ import 'package:mason_logger/mason_logger.dart';
|
||||
|
||||
final done = lightGreen.wrap('Done');
|
||||
final Logger _logger = Logger();
|
||||
RegExp urlReg = RegExp(
|
||||
r'\b(([\w-]+://?|www[.])[^\s()<>]+(?:[\w\d]+|([^[:punct:]\s]|/)))',
|
||||
);
|
||||
|
||||
///mirror 镜像源网址
|
||||
void writeMirrorIntoFile(String mirror, String path) {
|
||||
final file = File(path);
|
||||
final writting = lightYellow.wrap('Writting $path');
|
||||
final file = File(path);
|
||||
var fileContent = file.readAsStringSync();
|
||||
final url = urlReg.allMatches(fileContent);
|
||||
for (final item in url) {
|
||||
fileContent = fileContent.replaceAll(item.group(0) ?? '', mirror);
|
||||
}
|
||||
_logger.info(writting);
|
||||
if (!file.existsSync()) file.createSync(recursive: true);
|
||||
file.writeAsStringSync(mirror);
|
||||
file.writeAsStringSync(fileContent);
|
||||
_logger.info(done);
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
String yoyoSourcesListTemplate(String yoyoMirrorUrl) {
|
||||
return '''
|
||||
# Generate by yoyo-getfastmirror
|
||||
# Author: Gtibhub/Riceneeder
|
||||
|
||||
deb [arch=amd64] $yoyoMirrorUrl kokomi main
|
||||
''';
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
const packageVersion = '0.0.1';
|
||||
const packageVersion = '2023.1.31';
|
||||
|
||||
Reference in New Issue
Block a user