[建议]apt-get应该支持多线程!

为当前最终发行版之前的所有版本提供支持
回复
SmartGG
帖子: 97
注册时间: 2005-09-16 14:59
送出感谢: 0
接收感谢: 0

[建议]apt-get应该支持多线程!

#1

帖子 SmartGG » 2005-09-19 22:05

我今天用置顶帖的脚本升级了系统,从早上8:00多到下午5:00才只完成了3步,而且还有错误。下载速度一般只有几K,而我平时下载怎么也有100K左右,快的时候甚至上M!强烈建议apt-get升级时使用多线程技术!
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙
送出感谢: 4 次
接收感谢: 256 次

#2

帖子 eexpress » 2005-09-19 22:26

上M?又几k?什么网。apt-get的地址要是可以输出,才可以用其他多线程的下载。
● 鸣学
头像
paladinfly
帖子: 21
注册时间: 2005-09-19 9:51
来自: 南宁
送出感谢: 0
接收感谢: 0

#3

帖子 paladinfly » 2005-09-19 22:27

估计下载源问题?
ubuntu下载速度基本比windows下飞快,下载时候浏览器不能看网页
抢带宽一流。

最好看看/etc/apt/sources.list
资源是国内的?
上次由 paladinfly 在 2005-09-19 22:43,总共编辑 1 次。
头像
内存不足
论坛版主
帖子: 3277
注册时间: 2005-08-18 18:43
送出感谢: 0
接收感谢: 1 次
联系:

#4

帖子 内存不足 » 2005-09-19 22:35

看看www.ubuntu.org.cn里关于如何使用最快源的方法。
໌→ iCookie Gtk Theme
໌→DropPlusBluetheme
กรัก กรัก`菠萝
SmartGG
帖子: 97
注册时间: 2005-09-16 14:59
送出感谢: 0
接收感谢: 0

#5

帖子 SmartGG » 2005-09-20 9:55

内存不足 写了:看看www.ubuntu.org.cn里关于如何使用最快源的方法。


Will you please tell me how to do this?
头像
oneleaf
论坛管理员
帖子: 10218
注册时间: 2005-03-27 0:06
系统: Ubuntu 12.04
送出感谢: 7 次
接收感谢: 102 次

#6

帖子 oneleaf » 2005-09-20 9:58

SmartGG
帖子: 97
注册时间: 2005-09-16 14:59
送出感谢: 0
接收感谢: 0

#7

帖子 SmartGG » 2005-09-20 10:13

谢谢斑竹,我正在测试!
SmartGG
帖子: 97
注册时间: 2005-09-16 14:59
送出感谢: 0
接收感谢: 0

#8

帖子 SmartGG » 2005-09-20 11:25

谢谢斑竹,改成ftp://ftp.sjtu.edu.cn后已经有100多K的速度了!
玉剑
帖子: 7
注册时间: 2006-07-16 9:52
送出感谢: 0
接收感谢: 0

#9

帖子 玉剑 » 2006-11-11 9:41

有一个小脚本,叫apt-axel即使用axel(一个多线程下载工具)为apt-get加速,是别人编写的,可能是apt-get更新了之后,脚本不再和新版本的apt-get兼容,我稍微修改了一下,现在又好使了。
现在我使用它下载软件速度超快,一般都500K以上。

有什么问题可以上我的Blog: http://heaps.cn:D ,可能不太正式。
下面是程序代码

代码: 全选

#!/bin/bash

###########################################################################
#
# Authors: Jes? Espino Garc? & Lucas Garc?
# Email: jespino@imap.cc
# Date: 31/05/2004
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
###########################################################################
#
# Modified by ybyygu at 2006 3/18
# Updated at 2006 3/20
#
# Modified by Wang Xinxi at 11/10/2006
# Email: wangxinxi@cs.hit.edu.cn
#

#------------------------------------------------------------------------#
VERSION="0.2"
CONNECTIONS=20           # Max connections used by axel
VERBOSE="FALSE"
MIRRORS="$HOME/.ubuntu_mirrors"
MIRRORS_COUNT=3          # mirrors will used
#------------------------------------------------------------------------#

# Set the package variable to be global
package="";
URLS="";

# Show the help
show_usage() {
  echo "Usage: apt-axel <option> <package>";
  echo "";
  echo "Options:";
  echo "  src - Refresh the source from apt's source file"
  echo "  install - Install new packages (paquete es libc6 y no libc6.deb)";
  echo "  upgrade - Do a software upgrade";
  echo "  dist-upgrade - Do a distribution upgrade, see apt-get(8)";
  echo "  --version - Print the current version of apt-axel";
  echo "  --help - Show this help";
  echo "";
}

# Get a package from the ftp server
get_package()
{
    descargar() {
        # Check the the filesize, if the filesize is lower than 200K will use only 4 conections
        if [ -z "$size" ]; then
            echo "Can't find $package size, why?"
        elif [ "$size" -gt 200000 ]; then
            if [ "$VERBOSE" == "TRUE" ]; then
                echo axel -a -n $CONNECTIONS $URLS -o /tmp/$archivo
            fi

            axel -a -n $CONNECTIONS $URLS -o "/tmp/$archivo"
        else
            if [ "$VERBOSE" == "TRUE" ]; then
                echo axel -a -n 4 $URLS -o "/tmp/$archivo"
            fi

            axel -a -n 4 $URLS -o "/tmp/$archivo"
        fi
    }

    # Getting data
    local package=$1
    local path=$(apt-cache show $package | grep ^Filename: | sed s/^Filename:\ // | head -n 1)
    local archivo=$(echo "$path" | sed s/^.*$package/$package/)
    local pkgstatus=$(dpkg -s $package 2> /dev/null | grep ^Status: | grep -v "not-installed")
    local md5sum=$(apt-cache show $package | grep ^MD5sum: | head -n 1 | sed s/^MD5sum:\ //)
    local size=$(apt-cache show $package | grep ^Size: | sed s/^Size:\ // | head -n 1)
 
    # Getting the URLS
    local mirror
    local -i num=0
    URLS=""
    for mirror in $(cat $MIRRORS | awk '{print $1}'); do
        URLS="$URLS $mirror/$path"
        let "num++"

        if (("$num">=$MIRRORS_COUNT)); then
            break
        fi
    done
   
    if [ "$VERBOSE" == "TRUE" ]; then
        echo "URLS: $URLS"
    fi

    # Downloading the package
    if [ -f /var/cache/apt/archives/$archivo ]; then
        echo -n "Package already downloaded. Checking md5sum of $package package: "
       
        while [ $md5sum != $(md5sum /var/cache/apt/archives/$archivo | sed s/\ .*$//) ]; do
            echo "incorrect"
            echo "Downloading again $package package."
            sudo rm -f /var/cache/apt/archives/$archivo
            descargar
        done
        echo "correct"
    else
        descargar
    fi

    # Move the file to /var/cache/apt/archives
    if [ -f /tmp/$archivo ]; then
        if [ $md5sum == $(md5sum /tmp/$archivo | sed s/\ .*$//) ]; then
            sudo mv -f /tmp/$archivo /var/cache/apt/archives/
        else
            rm -f /tmp/$archivo
            echo -e "\e[1;34m[ !!md5sum check failure!! ]\e[0m"
        fi
    fi
}

pkg_download()
{
    local packages="$1"
    local package
    local -i current
    local -i total
    packages=$(echo "$packages" | tr "\n" " ")
     
    total=$(echo "$packages"|wc -w)
    if (( "$total" < 1)); then
        exit 1
    fi

    echo "The following packages will be installed:"
    echo $(echo "$packages")
    echo -e -n "\e[1m Do you want to continue? [y/n] \e[0m"
    local yn
    read yn
    if [ "$yn" != "y" ]; then
        exit 0
    fi

    current=1
    for package in $packages; do
        echo -e "\033[1m [ getting $package $current of $total ] \033[0m"

        get_package $package

        let "current++"
    done   
}

pkg_install() {
    local packages
   
    packages=$(sudo apt-get -s install "$1" | grep ^Inst\ | sed s/^Inst\ // | sed s/\ .*$//)
    pkg_download "$packages"   
    sudo apt-get -y install "$1"
}

upgrade() {
    local packages
    packages=$(sudo apt-get -s upgrade | grep ^Inst\ | sed s/^Inst\ // | sed s/\ .*$//)     
    pkg_download "$packages"
    sudo apt-get -y upgrade
}

dist_upgrade() {
    local packages

    packages=$(sudo apt-get -s dist-upgrade | grep ^Inst\ | sed s/^Inst\ // | sed s/\ .*$//)
   
    pkg_download "$packages"

    sudo apt-get -y dist-upgrade
}

download_from_file()
{
    local file=$1
    local packages=`cat $file`
    pkg_download "$packages"
}

src_refresh()
{
        sed 's/#.*$//; /^\s*$/d;' /etc/apt/sources.list | cut -d ' ' -f 2 | sort | uniq > ~/.ubuntu_mirrors
}

#
# Main program
#
case $1 in
    src) src_refresh ;;
    install) pkg_install $2;;
    download) pkg_download $2;;
    upgrade) upgrade;;
    dist-upgrade) dist_upgrade;;
    (--version) echo "Current Version: $VERSION";;
    (--file | -f) download_from_file $2;;
    (--help | -h | *) show_usage;;
esac
回复

回到 “老旧版本支持”