ipkg-utils: Fix a bug in the md5sum field handling and add some extra checks (md5sum, size) to ipkg-make-index when reusing data from the previous package file.

git-svn-id: https://svn.o-hand.com/repos/poky/trunk@544 311d38ba-8fff-0310-9ca6-ca027cbcb966
This commit is contained in:
Richard Purdie 2006-07-24 08:24:07 +00:00
parent f75754d05b
commit 215379647b
3 changed files with 58 additions and 3 deletions

View File

@ -2,12 +2,13 @@ include ipkg-utils_${PV}.bb
SRC_URI += "file://ipkg-utils-fix.patch;patch=1"
RDEPENDS = ""
PR = "r7"
PR = "r8"
inherit native
# Avoid circular dependencies from package_ipk.bbclass
PACKAGES = ""
FILESDIR = "${@os.path.dirname(bb.data.getVar('FILE',d,1))}/ipkg-utils"
do_stage() {
for i in ${INSTALL}; do

View File

@ -0,0 +1,53 @@
Index: ipkg-utils/ipkg-make-index
===================================================================
--- ipkg-utils.orig/ipkg-make-index 2005-03-20 18:10:54.000000000 +0000
+++ ipkg-utils/ipkg-make-index 2006-07-24 09:18:16.000000000 +0100
@@ -37,6 +37,21 @@
if os.path.exists(pkg_dir + "/" + filename + ".asc"):
os.rename(pkg_dir + "/" + filename + ".asc", locale_dir + "/" + filename + ".asc")
+def md5sum(file):
+ import md5
+ sum = md5.new()
+ f = open(file, "r")
+ while 1:
+ data = f.read(1024)
+ if not data: break
+ sum.update(data)
+ f.close()
+ if sys.version[:1] > '2':
+ # when using Python 2.0 or newer
+ return sum.hexdigest()
+ else:
+ return string.join(map((lambda x:"%02x" % ord(x)),sum.digest()),'')
+
old_filename = None
packages_filename = None
filelist_filename = "Packages.filelist"
@@ -87,7 +102,7 @@
files.sort()
for filename in files:
basename = os.path.basename(filename)
- if old_pkg_hash.has_key(basename):
+ if old_pkg_hash.has_key(basename) and old_pkg_hash[basename].md5 == md5sum(filename) and old_pkg_hash[basename].size == os.stat(filename)[6]:
if (verbose):
sys.stderr.write("Found %s in Packages\n" % (filename,))
pkg = old_pkg_hash[basename]
Index: ipkg-utils/ipkg.py
===================================================================
--- ipkg-utils.orig/ipkg.py 2005-01-20 23:09:10.000000000 +0000
+++ ipkg-utils/ipkg.py 2006-07-24 09:16:44.000000000 +0100
@@ -210,8 +210,13 @@
value = value + '\n' + line
if name == 'size':
self.size = int(value)
+ elif name == 'md5sum':
+ self.md5 = value
elif self.__dict__.has_key(name):
self.__dict__[name] = value
+ else:
+ print "Lost field %s, %s" % (name,value)
+
if line[0] == '\n':
return # consumes one blank line at end of package descriptoin
else:

View File

@ -5,9 +5,10 @@ LICENSE = "GPL"
CONFLICTS = "ipkg-link"
RDEPENDS = "python"
SRCDATE = "20050404"
PR = "r11"
PR = "r12"
SRC_URI = "${HANDHELDS_CVS};module=ipkg-utils"
SRC_URI = "${HANDHELDS_CVS};module=ipkg-utils \
file://index_speedup.patch;patch=1"
S = "${WORKDIR}/ipkg-utils"