[PATCH] add a stub for rpm on rpm-less systems

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

 



Attached is a patch which provides anaconda a rpm pacifier.  There are
still tons of places where anaconda does 'import rpm' (even if it's
now unnecessary).  This is a temporary solution until all of those
'import rpm's are gone.

Cheers,

Matt
-- 
Matt Wilson
Founding Engineer
rPath, Inc.
msw@xxxxxxxxx
--- anaconda/Makefile.inc.orig	2006-03-06 21:35:52.000000000 -0500
+++ anaconda/Makefile.inc	2006-03-06 21:35:37.000000000 -0500
@@ -25,6 +25,7 @@
 endif
 
 USESELINUX=1
+USERPM=1
 
 ifndef RPM_OPT_FLAGS
 RPM_OPT_FLAGS = -O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
--- anaconda/Makefile.orig	2006-03-06 20:11:17.000000000 -0500
+++ anaconda/Makefile	2006-03-06 20:08:13.000000000 -0500
@@ -18,7 +18,14 @@
 
 PYFILES = $(wildcard *.py)
 
-all:  subdirs mini-wm xmouse.so xutils.so $(CATALOGS) lang-table lang-names
+ifeq ($(USERPM), 0)
+STUBS = rpm.py
+endif
+
+all:  $(STUBS) subdirs mini-wm xmouse.so xutils.so $(CATALOGS) lang-table lang-names
+
+rpm.py: rpm-stub.py
+	cp rpm-stub.py rpm.py
 
 lang-names: lang-table
 	PYTHONPATH="." $(PYTHON) scripts/getlangnames.py > lang-names
--- anaconda/rpm-stub.py.orig	2006-03-06 20:08:56.000000000 -0500
+++ anaconda/rpm-stub.py	2006-03-06 21:35:15.000000000 -0500
@@ -0,0 +1,75 @@
+#
+# Copyright (c) 2004-2006 rPath, Inc.
+#
+# This software may be freely redistributed under the terms of the GNU
+# library public license.
+#
+# You should have received a copy of the GNU Library Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+
+def _createTags(*args):
+    i = 0
+    g = globals()
+    # create a mapping from name to enum
+    tags = {}
+    for index, (tag, default) in enumerate(args):
+        g[tag] = index
+        # strip off RPMTAG_, lowercase
+        name = tag[7:].lower()
+        tags[name] = (index, default)
+    return tags
+
+def delMacro(*args, **kwargs):
+    pass
+
+def addMacro(*args, **kwargs):
+    pass
+
+tags = _createTags(('RPMTAG_ARCH', None),
+                   ('RPMTAG_DESCRIPTION', None),
+                   ('RPMTAG_EPOCH', None),
+                   ('RPMTAG_GROUP', None),
+                   ('RPMTAG_NAME', None),
+                   ('RPMTAG_OBSOLETENAME', None),
+                   ('RPMTAG_RELEASE', None),
+                   ('RPMTAG_SIZE', None),
+                   ('RPMTAG_SUMMARY', None),
+                   ('RPMTAG_VERSION', None),
+                   ('RPMTAG_BASENAMES', []),
+                   ('RPMTAG_REQUIRENAME', []),
+                   ('RPMTAG_PROVIDENAME', []))
+tags['RPMTAG_FILENAME'] = (1000000, None)
+tags['RPMTAG_DISCNUM'] = (1000002, None)
+tags['RPMTAG_ORDER'] = (1000003, None)
+
+class Header(dict):
+    def __init__(self):
+        pass
+
+    def _getkey(self, key):
+        if type(key) is not int:
+            if key not in tags.keys():
+                raise KeyError, "invalid tag"
+            return tags[key]
+        else:
+            for k, default in tags.itervalues():
+                if key == k:
+                    return k, default
+        raise KeyError, "invalid tag"
+
+    def __setitem__(self, key, value):
+        key = self._getkey(key)[0]
+        dict.__setitem__(self, key, value)
+
+    def __getitem__(self, key):
+        key, default = self._getkey(key)
+        return dict.get(self, key, default)
+
+    def __hash__(self):
+        return hash(self.nvf)
+
+def versionCompare(a, b):
+    # rpmvercmp means nothing to us
+    return 1

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux