[Oval-devel] Patches to support different probes per distributions

Javier Fernández-Sanguino Peña jfs at computer.org
Tue Aug 7 21:20:08 UTC 2007


Attached are two patches which could be used as a starting point to 
make it possible to integrate both DPKGInfoProbe and RPMInfoProbe into OVAL
without making it necessary for both development libraries (libapt-pkg-dev
and librpm-dev) be installed.

The Makefile patch is straight forward:

- tries to determine if running on Debian or RedHat and set DISTRIBUTION
  appropiately

- set OBJS and REL_OBJS to contain DPKG/RPMInfoprobe  based on the
  DISTRIBUTION

- set LIBS to use the rpm or dpkg library depending on the case

And the patches to ProbeFactory too (just use the Probes associated with the
distribution). They might need to be modified (uppercase Debian and RedHat)

I'm not sure if this is the best approach (we might need to discuss the
patches on oval-devel) because if OVAL wants to support other distributions
(SuSE, Mandrake, Ubuntu) they have to modify the DISTRIBUTION-checking code.
It might be best to check the binaries and just set PACKAGE_FORMAT instead of
distribution.

In any case, you can add these patches to the Debian package and try them
out you could then probably remove the librpm-dev Build-Dep.


Regards

Javier

-------------- next part --------------
--- Makefile.orig	2007-08-07 23:08:09.000000000 +0200
+++ Makefile	2007-08-07 23:15:47.000000000 +0200
@@ -54,10 +54,27 @@
 LIBDIR = -L/usr/lib
 
 # What libraries do we need?
-LIBS = -lxerces-c -lxalan-c -lpcre -lrpm -lrpmdb -lrpmio -lpopt -lapt-pkg
+LIBS = -lxerces-c -lxalan-c -lpcre -lpopt
+
 
 # Determine what platform the source is being build on
 PLATFORM = $(shell uname)
+# Determine which distribution we are in
+# NOTE: could be abstracted to dpkg vs. rpm binaries being
+# available, as the DPKG or RPM probes could be used for
+# other distributions (RPM for SuSE or Mandrake, DPKG for
+# Ubuntu)
+DISTRIBUTION = $(shell if test  -e /etc/debian_version ; then echo DEBIAN; elif test -e /etc/redhat_release ; then echo REDHAT; else echo NO_DISTRIBUTION; fi)
+# Alternative (binary-based), note that both DPKG and RPM are 
+# mutually exclusive here:
+#PACKAGE_FORMAT = $(shell if test  -e /usr/bin/dpkg ; then echo DPKG; elif test -e /usr/bin/rpm ; then echo RPM; else echo NO_LINUX_PACKAGE; fi)
+
+ifeq ($(DISTRIBUTION), REDHAT)
+	LIBS += -lrpm -lrpmdb -lrpmio 
+endif
+ifeq ($(DISTRIBUTION), DEBIAN)
+	LIBS += -lapt-pkg
+endif
 
 # What object code are we expecting?
 OBJS = \
@@ -131,8 +148,6 @@
 	FileProbe.obj \
 	InetListeningServersProbe.obj \
 	ProcessProbe.obj \
-	RPMInfoProbe.obj \
-	DPKGInfoProbe.obj \
 	UnameProbe.obj \
 	TextFileContentProbe.obj \
 	XmlFileContentProbe.obj \
@@ -142,6 +157,13 @@
 	FileHashProbe.obj \
 	VariableProbe.obj \
 
+ifeq ($(DISTRIBUTION), REDHAT)
+	OBJS += RPMInfoProbe.obj
+endif
+ifeq ($(DISTRIBUTION), DEBIAN)
+	OBJS += DPKGInfoProbe.obj
+endif
+
 REL_OBJS = \
 	$(BUILDDIR)/Main.obj \
 	$(BUILDDIR)/AbsComponent.obj \
@@ -213,8 +235,6 @@
 	$(BUILDDIR)/FileProbe.obj \
 	$(BUILDDIR)/InetListeningServersProbe.obj \
 	$(BUILDDIR)/ProcessProbe.obj \
-	$(BUILDDIR)/RPMInfoProbe.obj \
-	$(BUILDDIR)/DPKGInfoProbe.obj \
 	$(BUILDDIR)/UnameProbe.obj \
 	$(BUILDDIR)/TextFileContentProbe.obj \
 	$(BUILDDIR)/XmlFileContentProbe.obj \
@@ -224,6 +244,13 @@
 	$(BUILDDIR)/FileHashProbe.obj \
 	$(BUILDDIR)/VariableProbe.obj \
 
+ifeq ($(DISTRIBUTION), REDHAT)
+	REL_OBJS += $(BUILDDIR)/RPMInfoProbe.obj
+endif
+ifeq ($(DISTRIBUTION), DEBIAN)
+	REL_OBJS += $(BUILDDIR)/DPKGInfoProbe.obj
+endif
+
 # Search the output directory for object files
 vpath %.obj $(BUILDDIR)
 vpath %.cpp $(SRCDIR)
@@ -241,7 +268,7 @@
 .SUFFIXES: .cpp .obj
 
 .cpp.obj:
-	$(CXX) -c $(CPPFLAGS) -D$(PLATFORM) $(INCDIRS) -o $(BUILDDIR)/$@ $^
+	$(CXX) -c $(CPPFLAGS) -D$(PLATFORM) -D$(DISTRIBUTION) $(INCDIRS) -o $(BUILDDIR)/$@ $^
 
 # *******************************************************************
 #                            Rules
@@ -251,6 +278,10 @@
 
 set-platform:
 	@if [ $(PLATFORM) = Linux ]; then \
+		if [ $(DISTRIBUTION) = NO_DISTRIBUTION ]; then \
+			echo "Unknown distribution. Exiting"; \
+			exit 1; \
+		fi; \
 		make linux; \
 	fi;
 
@@ -262,7 +293,7 @@
 linux: build
 
 
-sunos: PLATFORM = SUNOS
+sunos: PLATFORM = SUNOS 
 sunos: build
 
 update:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: probe-rh-debian.diff
Type: text/x-diff
Size: 1567 bytes
Desc: not available
Url : http://lists.alioth.debian.org/pipermail/oval-devel/attachments/20070807/72eb65f1/attachment.diff 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.alioth.debian.org/pipermail/oval-devel/attachments/20070807/72eb65f1/attachment.pgp 


More information about the Oval-devel mailing list