backend/satellite_tools/satsync.py | 8 +++++---
backend/server/importlib/backend.py | 26 +++++++++++++++++++++-----
backend/server/importlib/backendOracle.py | 19 +++++++++++++++----
backend/server/importlib/importLib.py | 7 +++++++
backend/server/importlib/packageImport.py | 4 ++++
5 files changed, 52 insertions(+), 12 deletions(-)
New commits:
commit 7fce9af210678744fa15e59a2ebcf8d95d327e15
Author: Pradeep Kilambi <pkilambi(a)redhat.com>
Date: Tue Jun 30 16:32:17 2009 -0400
prilimary work to get the importer to handle checksum changes. More changes on the way once I have exporter done.
diff --git a/backend/satellite_tools/satsync.py b/backend/satellite_tools/satsync.py
index 4504517..f4d0d37 100644
--- a/backend/satellite_tools/satsync.py
+++ b/backend/satellite_tools/satsync.py
@@ -830,15 +830,17 @@ Please contact your RHN representative""" % (generation, sat_cert.generation))
self._diff_packages()
_query_compare_packages = """
- select p.id, p.md5sum, p.path, p.package_size,
+ select p.id, pc.checksum md5sum, p.path, p.package_size,
TO_CHAR(p.last_modified, 'YYYYMMDDHH24MISS') last_modified
- from rhnPackage p
+ from rhnPackage p,
+ rhnPackageChecksum pc
where p.name_id = lookup_package_name(:name)
and p.evr_id = lookup_evr(:epoch, :version, :release)
and p.package_arch_id = lookup_package_arch(:arch)
and (p.org_id = :org_id or
(p.org_id is null and :org_id is null))
- and p.md5sum =: md5sum
+ and pc.package_id = p.id
+ and pc.checksum =: md5sum
"""
# XXX the "is null" condition will have to change in multiorg satellites
def _diff_packages(self):
diff --git a/backend/server/importlib/backend.py b/backend/server/importlib/backend.py
index 1d39047..55d0390 100644
--- a/backend/server/importlib/backend.py
+++ b/backend/server/importlib/backend.py
@@ -686,9 +686,9 @@ class Backend:
# Insert/update the packages
tbs = self.tables['rhnPackage']
- if CFG.ENABLE_NVREA:
+ #if CFG.ENABLE_NVREA:
# Add md5sum as a primarykey if nevra is enabled
- tbs.pk.append('md5sum')
+ # tbs.pk.append('md5sum')
childTables = {
'rhnPackageProvides': 'package_id',
@@ -1132,6 +1132,7 @@ class Backend:
UPDATE rhnChannel
SET channel_product_id = :channel_product_id
WHERE id = :id
+ AND channel_product_id <> :channel_product_id
""")
statement.execute(id = channel.id,
@@ -1209,7 +1210,20 @@ class Backend:
beta = channel['channel_product_beta'])
return id
-
+
+ def processPackageChecksum(self, packages):
+ sql_checksum = self.dbmodule.prepare("""
+ insert into rhnPackageChecksum
+ (package_id, checksum_type_id, checksum)
+ values (:package_id, :checksum_type_id, :checksum)
+ """)
+ for package in packages:
+ #TODO: replace checksum_type_id once exporter sets it
+ sql_checksum.execute(package_id = package.id,
+ checksum_type_id= 1,
+ checksum = package['md5sum'])
+
+
def subscribeToChannels(self, packages, strict=0):
hash = {
'package_id' : [],
@@ -1796,10 +1810,11 @@ class Backend:
pe.evr.release release,
pa.label arch,
p.org_id,
- p.md5sum
+ pc.checksum as md5sum
from rhnChannel c,
rhnChannelPackage cp,
rhnPackage p,
+ rhnPackageChecksum pc,
rhnPackageName pn,
rhnPackageEVR pe,
rhnPackageArch pa
@@ -1807,6 +1822,7 @@ class Backend:
and p.package_arch_id = pa.id
and cp.channel_id = c.id
and cp.package_id = p.id
+ and pc.package_id = p.id
and p.name_id = pn.id
and p.evr_id = pe.id
"""
@@ -2009,7 +2025,7 @@ def _buildExternalValue(dict, entry, tableObj):
def computeDiff(hash1, hash2, diffHash, diffobj, prefix=None):
# Compare if the key-values of hash1 are a subset of hash2's
difference = 0
- ignore_keys = ['last_modified']
+ ignore_keys = ['last_modified', 'channel_product_id']
for k, v in hash1.items():
if k in ignore_keys:
diff --git a/backend/server/importlib/backendOracle.py b/backend/server/importlib/backendOracle.py
index a967676..a032478 100644
--- a/backend/server/importlib/backendOracle.py
+++ b/backend/server/importlib/backendOracle.py
@@ -79,6 +79,17 @@ class OracleBackend(Backend):
pk = ['package_id', 'name', 'text', 'time'],
attribute = 'changelog',
),
+
+ Table('rhnPackageChecksum',
+ fields = {
+ 'package_id' : DBint(),
+ 'checksum_type_id' : DBint(),
+ 'checksum' : DBstring(128)
+ },
+ pk = ['package_id', 'checksum_type_id'],
+ attribute = 'checksum',
+ ),
+
Table('rhnPackageFile',
fields = {
'package_id' : DBint(),
@@ -91,7 +102,7 @@ class OracleBackend(Backend):
'rdev' : DBint(),
'file_size' : DBint(),
'mtime' : DBdateTime(),
- 'md5' : DBstring(32),
+ 'checksum' : DBstring(32),
'linkto' : DBstring(256),
'flags' : DBint(),
'verifyflags' : DBint(),
@@ -102,7 +113,7 @@ class OracleBackend(Backend):
severityHash = {
'mtime' : 0,
'file_size' : 4,
- 'md5' : 4,
+ 'checksum' : 4,
},
),
Table('rhnPackage',
@@ -121,7 +132,7 @@ class OracleBackend(Backend):
'build_host' : DBstring(256),
'build_time' : DBdateTime(),
'source_rpm_id' : DBint(),
- 'md5sum' : DBstring(64),
+ #'md5sum' : DBstring(64),
'vendor' : DBstring(64),
'payload_format': DBstring(32),
'path' : DBstring(1000),
@@ -135,7 +146,7 @@ class OracleBackend(Backend):
nullable = ['org_id'],
severityHash = {
'path' : 1,
- 'md5sum' : 2,
+ #'md5sum' : 2,
'package_size' : 2,
'build_time' : 3,
'build_host' : 3,
diff --git a/backend/server/importlib/importLib.py b/backend/server/importlib/importLib.py
index ab9138c..1900cb6 100644
--- a/backend/server/importlib/importLib.py
+++ b/backend/server/importlib/importLib.py
@@ -260,6 +260,12 @@ class ChangeLog(Item):
def __init__(self):
Item.__init__(self, self.attributeTypes)
+class Checksum(Information):
+ attributeTypes = {
+ 'checksum_type_id' : StringType,
+ 'checksum' : StringType,
+ }
+
class IncompletePackage(BaseInformation):
attributeTypes = {
@@ -342,6 +348,7 @@ class Package(IncompletePackage):
'obsoletes' : [Dependency],
'changelog' : [ChangeLog],
'channels' : [StringType],
+ #'checksum' : [Checksum],
}
def __init__(self):
# Inherit from IncompletePackage
diff --git a/backend/server/importlib/packageImport.py b/backend/server/importlib/packageImport.py
index 90ba02e..a1fb009 100644
--- a/backend/server/importlib/packageImport.py
+++ b/backend/server/importlib/packageImport.py
@@ -112,6 +112,8 @@ class ChannelPackageSubscription(GenericPackageImport):
def submit(self):
self.backend.lookupPackages(self.batch)
+
+ self.backend.processPackageChecksum(self.batch)
try:
affected_channels = self.backend.subscribeToChannels(self.batch,
strict=self._strict_subscription)
@@ -121,6 +123,8 @@ class ChannelPackageSubscription(GenericPackageImport):
self.compute_affected_channels(affected_channels)
self.backend.update_newest_package_cache(caller=self.caller,
affected_channels=self.affected_channel_packages)
+ taskomatic.add_to_repodata_queue_for_channel_package_subscription(
+ self.affected_channels, self.batch, self.caller)
self.backend.commit()
def compute_affected_channels(self, affected_channels):