targetcli-fb: new package
cover targetcli-fb: new package
Hi,
This patch serie adds a new package to Buildroot: targetcli-fb.
Targetcli is a CLI used to configure the Linux "SCSI target" driver. For instance, it allows to export a device with iSCSI or Fibre Channel.
Targetcli is written in Python and depends on the following packages:
pyparsing, urwid, rtslib-fb, and configshell-fb. It should run on both Python 2.7 and Python 3, but so far I had troubles with Python 3: it seems that 2to3 is not invoked during a build for Python 3. As a consequence targetcli-fb is currently not available when Python 3 is selected.
Christophe Vu-Brugier (6):
python, python3: add patch to prevent distutils from adjusting the
shebang
python-urwid: new package
python-rtslib-fb: new package
python-configshell-fb: new package
targetcli-fb: new package
targetcli-fb: add sysv initscript
package/Config.in | 4 ++ package/python-configshell-fb/Config.in | 11 ++++++ .../python-configshell-fb/python-configshell-fb.mk | 14 +++++++ package/python-rtslib-fb/Config.in | 9 +++++ package/python-rtslib-fb/python-rtslib.mk | 13 ++++++ package/python-urwid/Config.in | 7 ++++ package/python-urwid/python-urwid.mk | 14 +++++++ ...017-distutils-scripts-dont-adjust-shebang.patch | 25 ++++++++++++ ...015-distutils-scripts-dont-adjust-shebang.patch | 25 ++++++++++++ package/targetcli-fb/Config.in | 14 +++++++ package/targetcli-fb/S50target | 46 ++++++++++++++++++++++ package/targetcli-fb/targetcli-fb.mk | 25 ++++++++++++ 12 files changed, 207 insertions(+) create mode 100644 package/python-configshell-fb/Config.in create mode 100644 package/python-configshell-fb/python-configshell-fb.mk create mode 100644 package/python-rtslib-fb/Config.in create mode 100644 package/python-rtslib-fb/python-rtslib.mk create mode 100644 package/python-urwid/Config.in create mode 100644 package/python-urwid/python-urwid.mk create mode 100644 package/python/python-017-distutils-scripts-dont-adjust-shebang.patch create mode 100644 package/python3/python3-015-distutils-scripts-dont-adjust-shebang.patch create mode 100644 package/targetcli-fb/Config.in create mode 100755 package/targetcli-fb/S50target create mode 100644 package/targetcli-fb/targetcli-fb.mk
Signature · 1 line
2.1.0
PATCH 1/6 python, python3: add patch to prevent distutils from adjusting the shebang
The copy_scripts() method in distutils copies the scripts listed in the setup file and adjusts the first line to refer to the current Python interpreter. When cross-compiling, this means that the adjusted shebang refers to the host Python interpreter.
As a consequence, we add a patch for python and python3 that force copy_scripts() to preserve the shebang when cross-compilation is detected.
--- ...017-distutils-scripts-dont-adjust-shebang.patch | 25 ++++++++++++++++++++++ ...015-distutils-scripts-dont-adjust-shebang.patch | 25 ++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 package/python/python-017-distutils-scripts-dont-adjust-shebang.patch create mode 100644 package/python3/python3-015-distutils-scripts-dont-adjust-shebang.patch
package/python/python-017-distutils-scripts-dont-adjust-shebang.patch new file +25 -0
@@ -0,0 +1,25 @@ +Do not adjust the shebang of Python scripts for cross-compilation + +The copy_scripts() method in distutils copies the scripts listed in +the setup file and adjusts the first line to refer to the current +Python interpreter. When cross-compiling, this means that the adjusted +shebang refers to the host Python interpreter. + +This patch modifies copy_scripts() to preserve the shebang when +cross-compilation is detected. + +Signed-off-by: Christophe Vu-Brugier <[email protected]> + +Index: b/Lib/distutils/command/build_scripts.py +=================================================================== +--- a/Lib/distutils/command/build_scripts.py ++++ b/Lib/distutils/command/build_scripts.py +@@ -89,7 +89,7 @@ + adjust = 1 + post_interp = match.group(1) or '' + +- if adjust: ++ if adjust and not '_python_sysroot' in os.environ: + log.info("copying and adjusting %s -> %s", script, + self.build_dir) + if not self.dry_run:
package/python3/python3-015-distutils-scripts-dont-adjust-shebang.patch new file +25 -0
@@ -0,0 +1,25 @@ +Do not adjust the shebang of Python scripts for cross-compilation + +The copy_scripts() method in distutils copies the scripts listed in +the setup file and adjusts the first line to refer to the current +Python interpreter. When cross-compiling, this means that the adjusted +shebang refers to the host Python interpreter. + +This patch modifies copy_scripts() to preserve the shebang when +cross-compilation is detected. + +Signed-off-by: Christophe Vu-Brugier <[email protected]> + +Index: b/Lib/distutils/command/build_scripts.py +=================================================================== +--- a/Lib/distutils/command/build_scripts.py ++++ b/Lib/distutils/command/build_scripts.py +@@ -91,7 +91,7 @@ + adjust = True + post_interp = match.group(1) or b'' + +- if adjust: ++ if adjust and not '_python_sysroot' in os.environ: + log.info("copying and adjusting %s -> %s", script, + self.build_dir) + updated_files.append(outfile)
Signature · 1 line
2.1.0
PATCH 2/6 python-urwid: new package
In reply to Christophe Vu-BrugierUrwid is a console user interface library for Python.
--- package/Config.in | 1 + package/python-urwid/Config.in | 7 +++++++ package/python-urwid/python-urwid.mk | 14 ++++++++++++++ 3 files changed, 22 insertions(+) create mode 100644 package/python-urwid/Config.in create mode 100644 package/python-urwid/python-urwid.mk
package/Config.in +1 -0
@@ -508,6 +508,7 @@ menu "external python modules" source "package/python-simplejson/Config.in" source "package/python-thrift/Config.in" source "package/python-tornado/Config.in" + source "package/python-urwid/Config.in" source "package/python-versiontools/Config.in" endmenu endif
package/python-urwid/Config.in new file +7 -0
@@ -0,0 +1,7 @@ +config BR2_PACKAGE_PYTHON_URWID + bool "python-urwid" + depends on BR2_PACKAGE_PYTHON || BR2_PACKAGE_PYTHON3 + help + Urwid is a console user interface library for Python + + http://urwid.org/
package/python-urwid/python-urwid.mk new file +14 -0
@@ -0,0 +1,14 @@ +################################################################################ +# +# python-urwid +# +################################################################################ + +PYTHON_URWID_VERSION = 1.2.1 +PYTHON_URWID_SOURCE = urwid-$(PYTHON_URWID_VERSION).tar.gz +PYTHON_URWID_SITE = https://pypi.python.org/packages/source/u/urwid +PYTHON_URWID_LICENSE = LGPLv2.1+ +PYTHON_URWID_LICENSE_FILES = COPYING +PYTHON_URWID_SETUP_TYPE = setuptools + +$(eval $(python-package))
Signature · 1 line
2.1.0
PATCH 2/6 python-urwid: new package
Dear Christophe Vu-Brugier,
Quoted 10 lines · Christophe Vu-Brugier
Urwid is a console user interface library for Python.
Signed-off-by Christophe Vu-Brugier <[email protected]>--- package/Config.in | 1 + package/python-urwid/Config.in | 7 +++++++ package/python-urwid/python-urwid.mk | 14 ++++++++++++++ 3 files changed, 22 insertions(+) create mode 100644 package/python-urwid/Config.in create mode 100644 package/python-urwid/python-urwid.mk
Looks good to me, I've checked that the license is indeed LGPLv2.1+, the rest of the package is quite simple and obvious.
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH 3/6 python-rtslib-fb: new package
In reply to Christophe Vu-Brugierrtslib-fb is an object-based Python library for configuring the LIO generic SCSI target, present in 3.x Linux kernel versions.
--- package/Config.in | 1 + package/python-rtslib-fb/Config.in | 9 +++++++++ package/python-rtslib-fb/python-rtslib.mk | 13 +++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 package/python-rtslib-fb/Config.in create mode 100644 package/python-rtslib-fb/python-rtslib.mk
package/Config.in +1 -0
@@ -503,6 +503,7 @@ menu "external python modules" source "package/python-pysnmp-mibs/Config.in" source "package/python-pyusb/Config.in" source "package/python-pyzmq/Config.in" + source "package/python-rtslib-fb/Config.in" source "package/python-serial/Config.in" source "package/python-setuptools/Config.in" source "package/python-simplejson/Config.in"
package/python-rtslib-fb/Config.in new file +9 -0
@@ -0,0 +1,9 @@ +config BR2_PACKAGE_PYTHON_RTSLIB_FB + bool "python-rtslib-fb" + depends on BR2_PACKAGE_PYTHON + help + rtslib-fb is an object-based Python library for configuring + the LIO generic SCSI target, present in 3.x Linux kernel + versions. + + https://github.com/agrover/rtslib-fb
package/python-rtslib-fb/python-rtslib.mk new file +13 -0
@@ -0,0 +1,13 @@ +################################################################################ +# +# python-rtslib-fb +# +################################################################################ + +PYTHON_RTSLIB_FB_VERSION = v2.1.fb49 +PYTHON_RTSLIB_FB_SITE = $(call github,agrover,rtslib-fb,$(PYTHON_RTSLIB_FB_VERSION)) +PYTHON_RTSLIB_FB_LICENSE = Apache-2.0 +PYTHON_RTSLIB_FB_LICENSE_FILES = COPYING +PYTHON_RTSLIB_FB_SETUP_TYPE = setuptools + +$(eval $(python-package))
Signature · 1 line
2.1.0
PATCH 3/6 python-rtslib-fb: new package
Dear Christophe Vu-Brugier,
package/python-rtslib-fb/Config.in line 3
Quoted 9 lines · Christophe Vu-Brugier
package/python-rtslib-fb/Config.in new file +3
-0@@ -0,0 +1,9 @@ +config BR2_PACKAGE_PYTHON_RTSLIB_FB + bool "python-rtslib-fb" + depends on BR2_PACKAGE_PYTHON
Is it for this package that you had the Python 3 issue? Could you explain a bit more the 2to3 problems you have seen?
Quoted 15 lines
package/python-rtslib-fb/Config.in new file +6
-0+ help + rtslib-fb is an object-based Python library for configuring + the LIO generic SCSI target, present in 3.x Linux kernel + versions. + + https://github.com/agrover/rtslib-fbpackage/python-rtslib-fb/python-rtslib.mk new file +3
-0@@ -0,0 +1,13 @@ +################################################################################ +# +# python-rtslib-fb
package/python-rtslib-fb/python-rtslib.mk line 13
Quoted 10 lines
package/python-rtslib-fb/python-rtslib.mk new file +10
-0+# +################################################################################ + +PYTHON_RTSLIB_FB_VERSION = v2.1.fb49 +PYTHON_RTSLIB_FB_SITE = $(call github,agrover,rtslib-fb,$(PYTHON_RTSLIB_FB_VERSION)) +PYTHON_RTSLIB_FB_LICENSE = Apache-2.0 +PYTHON_RTSLIB_FB_LICENSE_FILES = COPYING +PYTHON_RTSLIB_FB_SETUP_TYPE = setuptools + +$(eval $(python-package))
Other than that, the patch looks good to me, and the Python 3 support can always be added later:
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH 3/6 python-rtslib-fb: new package
Hi Thomas,
Thank you for the prompt review.
Quoted 14 lines · Thomas Petazzoni
package/python-rtslib-fb/Config.in line 3
Quoted 9 lines · Christophe Vu-Brugier
package/python-rtslib-fb/Config.in new file +3
-0@@ -0,0 +1,9 @@ +config BR2_PACKAGE_PYTHON_RTSLIB_FB + bool "python-rtslib-fb" + depends on BR2_PACKAGE_PYTHONIs it for this package that you had the Python 3 issue? Could you explain a bit more the 2to3 problems you have seen?
It is for this package (and for configshell-fb and targetcli-fb) that I thought I had an issue with 2to3.
But I was wrong because it seems that 2to3 is correctly invoked by setup.py when it is run under Python 3.
The installed python files are different from the source python files and are modified by 2to3:
usr/lib/python3.4/site-packages/rtslib/utils.py renamed from python-rtslib-fb-v2.1.fb49/rtslib/utils.py +1 -1
@@ -435,14 +435,14 @@ raise def set_attributes(obj, attr_dict, err_func): - for name, value in attr_dict.iteritems(): + for name, value in attr_dict.items():
So if there is an issue, it is not caused by a broken 2to3.
Quoted 32 lines
Quoted 15 lines
package/python-rtslib-fb/Config.in new file +6
-0+ help + rtslib-fb is an object-based Python library for configuring + the LIO generic SCSI target, present in 3.x Linux kernel + versions. + + https://github.com/agrover/rtslib-fbpackage/python-rtslib-fb/python-rtslib.mk new file +3
-0@@ -0,0 +1,13 @@ +################################################################################ +# +# python-rtslib-fbpackage/python-rtslib-fb/python-rtslib.mk line 13
Quoted 10 lines
package/python-rtslib-fb/python-rtslib.mk new file +10
-0+# +################################################################################ + +PYTHON_RTSLIB_FB_VERSION = v2.1.fb49 +PYTHON_RTSLIB_FB_SITE = $(call github,agrover,rtslib-fb,$(PYTHON_RTSLIB_FB_VERSION)) +PYTHON_RTSLIB_FB_LICENSE = Apache-2.0 +PYTHON_RTSLIB_FB_LICENSE_FILES = COPYING +PYTHON_RTSLIB_FB_SETUP_TYPE = setuptools + +$(eval $(python-package))Other than that, the patch looks good to me, and the Python 3 support can always be added later:
Reviewed-by Thomas Petazzoni <[email protected]>Thomas
PATCH 3/6 python-rtslib-fb: new package
Dear Christophe Vu-Brugier,
Quoted 1 line · Christophe Vu-Brugier
Thank you for the prompt review.
You're welcome. Thanks for submitting those packages in the first place!
Quoted 19 lines
Quoted 2 lines
Is it for this package that you had the Python 3 issue? Could you explain a bit more the 2to3 problems you have seen?
It is for this package (and for configshell-fb and targetcli-fb) that I thought I had an issue with
2to3.
But I was wrong because it seems that2to3is correctly invoked bysetup.pywhen it is run under Python 3.
The installed python files are different from the source python files and are modified by2to3:usr/lib/python3.4/site-packages/rtslib/utils.py renamed from python-rtslib-fb-v2.1.fb49/rtslib/utils.py +1
-1@@ -435,14 +435,14 @@ raise def set_attributes(obj, attr_dict, err_func): - for name, value in attr_dict.iteritems(): + for name, value in attr_dict.items():
Quoted 1 line
So if there is an issue, it is not caused by a broken
2to3.
Indeed, this modification looks like a Python 2 vs. Python 3 conversion, even though I'm not familiar enough with the Python language changes to be sure.
What was the issue you had with Python 3 ?
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH 3/6 python-rtslib-fb: new package
Hi Thomas,
Quoted 1 line · Thomas Petazzoni
What was the issue you had with Python 3 ?
The only "issue" I face at the moment is with pyparsing. I get an ImportError when I try to import this module from Python 3. I think the module is correctly installed: I compared the installation in Buildroot and in a virtualenv and the only difference I see is that a "pyparsing.py" file is installed in "site-packages/" in my virtualenv.
It is expected since BR2_PACKAGE_PYTHON3_PYC_ONLY is selected. If I select BR2_PACKAGE_PYTHON3_PY_PYC instead, then importing the pyparsing module works.
I don't know how to properly fix this. What would you suggest?
Best regards,
--
Christophe Vu-Brugier
PATCH 3/6 python-rtslib-fb: new package
Dear Christophe Vu-Brugier,
Quoted 11 lines · Christophe Vu-Brugier
The only "issue" I face at the moment is with pyparsing. I get an ImportError when I try to import this module from Python 3. I think the module is correctly installed: I compared the installation in Buildroot and in a virtualenv and the only difference I see is that a "
pyparsing.py" file is installed in "site-packages/" in my virtualenv.It is expected since
BR2_PACKAGE_PYTHON3_PYC_ONLYis selected. If I selectBR2_PACKAGE_PYTHON3_PY_PYCinstead, then importing the pyparsing module works.I don't know how to properly fix this. What would you suggest?
Aah, yes, sorry, not your fault. There is an issue with Python 3 and external modules in the BR2_PACKAGE_PYTHON3_PYC_ONLY case, caused by PEP 3147. There is a patch pending at
http://patchwork.ozlabs.org/patch/373082/ to solve this, but I'm not really happy with the proposed solution, and I wanted to investigate this a bit more. Which I've started to do, but of course didn't had enough time to come to a conclusion.
For the time being, either apply the patch mentioned above, or use BR2_PACKAGE_PYTHON3_PY_PYC.
Sorry again :/
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH 3/6 python-rtslib-fb: new package
In reply to Christophe Vu-BrugierHi Christophe,
Quoted 8 lines
rtslib-fb is an object-based Python library for configuring the LIO generic SCSI target, present in 3.x Linux kernel versions.
Signed-off-by Christophe Vu-Brugier <[email protected]>--- package/Config.in | 1 + package/python-rtslib-fb/Config.in | 9 +++++++++ package/python-rtslib-fb/python-rtslib.mk | 13 +++++++++++++
Shouldn't this be:
package/python-rtslib-fb/python-rtslib-fb.mk ?
Regards,
Jerzy
Quoted 50 lines
3 files changed, 23 insertions(+)create mode 100644 package/python-rtslib-fb/Config.in create mode 100644
package/python-rtslib-fb/python-rtslib.mkpackage/Config.in +1
-0@@ -503,6 +503,7 @@ menu "external python modules" source "package/python-pysnmp-mibs/Config.in" source "package/python-pyusb/Config.in" source "package/python-pyzmq/Config.in" + source "package/python-rtslib-fb/Config.in" source "package/python-serial/Config.in" source "package/python-setuptools/Config.in" source "package/python-simplejson/Config.in"package/python-rtslib-fb/Config.in new file +9
-0@@ -0,0 +1,9 @@ +config BR2_PACKAGE_PYTHON_RTSLIB_FB + bool "python-rtslib-fb" + depends on BR2_PACKAGE_PYTHON + help + rtslib-fb is an object-based Python library for configuring + the LIO generic SCSI target, present in 3.x Linux kernel + versions. + + https://github.com/agrover/rtslib-fbpackage/python-rtslib-fb/python-rtslib.mk new file +13
-0@@ -0,0 +1,13 @@ +################################################################################ +# +# python-rtslib-fb +# +################################################################################ + +PYTHON_RTSLIB_FB_VERSION = v2.1.fb49 +PYTHON_RTSLIB_FB_SITE = $(call github,agrover,rtslib-fb,$(PYTHON_RTSLIB_FB_VERSION)) +PYTHON_RTSLIB_FB_LICENSE = Apache-2.0 +PYTHON_RTSLIB_FB_LICENSE_FILES = COPYING +PYTHON_RTSLIB_FB_SETUP_TYPE = setuptools + +$(eval $(python-package))
PATCH 3/6 python-rtslib-fb: new package
Hi Jerzy,
Quoted 9 lines · Jerzy Grzegorek
Quoted 8 lines
rtslib-fb is an object-based Python library for configuring the LIO generic SCSI target, present in 3.x Linux kernel versions.
Signed-off-by Christophe Vu-Brugier <[email protected]>--- package/Config.in | 1 + package/python-rtslib-fb/Config.in | 9 +++++++++ package/python-rtslib-fb/python-rtslib.mk | 13 +++++++++++++
Quoted 3 lines
Shouldn't this be:
package/python-rtslib-fb/python-rtslib-fb.mk?
Indeed. Thank you for catching this one!
Best regards,
Quoted 51 lines
Quoted 50 lines
3 files changed, 23 insertions(+)create mode 100644 package/python-rtslib-fb/Config.in create mode 100644
package/python-rtslib-fb/python-rtslib.mkpackage/Config.in +1
-0@@ -503,6 +503,7 @@ menu "external python modules" source "package/python-pysnmp-mibs/Config.in" source "package/python-pyusb/Config.in" source "package/python-pyzmq/Config.in" + source "package/python-rtslib-fb/Config.in" source "package/python-serial/Config.in" source "package/python-setuptools/Config.in" source "package/python-simplejson/Config.in"package/python-rtslib-fb/Config.in new file +9
-0@@ -0,0 +1,9 @@ +config BR2_PACKAGE_PYTHON_RTSLIB_FB + bool "python-rtslib-fb" + depends on BR2_PACKAGE_PYTHON + help + rtslib-fb is an object-based Python library for configuring + the LIO generic SCSI target, present in 3.x Linux kernel + versions. + + https://github.com/agrover/rtslib-fbpackage/python-rtslib-fb/python-rtslib.mk new file +13
-0@@ -0,0 +1,13 @@ +################################################################################ +# +# python-rtslib-fb +# +################################################################################ + +PYTHON_RTSLIB_FB_VERSION = v2.1.fb49 +PYTHON_RTSLIB_FB_SITE = $(call github,agrover,rtslib-fb,$(PYTHON_RTSLIB_FB_VERSION)) +PYTHON_RTSLIB_FB_LICENSE = Apache-2.0 +PYTHON_RTSLIB_FB_LICENSE_FILES = COPYING +PYTHON_RTSLIB_FB_SETUP_TYPE = setuptools + +$(eval $(python-package))
PATCH 4/6 python-configshell-fb: new package
In reply to Christophe Vu-Brugierconfigshell-fb is a Python library that provides a framework for building simple but nice CLI-based applications.
--- package/Config.in | 1 + package/python-configshell-fb/Config.in | 11 +++++++++++ package/python-configshell-fb/python-configshell-fb.mk | 14 ++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 package/python-configshell-fb/Config.in create mode 100644 package/python-configshell-fb/python-configshell-fb.mk
package/Config.in +1 -0
@@ -473,6 +473,7 @@ menu "external python modules" source "package/python-bottle/Config.in" source "package/python-cffi/Config.in" source "package/python-configobj/Config.in" + source "package/python-configshell-fb/Config.in" source "package/python-crc16/Config.in" source "package/python-daemon/Config.in" source "package/python-dialog/Config.in"
package/python-configshell-fb/Config.in new file +11 -0
@@ -0,0 +1,11 @@ +config BR2_PACKAGE_PYTHON_CONFIGSHELL_FB + bool "python-configshell-fb" + depends on BR2_PACKAGE_PYTHON + select BR2_PACKAGE_PYTHON_PYPARSING + select BR2_PACKAGE_PYTHON_READLINE + select BR2_PACKAGE_PYTHON_URWID + help + configshell-fb is a Python library that provides a framework + for building simple but nice CLI-based applications. + + https://github.com/agrover/configshell-fb
package/python-configshell-fb/python-configshell-fb.mk new file +14 -0
@@ -0,0 +1,14 @@ +################################################################################ +# +# python-configshell-fb +# +################################################################################ + +PYTHON_CONFIGSHELL_FB_VERSION = v1.1.fb14 +PYTHON_CONFIGSHELL_FB_SITE = $(call github,agrover,configshell-fb,$(PYTHON_CONFIGSHELL_FB_VERSION)) +PYTHON_CONFIGSHELL_FB_LICENSE = Apache-2.0 +PYTHON_CONFIGSHELL_FB_LICENSE_FILES = COPYING +PYTHON_CONFIGSHELL_FB_SETUP_TYPE = setuptools +PYTHON_CONFIGSHELL_FB_DEPENDENCIES = python-pyparsing python-urwid + +$(eval $(python-package))
Signature · 1 line
2.1.0
PATCH 4/6 python-configshell-fb: new package
Dear Christophe Vu-Brugier,
package/python-configshell-fb/Config.in line 3
Quoted 9 lines · Christophe Vu-Brugier
package/python-configshell-fb/Config.in new file +3
-0@@ -0,0 +1,11 @@ +config BR2_PACKAGE_PYTHON_CONFIGSHELL_FB + bool "python-configshell-fb" + depends on BR2_PACKAGE_PYTHON
Ok, I just read the README file for this package, and it explains that the setup.py script runs 2to3 to convert the package source code to Python 3 if needed. Most likely our installation of 2to3 is broken.
The patch anyway looks good to me, so:
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH 5/6 targetcli-fb: new package
In reply to Christophe Vu-Brugiertargetcli-fb is a command-line interface for configuring the LIO generic SCSI target, present in 3.x Linux kernel versions.
--- package/Config.in | 1 + package/targetcli-fb/Config.in | 14 ++++++++++++++ package/targetcli-fb/targetcli-fb.mk | 14 ++++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 package/targetcli-fb/Config.in create mode 100644 package/targetcli-fb/targetcli-fb.mk
package/Config.in +1 -0
@@ -364,6 +364,7 @@ endif source "package/sunxi-mali/Config.in" source "package/sunxi-mali-prop/Config.in" source "package/sysstat/Config.in" + source "package/targetcli-fb/Config.in" source "package/ti-gfx/Config.in" source "package/ti-uim/Config.in" source "package/ti-utils/Config.in"
package/targetcli-fb/Config.in new file +14 -0
@@ -0,0 +1,14 @@ +comment "targetcli-fb depends on python" + depends on !BR2_PACKAGE_PYTHON + +config BR2_PACKAGE_TARGETCLI_FB + bool "targetcli-fb" + depends on BR2_PACKAGE_PYTHON + select BR2_PACKAGE_PYTHON_CONFIGSHELL_FB + select BR2_PACKAGE_PYTHON_RTSLIB_FB + help + targetcli-fb is a command-line interface for configuring the + LIO generic SCSI target, present in 3.x Linux kernel + versions. + + https://github.com/agrover/targetcli-fb
package/targetcli-fb/targetcli-fb.mk new file +14 -0
@@ -0,0 +1,14 @@ +################################################################################ +# +# targetcli-fb +# +################################################################################ + +TARGETCLI_FB_VERSION = v2.1.fb36 +TARGETCLI_FB_SITE = $(call github,agrover,targetcli-fb,$(TARGETCLI_FB_VERSION)) +TARGETCLI_FB_LICENSE = Apache-2.0 +TARGETCLI_FB_LICENSE_FILES = COPYING +TARGETCLI_FB_SETUP_TYPE = setuptools +TARGETCLI_FB_DEPENDENCIES = python-configshell-fb python-rtslib-fb + +$(eval $(python-package))
Signature · 1 line
2.1.0
PATCH 6/6 targetcli-fb: add sysv initscript
In reply to Christophe Vu-Brugier--- package/targetcli-fb/S50target | 46 ++++++++++++++++++++++++++++++++++++ package/targetcli-fb/targetcli-fb.mk | 11 +++++++++ 2 files changed, 57 insertions(+) create mode 100755 package/targetcli-fb/S50target
package/targetcli-fb/S50target new file +46 -0
@@ -0,0 +1,46 @@ +#!/bin/sh +# +# Restore / clear the Linux "SCSI target" driver configuration with `targetctl` +# + +start() { + local ret + + echo -n "Restoring target configuration: " + /usr/bin/targetctl restore >/dev/null 2>&1 + ret=$? + echo "done" + + return $ret +} + +stop() { + local ret + + echo -n "Clearing target configuration: " + /usr/bin/targetctl clear >/dev/null 2>&1 + ret=$? + echo "done" + + return $ret +} + +restart() { + stop + start +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart) + restart + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 +esac
package/targetcli-fb/targetcli-fb.mk +11 -0
@@ -11,4 +11,15 @@ TARGETCLI_FB_LICENSE_FILES = COPYING TARGETCLI_FB_SETUP_TYPE = setuptools TARGETCLI_FB_DEPENDENCIES = python-configshell-fb python-rtslib-fb +define TARGETCLI_FB_INSTALL_INITSCRIPT + @if [ ! -f $(TARGET_DIR)/etc/init.d/S50target ]; then \ + $(INSTALL) -m 0755 -D package/targetcli-fb/S50target $(TARGET_DIR)/etc/init.d/S50target; \ + fi + @if [ ! -d $(TARGET_DIR)/etc/target ]; then \ + $(INSTALL) -m 0755 -d $(TARGET_DIR)/etc/target; \ + fi +endef + +TARGETCLI_FB_POST_INSTALL_TARGET_HOOKS += TARGETCLI_FB_INSTALL_INITSCRIPT + $(eval $(python-package))
Signature · 1 line
2.1.0
PATCH 6/6 targetcli-fb: add sysv initscript
Dear Christophe Vu-Brugier,
Quoted 6 lines · Christophe Vu-Brugier
Signed-off-by Christophe Vu-Brugier <[email protected]>--- package/targetcli-fb/S50target | 46 ++++++++++++++++++++++++++++++++++++ package/targetcli-fb/targetcli-fb.mk | 11 +++++++++ 2 files changed, 57 insertions(+) create mode 100755 package/targetcli-fb/S50target
I think this should be part of the previous patch.
package/targetcli-fb/targetcli-fb.mk TARGETCLI_FB_LICENSE_FILES = COPYING · line 17
Quoted 12 lines
package/targetcli-fb/targetcli-fb.mk +4
-0@@ -11,4 +11,15 @@ TARGETCLI_FB_LICENSE_FILES = COPYING TARGETCLI_FB_SETUP_TYPE = setuptools TARGETCLI_FB_DEPENDENCIES = python-configshell-fb python-rtslib-fb +define TARGETCLI_FB_INSTALL_INITSCRIPT + @if [ ! -f $(TARGET_DIR)/etc/init.d/S50target ]; then \ + $(INSTALL) -m 0755 -D package/targetcli-fb/S50target $(TARGET_DIR)/etc/init.d/S50target; \ + fi
This should not be handled using a post install target hook, but rather using the TARGETCLI_FB_INIT_SYSV mechanism. See the Buildroot manual or other packages for example (dnsmasq for example, or ntp if you want to see both the SysV and the systemd cases).
Also, I don't think adding a @ at the beginning is really needed, as we usually don't do that I believe. The test could also be summarized as:
[ -f $(TARGET_DIR)/etc/init.d/S50target ] || \ $(INSTALL) ...
package/targetcli-fb/targetcli-fb.mk TARGETCLI_FB_LICENSE_FILES = COPYING · line 20
Quoted 3 lines
package/targetcli-fb/targetcli-fb.mk +3
-0+ @if [ ! -d $(TARGET_DIR)/etc/target ]; then \ + $(INSTALL) -m 0755 -d $(TARGET_DIR)/etc/target; \ + fi
This should continue to belong to post install hook because it isn't related to which init system is used. Is the test really necessary in this case? Maybe you can just to the $(INSTALL), which doesn't fail if the directory already exists I believe. If not, just use mkdir -p and that's it. If you really want to be nice, you could also add a comment above the hook explaining why this directory is needed.
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH 6/6 targetcli-fb: add sysv initscript
Hi Thomas,
Quoted 9 lines · Thomas Petazzoni
Quoted 6 lines · Christophe Vu-Brugier
Signed-off-by Christophe Vu-Brugier <[email protected]>--- package/targetcli-fb/S50target | 46 ++++++++++++++++++++++++++++++++++++ package/targetcli-fb/targetcli-fb.mk | 11 +++++++++ 2 files changed, 57 insertions(+) create mode 100755 package/targetcli-fb/S50targetI think this should be part of the previous patch.
OK.
Quoted 8 lines
Quoted 8 lines
package/targetcli-fb/targetcli-fb.mk +0
-0@@ -11,4 +11,15 @@ TARGETCLI_FB_LICENSE_FILES = COPYING TARGETCLI_FB_SETUP_TYPE = setuptools TARGETCLI_FB_DEPENDENCIES = python-configshell-fb python-rtslib-fb
Quoted 9 lines
package/targetcli-fb/targetcli-fb.mk TARGETCLI_FB_LICENSE_FILES = COPYING · line 17
Quoted 4 lines
package/targetcli-fb/targetcli-fb.mk +4
-0+define TARGETCLI_FB_INSTALL_INITSCRIPT + @if [ ! -f $(TARGET_DIR)/etc/init.d/S50target ]; then \ + $(INSTALL) -m 0755 -D package/targetcli-fb/S50target $(TARGET_DIR)/etc/init.d/S50target; \ + fiThis should not be handled using a post install target hook, but rather using the
TARGETCLI_FB_INIT_SYSVmechanism. See the Buildroot manual or other packages for example (dnsmasq for example, or ntp if you want to see both the SysV and the systemd cases).
OK. By the way, I also intend to add a systemd unit file later.
Quoted 10 lines
Also, I don't think adding a @ at the beginning is really needed, as we usually don't do that I believe. The test could also be summarized as:
[ -f $(TARGET_DIR)/etc/init.d/S50target ] || \ $(INSTALL) ...package/targetcli-fb/targetcli-fb.mk TARGETCLI_FB_LICENSE_FILES = COPYING · line 20
Quoted 3 lines
package/targetcli-fb/targetcli-fb.mk +3
-0+ @if [ ! -d $(TARGET_DIR)/etc/target ]; then \ + $(INSTALL) -m 0755 -d $(TARGET_DIR)/etc/target; \ + fi
Quoted 6 lines
This should continue to belong to post install hook because it isn't related to which init system is used. Is the test really necessary in this case? Maybe you can just to the $(INSTALL), which doesn't fail if the directory already exists I believe. If not, just use mkdir -p and that's it. If you really want to be nice, you could also add a comment above the hook explaining why this directory is needed.
The directory "/etc/target" is needed because it is expected by targetcli. The configuration of the "SCSI target" driver is stored in a JSON file named "/etc/target/saveconfig.json". This configuration is used to create the configfs hierarchy that configures the target driver.
Thank you!
PATCH 6/6 targetcli-fb: add sysv initscript
Dear Christophe Vu-Brugier,
Quoted 6 lines · Christophe Vu-Brugier
Quoted 4 lines
This should not be handled using a post install target hook, but rather using the
TARGETCLI_FB_INIT_SYSVmechanism. See the Buildroot manual or other packages for example (dnsmasq for example, or ntp if you want to see both the SysV and the systemd cases).OK. By the way, I also intend to add a systemd unit file later.
Great!
Quoted 11 lines
Quoted 6 lines
This should continue to belong to post install hook because it isn't related to which init system is used. Is the test really necessary in this case? Maybe you can just to the $(INSTALL), which doesn't fail if the directory already exists I believe. If not, just use mkdir -p and that's it. If you really want to be nice, you could also add a comment above the hook explaining why this directory is needed.
The directory "
/etc/target" is needed because it is expected by targetcli. The configuration of the "SCSI target" driver is stored in a JSON file named "/etc/target/saveconfig.json". This configuration is used to create the configfs hierarchy that configures the target driver.
Ok, makes sense. Maybe just add exactly this explanation as a comment above the creation of /etc/target ?
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com