Ubuntugeek 上介绍了一个方法,通过一个名为 apt-fast 的脚本来让 axel 结合 apt-get 命令进行软件的安装,由于 axel 可以多线程下载软件包,这样就可以起到了加速的作用。而且整个使用过程基本与 apt-get 无异,只需要把平常的 apt-get 改为 apt-fast 就可以了,比如 sudo apt-fast install package 。
# 安装与使用:
先安装 axel 工具
sudo apt-get install axel
从这里下载 apt-fast.sh 脚本,把它移动到 /usr/bin 目录中同时改名为 apt-fast 。
sudo cp apt-fast.sh /usr/bin/apt-fast
最后给予可执行权限
sudo chmod +x apt-fast
apt-fast.sh
######
# !/bin/sh
# apt-fast v0.03 by Matt Parnell http://www.mattparnell.com, this thing is fully open-source
# if you do anything cool with it, let me know so I can publish or host it for you
# contact me at admin@mattparnell.com
# Special thanks
# Travis/travisn000 - support for complex apt-get commands
# Allan Hoffmeister - aria2c support
# Abhishek Sharma - aria2c with proxy support
# Richard Klien - Autocompletion, Download Size Checking (made for on ubuntu, untested on other distros)
# Patrick Kramer Ruiz - suggestions - see Suggestions.txt
# Sergio Silva - test to see if axel is installed, root detection/sudo autorun
# Use this just like apt-get for faster package downloading.
# Check for proper priveliges
[ "`whoami`" = root ] || exec sudo "$0" "$@"
# Test if the axel is installed
if [ ! -x /usr/bin/axel ]
then echo "axel is not installed, perform this?(y/n)"
read ops
case $ops in
y) if apt-get install axel -y --force-yes
then echo "axel installed"
else echo "unable to install the axel. you are using sudo?" ; exit
fi ;;
n) echo "not possible usage apt-fast" ; exit ;;
esac
fi
# If the user entered arguments contain upgrade, install, or dist-upgrade
if echo "$@" | grep -q "upgrade\|install\|dist-upgrade"; then
echo "Working...";
# Go into the directory apt-get normally puts downloaded packages
cd /var/cache/apt/archives/;
# Have apt-get print the information, including the URI's to the packages
# Strip out the URI's, and download the packages with Axel for speediness
# I found this regex elsewhere, showing how to manually strip package URI's you may need...thanks to whoever wrote it
apt-get -y --print-uris $@ | egrep -o -e "(ht|f)tp://[^\']+" > apt-fast.list && cat apt-fast.list | xargs -l1 axel -a
# Perform the user's requested action via apt-get
apt-get $@;
echo -e "\nDone! Verify that all packages were installed successfully. If errors are found, run apt-get clean as root and try again using apt-get directly.\n";
else
apt-get $@;
fi
######