Discussion:
[Libstoragemgmt-devel] [PATCH 0/4] Fix compile on Archlinux
Gris Ge
2014-08-19 03:54:54 UTC
Permalink
These things in Archlinux stop us from compiling:
1. python == python3.
2. json-c in Archlinux(0.12) is not providing back compatibility for
json.pc

Archlinux also shipping some newer version of tools which cause warnings:
1. Perl smart match is marked as experimental since 5.18
2. Automake 1.14 complain about 'subdir-objects' for util/qparams.c.
# I didn't fix this in this patch set.

Gris Ge (4):
autoconf: fix python2 checking and jons>=0.11
lsm REST daemon: Fix json-c include header path for json>=0.11
force using python2
lsmenv: Remove experimental smart match code

configure.ac | 22 +++++++++++++++++++---
daemon/Makefile.am | 3 ++-
daemon/lsm_rest.c | 2 +-
plugin/nstor/nstor_lsmplugin | 2 +-
plugin/ontap/ontap_lsmplugin | 4 ++--
plugin/sim/sim_lsmplugin | 4 ++--
plugin/smispy/smispy_lsmplugin | 4 ++--
plugin/targetd/targetd.py | 2 --
plugin/targetd/targetd_lsmplugin | 4 ++--
test/cmdtest.py | 2 +-
test/plugin_test.py | 2 +-
test/webtest/test_automated.py | 2 +-
test/webtest/test_hardware.py | 2 +-
test/webtest/test_results.py | 2 +-
tools/lsmcli/lsmcli | 2 +-
tools/lsmenv | 16 +++++++++++-----
tools/netapp/netapp.py | 4 +---
tools/utility/public_symbols.py | 4 ++--
tools/utility/web_cap.py | 2 +-
19 files changed, 52 insertions(+), 33 deletions(-)
--
2.0.4
Gris Ge
2014-08-19 03:54:55 UTC
Permalink
* Try to locate python in the sequence of:
python2.7 python 2.6 python2 python
Then check python version as we only support python 2.

* Pkconfig will try 'json.pc' if 'json-c.pc' failed.

Tested by OBS.
Manually tested by './configure && make check' on:
* Archlinux
* Fedora 20
* RHEL 6.5
* RHEL 7.0

Signed-off-by: Gris Ge <***@redhat.com>
---
configure.ac | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index cbf668b..0928c1b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -136,10 +136,22 @@ fi
AM_CONDITIONAL([BUILD_C_UNIT], [test "x${want_c_unit}" = "xyes"])

dnl ==========================================================================
-dnl Check for python as it is needed for the base cmd line function
+dnl Check for python2 as it is needed for the base cmd line function
dnl ==========================================================================

-AM_PATH_PYTHON([2.6], [], AC_MSG_ERROR([Python interpreter 2.6 or later required]) )
+AC_PATH_PROGS(PYTHON, python2.7 python2.6 python, [Python is required])
+AC_MSG_CHECKING([Check for Python major version])
+PYTHON_MAJOR_VERSION=`$PYTHON -c "import sys; print(sys.version_info[[0]])"`
+case "$PYTHON_MAJOR_VERSION" in
+ 2)
+ ;;
+ *)
+ AC_MSG_ERROR(
+ [we need Python version 2.x but found $PYTHON_MAJOR_VERSION.x]) ;;
+esac
+AC_MSG_RESULT([$PYTHON_MAJOR_VERSION])
+AM_PATH_PYTHON([2.6], [], AC_MSG_ERROR([Python interpreter 2.6 or 2.7 required]) )
+
AC_PYTHON_MODULE([pywbem], [Required])
AC_PYTHON_MODULE([M2Crypto], [Required])
AC_PYTHON_MODULE([argparse], [Required])
@@ -155,7 +167,11 @@ AC_ARG_WITH([rest-api],
[with_rest_api=yes])
if test "x$with_rest_api" = "xyes"; then
PKG_CHECK_MODULES([LIBMICROHTTPD], [libmicrohttpd >= 0.9])
- PKG_CHECK_MODULES([JSON], [json >= 0.10], [], AC_MSG_ERROR([json-c development libraries 0.10 or later required]))
+ PKG_CHECK_MODULES([JSON], [json >= 0.10], [], [
+ PKG_CHECK_MODULES([JSON], [json-c], [], [
+ AC_MSG_ERROR([json-c development libraries 0.10 or later required])
+ ])
+ ])
fi
AM_CONDITIONAL([WITH_REST_API], [test "x$with_rest_api" = "xyes"])
--
2.0.4
Gris Ge
2014-08-19 03:54:56 UTC
Permalink
Some platform(like Archlinux, json-c-0.12), does not store header in json
folder.

Use 'json.h' instead of 'json/json.h' and let autotools handle it.

Signed-off-by: Gris Ge <***@redhat.com>
---
daemon/Makefile.am | 3 ++-
daemon/lsm_rest.c | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index 20d2723..de45612 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -2,7 +2,8 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/c_binding/include \
-I$(top_builddir)/c_binding/include \
-***@srcdir@/c_binding/include \
- $(LIBXML_CFLAGS) $(LIBGLIB_CFLAGS)
+ $(LIBXML_CFLAGS) $(LIBGLIB_CFLAGS) \
+ $(JSON_CFLAGS) $(LIBMICROHTTPD_CFLAGS)

bin_PROGRAMS = lsmd

diff --git a/daemon/lsm_rest.c b/daemon/lsm_rest.c
index 6fba3bf..1f38235 100644
--- a/daemon/lsm_rest.c
+++ b/daemon/lsm_rest.c
@@ -25,7 +25,7 @@
#include <sys/un.h>
#include <string.h>
#include <microhttpd.h>
-#include <json/json.h>
+#include <json.h>
#include <libxml/uri.h>
#include <stdio.h>
#include <unistd.h>
--
2.0.4
Gris Ge
2014-08-19 03:54:57 UTC
Permalink
The '/usr/bin/python' of some platform like Archlinux is actually python3.

Currently none of our python codes is tested on python3, hence forcing to use
python2.

Signed-off-by: Gris Ge <***@redhat.com>
---
plugin/nstor/nstor_lsmplugin | 2 +-
plugin/ontap/ontap_lsmplugin | 4 ++--
plugin/sim/sim_lsmplugin | 4 ++--
plugin/smispy/smispy_lsmplugin | 4 ++--
plugin/targetd/targetd.py | 2 --
plugin/targetd/targetd_lsmplugin | 4 ++--
test/cmdtest.py | 2 +-
test/plugin_test.py | 2 +-
test/webtest/test_automated.py | 2 +-
test/webtest/test_hardware.py | 2 +-
test/webtest/test_results.py | 2 +-
tools/lsmcli/lsmcli | 2 +-
tools/netapp/netapp.py | 4 +---
tools/utility/public_symbols.py | 4 ++--
tools/utility/web_cap.py | 2 +-
15 files changed, 19 insertions(+), 23 deletions(-)

diff --git a/plugin/nstor/nstor_lsmplugin b/plugin/nstor/nstor_lsmplugin
index c62bae6..82c3171 100755
--- a/plugin/nstor/nstor_lsmplugin
+++ b/plugin/nstor/nstor_lsmplugin
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2

#
# Copyright (C) 2012 Nexenta Systems, Inc.
diff --git a/plugin/ontap/ontap_lsmplugin b/plugin/ontap/ontap_lsmplugin
index 6ef4dc4..396106c 100755
--- a/plugin/ontap/ontap_lsmplugin
+++ b/plugin/ontap/ontap_lsmplugin
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2

# Copyright (C) 2011-2013 Red Hat, Inc.
# This library is free software; you can redistribute it and/or
@@ -34,4 +34,4 @@ except Exception:
msg = str(traceback.format_exc())
syslog.syslog(syslog.LOG_ERR, msg)
sys.stderr.write(msg)
- sys.exit(1)
\ No newline at end of file
+ sys.exit(1)
diff --git a/plugin/sim/sim_lsmplugin b/plugin/sim/sim_lsmplugin
index ef9e477..9a7aa1d 100755
--- a/plugin/sim/sim_lsmplugin
+++ b/plugin/sim/sim_lsmplugin
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2

# Copyright (C) 2011-2013 Red Hat, Inc.
# This library is free software; you can redistribute it and/or
@@ -34,4 +34,4 @@ except Exception:
msg = str(traceback.format_exc())
syslog.syslog(syslog.LOG_ERR, msg)
sys.stderr.write(msg)
- sys.exit(1)
\ No newline at end of file
+ sys.exit(1)
diff --git a/plugin/smispy/smispy_lsmplugin b/plugin/smispy/smispy_lsmplugin
index 13ecfc2..de87c7d 100755
--- a/plugin/smispy/smispy_lsmplugin
+++ b/plugin/smispy/smispy_lsmplugin
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2

# Copyright (C) 2011-2013 Red Hat, Inc.
# This library is free software; you can redistribute it and/or
@@ -34,4 +34,4 @@ except Exception:
msg = str(traceback.format_exc())
syslog.syslog(syslog.LOG_ERR, msg)
sys.stderr.write(msg)
- sys.exit(1)
\ No newline at end of file
+ sys.exit(1)
diff --git a/plugin/targetd/targetd.py b/plugin/targetd/targetd.py
index 9cf763e..9f1cac1 100644
--- a/plugin/targetd/targetd.py
+++ b/plugin/targetd/targetd.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
# Copyright (C) 2011-2014 Red Hat, Inc.
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
diff --git a/plugin/targetd/targetd_lsmplugin b/plugin/targetd/targetd_lsmplugin
index ef33be0..3a75334 100755
--- a/plugin/targetd/targetd_lsmplugin
+++ b/plugin/targetd/targetd_lsmplugin
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2

# Copyright (C) 2011-2013 Red Hat, Inc.
# This library is free software; you can redistribute it and/or
@@ -34,4 +34,4 @@ except Exception:
msg = str(traceback.format_exc())
syslog.syslog(syslog.LOG_ERR, msg)
sys.stderr.write(msg)
- sys.exit(1)
\ No newline at end of file
+ sys.exit(1)
diff --git a/test/cmdtest.py b/test/cmdtest.py
index 408dc10..790fa39 100755
--- a/test/cmdtest.py
+++ b/test/cmdtest.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2

# Copyright (C) 2011-2014 Red Hat, Inc.
#
diff --git a/test/plugin_test.py b/test/plugin_test.py
index 83f1b3b..88e7988 100755
--- a/test/plugin_test.py
+++ b/test/plugin_test.py
@@ -1,4 +1,4 @@
-#!/bin/env python
+#!/bin/env python2

# Copyright (C) 2013-2014 Red Hat, Inc.
# This library is free software; you can redistribute it and/or
diff --git a/test/webtest/test_automated.py b/test/webtest/test_automated.py
index 53e99af..f0b5e33 100755
--- a/test/webtest/test_automated.py
+++ b/test/webtest/test_automated.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2

# Copyright (C) 2014 Red Hat, Inc.
# This library is free software; you can redistribute it and/or
diff --git a/test/webtest/test_hardware.py b/test/webtest/test_hardware.py
index 64f78c3..5550d0d 100755
--- a/test/webtest/test_hardware.py
+++ b/test/webtest/test_hardware.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2

# Copyright (C) 2014 Red Hat, Inc.
# This library is free software; you can redistribute it and/or
diff --git a/test/webtest/test_results.py b/test/webtest/test_results.py
index 64f7d2e..2b2c527 100755
--- a/test/webtest/test_results.py
+++ b/test/webtest/test_results.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2

# Copyright (C) 2014 Red Hat, Inc.
# This library is free software; you can redistribute it and/or
diff --git a/tools/lsmcli/lsmcli b/tools/lsmcli/lsmcli
index d626b99..6baa2df 100755
--- a/tools/lsmcli/lsmcli
+++ b/tools/lsmcli/lsmcli
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2

# Copyright (C) 2012 Red Hat, Inc.
# This library is free software; you can redistribute it and/or
diff --git a/tools/netapp/netapp.py b/tools/netapp/netapp.py
index c86a50f..a219a28 100755
--- a/tools/netapp/netapp.py
+++ b/tools/netapp/netapp.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
# Copyright (C) 2012-2014 Red Hat, Inc.
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -75,4 +73,4 @@ if __name__ == '__main__':
else:
print 'Please create environmental variables for ' \
'NA_USER and NA_PASSWORD'
- sys.exit(1)
\ No newline at end of file
+ sys.exit(1)
diff --git a/tools/utility/public_symbols.py b/tools/utility/public_symbols.py
index dfc597c..e030f0a 100755
--- a/tools/utility/public_symbols.py
+++ b/tools/utility/public_symbols.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2

# Copyright (C) 2014 Red Hat, Inc.
# This library is free software; you can redistribute it and/or
@@ -117,4 +117,4 @@ def h_module(mod):
h_module(m[1])

if __name__ == '__main__':
- h_module(lsm)
\ No newline at end of file
+ h_module(lsm)
diff --git a/tools/utility/web_cap.py b/tools/utility/web_cap.py
index b9d5af3..e4740e3 100755
--- a/tools/utility/web_cap.py
+++ b/tools/utility/web_cap.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2

# Copyright (C) 2011-2013 Red Hat, Inc.
# This library is free software; you can redistribute it and/or
--
2.0.4
Gris Ge
2014-08-19 03:54:58 UTC
Permalink
The smart match '~~' is marked as experimental since perl 5.18.
We replaced it with is_in_array() subroutine.

Signed-off-by: Gris Ge <***@redhat.com>
---
tools/lsmenv | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/tools/lsmenv b/tools/lsmenv
index e238380..0cedfa3 100755
--- a/tools/lsmenv
+++ b/tools/lsmenv
@@ -17,7 +17,6 @@
# Author: Gris Ge <***@redhat.com>

use strict;
-require 5.10.0; # For smart match ~~
use Config::IniFiles;
use File::Basename;
use Cwd 'abs_path';
@@ -25,7 +24,7 @@ use Cwd 'abs_path';
$|++;

my $LSM_UDS_PATH = '/tmp/lsm/ipc/';
-my $BASE_DIR; # Used to store the path of libstoragemgmt-code path.
+my $BASE_DIR; # Used to store the path of libstoragemgmt-code path.
my $LSM_URI_FILE = "$ENV{HOME}/.lsm_uri";
my $URI_CFG = Config::IniFiles->new( -file => $LSM_URI_FILE );

@@ -71,6 +70,13 @@ END
exit 1;
}

+sub is_in_array($$) {
+ my $ref_array = shift;
+ my $item = shift;
+ return 1 if grep { $_ eq $item } @{$ref_array};
+ return undef;
+}
+
sub lsm_env_setup() {
$BASE_DIR = dirname( dirname( abs_path($0) ) );
my $py_binding_dir = "$BASE_DIR/python_binding";
@@ -110,7 +116,7 @@ sub call_out($) {
help();
}

- if ( $dev_alias ~~ [ keys( %{$REF_PRE_BUILD_URI} ) ] ) {
+ if ( is_in_array( [ keys( %{$REF_PRE_BUILD_URI} ) ], $dev_alias ) ) {
$ENV{LSMCLI_URI} = $REF_PRE_BUILD_URI->{$dev_alias};
}
else {
@@ -183,8 +189,8 @@ sub main() {
elsif ( $ARGV[0] =~ /^-h$|^--help$/ ) {
help();
}
- elsif (( $ARGV[0] ~~ [ keys( %{$REF_PRE_BUILD_URI} ) ] )
- || ( $ARGV[0] ~~ @{ $URI_CFG->{sects} } ) )
+ elsif (( is_in_array( [ keys( %{$REF_PRE_BUILD_URI} ) ], $ARGV[0] ) )
+ || ( is_in_array( $URI_CFG->{sects}, $ARGV[0] ) ) )
{
call_out( $ARGV[0] );
exit 0;
--
2.0.4
Tony Asleson
2014-08-19 20:36:29 UTC
Permalink
Patch series committed.

Thanks,
Tony
Post by Gris Ge
1. python == python3.
2. json-c in Archlinux(0.12) is not providing back compatibility for
json.pc
1. Perl smart match is marked as experimental since 5.18
2. Automake 1.14 complain about 'subdir-objects' for util/qparams.c.
# I didn't fix this in this patch set.
autoconf: fix python2 checking and jons>=0.11
lsm REST daemon: Fix json-c include header path for json>=0.11
force using python2
lsmenv: Remove experimental smart match code
configure.ac | 22 +++++++++++++++++++---
daemon/Makefile.am | 3 ++-
daemon/lsm_rest.c | 2 +-
plugin/nstor/nstor_lsmplugin | 2 +-
plugin/ontap/ontap_lsmplugin | 4 ++--
plugin/sim/sim_lsmplugin | 4 ++--
plugin/smispy/smispy_lsmplugin | 4 ++--
plugin/targetd/targetd.py | 2 --
plugin/targetd/targetd_lsmplugin | 4 ++--
test/cmdtest.py | 2 +-
test/plugin_test.py | 2 +-
test/webtest/test_automated.py | 2 +-
test/webtest/test_hardware.py | 2 +-
test/webtest/test_results.py | 2 +-
tools/lsmcli/lsmcli | 2 +-
tools/lsmenv | 16 +++++++++++-----
tools/netapp/netapp.py | 4 +---
tools/utility/public_symbols.py | 4 ++--
tools/utility/web_cap.py | 2 +-
19 files changed, 52 insertions(+), 33 deletions(-)
Loading...