Hide Forgot
Description of problem: Reading rpm headers via rpm-python bindins shows different results for RHEL5 and RHEL6 packages. Version-Release number of selected component (if applicable): rpm-python-4.8.0-12.el6.i686 the same behaviour found also in rpm-python-4.4.2.3-22.el5.x86_64 How reproducible: always Steps to Reproduce: 1. cat >rpm-test.py <<EOF import sys f = os.open(sys.argv[1], os.O_RDONLY) os.lseek(f,96,0) h, offset = rpm.readHeaderFromFD(f) while h: print offset, h.keys() for i in h.keys(): print i, h[i] h, offset = rpm.readHeaderFromFD(f) EOF 2. python rpm-test.py redhat-release-5Server-5.5.0.2.i386.rpm 3. python rpm-test.py redhat-release-server-6Server-6.0.0.37.el6.i686.rpm Actual results: $ python rpm-test.py redhat-release-5Server-5.5.0.2.i386.rpm 96 [267, 269, 1000, 1004, 1005, 1007] 440 [100, 1000, 1001, 1002, 1004, 1005, 1006, 1007, 1009, 1010, 1011, 1014, 1015, 1016, 1021, 1022, 1028, 1030, 1033, 1034, 1035, 1036, 1037, 1039, 1040, 1044, 1045, 1047, 1048, 1049, 1050, 1064, 1080, 1081, 1082, 1090, 1095, 1096, 1097, 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1122, 1124, 1125, 1126, 1131, 1132, 1140, 1141, 1142, 1143, 1144, 1145, 1147] $ python rpm-test.py redhat-release-server-6Server-6.0.0.37.el6.i686.rpm 96 [268, 269, 1000, 1002, 1004, 1007] Expected results: To be able to read all headers from RHEL6 packages. Additional info: Both packages are signed(!). The same (bad) behavior as on RHEL6 packages can bee seen on any unsigned packages.
Since RHEL 6.1 External Beta has begun, and this bug remains unresolved, it has been rejected as it is not proposed as exception or blocker. Red Hat invites you to ask your support representative to propose this request, if appropriate and relevant, in the next release of Red Hat Enterprise Linux.
That isn't even supposed to work, not quite like that. readHeaderFromFD() knows how to read a single header, but it doesn't know how to read a /package/ file, tha's what ts.hdrFromFdno() is for. The reason your snippet doesn't work is that there can be a padding between the signature header and the "real" header, which you need to skip when its there, something like this: # skip lead os.lseek(f,96,0) # read signature header h, offset = rpm.readHeaderFromFD(f) for i in h.keys(): print i, h[i] # skip padding pad = (8 - (len(h.unload()) % 8)) % 8 os.lseek(f,pad,os.SEEK_CUR) # read the real header h, offset = rpm.readHeaderFromFD(f) for i in h.keys(): print i, h[i]