[Yum] Once more not so urgent patch and once more typo bugfix

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a multi-part message in MIME format.
--------------090302080400010303090708
Content-Type: text/plain; charset=KOI8-R; format=flowed
Content-Transfer-Encoding: 7bit

Start from tail :)
-----------------------------------------------
[root@yumi forGala]# yum update
Gathering package information from servers
Getting headers from: ASPLinux 7.2 Master Site
Getting headers from: ASPLinux 7.2 Updates
Traceback (innermost last):
  File "/usr/sbin/yum", line 24, in ?
    yummain.main()
  File "yummain.py", line 242, in main
  File "clientStuff.py", line 150, in rpmdbNevralLoad
NameError: key
[root@yumi forGala]# 

-----------------------------------
Just a typo i think. :)

And - i and my good friend Vladimir Bormotov make
a little 10k patch what clean some stuff, make more
error handling and debuggin stuff.

Patch attached :)

I think what in AUTORS file you need to add new field:
Main bug reporter :)



--------------090302080400010303090708
Content-Type: text/plain;
 name="yum-0.8.9.asplinux.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="yum-0.8.9.asplinux.diff"

diff -BurN MAIN/README HEAD/README
--- MAIN/README	Fri Jun 21 11:38:44 2002
+++ HEAD/README	Fri Jun 21 11:28:04 2002
@@ -15,6 +15,10 @@
 	currently installed package.  If one or more packages are
 	specified, Yum will only update the packages listed.
 
+ - upgrade
+	Yum will compleatly upgrade current system to newest packages,
+	include replace old obsolete packages with new one.
+	
  - install <package list>
 	Yum will install the latest version of the specified package
 	(don't specify version information).
diff -BurN MAIN/clientStuff.py HEAD/clientStuff.py
--- MAIN/clientStuff.py	Fri Jun 21 11:38:44 2002
+++ HEAD/clientStuff.py	Fri Jun 21 11:49:28 2002
@@ -147,7 +147,8 @@
 			if (rc == -1):
 				rpmdbdict[(name,arch)] = (epoch, ver, rel)
 			elif (rc == 0):
-				log(4,"dupe entry in rpmdb %s\n" % key)
+				log(4, "dupe rpmdb entry %s: name-ver-rel-arch=%s-%s-%s-%s, epoch=%s ",
+					 % (index, name, ver, rel, arch, epoch)
 		index = db.nextkey(index)
 	for value in rpmdbdict.keys():
 		(name, arch) = value
@@ -162,11 +163,16 @@
 		return h
 	else:
 		try:
-			fd = gzip.open(rpmfn,"r")
-			h = rpm.headerLoad(fd.read())
+			fd = gzip.open(rpmfn, "r")
+			header = fd.read()
 		except IOError,e:
 			fd = open(rpmfn, "r")
-			h = rpm.headerLoad(fd.read())
+			header = fd.read()
+		try:
+			h = rpm.headerLoad(header)
+		except:
+			errorlog(0, "Error decoding header file '%s'." % (rpmfn))
+			sys.exit(1)
 	fd.close()
 	return h
 
diff -BurN MAIN/yummain.py HEAD/yummain.py
--- MAIN/yummain.py	Fri Jun 21 11:38:44 2002
+++ HEAD/yummain.py	Fri Jun 21 11:49:19 2002
@@ -20,6 +20,7 @@
 import callback
 import nevral
 import pkgaction
+import gzip
 from config import conf
 from logger import Logger
 ##############################################################
@@ -56,40 +57,70 @@
 def get_package_info_from_servers(conf,HeaderInfo):
 	#this function should be split into - server paths etc and getting the header info/populating the 
 	#the HeaderInfo nevral class so we can do non-root runs of yum
-	log(2,"Gathering package information from servers")
-	#sorting the servers so that sort() will order them consistently
-	serverlist=conf.servers
+	log(2, 'Gathering package information from servers')
+	# sorting the servers so that sort() will order them consistently
+	serverlist = conf.servers
+	log(4, 'Total %s servers' % len(serverlist))
 	serverlist.sort()
 	for serverid in serverlist:
-		baseurl = conf.serverurl[serverid]
 		servername = conf.servername[serverid]
-		serverheader = os.path.join(baseurl,'headers/header.info')
+		log(2, 'Getting headers from: %s' % (servername))
+		baseurl = conf.serverurl[serverid]
+		log(4, 'BaseURL: %s' % baseurl)
 		servercache = conf.servercache[serverid]
-		log(4,'server name/cachedir:' + servername + '-' + servercache)
-		log(2,'Getting headers from: %s' % (servername))
-		localpkgs = conf.serverpkgdir[serverid]
-		localhdrs = conf.serverhdrdir[serverid]
-		localheaderinfo = os.path.join(servercache,'header.info')
 		if not os.path.exists(servercache):
+			log(4, 'Create CacheDir')
 			os.mkdir(servercache)
+		log(4, 'CacheDir: %s' % servercache)
+		localpkgs = conf.serverpkgdir[serverid]
 		if not os.path.exists(localpkgs):
+			log(4, 'Create LocalPkgs dir')
 			os.mkdir(localpkgs)
+		log(4, 'LocalPkgs: %s' % localpkgs)
+		localhdrs = conf.serverhdrdir[serverid]
 		if not os.path.exists(localhdrs):
+			log(4, 'Create LocalHdrs dir')
 			os.mkdir(localhdrs)
-		headerinfofn = clientStuff.urlgrab(serverheader, localheaderinfo,'nohook')
-		log(4,'headerinfofn: ' + headerinfofn)
-		clientStuff.HeaderInfoNevralLoad(headerinfofn,HeaderInfo,serverid)
-
-
-def download_headers(HeaderInfo,nulist):
+		log(4, 'LocalHdrs: %s' % localhdrs)
+		serverheader = os.path.join(baseurl, 'headers/header.info')
+		localheaderinfo = os.path.join(servercache, 'header.info')
+		log(4, 'Try to get serverheader')
+		headerinfofn = clientStuff.urlgrab(serverheader, localheaderinfo, 'nohook')
+		log(4, 'HeaderInfoFn: %s' % (headerinfofn))
+		log(4, 'Try to load HeaderNevral')
+		clientStuff.HeaderInfoNevralLoad(headerinfofn, HeaderInfo, serverid)
+		log(4, 'Load HeaderNevral done')
+
+def check_header(hi, name, arch):
+	"""check header file"""
+	# this should do something real, like, oh I dunno, 
+	# check the header - but I'll be damned if I know how
+	file_name = hi.localHdrPath(name, arch)
+	if os.path.exists(file_name):
+		# header exist, try to read...
+		try:
+			# try read gzipped header
+			fd = gzip.open(file_name, "r")
+			header = fd.read()
+		except IOError, e:
+			# plain header
+			fd = open(file_name, "r")
+			header = fd.read()
+		fd.close()
+		return len(header) != 0
+	else:
+		log(5, 'Missed %s' % file_name)
+		return 0
+		
+def download_headers(HeaderInfo, nulist):
+	"""check header in cache and download if it missed"""
 	for (name,arch) in nulist:
-		#this should do something real, like, oh I dunno, check the header - but I'll be damned if I know how
-		if os.path.exists(HeaderInfo.localHdrPath(name, arch)):
-			log(4,"cached %s" % (HeaderInfo.hdrfn(name,arch)))
-			pass
+		if check_header(HeaderInfo, name, arch):
+			log(4, 'Cached %s' % (HeaderInfo.hdrfn(name, arch)))
 		else:
-			log(2,"getting %s" % (HeaderInfo.hdrfn(name,arch)))
-			clientStuff.urlgrab(HeaderInfo.remoteHdrUrl(name,arch), HeaderInfo.localHdrPath(name,arch),'nohook')
+			log(2, 'Getting %s' % (HeaderInfo.hdrfn(name, arch)))
+			clientStuff.urlgrab(HeaderInfo.remoteHdrUrl(name, arch), 
+				HeaderInfo.localHdrPath(name,arch), 'nohook')
 
 def take_action(cmds,nulist,uplist,newlist,obslist,tsInfo,HeaderInfo,rpmDBInfo,obsdict):
 	if cmds[0] == "install":
@@ -250,18 +281,18 @@
 	#nulist == combination of the two
 	#obslist == packages obsoleting a package we have installed
 	################################################################################
-	log(2,"Finding updated packages")
-	(uplist,newlist,nulist) = clientStuff.getupdatedhdrlist(HeaderInfo,rpmDBInfo)
-	log(2,"Downloading needed headers")
+	log(2, 'Finding updated packages')
+	(uplist, newlist, nulist) = clientStuff.getupdatedhdrlist(HeaderInfo, rpmDBInfo)
+	log(2, 'Downloading needed headers')
 	download_headers(HeaderInfo, nulist)
-	log(2,"Finding obsoleted packages")
-	obsdict=clientStuff.returnObsoletes(HeaderInfo,rpmDBInfo,nulist)
-	obslist=obsdict.keys()
-	
-	log(4,"nulist = %s" % len(nulist))
-	log(4,"uplist = %s" % len(uplist))
-	log(4,"newlist = %s" % len(newlist))
-	log(4,"obslist = %s" % len(obslist))
+	log(2, 'Finding obsoleted packages')
+	obsdict = clientStuff.returnObsoletes(HeaderInfo, rpmDBInfo, nulist)
+	obslist = obsdict.keys()
+	
+	log(4, 'nulist = %d' % len(nulist))
+	log(4, 'uplist = %d' % len(uplist))
+	log(4, 'newlist = %d' % len(newlist))
+	log(4, 'obslist = %d' % len(obslist))
 	
 	##################################################################
 	#at this point we have all the prereq info we could ask for. we 
@@ -275,51 +306,53 @@
 	#at this point we should have a tsInfo nevral with all we need to complete our task.
 	#if for some reason we've gotten all the way through this step with an empty tsInfo then exit and be confused :)
 	if len(tsInfo.NAkeys()) < 1:
-		log(2,"No actions to take")
+		log(2, 'No actions to take')
 		sys.exit(0)
 		
-	if process not in ('erase','remove'):
+	if process not in ('erase', 'remove'):
 		#put available pkgs in tsInfonevral in state 'a'
 		for (name,arch) in nulist:
 			if not tsInfo.exists(name, arch):
-				((e, v, r, a, l, i), s)=HeaderInfo._get_data(name,arch)
-				log(6,"making available: %s" % name)
-				tsInfo.add((name,e,v,r,arch,l,i),'a')   
+				((e, v, r, a, l, i), s) = HeaderInfo._get_data(name, arch)
+				log(6, 'making available: %s' % name)
+				tsInfo.add((name,e,v,r,arch,l,i), 'a')   
 
-	log(2,"Resolving dependencies")
+	log(2, 'Resolving dependencies')
 	(code, msgs) = tsInfo.resolvedeps(rpmDBInfo)
 	if code == 1:
 		for msg in msgs:
 			print msg
 		sys.exit(1)
-	log(2,"Dependencies resolved")
+	log(2, 'Dependencies resolved')
 	
 	#prompt for use permission to do stuff in tsInfo - list all the actions 
 	#(i, u, e, ed, ud,iu(installing, but marking as 'u' in the actual ts, just in case)) confirm w/the user
 	
-	(i_list,u_list,e_list,ud_list,ed_list)=clientStuff.actionslists(tsInfo)
+	(i_list, u_list, e_list, ud_list, ed_list) = clientStuff.actionslists(tsInfo)
 	
-	clientStuff.printactions(i_list,u_list,e_list,ud_list,ed_list)
-	if conf.assumeyes==0:
+	clientStuff.printactions(i_list, u_list, e_list, ud_list, ed_list)
+	if conf.assumeyes == 0:
 		if clientStuff.userconfirm():
-			errorlog(1,"Exiting on user command.")
+			errorlog(1, 'Exiting on user command.')
 			sys.exit(1)
 	
-	if uid==0:
-		dbfin = clientStuff.openrpmdb(1,'/')
+	if uid == 0:
+		log(4, 'Open rpmdb with option 1')
+		dbfin = clientStuff.openrpmdb(1, '/')
 	else:
-		dbfin = clientStuff.openrpmdb(0,'/')
+		log(4, 'Open rpmdb with option 0')
+		dbfin = clientStuff.openrpmdb(0, '/')
 	
-	tsfin = create_final_ts(tsInfo,dbfin)
+	tsfin = create_final_ts(tsInfo, dbfin)
 
 	if uid == 0:
 		#sigh - the magical "order" command - nice of this not to really be documented anywhere.
 		tsfin.order()
 		errors = tsfin.run(0, 0, callback.install_callback, '')
 		if errors:
-			errorlog(0,"Errors installing:")
+			errorlog(0, 'Errors installing:')
 			for error in errors:
-				errorlog(0,error)
+				errorlog(0, error)
 			sys.exit(1)
 		
 		del dbfin
@@ -329,14 +362,14 @@
 		pkgaction.kernelupdate(tsInfo)
 		
 		#log what we did and also print it out
-		clientStuff.filelogactions(i_list,u_list,e_list,ud_list,ed_list)
-		clientStuff.shortlogactions(i_list,u_list,e_list,ud_list,ed_list)
+		clientStuff.filelogactions(i_list, u_list, e_list, ud_list, ed_list)
+		clientStuff.shortlogactions(i_list, u_list, e_list, ud_list, ed_list)
 		
 	else:
-		errorlog(1,"You're not root, we can't install things")
+		errorlog(1, "You're not root, we can't install things")
 		sys.exit(0)
 		
-	log(2,"Transaction(s) Complete")
+	log(2, 'Transaction(s) Complete')
 	sys.exit(0)
 
 

--------------090302080400010303090708--



[Index of Archives]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux