[PATCH 1/4] Make anaconda know its version number (#520061)

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

 



Remove the ANACONDAVERSION environment variable and embed the version
number at build time.  The isys.getAnacondaVersion() function returns
the version number to Python code.  If need be, it can be extended to
libisys.
---
 exception.py      |    3 ++-
 isys/Makefile.am  |    5 +++--
 isys/isys.c       |    6 ++++++
 isys/isys.py      |    3 +++
 liveinst/liveinst |    1 -
 loader/loader.c   |    1 -
 6 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/exception.py b/exception.py
index 0df4eab..3493786 100644
--- a/exception.py
+++ b/exception.py
@@ -90,7 +90,8 @@ class AnacondaExceptionHandler(ExceptionHandler):
         os.kill(os.getpid(), signal.SIGKILL)
 
 def initExceptionHandling(anaconda):
-    conf = Config(programName="anaconda", programVersion=os.environ["ANACONDAVERSION"],
+    conf = Config(programName="anaconda",
+                  programVersion=isys.getAnacondaVersion(),
                   bugFiler=anaconda.id.instClass.bugFiler,
                   attrSkipList=[ "anaconda.backend.ayum",
                                  "anaconda.backend.dlpkgs",
diff --git a/isys/Makefile.am b/isys/Makefile.am
index b434299..e591b40 100644
--- a/isys/Makefile.am
+++ b/isys/Makefile.am
@@ -27,8 +27,9 @@ endif
 
 dist_noinst_HEADERS = *.h
 
-ISYS_CFLAGS = $(NFS_CFLAGS) $(NETWORKMANAGER_CFLAGS) $(LIBNL_CFLAGS) \
-              $(LIBNM_GLIB_CFLAGS) $(SELINUX_CFLAGS)
+ISYS_CFLAGS = -DVERSION='"$(PACKAGE_VERSION)"' $(NFS_CFLAGS) \
+              $(NETWORKMANAGER_CFLAGS) $(LIBNL_CFLAGS) $(LIBNM_GLIB_CFLAGS) \
+              $(SELINUX_CFLAGS)
 ISYS_LIBS   = $(RESOLV_LIBS) $(POPT_LIBS) $(EXT2FS_LIBS) $(ZLIB_LIBS) \
               $(DEVMAPPER_LIBS) $(BLKID_LIBS) $(X11_LIBS) $(SELINUX_LIBS) \
               $(LIBNL_LIBS) $(LIBNM_GLIB_LIBS)
diff --git a/isys/isys.c b/isys/isys.c
index 8a83a54..fc4b817 100644
--- a/isys/isys.c
+++ b/isys/isys.c
@@ -128,6 +128,7 @@ static PyObject * doPrefixToNetmask(PyObject *s, PyObject *args);
 static PyObject * doGetBlkidData(PyObject * s, PyObject * args);
 static PyObject * doIsCapsLockEnabled(PyObject * s, PyObject * args);
 static PyObject * doGetLinkStatus(PyObject * s, PyObject * args);
+static PyObject * doGetAnacondaVersion(PyObject * s, PyObject * args);
 
 static PyMethodDef isysModuleMethods[] = {
     { "ejectcdrom", (PyCFunction) doEjectCdrom, METH_VARARGS, NULL },
@@ -172,6 +173,7 @@ static PyMethodDef isysModuleMethods[] = {
     { "getblkid", (PyCFunction) doGetBlkidData, METH_VARARGS, NULL },
     { "isCapsLockEnabled", (PyCFunction) doIsCapsLockEnabled, METH_VARARGS, NULL },
     { "getLinkStatus", (PyCFunction) doGetLinkStatus, METH_VARARGS, NULL },
+    { "getAnacondaVersion", (PyCFunction) doGetAnacondaVersion, METH_VARARGS, NULL },
     { NULL, NULL, 0, NULL }
 } ;
 
@@ -872,4 +874,8 @@ static PyObject * doGetLinkStatus(PyObject * s, PyObject * args) {
     return PyBool_FromLong(0);
 }
 
+static PyObject * doGetAnacondaVersion(PyObject * s, PyObject * args) {
+    return Py_BuildValue("s", VERSION);
+}
+
 /* vim:set shiftwidth=4 softtabstop=4: */
diff --git a/isys/isys.py b/isys/isys.py
index 79959d0..721aca0 100755
--- a/isys/isys.py
+++ b/isys/isys.py
@@ -716,6 +716,9 @@ def isPaeAvailable():
 def getLinkStatus(dev):
     return _isys.getLinkStatus(dev)
 
+def getAnacondaVersion():
+    return _isys.getAnacondaVersion()
+
 auditDaemon = _isys.auditdaemon
 
 handleSegv = _isys.handleSegv
diff --git a/liveinst/liveinst b/liveinst/liveinst
index 7066143..eed4e41 100755
--- a/liveinst/liveinst
+++ b/liveinst/liveinst
@@ -37,7 +37,6 @@ for i in raid0 raid1 raid5 raid6 raid456 raid10 dm-mod dm-zero dm-mirror dm-snap
 export ANACONDA_PRODUCTNAME=$( cat /etc/system-release | cut -d ' ' -f 1 )
 export ANACONDA_PRODUCTVERSION=$( cat /etc/system-release | sed -r -e 's/^.*([0-9]+) *\(.*$/\1/' )
 export ANACONDA_BUGURL=${ANACONDA_BUGURL:="https://bugzilla.redhat.com/bugzilla/"}
-export ANACONDAVERSION=$(rpm -q --qf "%{VERSION}-%{RELEASE}" anaconda)
 
 export PATH=/sbin:/usr/sbin:$PATH
 
diff --git a/loader/loader.c b/loader/loader.c
index b629872..7a0e1c5 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -2234,7 +2234,6 @@ int main(int argc, char ** argv) {
         printf(fmt, VERSION, getProductName());
 
         if (!(pid = fork())) {
-            setenv("ANACONDAVERSION", VERSION, 1);
             if (execv(anacondaArgs[0], anacondaArgs) == -1) {
                fprintf(stderr,"exec of anaconda failed: %m\n");
                exit(1);
-- 
1.6.2.5

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[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