#2 Update to 0.9.20, switch to Python 3 on RHEL 8+ and Fedora 32+
Closed 4 years ago by churchyard. Opened 4 years ago by churchyard.
rpms/ churchyard/python-impacket 0.9.20  into  master

file modified
+1
@@ -5,3 +5,4 @@ 

  /python-impacket-0.9.17-e0af5bb.tar.gz

  /impacket-0.9.18.tar.gz

  /impacket-0.9.19.tar.gz

+ /impacket-0.9.20.tar.gz

file modified
+12 -10
@@ -2,16 +2,18 @@ 

  # python version < 2.7. The way how it is checked required setuptools newer than

  # what is available in EPEL7 EL6 repositories and breaks the build

  

- diff -ru impacket-0.9.18/setup.py impacket-0.9.18.new/setup.py

- diff -ru impacket-0.9.19.orig/setup.py impacket-0.9.19.new/setup.py

- --- impacket-0.9.19.orig/setup.py	2019-04-01 17:44:02.000000000 +0000

- +++ impacket-0.9.19.new/setup.py	2019-04-04 14:25:58.797000000 +0000

- @@ -40,7 +40,7 @@

-        install_requires=['pyasn1>=0.2.3', 'pycryptodomex', 'pyOpenSSL>=0.13.1', 'six', 'ldap3==2.5.1', 'ldapdomaindump', 'flask>=1.0'],

-        extras_require={

-                        'pyreadline:sys_platform=="win32"': [],

+ diff --git a/setup.py b/setup.py

+ index a1e6c9c..84f7220 100644

+ --- a/setup.py

+ +++ b/setup.py

+ @@ -37,10 +37,6 @@ setup(name = PACKAGE_NAME,

+        scripts = glob.glob(os.path.join('examples', '*.py')),

+        data_files = data_files,

+        install_requires=['pyasn1>=0.2.3', 'pycryptodomex', 'pyOpenSSL>=0.13.1', 'six', 'ldap3==2.5.1', 'ldapdomaindump>=0.9.0', 'flask>=1.0'],

+ -      extras_require={

+ -                      'pyreadline:sys_platform=="win32"': [],

  -                      'python_version<"2.7"': [ 'argparse' ],

- +                      #'python_version<"2.7"': [ 'argparse' ],

-                      },

+ -                    },

         classifiers = [

+            "Programming Language :: Python :: 3.6",

             "Programming Language :: Python :: 2.7",

file modified
+50 -108
@@ -1,6 +1,6 @@ 

  Name:           python-impacket

- Version:        0.9.19

- %global         rel             2

+ Version:        0.9.20

+ %global         baserelease     1

  

  License:        ASL 1.1 and zlib

  URL:            https://github.com/SecureAuthCorp/impacket
@@ -22,35 +22,31 @@ 

  

  %global         sum             Collection of Python classes providing access to network packets

  

- %global         with_python3    0

- %global         with_python27   1

- %global         with_tests      0

- 

- #Python sitearch/sitelib macros for RHEL6

- %if 0%{?rhel} && 0%{?rhel} <= 6

- %{!?__python2:        %global __python2 /usr/bin/python2}

- %{!?python2_sitelib:  %global python2_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}

- %{!?python2_sitearch: %global python2_sitearch %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}

+ %if 0%{?rhel} < 8 && 0%{?fedora} < 32

+ %global __python                %{__python2}

+ %global pyprefix                python2

+ %else

+ %global __python                %{__python3}

+ %global pyprefix                python%{python3_pkgversion}

  %endif

  

- #Python build/install macros for older platforms

- %if 0%{?fedora} <= 21

-  %{!?py2_build:         %global py2_build       %{__python2} setup.py build --executable="%{__python2} -s"}

-  %{!?py2_install:       %global py2_install     %{__python2} setup.py install -O1 --skip-build --root %{buildroot}}

-  %{!?py3_build:         %global py3_build       %{__python3} setup.py build --executable="%{__python3} -s"}

-  %{!?py3_install:       %global py3_install     %{__python3} setup.py install -O1 --skip-build --root %{buildroot}}

+ %if 0%{?rhel} == 8

+ # https://bugzilla.redhat.com/show_bug.cgi?id=1757833

+ %global __python2               %{__python3}

  %endif

  

+ %global         with_tests      0

+ 

  %global         pkgver          %(echo %{version} | sed 's/\\./_/g')

  

  # Build source is github release=1 or git commit=0

  %global         build_release    1

  

  %if 0%{?build_release}  > 0

- Release:        %{rel}%{?dist}

+ Release:        %{baserelease}%{?dist}

  Source0:        https://github.com/%{gituser}/%{gitname}/releases/download/%{gitname}_%{pkgver}/%{gitname}-%{version}.tar.gz

  %else:

- Release:        %{rel}.%{gitdate}git%{shortcommit}%{?dist}

+ Release:        %{baserelease}.%{gitdate}git%{shortcommit}%{?dist}

  Source0:        https://github.com/%{gituser}/%{gitname}/archive/%{commit}/%{name}-%{version}-%{shortcommit}.tar.gz

  %endif #Build_release

  
@@ -68,16 +64,8 @@ 

  BuildRequires:  sed

  BuildRequires:  grep

  

- %if 0%{?with_python27}

- BuildRequires:  python2

- BuildRequires:  python2-devel

- BuildRequires:  python2-setuptools

- %endif # with_python27

- 

- %if 0%{?with_python3}

- BuildRequires:  python%{python3_pkgversion}-devel

- BuildRequires:  python%{python3_pkgversion}-setuptools

- %endif # with_python3

+ BuildRequires:  %{pyprefix}-devel

+ BuildRequires:  %{pyprefix}-setuptools

  

  

  
@@ -91,52 +79,42 @@ 

  

  

  

- #===== the python2 package definition

- %if 0%{?with_python27}

- %package -n python2-%{gitname}

+ #===== the python package definition

+ %package -n %{pyprefix}-%{gitname}

  Summary:        %{sum}

- %{?python_provide:%python_provide python2-%{gitname}}

+ %{?python_provide:%python_provide %{pyprefix}-%{gitname}}

  Provides:       %{name} = %{version}-%{release}

  Provides:       impacket = %{version}-%{release}

  

  # Used by many

- Requires:       python2-pycryptodomex

+ Requires:       %{pyprefix}-pycryptodomex

  

  # Used by /usr/bin/npsexec.py

- Requires:       python2-crypto

- Requires:       python2-pyasn1

+ Requires:       %{pyprefix}-crypto

+ Requires:       %{pyprefix}-pyasn1

  

  # Used by /usr/bin/nsplit.py

- Requires:       pcapy

+ Requires:       %{pyprefix}-pcapy

  # Used by /usr/bin/ntlmrelayx.py

- Requires:       python2-pyOpenSSL

- Requires:       python2-ldap3

- # Used by impacket/examples/ntlmrelayx/servers/socksserver.py

- Recommends:     python2-httplib2

- Recommends:     python2-flask

- 

+ Requires:       %{pyprefix}-pyOpenSSL

+ Requires:       %{pyprefix}-ldap3

  

+ # Used by impacket/examples/ntlmrelayx/servers/socksserver.py

+ %if 0%{?fedora} || 0%{?rhel} >= 8

+ Recommends:     %{pyprefix}-httplib2

+ Recommends:     %{pyprefix}-flask

+ %else

+ Requires:       %{pyprefix}-httplib2

+ Requires:       %{pyprefix}-flask

+ %endif

  

- %description -n python2-%{gitname}

- Python2 package of %{name}.

- Impacket is a collection of Python classes focused on providing access to

- network packets. Impacket allows Python developers to craft and decode network

- packets in simple and consistent manner. it is highly effective when used in

- conjunction with a packet capture utility or package such as Pcapy. Packets

- can be constructed from scratch, as well as parsed from raw data. Furthermore,

- the object oriented API makes it simple to work with deep protocol hierarchies.

- 

- %endif # with_python27

- 

+ %if 0%{?rhel} < 8 && 0%{?fedora} < 32

+ Obsoletes:      python2-%{gitname} < 0.9.20-1

+ %endif

  

- #===== the python3 package definition

- %if 0%{?with_python3}

- %package -n python%{python3_pkgversion}-%{gitname}

- Summary:        %{sum}

- %{?python_provide:%python_provide python%{python3_pkgversion}-%{gitname}}

  

- %description -n python%{python3_pkgversion}-%{gitname}

- Python3 package of %{name}.

+ %description -n %{pyprefix}-%{gitname}

+ Python package of %{name}.

  Impacket is a collection of Python classes focused on providing access to

  network packets. Impacket allows Python developers to craft and decode network

  packets in simple and consistent manner. it is highly effective when used in
@@ -145,12 +123,6 @@ 

  the object oriented API makes it simple to work with deep protocol hierarchies.

  

  

- Requires:  python3-ldap3

- 

- %endif # with_python3

- 

- 

- 

  #===== Preparation

  %prep

  %if 0%{?build_release} > 0
@@ -164,9 +136,8 @@ 

  

  # Clean-up

  

- # Use explicit python2 shabeng instead of generic env python

- # to get prepared for switch the default to python3

- sed -i -e 's|#!/usr/bin/env python|#!/usr/bin/python2|' \

+ # Use explicit pythonX shabeng instead of generic env python

+ sed -i -e 's|#!/usr/bin/env python|#!%{__python}|' \

      impacket/mqtt.py \

      impacket/examples/ntlmrelayx/servers/socksserver.py

  
@@ -178,63 +149,34 @@ 

  

  #===== Build

  %build

- %if 0%{?with_python27}

- %py2_build

- %endif # with_python27

- 

- %if 0%{?with_python3}

- %py3_build

- %endif # with_python3

- 

+ %py_build

  

  

  #===== Install

  %install

- %if 0%{?with_python27}

- %py2_install

- %endif # with_python27

- 

- %if 0%{?with_python3}

- %py3_install

- %endif # with_python3

+ %py_install

  

  #now in license directory

  rm -f %{buildroot}%{_defaultdocdir}/%{name}/LICENSE

  

  

  

- #===== files for python2 package

- %if 0%{?with_python27}

- %files -n       python2-%{gitname}

+ #===== files for python package

+ %files -n       %{pyprefix}-%{gitname}

  %license        LICENSE

  %doc            ChangeLog README.md

- %{python2_sitelib}/%{gitname}/

- %{python2_sitelib}/%{gitname}*.egg-info

+ %{python_sitelib}/%{gitname}/

+ %{python_sitelib}/%{gitname}*.egg-info/

  %exclude %{_defaultdocdir}/%{gitname}

- %exclude %{_defaultdocdir}/%{gitname}/testcases/*

  %exclude %{_defaultdocdir}/%{gitname}/README.md

  %{_bindir}/*.py

- %endif # with_python27

- 

  

  

- #===== files for python3 package

- %if 0%{?with_python3}

- 

- %files -n       python%{python3_pkgversion}-%{gitname}

- %license        LICENSE

- %doc            ChangeLog README.md

- %{python3_sitelib}/%{gitname}*.egg-info

- %{python3_sitelib}/__pycache__/*

- %exclude %{_defaultdocdir}/%{gitname}

- %exclude %{_defaultdocdir}/%{gitname}/testcases/*

- %exclude %{_defaultdocdir}/%{gitname}/README.md

- %{_bindir}/*.py

- 

- %endif # with_python3

- 

  

  %changelog

+ * Wed Oct 09 2019 Miro Hrončok <mhroncok@redhat.com> - 0.9.20-1

+ - Update to 0.9.20, switch to Python 3 on RHEL 8+ and Fedora 32+

+ 

  * Tue Sep 17 2019 Miro Hrončok <mhroncok@redhat.com> - 0.9.19-2

  - Only recommend packages needed for examples

  

file modified
+1 -1
@@ -1,1 +1,1 @@ 

- SHA512 (impacket-0.9.19.tar.gz) = 7707e7053de339f80167dc4f4846201db752cf260034eb74608092714a4587a2ab5fb04b73ca6440c91db8db227d7a9f7b70ad7e7fd48aa9057e45abe3f84a7d

+ SHA512 (impacket-0.9.20.tar.gz) = 6fbe3a042e2ef55c268390ad85e582372051afe52362e8cd7884d293973be8cbc3b8bf7c70a8a997bdf5e9c70deca01f6bc0f8e6c74ef5408ef973ecaad3b3ea

I went with only one Python version - The tools are more important than the Python module, hence it IMHO brings no benefit to build both python2-impacket and python3-impacket on one Fedora/EPEL version.

The logic is simple: For EPEL 8+ and Fedora 32+, build python3-impacket, for anything older, keep just python2-impacket.

This successfully builds on F29, F30, F31, f32, EPEL6, EPEL7 and EPEL8. I haven't really tested installing it and running it, but it builds.

If you push this to epel6 / epel7, a joined update with pcapy-0.10.5-7.el6 / pcapy-0.10.8-6.el7 is needed. Let me know if you need provenpackager rights.

Hello Miro,
thanks for the PR. I have cherry picked things, but decided to build py2 py3 side by side to be able to test py3 even on currently supported platforms.

I plan to push to epel7.

Pull-Request has been closed by churchyard

4 years ago