有一定的资源,想建一个ppa的源(全的),可不知道怎么建

系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
回复
hyy
帖子: 20
注册时间: 2006-03-20 13:29

有一定的资源,想建一个ppa的源(全的),可不知道怎么建

#1

帖子 hyy » 2009-09-25 18:13

到处都找不到ppa的sync源
头像
daf3707
论坛版主
帖子: 12731
注册时间: 2007-06-13 15:57
来自: 在他乡

Re: 有一定的资源,想建一个ppa的源(全的),可不知道怎么建

#2

帖子 daf3707 » 2009-09-25 18:37

沙发,支持! :em11
头像
oneleaf
论坛管理员
帖子: 10441
注册时间: 2005-03-27 0:06
系统: Ubuntu 12.04

Re: 有一定的资源,想建一个ppa的源(全的),可不知道怎么建

#3

帖子 oneleaf » 2009-09-25 18:46

给你我的镜像脚本, 希望对你有用。

代码: 全选

$ cat ppamirror.py 
#!/usr/bin/env python
#coding=utf-8
import os,re
import threading
import time

release=["hardy","jaunty","karmic"]
component=["main"]
system=["binary-i386","binary-amd64"]
baseUrl="http://ppa.launchpad.net/"
savePath="/share/ubuntu-cn/"
maxdownThread=20
currdownThread=0

def downfile(url,savefile):
    cmd="wget -nv -T 20 -c -t 0 -O "+savefile+" "+url
#    print cmd
    global currdownThread 
    currdownThread=currdownThread+1
    result=os.spawnvp(os.P_WAIT,'wget',cmd.split())
    currdownThread=currdownThread-1
    return result

def getPackageFiles(ppaurl,component,system,release):
    path=ppaurl[25:]+"/dists/"+release+"/"+component+"/"+system+"/"
    ppaname=path.split('/')[0]
    url=baseUrl+path+"Release"
    savefile=savePath+path+"Release"
    if not os.path.exists(savePath+path):
        try:
           os.makedirs(savePath+path)
        except:
            pass
    if os.path.exists(savefile):
        os.remove(savefile)

    if downfile(url,savefile)!=0:
        print "downing",url, "error!"
        try:
            os.removedirs(savePath+ppanme)
        except:
            pass          
        return

    url=baseUrl+path+"Packages.gz"
    savefile=savePath+path+"Packages.gz"
    backfile=savePath+path+"Packages.gz.bak"
    if os.path.exists(savefile):
        if os.path.exists(backfile):
            os.remove(backfile)
        os.rename(savefile,backfile)
    if downfile(url,savefile)!=0:
        print "downing",url, "error!"
        return
    if os.path.exists(backfile):
        if os.path.getsize(savefile)==os.path.getsize(backfile):
            os.remove(backfile)
            if os.path.getsize(savefile)>=100:
               return
        else:
            os.remove(backfile)
    if os.path.getsize(savefile)<100:
        try:
            os.removedirs(savePath+ppanme)
        except:
            pass
        return

    url=baseUrl+path+"Packages"
    savefile=savePath+path+"Packages"
    if os.path.exists(savefile):
        os.remove(savefile)
    if downfile(url,savefile)!=0:
        print "downing",url, "error!"
        return
    if os.path.getsize(savefile)==0:
        try:
            os.removedirs(savePath+ppanme)
        except:
            pass
        return

    f=open(savefile)
    html=f.read()
    f.close()
    regx = r'Filename: (.*)'
    matchs=re.findall(regx, html)
    for match in matchs:
        url=baseUrl+ppaurl[25:]+"/"+match
        savefile=savePath+ppaurl[25:]+"/"+match
        path=savefile[:savefile.rfind("/")+1]
        try:
            os.makedirs(path)
        except:
            pass         
        if downfile(url,savefile)!=0:
            print "downing",url, "error!"

class DownloadThread(threading.Thread):
    def __init__(self, ppaname,component,system,release):
        threading.Thread.__init__(self)
        self.component=component
        self.system=system
        self.ppaname=ppaname
        self.release=release
        
    def run(self):
        getPackageFiles(self.ppaname,self.component,self.system,self.release)
        
if __name__ == "__main__":
    f=open("/share/ppasource")
    lines=f.readlines()
    f.close()
    threadList=[]
    for line in lines:
        for a in release:
            for b in component:
                for c in system:
                    threadList.append(DownloadThread(line.strip(),b,c,a))
    for thread in threadList:
        i=0
        while currdownThread>maxdownThread:
            time.sleep(5)
            i=i+1
            if i>6:
                break
        thread.start()    
    print 'All threads started'
    for thread in threadList:
        thread.join()   
    print 'All threads stoped'

代码: 全选

$ cat ppasource 
http://ppa.launchpad.net/ubuntu-china-repo/ppa/ubuntu
http://ppa.launchpad.net/amule-releases/ppa/ubuntu
http://ppa.launchpad.net/awn-testing/ppa/ubuntu
http://ppa.launchpad.net/bisigi/ppa/ubuntu
http://ppa.launchpad.net/blueman/ppa/ubuntu
http://ppa.launchpad.net/breathe-dev/ppa/ubuntu
http://ppa.launchpad.net/chmsee/jaunty/ubuntu
http://ppa.launchpad.net/chromium-daily/ppa/ubuntu
http://ppa.launchpad.net/c-korn/vlc/ubuntu
http://ppa.launchpad.net/compiz/ppa/ubuntu
http://ppa.launchpad.net/debfx/qt/ubuntu
http://ppa.launchpad.net/debfx/virtualbox/ubuntu
http://ppa.launchpad.net/do-core/ppa/ubuntu
http://ppa.launchpad.net/exaile-devel/ppa/ubuntu
http://ppa.launchpad.net/firerabbit/ppa/ubuntu
http://ppa.launchpad.net/galaxium/ppa/ubuntu
http://ppa.launchpad.net/geany-dev/ppa/ubuntu
http://ppa.launchpad.net/globalmenu-team/ppa/ubuntu
http://ppa.launchpad.net/gmchess/ppa/ubuntu
http://ppa.launchpad.net/gnome-colors-packagers/ppa/ubuntu
http://ppa.launchpad.net/gnome-games-experimental/ppa/ubuntu
http://ppa.launchpad.net/gnome-terminator/ppa/ubuntu
http://ppa.launchpad.net/gnote/ppa/ubuntu
http://ppa.launchpad.net/gstreamer-developers/ppa/ubuntu
http://ppa.launchpad.net/gtg/ppa/ubuntu
http://ppa.launchpad.net/gwibber-daily/ppa/ubuntu
http://ppa.launchpad.net/gwibber-team/ppa/ubuntu
http://ppa.launchpad.net/ibus-dev/ibus-1.2-jaunty/ubuntu
http://ppa.launchpad.net/ibus-dev/ppa/ubuntu
http://ppa.launchpad.net/kubuntu-ppa/backports/ubuntu
http://ppa.launchpad.net/kubuntu-ppa/ppa/ubuntu
http://ppa.launchpad.net/liferea/ppa/ubuntu
http://ppa.launchpad.net/lyx/ppa/ubuntu
http://ppa.launchpad.net/markuz/ppa/ubuntu
http://ppa.launchpad.net/matthaeus123/mrw-gimp-svn/ubuntu
http://ppa.launchpad.net/midori/ppa/ubuntu
http://ppa.launchpad.net/moblin/ppa/ubuntu
http://ppa.launchpad.net/mono-edge/ppa/ubuntu
http://ppa.launchpad.net/moovida-packagers/ppa/ubuntu
http://ppa.launchpad.net/njpatel/clutter-edgers/ubuntu
http://ppa.launchpad.net/pidgin-developers/ppa/ubuntu
http://ppa.launchpad.net/rvm/mplayer/ubuntu
http://ppa.launchpad.net/rvm/smplayer/ubuntu
http://ppa.launchpad.net/rvm/testing/ubuntu
http://ppa.launchpad.net/shutter/ppa/ubuntu
http://ppa.launchpad.net/specto/ppa/ubuntu
http://ppa.launchpad.net/spicebird/ppa/ubuntu
http://ppa.launchpad.net/spicebird/test-build/ubuntu
http://ppa.launchpad.net/sudbury-team/ppa/ubuntu
http://ppa.launchpad.net/team-xbmc/ppa/ubuntu
http://ppa.launchpad.net/telepathy/ppa/ubuntu
http://ppa.launchpad.net/tp-fan/ppa/ubuntu
http://ppa.launchpad.net/transmissionbt/ppa/ubuntu
http://ppa.launchpad.net/tualatrix/gloobus/ubuntu
http://ppa.launchpad.net/tualatrix/ppa/ubuntu
http://ppa.launchpad.net/ubuntu-mozilla-security/ppa/ubuntu
http://ppa.launchpad.net/ubuntu-x-swat/x-updates/ubuntu
http://ppa.launchpad.net/vicox/ppa/ubuntu
http://ppa.launchpad.net/webkit-team/ppa/ubuntu
头像
jandyzhu
帖子: 3331
注册时间: 2008-04-02 13:26
来自: 上海
联系:

Re: 有一定的资源,想建一个ppa的源(全的),可不知道怎么建

#4

帖子 jandyzhu » 2009-09-25 19:49

强烈支持!!!现在的PPA源慢的要命命命命命命~~~~~
头像
hcym
帖子: 15634
注册时间: 2007-05-06 2:46

Re: 有一定的资源,想建一个ppa的源(全的),可不知道怎么建

#5

帖子 hcym » 2009-09-25 20:08

早就绝了PPA的念

据说国外快,莫非该死的对.cn限速
头像
jandyzhu
帖子: 3331
注册时间: 2008-04-02 13:26
来自: 上海
联系:

Re: 有一定的资源,想建一个ppa的源(全的),可不知道怎么建

#6

帖子 jandyzhu » 2009-09-25 21:18

hcym 写了:早就绝了PPA的念

据说国外快,莫非该死的对.cn限速
能跟国外比吗。
hyy
帖子: 20
注册时间: 2006-03-20 13:29

Re: 有一定的资源,想建一个ppa的源(全的),可不知道怎么建

#7

帖子 hyy » 2009-09-25 23:53

:em11
忒感谢了,马上开始爬文件去
头像
mickeywaley
帖子: 1427
注册时间: 2009-03-19 9:19
系统: ubuntu
来自: 江苏
联系:

Re: 有一定的资源,想建一个ppa的源(全的),可不知道怎么建

#8

帖子 mickeywaley » 2009-09-26 5:10

:em11 :em11 :em11
回复