Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 78ff1536b4 | |||
| 7bfb118ed1 | |||
| 01397bf9c6 | |||
| bb869eec89 | |||
| 8510d08952 | |||
|
|
537fcb8701 | ||
|
|
b49e59b45c | ||
|
|
9604563a22 | ||
|
|
381136551f | ||
|
|
b220fc45a5 | ||
| cb8e70c6ac | |||
|
|
963c19cc14 | ||
| 4a36e72c6e |
@@ -1,9 +1,9 @@
|
|||||||
Package: oyo
|
Package: oyo
|
||||||
Version: 1.1
|
Version: 1.2.4
|
||||||
Maintainer: shenmo <shenmo@spark-app.store>
|
Maintainer: shenmo <shenmo@spark-app.store>
|
||||||
Section: utils
|
Section: utils
|
||||||
Installed-Size:10
|
Installed-Size:10
|
||||||
Depends: curl,transhell
|
Depends: transhell,aria2
|
||||||
Description: Aptss for Yoyo OS
|
Description: Aptss for Yoyo OS
|
||||||
Architecture: amd64
|
Architecture: amd64
|
||||||
Homepage: https://gitee.com/spark-community-works-collections/oyo
|
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
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
source /opt/durapps/transhell/transhell.sh
|
|
||||||
load_transhell
|
|
||||||
|
|
||||||
echo "${TRANSHELL_CONTENT_APT_IS_PROVIDED_BY_OYO} "
|
|
||||||
oyo $@
|
|
||||||
@@ -33,6 +33,9 @@ fi
|
|||||||
if [ "$1" = "yyupdate" ];then
|
if [ "$1" = "yyupdate" ];then
|
||||||
update-apt-fast-conf
|
update-apt-fast-conf
|
||||||
##### 其他的直接转给apt-fast
|
##### 其他的直接转给apt-fast
|
||||||
|
|
||||||
|
elif [ "$1" = "install" ];then
|
||||||
|
${YY_APT_FAST} $@ --allow-downgrades
|
||||||
else
|
else
|
||||||
${YY_APT_FAST} $@
|
${YY_APT_FAST} $@
|
||||||
fi
|
fi
|
||||||
|
|||||||
8
OYO/usr/local/bin/apt
Executable file
8
OYO/usr/local/bin/apt
Executable file
@@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
source /opt/durapps/transhell/transhell.sh
|
||||||
|
load_transhell
|
||||||
|
if [[ ! -t 1 ]]; then # 如果标准输出不是终端,输出警告信息到 stderr
|
||||||
|
echo -e "${TRANSHELL_CONTENT_APT_IS_PROVIDED_BY_OYO} " >&2
|
||||||
|
fi
|
||||||
|
|
||||||
|
oyo $@
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
#!/bin/bash
|
#!/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
|
#!/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
|
||||||
@@ -1,165 +0,0 @@
|
|||||||
###################################################################
|
|
||||||
# CONFIGURATION OPTIONS
|
|
||||||
###################################################################
|
|
||||||
# Every item has a default value besides MIRRORS (which is unset).
|
|
||||||
|
|
||||||
# Use aptitude, apt-get, or apt?
|
|
||||||
# Note that apt-get is used as a fallback for outputting the
|
|
||||||
# package URI list for e.g. aptitude, which can't do this
|
|
||||||
# Optionally add the FULLPATH to apt-get or apt-rpm or aptitude
|
|
||||||
# e.g. /usr/bin/aptitude
|
|
||||||
#
|
|
||||||
# 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
|
|
||||||
|
|
||||||
####
|
|
||||||
#
|
|
||||||
# UOS sources auth config
|
|
||||||
#
|
|
||||||
#
|
|
||||||
if grep -Eqi "UnionTech" /etc/issue || grep -Eq "UnionTech" /etc/*-release;then
|
|
||||||
AUTH_UOS_USER="uos-https://license.chinauos.com-apt"
|
|
||||||
AUTH_UOS_PASSWD="`cat /etc/apt/auth.conf.d/uos.conf | grep home-packages.chinauos.com`"
|
|
||||||
AUTH_UOS_PASSWD=`echo ${AUTH_UOS_PASSWD#*password }`
|
|
||||||
|
|
||||||
fi
|
|
||||||
##### UOS自动读取账号密码以实现使用aptss来加速下载
|
|
||||||
|
|
||||||
# Enable DOWNLOADBEFORE to suppress apt-fast confirmation dialog and download
|
|
||||||
# packages directly.
|
|
||||||
#
|
|
||||||
# Default: dialog enabled
|
|
||||||
#
|
|
||||||
DOWNLOADBEFORE=true
|
|
||||||
|
|
||||||
|
|
||||||
# Choose mirror list to speed up downloads from same archive. To select some
|
|
||||||
# mirrors take a look at your distribution's archive mirror lists.
|
|
||||||
# Debian: http://www.debian.org/mirror/list
|
|
||||||
# Ubuntu: https://launchpad.net/ubuntu/+archivemirrors
|
|
||||||
#
|
|
||||||
# It is required to add mirrors in the sources.list to this array as well, so
|
|
||||||
# apt-fast can destinguish between different distributions.
|
|
||||||
#
|
|
||||||
# Examples:
|
|
||||||
#
|
|
||||||
# Different distributions (as in operating systems):
|
|
||||||
#
|
|
||||||
# sources.list:
|
|
||||||
# deb http://deb.debian.org/debian/ unstable main non-free contrib
|
|
||||||
# deb http://de.archive.ubuntu.com/ubuntu/ bionic main universe
|
|
||||||
#
|
|
||||||
# apt-fast.conf:
|
|
||||||
# MIRRORS=( 'http://deb.debian.org/debian','http://ftp.debian.org/debian,http://ftp2.de.debian.org/debian,http://ftp.de.debian.org/debian,ftp://ftp.uni-kl.de/debian'
|
|
||||||
# 'http://archive.ubuntu.com/ubuntu,http://de.archive.ubuntu.com/ubuntu,http://ftp.halifax.rwth-aachen.de/ubuntu,http://ftp.uni-kl.de/pub/linux/ubuntu,http://mirror.informatik.uni-mannheim.de/pub/linux/distributions/ubuntu/' )
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Single distribution:
|
|
||||||
#
|
|
||||||
# sources.list:
|
|
||||||
# deb http://fr.archive.ubuntu.com/ubuntu/ bionic main
|
|
||||||
# deb http://fr.archive.ubuntu.com/ubuntu/ artful main
|
|
||||||
#
|
|
||||||
# apt-fast.conf:
|
|
||||||
# MIRRORS=( 'http://fr.archive.ubuntu.com/ubuntu,http://bouyguestelecom.ubuntu.lafibre.info/ubuntu,http://mirror.ovh.net/ubuntu,http://ubuntu-archive.mirrors.proxad.net/ubuntu' )
|
|
||||||
#
|
|
||||||
# Default: disabled
|
|
||||||
#
|
|
||||||
MIRRORS=( 'https://code.gitlink.org.cn/yoyo-os/packages/raw/branch/master, https://packages.yzzi.icu/, http://mirror2.inuyasha.love/yoyo, https://yoyo-os.github.io/packages' )
|
|
||||||
|
|
||||||
|
|
||||||
# Maximum number of connections
|
|
||||||
# You can use this value in _DOWNLOADER command. Escape with ${}: ${_MAXNUM}
|
|
||||||
#
|
|
||||||
# Default: 5
|
|
||||||
#
|
|
||||||
_MAXNUM=16
|
|
||||||
|
|
||||||
|
|
||||||
# Maximum number of connections per server
|
|
||||||
# Default: 10
|
|
||||||
#
|
|
||||||
_MAXCONPERSRV=1
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Split size i.e. size of each piece
|
|
||||||
# Possible Values: 1M-1024M
|
|
||||||
#
|
|
||||||
_MINSPLITSZ=1M
|
|
||||||
|
|
||||||
|
|
||||||
# Piece selection algorithm to use
|
|
||||||
# Available values are: default, inorder, geom
|
|
||||||
# default: selects piece so that it reduces the number of establishing connection, reasonable for most cases
|
|
||||||
# inorder: selects pieces in sequential order starting from first piece
|
|
||||||
# geom: selects piece which has minimum index like inorder, but it exponentially increasingly keeps space from previously selected pieces
|
|
||||||
#
|
|
||||||
_PIECEALGO=default
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Downloadmanager listfile
|
|
||||||
# You can use this value in _DOWNLOADER command. Escape with ${}: ${DLLIST}
|
|
||||||
#
|
|
||||||
# Default: /tmp/apt-fast.list
|
|
||||||
#
|
|
||||||
DLLIST='/tmp/apt-fast.list'
|
|
||||||
|
|
||||||
|
|
||||||
# Download command to use. Temporary download list is designed for aria2. But
|
|
||||||
# you can choose another download command or download manager. It has to
|
|
||||||
# support following input file syntax (\t is tab character):
|
|
||||||
#
|
|
||||||
# # Comment
|
|
||||||
# MIRROR1\tMIRROR2\tMIRROR3...
|
|
||||||
# out=FILENAME1
|
|
||||||
# MIRROR1\tMIRROR2\tMIRROR3...
|
|
||||||
# out=FILENAME2
|
|
||||||
# ...
|
|
||||||
#
|
|
||||||
# Examples:
|
|
||||||
# aria2c with a proxy (set username, proxy, ip and password!)
|
|
||||||
# _DOWNLOADER='aria2c --no-conf -c -j ${_MAXNUM} -x ${_MAXCONPERSRV} -s ${_SPLITCON} --min-split-size=${_MINSPLITSZ} --stream-piece-selector=${_PIECEALGO} --http-proxy=http://username:password@proxy_ip:proxy_port -i ${DLLIST}'
|
|
||||||
#
|
|
||||||
# Default: _DOWNLOADER='aria2c --no-conf -c -j ${_MAXNUM} -x ${_MAXCONPERSRV} -s ${_SPLITCON} --min-split-size=${_MINSPLITSZ} --stream-piece-selector=${_PIECEALGO} -i ${DLLIST} --connect-timeout=600 --timeout=600 -m0'
|
|
||||||
#
|
|
||||||
_DOWNLOADER='aria2c --no-conf -c -j ${_MAXNUM} -x ${_MAXCONPERSRV} --min-split-size=${_MINSPLITSZ} --stream-piece-selector=${_PIECEALGO} -i ${DLLIST} --connect-timeout=600 --timeout=600 -m0 --http-user ${AUTH_UOS_USER} --http-passwd ${AUTH_UOS_PASSWD}'
|
|
||||||
|
|
||||||
|
|
||||||
# Download temp folder for Downloadmanager
|
|
||||||
# example /tmp/apt-fast. Standard is /var/cache/apt-fast
|
|
||||||
#
|
|
||||||
# Default: /var/cache/apt/apt-fast
|
|
||||||
#
|
|
||||||
DLDIR='/var/cache/apt/apt-fast'
|
|
||||||
|
|
||||||
|
|
||||||
# APT archives cache directory
|
|
||||||
#
|
|
||||||
# Default /var/cache/apt/archives
|
|
||||||
# (APT configuration items Dir::Cache and Dir::Cache::archives)
|
|
||||||
#
|
|
||||||
APTCACHE='/var/cache/apt/archives'
|
|
||||||
|
|
||||||
|
|
||||||
# apt-fast colors
|
|
||||||
# Colors are disabled when not using a terminal.
|
|
||||||
#
|
|
||||||
# Default colors are:
|
|
||||||
# cGreen='\e[0;32m'
|
|
||||||
# cRed='\e[0;31m'
|
|
||||||
# cBlue='\e[0;34m'
|
|
||||||
# endColor='\e[0m'
|
|
||||||
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="102" height="20">
|
|
||||||
<linearGradient id="b" x2="0" y2="100%">
|
|
||||||
<stop offset="0" stop-color="#bbb" stop-opacity=".1" />
|
|
||||||
<stop offset="1" stop-opacity=".1" />
|
|
||||||
</linearGradient>
|
|
||||||
<clipPath id="a">
|
|
||||||
<rect width="102" height="20" rx="3" fill="#fff" />
|
|
||||||
</clipPath>
|
|
||||||
<g clip-path="url(#a)">
|
|
||||||
<path fill="#555" d="M0 0h59v20H0z" />
|
|
||||||
<path fill="#44cc11" d="M59 0h43v20H59z" />
|
|
||||||
<path fill="url(#b)" d="M0 0h102v20H0z" />
|
|
||||||
</g>
|
|
||||||
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="110">
|
|
||||||
<text x="305" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="490">coverage</text>
|
|
||||||
<text x="305" y="140" transform="scale(.1)" textLength="490">coverage</text>
|
|
||||||
<text x="795" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="330">100%</text>
|
|
||||||
<text x="795" y="140" transform="scale(.1)" textLength="330">100%</text>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 1.1 KiB |
40
yoyo-getfastmirror/lib/i18n.dart
Normal file
40
yoyo-getfastmirror/lib/i18n.dart
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
// ignore_for_file: avoid_dynamic_calls
|
||||||
|
|
||||||
|
import 'dart:io';
|
||||||
|
import 'package:yoyo_get_fast_mirror/i18n/lang.i18n.dart';
|
||||||
|
import 'package:yoyo_get_fast_mirror/i18n/lang_zh-CN.i18n.dart';
|
||||||
|
|
||||||
|
final local = Platform.environment['LANG']!.indexOf('zh_CN') == 0;
|
||||||
|
final lang = local ? zhCN : enUS;
|
||||||
|
|
||||||
|
class Error {
|
||||||
|
static String network =
|
||||||
|
lang['GetfastmirroCommand']['Error']['NetWork'] as String;
|
||||||
|
static String generateConfig =
|
||||||
|
lang['GetfastmirroCommand']['Error']['GenerateConfig'] as String;
|
||||||
|
}
|
||||||
|
|
||||||
|
class GetfastmirroCommand {
|
||||||
|
static String description =
|
||||||
|
lang['GetfastmirroCommand']['Description'] as String;
|
||||||
|
static String flagOnlyTestHlep =
|
||||||
|
lang['GetfastmirroCommand']['FlagOnlyTestHlep'] as String;
|
||||||
|
static String runOutPut = lang['GetfastmirroCommand']['RunOutPut'] as String;
|
||||||
|
static String writting = lang['GetfastmirroCommand']['Writting'] as String;
|
||||||
|
static String done = lang['GetfastmirroCommand']['Done'] as String;
|
||||||
|
static String speedTest = lang['GetfastmirroCommand']['SpeedTest'] as String;
|
||||||
|
static String speedResult =
|
||||||
|
lang['GetfastmirroCommand']['SpeedResult'] as String;
|
||||||
|
static Error error = Error();
|
||||||
|
}
|
||||||
|
|
||||||
|
class Lang {
|
||||||
|
static String description = lang['Description'] as String;
|
||||||
|
static String flagVersionHlep =lang['FlagVersionHlep'] as String;
|
||||||
|
static String flagVerboseHlep =lang['FlagVerboseHlep'] as String;
|
||||||
|
static String argumentinformation =lang['Argumentinformation'] as String;
|
||||||
|
static String topLevelOptions =lang['TopLevelOptions'] as String;
|
||||||
|
static String command =lang['Command'] as String;
|
||||||
|
static String commandOptions =lang['CommandOptions'] as String;
|
||||||
|
static GetfastmirroCommand getfastmirroCommand = GetfastmirroCommand();
|
||||||
|
}
|
||||||
23
yoyo-getfastmirror/lib/i18n/lang.i18n.dart
Normal file
23
yoyo-getfastmirror/lib/i18n/lang.i18n.dart
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
Map<dynamic,dynamic> enUS = {
|
||||||
|
'Description': 'A Very Good aptss created by Yoyo.',
|
||||||
|
'FlagVersionHlep': 'Print the current version.',
|
||||||
|
'FlagVerboseHlep': 'Noisy logging, including all shell commands executed.',
|
||||||
|
'Argumentinformation': 'Argument information:',
|
||||||
|
'TopLevelOptions': ' Top level options:',
|
||||||
|
'Command': ' Command:',
|
||||||
|
'CommandOptions': ' Command options:',
|
||||||
|
'GetfastmirroCommand': {
|
||||||
|
'Description': 'Get fastest mirror and generate config file for oyo',
|
||||||
|
'FlagOnlyTestHlep': "Only test mirrors' speed",
|
||||||
|
'RunOutPut':
|
||||||
|
'Get the fastest mirror which will be write into source file\nAnd generate a config file for oyo',
|
||||||
|
'Error': {
|
||||||
|
'NetWork': 'NetWork Error',
|
||||||
|
'GenerateConfig': 'Generate Config File Error'
|
||||||
|
},
|
||||||
|
'Writting': 'Writting',
|
||||||
|
'Done': 'Done',
|
||||||
|
'SpeedTest': 'Speed Test......',
|
||||||
|
'SpeedResult': 'Speed Result:'
|
||||||
|
}
|
||||||
|
};
|
||||||
19
yoyo-getfastmirror/lib/i18n/lang_zh-CN.i18n.dart
Normal file
19
yoyo-getfastmirror/lib/i18n/lang_zh-CN.i18n.dart
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
Map<dynamic,dynamic> zhCN = {
|
||||||
|
'Description': '一个Yoyo OS定制版aptss配置器',
|
||||||
|
'FlagVersionHlep': '打印当前cli的版本',
|
||||||
|
'FlagVerboseHlep': '啰嗦模式',
|
||||||
|
'Argumentinformation': '参数信息:',
|
||||||
|
'TopLevelOptions': ' 顶级选项:',
|
||||||
|
'Command': ' 命令:',
|
||||||
|
'CommandOptions': ' 命令选项:',
|
||||||
|
'GetfastmirroCommand': {
|
||||||
|
'Description': '切换最快的镜像源并为oyo生成配置文件',
|
||||||
|
'FlagOnlyTestHlep': '只测试镜像源速度,不生成配置',
|
||||||
|
'RunOutPut': '切换最快的镜像源并为oyo生成配置文件',
|
||||||
|
'Error': {'NetWork': '网络错误', 'GenerateConfig': '生成文件失败'},
|
||||||
|
'Writting': '写入中',
|
||||||
|
'Done': '完成',
|
||||||
|
'SpeedTest': '速度测试中......',
|
||||||
|
'SpeedResult': '测速结果:'
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -1,12 +1,13 @@
|
|||||||
import 'package:args/args.dart';
|
import 'package:args/args.dart';
|
||||||
import 'package:args/command_runner.dart';
|
import 'package:args/command_runner.dart';
|
||||||
import 'package:mason_logger/mason_logger.dart';
|
import 'package:mason_logger/mason_logger.dart';
|
||||||
|
import 'package:yoyo_get_fast_mirror/i18n.dart';
|
||||||
import 'package:yoyo_get_fast_mirror/src/commands/commands.dart';
|
import 'package:yoyo_get_fast_mirror/src/commands/commands.dart';
|
||||||
import 'package:yoyo_get_fast_mirror/src/version.dart';
|
import 'package:yoyo_get_fast_mirror/src/version.dart';
|
||||||
|
|
||||||
const executableName = 'yoyo-getfastmirror';
|
const executableName = 'yoyo-getfastmirror';
|
||||||
const packageName = 'yoyo_get_fast_mirror';
|
const packageName = 'yoyo_get_fast_mirror';
|
||||||
const description = 'A Very Good Project created by Yoyo.';
|
final description = Lang.description;
|
||||||
|
|
||||||
class YoyoGetFastMirrorCommandRunner extends CommandRunner<int> {
|
class YoyoGetFastMirrorCommandRunner extends CommandRunner<int> {
|
||||||
/// {@macro yoyo_get_fast_mirror_command_runner}
|
/// {@macro yoyo_get_fast_mirror_command_runner}
|
||||||
@@ -20,15 +21,15 @@ class YoyoGetFastMirrorCommandRunner extends CommandRunner<int> {
|
|||||||
'version',
|
'version',
|
||||||
abbr: 'v',
|
abbr: 'v',
|
||||||
negatable: false,
|
negatable: false,
|
||||||
help: 'Print the current version.',
|
help: Lang.flagVersionHlep,
|
||||||
)
|
)
|
||||||
..addFlag(
|
..addFlag(
|
||||||
'verbose',
|
'verbose',
|
||||||
help: 'Noisy logging, including all shell commands executed.',
|
help: Lang.flagVerboseHlep,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Add sub commands
|
// Add sub commands
|
||||||
addCommand(GetfastmirroCommand(logger: _logger));
|
addCommand(GetfastmirrorCommand(logger: _logger));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -67,8 +68,8 @@ class YoyoGetFastMirrorCommandRunner extends CommandRunner<int> {
|
|||||||
@override
|
@override
|
||||||
Future<int?> runCommand(ArgResults topLevelResults) async {
|
Future<int?> runCommand(ArgResults topLevelResults) async {
|
||||||
_logger
|
_logger
|
||||||
..detail('Argument information:')
|
..detail(Lang.argumentinformation)
|
||||||
..detail(' Top level options:');
|
..detail(Lang.topLevelOptions);
|
||||||
for (final option in topLevelResults.options) {
|
for (final option in topLevelResults.options) {
|
||||||
if (topLevelResults.wasParsed(option)) {
|
if (topLevelResults.wasParsed(option)) {
|
||||||
_logger.detail(' - $option: ${topLevelResults[option]}');
|
_logger.detail(' - $option: ${topLevelResults[option]}');
|
||||||
@@ -77,8 +78,8 @@ class YoyoGetFastMirrorCommandRunner extends CommandRunner<int> {
|
|||||||
if (topLevelResults.command != null) {
|
if (topLevelResults.command != null) {
|
||||||
final commandResult = topLevelResults.command!;
|
final commandResult = topLevelResults.command!;
|
||||||
_logger
|
_logger
|
||||||
..detail(' Command: ${commandResult.name}')
|
..detail('${Lang.command} ${commandResult.name}')
|
||||||
..detail(' Command options:');
|
..detail(Lang.commandOptions);
|
||||||
for (final option in commandResult.options) {
|
for (final option in commandResult.options) {
|
||||||
if (commandResult.wasParsed(option)) {
|
if (commandResult.wasParsed(option)) {
|
||||||
_logger.detail(' - $option: ${commandResult[option]}');
|
_logger.detail(' - $option: ${commandResult[option]}');
|
||||||
|
|||||||
@@ -1,22 +1,22 @@
|
|||||||
import 'package:args/command_runner.dart';
|
import 'package:args/command_runner.dart';
|
||||||
import 'package:mason_logger/mason_logger.dart';
|
import 'package:mason_logger/mason_logger.dart';
|
||||||
import 'package:yoyo_get_fast_mirror/src/commands/modules/getfastmirro/getfastmirror.dart';
|
import 'package:yoyo_get_fast_mirror/i18n.dart';
|
||||||
|
import 'package:yoyo_get_fast_mirror/src/commands/modules/getfastmirror/getfastmirror.dart';
|
||||||
|
|
||||||
class GetfastmirroCommand extends Command<int> {
|
class GetfastmirrorCommand extends Command<int> {
|
||||||
GetfastmirroCommand({
|
GetfastmirrorCommand({
|
||||||
required Logger logger,
|
required Logger logger,
|
||||||
}) : _logger = logger {
|
}) : _logger = logger {
|
||||||
argParser.addFlag(
|
argParser.addFlag(
|
||||||
'only-test',
|
'only-test',
|
||||||
abbr: 'o',
|
abbr: 'o',
|
||||||
help: "Only test mirrors' speed",
|
help: GetfastmirroCommand.flagOnlyTestHlep,
|
||||||
negatable: false,
|
negatable: false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get description =>
|
String get description => GetfastmirroCommand.description;
|
||||||
'Get fastest mirror and generate config file for oyo';
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get name => 'getfastmirror';
|
String get name => 'getfastmirror';
|
||||||
@@ -25,10 +25,7 @@ class GetfastmirroCommand extends Command<int> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future<int> run() async {
|
Future<int> run() async {
|
||||||
final output = lightBlue.wrap('''
|
final output = lightBlue.wrap(GetfastmirroCommand.runOutPut);
|
||||||
Get the fastest mirror which will be write into source file
|
|
||||||
And generate a config file for oyo
|
|
||||||
''');
|
|
||||||
_logger.info(output);
|
_logger.info(output);
|
||||||
final onlyTest = argResults?['only-test'] == true;
|
final onlyTest = argResults?['only-test'] == true;
|
||||||
final commandResult = await getFastMirror(onlyTest: onlyTest);
|
final commandResult = await getFastMirror(onlyTest: onlyTest);
|
||||||
|
|||||||
@@ -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
|
|
||||||
''';
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
import 'dart:io';
|
|
||||||
import 'package:mason_logger/mason_logger.dart';
|
|
||||||
|
|
||||||
final done = lightGreen.wrap('Done');
|
|
||||||
final Logger _logger = Logger();
|
|
||||||
|
|
||||||
void writeMirrorIntoFile(String mirror, String path) {
|
|
||||||
final file = File(path);
|
|
||||||
final writting = lightYellow.wrap('Writting $path');
|
|
||||||
_logger.info(writting);
|
|
||||||
if (!file.existsSync()) file.createSync(recursive: true);
|
|
||||||
file.writeAsStringSync(mirror);
|
|
||||||
_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
|
|
||||||
''';
|
|
||||||
}
|
|
||||||
@@ -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,15 @@
|
|||||||
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/getfastmirror/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/getfastmirror/Yoyo/yoyo_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/getfastmirror/Yoyo/yoyo_is_exist.dart';
|
||||||
import 'package:yoyo_get_fast_mirror/src/commands/modules/getfastmirro/test_mirro_speed.dart';
|
import 'package:yoyo_get_fast_mirror/src/commands/modules/getfastmirror/utils/generate_apt_fast_config_file.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/getfastmirror/utils/network_test.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/getfastmirror/utils/test_mirro_speed.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/getfastmirror/utils/write_mirror_into_file.dart';
|
||||||
|
import 'package:yoyo_get_fast_mirror/i18n.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:');
|
||||||
@@ -22,14 +18,22 @@ Future<Map<String, dynamic>> getFastMirror({bool onlyTest = false}) async {
|
|||||||
//首先测试网络链接
|
//首先测试网络链接
|
||||||
if (!await networkTest()) {
|
if (!await networkTest()) {
|
||||||
status['success'] = false;
|
status['success'] = false;
|
||||||
status['msg'] = 'NetWork Error';
|
status['msg'] = Error.network;
|
||||||
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,30 +41,31 @@ 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'] = Error.generateConfig;
|
||||||
return status;
|
return status;
|
||||||
} finally {
|
} finally {
|
||||||
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);
|
|
||||||
writeMirrorIntoFile(
|
writeMirrorIntoFile(
|
||||||
yoyoSourcesListFile,
|
fastestYoyoMirror,
|
||||||
'/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;
|
||||||
final ubuntuSourcesLIstFile =
|
|
||||||
ubuntuSourcesListTemplate(fastestUbuntuMirror);
|
|
||||||
writeMirrorIntoFile(
|
writeMirrorIntoFile(
|
||||||
ubuntuSourcesLIstFile,
|
fastestUbuntuMirror,
|
||||||
'/etc/apt/sources.list',
|
'/etc/apt/sources.list',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -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/getfastmirror/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';
|
||||||
@@ -3,15 +3,16 @@ import 'dart:collection';
|
|||||||
import 'package:cli_spinner/cli_spinner.dart';
|
import 'package:cli_spinner/cli_spinner.dart';
|
||||||
import 'package:dart_ping/dart_ping.dart';
|
import 'package:dart_ping/dart_ping.dart';
|
||||||
import 'package:mason_logger/mason_logger.dart';
|
import 'package:mason_logger/mason_logger.dart';
|
||||||
|
import 'package:yoyo_get_fast_mirror/i18n.dart';
|
||||||
|
|
||||||
Logger _logger = Logger();
|
Logger _logger = Logger();
|
||||||
final speedResult = lightGreen.wrap('Speed Result:');
|
final speedResult = lightGreen.wrap(GetfastmirroCommand.speedResult);
|
||||||
|
|
||||||
Future<List<Map<String, String>>> testMirroSpeed(
|
Future<List<Map<String, String>>> testMirroSpeed(
|
||||||
List<String> mirrorList,
|
List<String> mirrorList,
|
||||||
) async {
|
) async {
|
||||||
final spinner =
|
final spinner =
|
||||||
Spinner.type('Speed Test ......', SpinnerType.boxCircle)..start();
|
Spinner.type(GetfastmirroCommand.speedTest, SpinnerType.boxCircle)..start();
|
||||||
final testResult = <Map<String, String>>[];
|
final testResult = <Map<String, String>>[];
|
||||||
final logMsg = StringBuffer()..write(speedResult);
|
final logMsg = StringBuffer()..write(speedResult);
|
||||||
for (final element in mirrorList) {
|
for (final element in mirrorList) {
|
||||||
@@ -28,6 +29,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();
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
import 'package:mason_logger/mason_logger.dart';
|
||||||
|
import 'package:yoyo_get_fast_mirror/i18n.dart';
|
||||||
|
|
||||||
|
final done = lightGreen.wrap(GetfastmirroCommand.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 writting = lightYellow.wrap('${GetfastmirroCommand.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(fileContent);
|
||||||
|
_logger.info(done);
|
||||||
|
}
|
||||||
@@ -1 +1 @@
|
|||||||
const packageVersion = '0.0.1';
|
const packageVersion = '2023.1.31-2';
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
name: yoyo_get_fast_mirror
|
name: yoyo_get_fast_mirror
|
||||||
description: A Very Good Project created by Very Good CLI.
|
description: A Very Good Project created by Very Good CLI.
|
||||||
version: 0.0.1
|
version: 2023.1.31-2
|
||||||
publish_to: none
|
publish_to: none
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
|
|||||||
Reference in New Issue
Block a user