Esempio n. 1
0
    def go_install_drbl(self, widget):
	if self.linux_dist == "":
	    self.linux_dist = self.get_linux_dist()

	if self.linux_dist == "not support":
	    return -1
	
	if self.linux_dist == "Fedora":
	    os.system('yum -y install perl-Digest-SHA1')
	    os.system('yum -y install wget')
	    os.system('rm -f GPG-KEY-DRBL')
	    os.system('wget http://drbl.nchc.org.tw/GPG-KEY-DRBL')
	    os.system('rpm --import GPG-KEY-DRBL')
	    os.system('wget http://drbl.nchc.org.tw/one4all/desktop/download/stable/RPMS/drbl-current.i386.rpm')
	    os.system('yum -y install drbl-current.i386.rpm')

	elif self.linux_dist == "Ubuntu":
	    sourceslist = SourcesList ()
	    distro = aptsources.distro.get_distro ()
	    try:
		distro.get_sources (sourceslist)
	    except:
		print "your distribution is remix release!"
		return -1
	    has_drbl_repo = 0
	    has_drbl_comps = 0
	    for source in sourceslist:
		if source.disabled == False:
		    if source.uri == "http://free.nchc.org.tw/drbl-core":
			has_drbl_repo = 1
			if source.comps == self.comps:
			    has_drbl_comps = 1
			else:
			    print "remove drbl repo"
			    sourceslist.remove(source)

	    if has_drbl_repo == 0 or has_drbl_comps == 0:
		drbl_uri = "http://free.nchc.org.tw/drbl-core"
		drbl_dist = "drbl"
		drbl_comps = self.comps
		distro.add_source (type="deb", uri=drbl_uri, dist=drbl_dist, comps=drbl_comps, comment="DRBL Repository (Add by drbl_assistant)")
		sourceslist.backup ()
		sourceslist.save ()

	    add_key_st = os.popen("wget -q http://drbl.nchc.org.tw/GPG-KEY-DRBL -O- | apt-key add -").readlines()[0][:-1]

	    try:
		cache = apt.Cache()
		pkg = cache['drbl'] # Access the Package object for python-apt
		pkg.mark_install()
		# Now, really install it
		cache.commit()
	    except:
		print "apt-get install drbl"
		os.system("apt-get update")
		os.system("apt-get install drbl")
	else:
	    print "Unknown linux"
	print "install finish"
def main ():
    uri = sys.argv[1].strip ()
    dist = sys.argv[2].strip ()
    comps = sys.argv[3].split (' ')
    comment = sys.argv[4].strip ()

    distro = aptsources.distro.get_distro ()
    sourceslist = SourcesList ()
    
    for source in sourceslist:
      if source.disabled == False:
        if source.uri == uri and source.comps == comps:
	  print "套件庫已存在。"
        else:
          distro.get_sources (sourceslist)
          distro.add_source (uri=uri, dist=dist, comps=comps, comment=comment)

    sourceslist.backup ()
    sourceslist.save ()

    return 0
def main():
    uri = sys.argv[1].strip()
    dist = sys.argv[2].strip()
    comps = sys.argv[3].split(' ')
    comment = sys.argv[4].strip()

    distro = aptsources.distro.get_distro()
    sourceslist = SourcesList()

    for source in sourceslist:
        if source.disabled == False:
            if source.uri == uri and source.comps == comps:
                print "套件庫已存在。"
            else:
                distro.get_sources(sourceslist)
                distro.add_source(uri=uri,
                                  dist=dist,
                                  comps=comps,
                                  comment=comment)

    sourceslist.backup()
    sourceslist.save()

    return 0
def main ():
    comps = []
    sourceslist = SourcesList ()
    distro = aptsources.distro.get_distro ()
    security_uri = ""
    security_dist = ""

    if distro.id == "Debian":
        comps = ["main", "contrib", "non-free"]
        security_uri = "http://security.debian.org/"
        security_dist = "%s/updates" % distro.codename
    elif distro.id == "Ubuntu":
        comps = ["main", "universe", "restricted", "multiverse"]
        security_uri = "http://security.ubuntu.com/ubuntu/"
        security_dist = "%s-security" % distro.codename
    else:
        print "can't identify distribution"
        return -1

    try:
        distro.get_sources (sourceslist)
    except:
        print "your distribution is remix release!"
        return -1

    has_medibuntu_source = 0
    has_ubuntu_tweak_source = 0
    has_swiftfox_source = 0
    has_winehq_source = 0
    for source in sourceslist:
     if source.disabled == False:
      if source.uri == "http://packages.medibuntu.org/":
       has_medibuntu_source = 1
      if source.uri == "http://ppa.launchpad.net/tualatrix/ubuntu":
       has_ubuntu_tweak_source = 1
      if source.uri == "http://getswiftfox.com/builds/debian":
       has_swiftfox_source = 1
      if source.uri == "http://wine.budgetdedicated.com/apt":
       has_winehq_source = 1

    [entry.set_enabled (False) for entry in sourceslist if entry.invalid == False]

    if distro.country_code == "tw" and distro.id == "Ubuntu":
        twaren_uri = "http://ftp.twaren.net/ubuntu"
        distro.change_server (uri=twaren_uri)
        distro.add_source (uri=twaren_uri, comps=comps, comment="國網中心伺服器 (Lazybuntu 新增)")
        distro.add_source (type="deb-src", uri=twaren_uri, comps=comps, comment="國網中心伺服器 (Lazybuntu 新增)")
    else:
        distro.add_source (uri=distro.nearest_server, comps=comps, comment="地區性伺服器 (Lazybuntu 新增)")
        distro.add_source (type="deb-src", uri=distro.nearest_server, comps=comps, comment="地區性伺服器 (Lazybuntu 新增)")

    distro.add_source (uri=security_uri, dist=security_dist, comps=comps, comment="安全性更新伺服器 (Lazybuntu 新增)")
    distro.add_source (type="deb-src", uri=security_uri, dist=security_dist, comps=comps, comment="安全性更新伺服器 (Lazybuntu 新增)")

    if has_medibuntu_source:
       medibuntu_uri = "http://packages.medibuntu.org/"
       medibuntu_comps = ["free non-free"]
       distro.add_source (uri=medibuntu_uri, comps=medibuntu_comps, comment="Medibuntu Install Source (Lazybuntu 新增)")
    if has_ubuntu_tweak_source:
       ubuntu_tweak_uri = "http://ppa.launchpad.net/tualatrix/ubuntu"
       ubuntu_tweak_comps = ["main"]
       if distro.codename == 'intrepid':
          ubuntu_tweak_dist = distro.codename
       else:
          ubuntu_tweak_dist = 'hardy'
       distro.add_source (uri=ubuntu_tweak_uri, dist=ubuntu_tweak_dist, comps=ubuntu_tweak_comps, comment="Ubuntu Tweak Install Source (Lazybuntu 新增)")
       distro.add_source (type="deb-src", uri=ubuntu_tweak_uri, dist=ubuntu_tweak_dist, comps=ubuntu_tweak_comps, comment="Ubuntu Tweak Install Source (Lazybuntu 新增)")
    if has_swiftfox_source:
       swiftfox_uri = "http://getswiftfox.com/builds/debian"
       swiftfox_comps = ["non-free"]
       swiftfox_dist = "unstable"
       distro.add_source (uri=swiftfox_uri, dist=swiftfox_dist, comps=swiftfox_comps, comment="Swiftfox Install Source (Lazybuntu 新增)")
    if has_winehq_source:
       winehq_uri = "http://wine.budgetdedicated.com/apt"
       winehq_comps = ["main"]
       distro.add_source (uri=winehq_uri, comps=winehq_comps, comment="WineHQ Install Source (Lazybuntu 新增)")


    sourceslist.backup ()
    sourceslist.save ()

    return 0