[Yum] Gziped headers patch

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

 



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

Hello.
I make a little patch to work with gziped headers for yum.
patch attached.

also i found another silly bug

[root@black etc]# [root@black headers]# yum remove sane
Gathering package information from servers
Getting headers from: 7.3 main
Finding updated packages
Downloading needed headers
Finding obsoleted packages
Traceback (innermost last):
  File "/usr/sbin/yum", line 24, in ?
    yummain.main()
  File "yummain.py", line 266, in main
  File "yummain.py", line 115, in take_action
  File "pkgaction.py", line 152, in erasepkgs
NameError: errolog


As we see - just a typo.

-- 
........................................................................
IRC: irc.openproject.net #asplinux                       Grigory Bakunov 
EMAIL: black@xxxxxxxxxxx 			   ASPLinux Support Team
ICQ: 51369901                                     http://www.asplinux.ru
-----BEGIN GEEK CODE BLOCK-----
GCS/MU d-(--) s:- a- C+++>++$ UBLAVSX+++$
P+ L++++$ E++$ W++ N+>- o? K? w-- O- M V-(--) 
PS+ PE+ !Y PGP+>++++ t+ 5++ X+++ R+++ tv+>--
b+++ ?DI D+ G++ e>++$ h- r++ y+ z++(+++)
------END GEEK CODE BLOCK------


--------------080407060205030609050309
Content-Type: text/plain;
 name="yum-0.8.6.gzipheaders.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="yum-0.8.6.gzipheaders.patch"

diff -BurN yum-0.8.6.old/clientStuff.py yum-0.8.6/clientStuff.py
--- yum-0.8.6.old/clientStuff.py	Thu Jun 13 18:41:46 2002
+++ yum-0.8.6/clientStuff.py	Sat Jun 15 19:05:56 2002
@@ -18,6 +18,8 @@
 import rpm
 import os
 import sys
+import gzip
+
 from config import conf
 
 def stripENVRA(foo):
@@ -161,7 +163,16 @@
      fd.close()
      return h
    else:
-     fd = open(rpmfn, "r")
+     try:
+       fd=gzip.open(rpmfn,"r")
+       yumv=fd.readline();
+     except IOError:
+       fd=open(rpmfn,"r")
+       yumv=fd.readline();
+
+     if yumv != "YUM1\n":
+          log(2, "Wrong header version in %s" % rpmfn);
+
      h = rpm.headerLoad(fd.read())
      fd.close()
      return h
diff -BurN yum-0.8.6.old/docs/yum-arch.8 yum-0.8.6/docs/yum-arch.8
--- yum-0.8.6.old/docs/yum-arch.8	Thu Jun 13 18:41:46 2002
+++ yum-0.8.6/docs/yum-arch.8	Sat Jun 15 19:16:41 2002
@@ -18,6 +18,8 @@
 don't generate headers.
 .IP "\fB\-c\fP"
 check pkgs with gpg and md5 checksums \- cannot be used with \-n.
+.IP "\fB\-C\fP"
+compress headers with gzip algorithm.
 .br 
 .IP "\fBdirectory\fP"
 a directory where you want to create the \fIheaders\fP directory.
diff -BurN yum-0.8.6.old/pullheaders.py yum-0.8.6/pullheaders.py
--- yum-0.8.6.old/pullheaders.py	Thu Jun 13 18:41:46 2002
+++ yum-0.8.6/pullheaders.py	Sat Jun 15 19:14:29 2002
@@ -23,7 +23,7 @@
 log=Logger(threshold=0,default=2,prefix='',preprefix='')
 serverStuff.log = log
 
-def genhdrs(rpms,headerdir,rpmcheck):
+def genhdrs(rpms,headerdir,rpmcheck,compress):
 	rpmdelete = 0 # define this if you have the rpmheader stripping patch built into rpm
 	rpminfo = {}
 	numrpms = len(rpms)
@@ -69,7 +69,7 @@
 						shortheader = serverStuff.cleanHeader(header)
 					else:
 						shortheader = header
-					headerloc = serverStuff.writeHeader(headerdir,shortheader)       
+					headerloc = serverStuff.writeHeader(headerdir,shortheader,compress)
 					rpminfo[rpmtup]=(epoch,ver,rel,rpmloc)
 				elif rc == 0:
 					# hmm, they match complete - warn the user that they've got a dupe in the tree
@@ -82,7 +82,7 @@
 					shortheader = serverStuff.cleanHeader(header)
 				else:
 					shortheader = header
-				headerloc = serverStuff.writeHeader(headerdir,shortheader)
+				headerloc = serverStuff.writeHeader(headerdir,shortheader,compress)
 				rpminfo[rpmtup]=(epoch,ver,rel,rpmloc)
 				goodrpm = goodrpm + 1
 		else:
@@ -97,6 +97,7 @@
 	checkdeps=0
 	writehdrs=1
 	rpmcheck=0
+	compress=0
 	if  len(sys.argv) < 2:
 		serverStuff.Usage()
 	args = sys.argv[1:]
@@ -111,6 +112,8 @@
 			writehdrs=0
 		if arg == "-c":
 			rpmcheck=1
+		if arg == "-C":
+			compress=1
 		
 		
 	#save where we are right now
@@ -151,7 +154,7 @@
 			os.unlink(hdr)
 		if os.path.exists(headerinfo):
 			os.unlink(headerinfo)
-		rpminfo = genhdrs(rpms, headerdir,rpmcheck)
+		rpminfo = genhdrs(rpms, headerdir,rpmcheck,compress)
 
 		#Write header.info file
 		print "\nWriting header.info file"
diff -BurN yum-0.8.6.old/serverStuff.py yum-0.8.6/serverStuff.py
--- yum-0.8.6.old/serverStuff.py	Thu Jun 13 18:41:46 2002
+++ yum-0.8.6/serverStuff.py	Sat Jun 15 19:15:10 2002
@@ -50,10 +50,10 @@
 	return header
 
 
-def writeHeader(headerdir,header):
+def writeHeader(headerdir,header,compress):
 	# write the header out to a file with the format: name-epoch-ver-rel.arch.hdr
 	# return the name of the file it just made - no real reason :)
-	import os,rpm,sys
+	import os,rpm,sys,gzip
 	name = header[rpm.RPMTAG_NAME]
 	ver = header[rpm.RPMTAG_VERSION]
 	rel = header[rpm.RPMTAG_RELEASE]
@@ -64,9 +64,16 @@
 		epoch = '%s' % header[rpm.RPMTAG_EPOCH]
 
 	headerfn = "%s/%s-%s-%s-%s.%s.hdr" % (headerdir, name, epoch,ver, rel, arch)
-	headerout = open(headerfn, "w")
+
+ 	if compress :
+ 		headerout = gzip.open(headerfn , "w")
+ 	else:
+		headerout = open(headerfn, "w")
+
+	headerout.write("YUM1\n")
 	headerout.write(header.unload(1))
 	headerout.close()
+
 	return(headerfn)
 
 
@@ -112,11 +119,12 @@
 def Usage():
 	import sys
 	print "Usage:"
-	print "yum-arch [-v] [-c] [-n] [-d] (path of dir where headers/ should/does live)"
+	print "yum-arch [-v] [-C] [-c] [-n] [-d] (path of dir where headers/ should/does live)"
 	print "\t-d = check dependencies and conflicts in tree"
 	print "\t-v = print debugging information"
 	print "\t-n = don't generate headers"
 	print "\t-c = check pkgs with gpg and md5 checksums - cannot be used with -n"
+	print "\t-C = make gziped headers"	
 	sys.exit(1)
 
 

--------------080407060205030609050309--



[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