Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 8539 Details for
Bug 15990
emerge-webrsync redownloads snapshots if no newer snapshots are available
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
emerge-webrsync in python
emerge-webrsync.py (text/plain), 4.50 KB, created by
Marc 'huz' REYNES
on 2003-02-20 08:30:03 UTC
(
hide
)
Description:
emerge-webrsync in python
Filename:
MIME Type:
Creator:
Marc 'huz' REYNES
Created:
2003-02-20 08:30:03 UTC
Size:
4.50 KB
patch
obsolete
>#!/usr/bin/env python2.2 ># Copyright 2003 Marc REYNES <marc.reynes@tuxfamily.org> ># Distributed under the terms of the GNU General Public Licence v2 ># Author: Marc 'huz' REYNES <marc.reynes@tuxfamily.org> > ># This is my first python script, however I hope it isn't too bad ># It is written from the old bash script of Karl Trygve Kalleberg <karltk@gentoo.org> ># this late one was already rewritten from a perl script I never knew ># VERSION 0.1.5 ># - scores of bug fixes ># VERSION 0.2 ># - help written > >import portage,os,sys,time >from output import * > >VERSION="0.1" >syncpath = "/var/tmp/emerge-webrsync" >options=[ > "--verbose", "--help", > "--no-download", "--version", > "--force" > ] >shortmapping={ > "v":"--verbose", "h":"--help", > "n":"--no-download", "V":"--version", > "f":"--force" > } > >found = 0 >attempts = 0 >debug = 0 > >myopts=[] >cmdline=[] > >if not sys.stdout.isatty() or portage.settings["NOCOLOR"] in ["yes","true"]: > nocolor() > >def shorthelp(): > pass > >def help(): > pass > > > >def sync_local(file): > global debug > print "Syncing local tree..." > if "--verbose" in myopts: > print "Decompressing "+file+"..." > osreturn = os.system("tar xjf "+file) > if osreturn: > print "!!! "+file+" is corrupted. please remove "+os.getcwd()+"/"+file+" and fetch it again " > sys.exit(-1) > os.chdir("portage") > if not debug : > if "--verbose" in myopts: > print "Synchronizing "+portage.settings['PORTDIR']+"..." > os.system("rsync -av --progress --stats --delete --delete-after \ > --exclude='distfiles/*' --exclude='packages/*' . "+portage.settings['PORTDIR']) > os.chdir("..") > if not debug : > os.system("rm -rf portage") > else: > print "rm -rf "+os.getcwd()+"/portage" > >if "--help" in myopts: > help() >elif not myopts: > shorthelp() > > >if os.getuid()!=0: > print "!!! emerge-webrsync must be run by root." > sys.exit(1) > >tmpcmdline=sys.argv[1:] >for x in tmpcmdline: > if x[0:1]=="-" and x[1:2]!="-": > for y in x[1:]: > if shortmapping.has_key(y): > if shortmapping[y] in cmdline: > print > print "*** Warning : Redundant use of ",shortmapping[y] > else: > cmdline.append(shortmapping[y]) > else: > print "!! Error -"+y+" is an invalid short action or option." > sys.exit(1) > else: > cmdline.append(x) > >for x in cmdline: > if len(x)>=2 and x[0:2]=="--": > if x in options: > myopts.append(x) > else: > print "!!! Error: ",x," is an invalid option." > sys.exit(1) > >if "--version" in myopts: > print VERSION > sys.exit(1) > > >if not os.path.isdir(syncpath): > print "Creating "+syncpath+" ..." > os.path.makedirs(syncpath) >os.chdir(syncpath) > >if "--verbose" in myopts: > wgetopts="" >else: > wgetopts="-q" > >print "Fetching the most recent snapshot" >thisyear,thismonth,today = time.localtime()[0],time.localtime()[1],time.localtime()[2] > >while attempts < 40 : > tmptime = time.mktime([thisyear,thismonth,today-attempts,0,0,0,0,0,0]) > tmptime = time.localtime(tmptime) ; > year,month,day = time.strftime("%Y",tmptime),time.strftime("%m",tmptime),time.strftime("%d",tmptime) > file="portage-%s%s%s.tar.bz2" % (year,month,day) > > > if "--no-download" in myopts: > if os.path.isfile(file): > sync_local(file) > sys.exit(0) > else: > print "!!! No snapashot called "+file+" in "+os.getcwd() > attempts = attempts + 1 > continue > > if os.path.isfile(syncpath+"/"+file+".lock") and not "--force" in myopts: > print "!!! No new portage snapshot available." > print "!!! Latest snapshot used: "+file > sys.exit(1) > > for i in portage.settings['GENTOO_MIRRORS'].split(): > url = i+"/snapshots/"+file > if not debug: > try: > os.unlink(file) > except OSError: > pass > if debug: > print ("tryng : wget "+wgetopts+" "+url) > if not portage.spawn("wget "+wgetopts+" "+url,0,1) and os.path.isfile(file) and os.path.getsize(file): > lock = open(file+".lock","w") > lock.close() > if not debug: > sync_local(file) > print > print " *** Completed websync, please now perform a normal rsync if possible." > os.unlink(file) > sys.exit(0) > attempts=attempts+1 > >if not debug: > os.system("rm -rf portage") >sys.exit(1) > >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 15990
: 8539 |
8540