URL: https://github.com/freeipa/freeipa/pull/379 Author: tiran Title: #379: Packaging: Add placeholder and IPA commands packages Action: synchronized
To pull the PR as Git branch: git remote add ghfreeipa https://github.com/freeipa/freeipa git fetch ghfreeipa pull/379/head:pr379 git checkout pr379
From aee633348478771b576a5abfca6b9fabf6786109 Mon Sep 17 00:00:00 2001 From: Christian Heimes <chei...@redhat.com> Date: Thu, 16 Feb 2017 15:27:49 +0100 Subject: [PATCH 1/6] Packaging: Add placeholder packages The ipa and freeipa packages are placeholders to prevent PyPI squashing attacks and reserve the names for future use. `pip install ipa` installs ipaclient. Signed-off-by: Christian Heimes <chei...@redhat.com> --- Makefile.am | 4 +++- Makefile.python.am | 21 +++++++++++++-------- configure.ac | 3 +++ packaging/Makefile.am | 10 ++++++++++ packaging/freeipa/Makefile.am | 3 +++ packaging/freeipa/README.txt | 2 ++ packaging/freeipa/setup.cfg | 6 ++++++ packaging/freeipa/setup.py | 23 +++++++++++++++++++++++ packaging/ipa/Makefile.am | 3 +++ packaging/ipa/README.txt | 2 ++ packaging/ipa/setup.cfg | 6 ++++++ packaging/ipa/setup.py | 23 +++++++++++++++++++++++ 12 files changed, 97 insertions(+), 9 deletions(-) create mode 100644 packaging/Makefile.am create mode 100644 packaging/freeipa/Makefile.am create mode 100644 packaging/freeipa/README.txt create mode 100644 packaging/freeipa/setup.cfg create mode 100755 packaging/freeipa/setup.py create mode 100644 packaging/ipa/Makefile.am create mode 100644 packaging/ipa/README.txt create mode 100644 packaging/ipa/setup.cfg create mode 100755 packaging/ipa/setup.py diff --git a/Makefile.am b/Makefile.am index 30ad9bb..a6faa11 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,7 +1,7 @@ ACLOCAL_AMFLAGS = -I m4 IPACLIENT_SUBDIRS = ipaclient ipalib ipapython -SUBDIRS = asn1 util client contrib daemons init install $(IPACLIENT_SUBDIRS) ipaplatform ipaserver ipatests po +SUBDIRS = asn1 util client contrib daemons init install $(IPACLIENT_SUBDIRS) ipaplatform ipaserver ipatests packaging po MOSTLYCLEANFILES = ipasetup.pyc ipasetup.pyo \ ignore_import_errors.pyc ignore_import_errors.pyo \ @@ -206,6 +206,8 @@ $(WHEELBUNDLEDIR): mkdir -p $(WHEELBUNDLEDIR) bdist_wheel: $(WHEELDISTDIR) + $(MAKE) $(AM_MAKEFLAGS) -C packaging/ipa bdist_wheel || exit 1; + $(MAKE) $(AM_MAKEFLAGS) -C packaging/freeipa bdist_wheel || exit 1; for dir in $(IPACLIENT_SUBDIRS); do \ $(MAKE) $(AM_MAKEFLAGS) -C $${dir} $@ || exit 1; \ done diff --git a/Makefile.python.am b/Makefile.python.am index 665893f..9c34fe3 100644 --- a/Makefile.python.am +++ b/Makefile.python.am @@ -1,5 +1,6 @@ pkgname = $(shell basename "$(abs_srcdir)") pkgpythondir = $(pythondir)/$(pkgname) +pkginstall = true if VERBOSE_MAKE VERBOSITY="--verbose" @@ -19,16 +20,20 @@ all-local: $(top_builddir)/ipasetup.py --build-base "$(abs_builddir)/build" install-exec-local: $(top_builddir)/ipasetup.py - $(PYTHON) $(srcdir)/setup.py \ - $(VERBOSITY) \ - install \ - --prefix "$(DESTDIR)$(prefix)" \ - --single-version-externally-managed \ - --record "$(DESTDIR)$(pkgpythondir)/install_files.txt" \ - --optimize 1 + if [ "x$(pkginstall)" = "xtrue" ]; then \ + $(PYTHON) $(srcdir)/setup.py \ + $(VERBOSITY) \ + install \ + --prefix "$(DESTDIR)$(prefix)" \ + --single-version-externally-managed \ + --record "$(DESTDIR)$(pkgpythondir)/install_files.txt" \ + --optimize 1; \ + fi uninstall-local: - cat "$(DESTDIR)$(pkgpythondir)/install_files.txt" | xargs rm -rf + if [ -f "$(DESTDIR)$(pkgpythondir)/install_files.txt" ]; then \ + cat "$(DESTDIR)$(pkgpythondir)/install_files.txt" | xargs rm -rf ; \ + fi rm -rf "$(DESTDIR)$(pkgpythondir)" clean-local: $(top_builddir)/ipasetup.py diff --git a/configure.ac b/configure.ac index 44dc11b..f48ba14 100644 --- a/configure.ac +++ b/configure.ac @@ -577,6 +577,9 @@ AC_CONFIG_FILES([ ipaserver/Makefile ipatests/Makefile ipatests/man/Makefile + packaging/Makefile + packaging/freeipa/Makefile + packaging/ipa/Makefile po/Makefile.in po/Makefile.hack util/Makefile diff --git a/packaging/Makefile.am b/packaging/Makefile.am new file mode 100644 index 0000000..5725ed9 --- /dev/null +++ b/packaging/Makefile.am @@ -0,0 +1,10 @@ +# This file will be processed with automake-1.7 to create Makefile.in +# +AUTOMAKE_OPTIONS = 1.7 subdir-objects + +NULL = + +SUBDIRS = \ + freeipa \ + ipa \ + $(NULL) diff --git a/packaging/freeipa/Makefile.am b/packaging/freeipa/Makefile.am new file mode 100644 index 0000000..15d86ce --- /dev/null +++ b/packaging/freeipa/Makefile.am @@ -0,0 +1,3 @@ +include $(top_srcdir)/Makefile.python.am + +pkginstall = false diff --git a/packaging/freeipa/README.txt b/packaging/freeipa/README.txt new file mode 100644 index 0000000..b58448f --- /dev/null +++ b/packaging/freeipa/README.txt @@ -0,0 +1,2 @@ +This is a dummy package for FreeIPA's ipaclient. + diff --git a/packaging/freeipa/setup.cfg b/packaging/freeipa/setup.cfg new file mode 100644 index 0000000..62f65c7 --- /dev/null +++ b/packaging/freeipa/setup.cfg @@ -0,0 +1,6 @@ +[bdist_wheel] +universal = 1 + +[aliases] +packages = clean --all egg_info bdist_wheel +release = packages register upload diff --git a/packaging/freeipa/setup.py b/packaging/freeipa/setup.py new file mode 100755 index 0000000..230fffd --- /dev/null +++ b/packaging/freeipa/setup.py @@ -0,0 +1,23 @@ +# +# Copyright (C) 2017 FreeIPA Contributors see COPYING for license +# +"""Dummy package for FreeIPA + +Please install ipaclient instead. +""" + +from os.path import abspath, dirname +import sys + +if __name__ == '__main__': + # include ../../ for ipasetup.py + sys.path.append(dirname(dirname(dirname(abspath(__file__))))) + from ipasetup import ipasetup # noqa: E402 + + ipasetup( + name='freeipa', + doc = __doc__, + install_requires=[ + "ipaclient", + ] + ) diff --git a/packaging/ipa/Makefile.am b/packaging/ipa/Makefile.am new file mode 100644 index 0000000..15d86ce --- /dev/null +++ b/packaging/ipa/Makefile.am @@ -0,0 +1,3 @@ +include $(top_srcdir)/Makefile.python.am + +pkginstall = false diff --git a/packaging/ipa/README.txt b/packaging/ipa/README.txt new file mode 100644 index 0000000..b58448f --- /dev/null +++ b/packaging/ipa/README.txt @@ -0,0 +1,2 @@ +This is a dummy package for FreeIPA's ipaclient. + diff --git a/packaging/ipa/setup.cfg b/packaging/ipa/setup.cfg new file mode 100644 index 0000000..62f65c7 --- /dev/null +++ b/packaging/ipa/setup.cfg @@ -0,0 +1,6 @@ +[bdist_wheel] +universal = 1 + +[aliases] +packages = clean --all egg_info bdist_wheel +release = packages register upload diff --git a/packaging/ipa/setup.py b/packaging/ipa/setup.py new file mode 100755 index 0000000..403389b --- /dev/null +++ b/packaging/ipa/setup.py @@ -0,0 +1,23 @@ +# +# Copyright (C) 2017 FreeIPA Contributors see COPYING for license +# +"""Dummy package for FreeIPA + +Please install ipaclient instead. +""" + +from os.path import abspath, dirname +import sys + +if __name__ == '__main__': + # include ../../ for ipasetup.py + sys.path.append(dirname(dirname(dirname(abspath(__file__))))) + from ipasetup import ipasetup # noqa: E402 + + ipasetup( + name='ipa', + doc = __doc__, + install_requires=[ + "ipaclient", + ] + ) From 7f3f6619ece73feab9ca1e436683bb8cf77de412 Mon Sep 17 00:00:00 2001 From: Christian Heimes <chei...@redhat.com> Date: Fri, 17 Feb 2017 17:46:20 +0100 Subject: [PATCH 2/6] Add python-wheel as build requirement Signed-off-by: Christian Heimes <chei...@redhat.com> --- freeipa.spec.in | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/freeipa.spec.in b/freeipa.spec.in index 5c835ca..acc197e 100644 --- a/freeipa.spec.in +++ b/freeipa.spec.in @@ -124,6 +124,16 @@ BuildRequires: python-libsss_nss_idmap BuildRequires: python-cffi # +# Build dependencies for wheel packaging +# +%if 0%{?fedora} +BuildRequires: python2-wheel +%if 0%{?with_python3} +BuildRequires: python3-wheel +%endif +%endif # Fedora + +# # Build dependencies for lint # %if 0%{?with_lint} From ce38000d583b9e75cf0c80a6044dd63caf6eb408 Mon Sep 17 00:00:00 2001 From: Christian Heimes <chei...@redhat.com> Date: Fri, 17 Feb 2017 17:46:42 +0100 Subject: [PATCH 3/6] Add placeholders for ipaplatform, ipaserver and ipatests I also renamed the base directory to pypi and added a new build target pypi_packages. Signed-off-by: Christian Heimes <chei...@redhat.com> --- Makefile.am | 16 ++++++++++++---- Makefile.python.am | 2 +- configure.ac | 9 ++++++--- packaging/Makefile.am | 10 ---------- packaging/freeipa/Makefile.am | 3 --- packaging/freeipa/README.txt | 2 -- packaging/freeipa/setup.cfg | 6 ------ packaging/freeipa/setup.py | 23 ----------------------- packaging/ipa/Makefile.am | 3 --- packaging/ipa/README.txt | 2 -- packaging/ipa/setup.cfg | 6 ------ packaging/ipa/setup.py | 23 ----------------------- pypi/Makefile.am | 13 +++++++++++++ pypi/freeipa/Makefile.am | 3 +++ pypi/freeipa/README.txt | 2 ++ pypi/freeipa/setup.cfg | 6 ++++++ pypi/freeipa/setup.py | 23 +++++++++++++++++++++++ pypi/ipa/Makefile.am | 3 +++ pypi/ipa/README.txt | 2 ++ pypi/ipa/setup.cfg | 6 ++++++ pypi/ipa/setup.py | 23 +++++++++++++++++++++++ pypi/ipaplatform/Makefile.am | 3 +++ pypi/ipaplatform/README.txt | 2 ++ pypi/ipaplatform/ipaplatform/__init__.py | 5 +++++ pypi/ipaplatform/setup.cfg | 6 ++++++ pypi/ipaplatform/setup.py | 26 ++++++++++++++++++++++++++ pypi/ipaserver/Makefile.am | 3 +++ pypi/ipaserver/README.txt | 2 ++ pypi/ipaserver/ipaserver/__init__.py | 5 +++++ pypi/ipaserver/setup.cfg | 6 ++++++ pypi/ipaserver/setup.py | 26 ++++++++++++++++++++++++++ pypi/ipatests/Makefile.am | 3 +++ pypi/ipatests/README.txt | 2 ++ pypi/ipatests/ipatests/__init__.py | 5 +++++ pypi/ipatests/setup.cfg | 6 ++++++ pypi/ipatests/setup.py | 26 ++++++++++++++++++++++++++ 36 files changed, 226 insertions(+), 86 deletions(-) delete mode 100644 packaging/Makefile.am delete mode 100644 packaging/freeipa/Makefile.am delete mode 100644 packaging/freeipa/README.txt delete mode 100644 packaging/freeipa/setup.cfg delete mode 100755 packaging/freeipa/setup.py delete mode 100644 packaging/ipa/Makefile.am delete mode 100644 packaging/ipa/README.txt delete mode 100644 packaging/ipa/setup.cfg delete mode 100755 packaging/ipa/setup.py create mode 100644 pypi/Makefile.am create mode 100644 pypi/freeipa/Makefile.am create mode 100644 pypi/freeipa/README.txt create mode 100644 pypi/freeipa/setup.cfg create mode 100755 pypi/freeipa/setup.py create mode 100644 pypi/ipa/Makefile.am create mode 100644 pypi/ipa/README.txt create mode 100644 pypi/ipa/setup.cfg create mode 100755 pypi/ipa/setup.py create mode 100644 pypi/ipaplatform/Makefile.am create mode 100644 pypi/ipaplatform/README.txt create mode 100644 pypi/ipaplatform/ipaplatform/__init__.py create mode 100644 pypi/ipaplatform/setup.cfg create mode 100755 pypi/ipaplatform/setup.py create mode 100644 pypi/ipaserver/Makefile.am create mode 100644 pypi/ipaserver/README.txt create mode 100644 pypi/ipaserver/ipaserver/__init__.py create mode 100644 pypi/ipaserver/setup.cfg create mode 100755 pypi/ipaserver/setup.py create mode 100644 pypi/ipatests/Makefile.am create mode 100644 pypi/ipatests/README.txt create mode 100644 pypi/ipatests/ipatests/__init__.py create mode 100644 pypi/ipatests/setup.cfg create mode 100755 pypi/ipatests/setup.py diff --git a/Makefile.am b/Makefile.am index a6faa11..4826b93 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,7 +1,8 @@ ACLOCAL_AMFLAGS = -I m4 IPACLIENT_SUBDIRS = ipaclient ipalib ipapython -SUBDIRS = asn1 util client contrib daemons init install $(IPACLIENT_SUBDIRS) ipaplatform ipaserver ipatests packaging po +IPA_PLACEHOLDERS = freeipa ipa ipaplatform ipaserver ipatests +SUBDIRS = asn1 util client contrib daemons init install $(IPACLIENT_SUBDIRS) ipaplatform ipaserver ipatests pypi po MOSTLYCLEANFILES = ipasetup.pyc ipasetup.pyo \ ignore_import_errors.pyc ignore_import_errors.pyo \ @@ -195,7 +196,7 @@ jslint-html: cd $(top_srcdir)/install/html; \ jsl -nologo -nosummary -nofilelisting -conf jsl.conf -.PHONY: bdist_wheel wheel_bundle +.PHONY: bdist_wheel wheel_bundle wheel_placeholder pypi_packages WHEELDISTDIR = $(top_builddir)/dist/wheels WHEELBUNDLEDIR = $(top_builddir)/dist/bundle @@ -206,8 +207,6 @@ $(WHEELBUNDLEDIR): mkdir -p $(WHEELBUNDLEDIR) bdist_wheel: $(WHEELDISTDIR) - $(MAKE) $(AM_MAKEFLAGS) -C packaging/ipa bdist_wheel || exit 1; - $(MAKE) $(AM_MAKEFLAGS) -C packaging/freeipa bdist_wheel || exit 1; for dir in $(IPACLIENT_SUBDIRS); do \ $(MAKE) $(AM_MAKEFLAGS) -C $${dir} $@ || exit 1; \ done @@ -215,6 +214,15 @@ bdist_wheel: $(WHEELDISTDIR) wheel_bundle: $(WHEELBUNDLEDIR) bdist_wheel $(PYTHON) -m pip wheel --wheel-dir $(WHEELBUNDLEDIR) $(WHEELDISTDIR)/*.whl +wheel_placeholder: $(WHEELDISTDIR) + for dir in $(IPA_PLACEHOLDERS); do \ + $(MAKE) $(AM_MAKEFLAGS) -C $(top_srcdir)/pypi/$${dir} bdist_wheel || exit 1; \ + done + +pypi_packages: bdist_wheel wheel_placeholder + @echo -e "\n\nTo upload packages to PyPI, run:\n" + @echo -e " twine upload $(WHEELDISTDIR)/*-$(VERSION)-py2.py3-none-any.whl\n" + .PHONY: strip-po: $(MAKE) -C po strip-po diff --git a/Makefile.python.am b/Makefile.python.am index 9c34fe3..e4efc17 100644 --- a/Makefile.python.am +++ b/Makefile.python.am @@ -58,5 +58,5 @@ dist-hook: $(top_builddir)/ipasetup.py WHEELDISTDIR = $(top_builddir)/dist/wheels .PHONY: bdist_wheel bdist_wheel: $(top_builddir)/ipasetup.py - rm -rf $(WHEELDISTDIR)/$(pkgname)*.whl + rm -rf $(WHEELDISTDIR)/$(pkgname)-*.whl $(PYTHON) "$(srcdir)/setup.py" bdist_wheel --dist-dir=$(WHEELDISTDIR) diff --git a/configure.ac b/configure.ac index f48ba14..b633cba 100644 --- a/configure.ac +++ b/configure.ac @@ -577,9 +577,12 @@ AC_CONFIG_FILES([ ipaserver/Makefile ipatests/Makefile ipatests/man/Makefile - packaging/Makefile - packaging/freeipa/Makefile - packaging/ipa/Makefile + pypi/Makefile + pypi/freeipa/Makefile + pypi/ipa/Makefile + pypi/ipaplatform/Makefile + pypi/ipaserver/Makefile + pypi/ipatests/Makefile po/Makefile.in po/Makefile.hack util/Makefile diff --git a/packaging/Makefile.am b/packaging/Makefile.am deleted file mode 100644 index 5725ed9..0000000 --- a/packaging/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ -# This file will be processed with automake-1.7 to create Makefile.in -# -AUTOMAKE_OPTIONS = 1.7 subdir-objects - -NULL = - -SUBDIRS = \ - freeipa \ - ipa \ - $(NULL) diff --git a/packaging/freeipa/Makefile.am b/packaging/freeipa/Makefile.am deleted file mode 100644 index 15d86ce..0000000 --- a/packaging/freeipa/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -include $(top_srcdir)/Makefile.python.am - -pkginstall = false diff --git a/packaging/freeipa/README.txt b/packaging/freeipa/README.txt deleted file mode 100644 index b58448f..0000000 --- a/packaging/freeipa/README.txt +++ /dev/null @@ -1,2 +0,0 @@ -This is a dummy package for FreeIPA's ipaclient. - diff --git a/packaging/freeipa/setup.cfg b/packaging/freeipa/setup.cfg deleted file mode 100644 index 62f65c7..0000000 --- a/packaging/freeipa/setup.cfg +++ /dev/null @@ -1,6 +0,0 @@ -[bdist_wheel] -universal = 1 - -[aliases] -packages = clean --all egg_info bdist_wheel -release = packages register upload diff --git a/packaging/freeipa/setup.py b/packaging/freeipa/setup.py deleted file mode 100755 index 230fffd..0000000 --- a/packaging/freeipa/setup.py +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (C) 2017 FreeIPA Contributors see COPYING for license -# -"""Dummy package for FreeIPA - -Please install ipaclient instead. -""" - -from os.path import abspath, dirname -import sys - -if __name__ == '__main__': - # include ../../ for ipasetup.py - sys.path.append(dirname(dirname(dirname(abspath(__file__))))) - from ipasetup import ipasetup # noqa: E402 - - ipasetup( - name='freeipa', - doc = __doc__, - install_requires=[ - "ipaclient", - ] - ) diff --git a/packaging/ipa/Makefile.am b/packaging/ipa/Makefile.am deleted file mode 100644 index 15d86ce..0000000 --- a/packaging/ipa/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -include $(top_srcdir)/Makefile.python.am - -pkginstall = false diff --git a/packaging/ipa/README.txt b/packaging/ipa/README.txt deleted file mode 100644 index b58448f..0000000 --- a/packaging/ipa/README.txt +++ /dev/null @@ -1,2 +0,0 @@ -This is a dummy package for FreeIPA's ipaclient. - diff --git a/packaging/ipa/setup.cfg b/packaging/ipa/setup.cfg deleted file mode 100644 index 62f65c7..0000000 --- a/packaging/ipa/setup.cfg +++ /dev/null @@ -1,6 +0,0 @@ -[bdist_wheel] -universal = 1 - -[aliases] -packages = clean --all egg_info bdist_wheel -release = packages register upload diff --git a/packaging/ipa/setup.py b/packaging/ipa/setup.py deleted file mode 100755 index 403389b..0000000 --- a/packaging/ipa/setup.py +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (C) 2017 FreeIPA Contributors see COPYING for license -# -"""Dummy package for FreeIPA - -Please install ipaclient instead. -""" - -from os.path import abspath, dirname -import sys - -if __name__ == '__main__': - # include ../../ for ipasetup.py - sys.path.append(dirname(dirname(dirname(abspath(__file__))))) - from ipasetup import ipasetup # noqa: E402 - - ipasetup( - name='ipa', - doc = __doc__, - install_requires=[ - "ipaclient", - ] - ) diff --git a/pypi/Makefile.am b/pypi/Makefile.am new file mode 100644 index 0000000..5d8be9c --- /dev/null +++ b/pypi/Makefile.am @@ -0,0 +1,13 @@ +# This file will be processed with automake-1.7 to create Makefile.in +# +AUTOMAKE_OPTIONS = 1.7 subdir-objects + +NULL = + +SUBDIRS = \ + freeipa \ + ipa \ + ipaplatform \ + ipaserver \ + ipatests \ + $(NULL) diff --git a/pypi/freeipa/Makefile.am b/pypi/freeipa/Makefile.am new file mode 100644 index 0000000..15d86ce --- /dev/null +++ b/pypi/freeipa/Makefile.am @@ -0,0 +1,3 @@ +include $(top_srcdir)/Makefile.python.am + +pkginstall = false diff --git a/pypi/freeipa/README.txt b/pypi/freeipa/README.txt new file mode 100644 index 0000000..b58448f --- /dev/null +++ b/pypi/freeipa/README.txt @@ -0,0 +1,2 @@ +This is a dummy package for FreeIPA's ipaclient. + diff --git a/pypi/freeipa/setup.cfg b/pypi/freeipa/setup.cfg new file mode 100644 index 0000000..62f65c7 --- /dev/null +++ b/pypi/freeipa/setup.cfg @@ -0,0 +1,6 @@ +[bdist_wheel] +universal = 1 + +[aliases] +packages = clean --all egg_info bdist_wheel +release = packages register upload diff --git a/pypi/freeipa/setup.py b/pypi/freeipa/setup.py new file mode 100755 index 0000000..230fffd --- /dev/null +++ b/pypi/freeipa/setup.py @@ -0,0 +1,23 @@ +# +# Copyright (C) 2017 FreeIPA Contributors see COPYING for license +# +"""Dummy package for FreeIPA + +Please install ipaclient instead. +""" + +from os.path import abspath, dirname +import sys + +if __name__ == '__main__': + # include ../../ for ipasetup.py + sys.path.append(dirname(dirname(dirname(abspath(__file__))))) + from ipasetup import ipasetup # noqa: E402 + + ipasetup( + name='freeipa', + doc = __doc__, + install_requires=[ + "ipaclient", + ] + ) diff --git a/pypi/ipa/Makefile.am b/pypi/ipa/Makefile.am new file mode 100644 index 0000000..15d86ce --- /dev/null +++ b/pypi/ipa/Makefile.am @@ -0,0 +1,3 @@ +include $(top_srcdir)/Makefile.python.am + +pkginstall = false diff --git a/pypi/ipa/README.txt b/pypi/ipa/README.txt new file mode 100644 index 0000000..b58448f --- /dev/null +++ b/pypi/ipa/README.txt @@ -0,0 +1,2 @@ +This is a dummy package for FreeIPA's ipaclient. + diff --git a/pypi/ipa/setup.cfg b/pypi/ipa/setup.cfg new file mode 100644 index 0000000..62f65c7 --- /dev/null +++ b/pypi/ipa/setup.cfg @@ -0,0 +1,6 @@ +[bdist_wheel] +universal = 1 + +[aliases] +packages = clean --all egg_info bdist_wheel +release = packages register upload diff --git a/pypi/ipa/setup.py b/pypi/ipa/setup.py new file mode 100755 index 0000000..403389b --- /dev/null +++ b/pypi/ipa/setup.py @@ -0,0 +1,23 @@ +# +# Copyright (C) 2017 FreeIPA Contributors see COPYING for license +# +"""Dummy package for FreeIPA + +Please install ipaclient instead. +""" + +from os.path import abspath, dirname +import sys + +if __name__ == '__main__': + # include ../../ for ipasetup.py + sys.path.append(dirname(dirname(dirname(abspath(__file__))))) + from ipasetup import ipasetup # noqa: E402 + + ipasetup( + name='ipa', + doc = __doc__, + install_requires=[ + "ipaclient", + ] + ) diff --git a/pypi/ipaplatform/Makefile.am b/pypi/ipaplatform/Makefile.am new file mode 100644 index 0000000..15d86ce --- /dev/null +++ b/pypi/ipaplatform/Makefile.am @@ -0,0 +1,3 @@ +include $(top_srcdir)/Makefile.python.am + +pkginstall = false diff --git a/pypi/ipaplatform/README.txt b/pypi/ipaplatform/README.txt new file mode 100644 index 0000000..15064b0 --- /dev/null +++ b/pypi/ipaplatform/README.txt @@ -0,0 +1,2 @@ +This is a dummy package for FreeIPA's ipaplatform. + diff --git a/pypi/ipaplatform/ipaplatform/__init__.py b/pypi/ipaplatform/ipaplatform/__init__.py new file mode 100644 index 0000000..3b12c8c --- /dev/null +++ b/pypi/ipaplatform/ipaplatform/__init__.py @@ -0,0 +1,5 @@ +# +# Copyright (C) 2017 FreeIPA Contributors see COPYING for license +# + +raise ImportError("ipaplatform is not yet supported as PyPI package.") diff --git a/pypi/ipaplatform/setup.cfg b/pypi/ipaplatform/setup.cfg new file mode 100644 index 0000000..62f65c7 --- /dev/null +++ b/pypi/ipaplatform/setup.cfg @@ -0,0 +1,6 @@ +[bdist_wheel] +universal = 1 + +[aliases] +packages = clean --all egg_info bdist_wheel +release = packages register upload diff --git a/pypi/ipaplatform/setup.py b/pypi/ipaplatform/setup.py new file mode 100755 index 0000000..f0fca2c --- /dev/null +++ b/pypi/ipaplatform/setup.py @@ -0,0 +1,26 @@ +# +# Copyright (C) 2017 FreeIPA Contributors see COPYING for license +# +"""Dummy package for FreeIPA + +ipaplatform is not yet available as PyPI package. +""" + +from os.path import abspath, dirname +import sys + +if __name__ == '__main__': + # include ../../ for ipasetup.py + sys.path.append(dirname(dirname(dirname(abspath(__file__))))) + from ipasetup import ipasetup # noqa: E402 + + ipasetup( + name='ipaplatform', + doc = __doc__, + packages=[ + "ipaplatform", + ], + install_requires=[ + "ipaclient", + ] + ) diff --git a/pypi/ipaserver/Makefile.am b/pypi/ipaserver/Makefile.am new file mode 100644 index 0000000..15d86ce --- /dev/null +++ b/pypi/ipaserver/Makefile.am @@ -0,0 +1,3 @@ +include $(top_srcdir)/Makefile.python.am + +pkginstall = false diff --git a/pypi/ipaserver/README.txt b/pypi/ipaserver/README.txt new file mode 100644 index 0000000..dea6ac4 --- /dev/null +++ b/pypi/ipaserver/README.txt @@ -0,0 +1,2 @@ +This is a dummy package for FreeIPA's ipaserver. + diff --git a/pypi/ipaserver/ipaserver/__init__.py b/pypi/ipaserver/ipaserver/__init__.py new file mode 100644 index 0000000..4cbf200 --- /dev/null +++ b/pypi/ipaserver/ipaserver/__init__.py @@ -0,0 +1,5 @@ +# +# Copyright (C) 2017 FreeIPA Contributors see COPYING for license +# + +raise ImportError("ipaserver is not yet supported as PyPI package.") diff --git a/pypi/ipaserver/setup.cfg b/pypi/ipaserver/setup.cfg new file mode 100644 index 0000000..62f65c7 --- /dev/null +++ b/pypi/ipaserver/setup.cfg @@ -0,0 +1,6 @@ +[bdist_wheel] +universal = 1 + +[aliases] +packages = clean --all egg_info bdist_wheel +release = packages register upload diff --git a/pypi/ipaserver/setup.py b/pypi/ipaserver/setup.py new file mode 100755 index 0000000..73e1e63 --- /dev/null +++ b/pypi/ipaserver/setup.py @@ -0,0 +1,26 @@ +# +# Copyright (C) 2017 FreeIPA Contributors see COPYING for license +# +"""Dummy package for FreeIPA + +ipatests is not yet available as PyPI package. +""" + +from os.path import abspath, dirname +import sys + +if __name__ == '__main__': + # include ../../ for ipasetup.py + sys.path.append(dirname(dirname(dirname(abspath(__file__))))) + from ipasetup import ipasetup # noqa: E402 + + ipasetup( + name='ipaserver', + doc = __doc__, + packages=[ + "ipaserver", + ], + install_requires=[ + "ipaclient", + ] + ) diff --git a/pypi/ipatests/Makefile.am b/pypi/ipatests/Makefile.am new file mode 100644 index 0000000..15d86ce --- /dev/null +++ b/pypi/ipatests/Makefile.am @@ -0,0 +1,3 @@ +include $(top_srcdir)/Makefile.python.am + +pkginstall = false diff --git a/pypi/ipatests/README.txt b/pypi/ipatests/README.txt new file mode 100644 index 0000000..3347eac --- /dev/null +++ b/pypi/ipatests/README.txt @@ -0,0 +1,2 @@ +This is a dummy package for FreeIPA's ipatests. + diff --git a/pypi/ipatests/ipatests/__init__.py b/pypi/ipatests/ipatests/__init__.py new file mode 100644 index 0000000..5592c53 --- /dev/null +++ b/pypi/ipatests/ipatests/__init__.py @@ -0,0 +1,5 @@ +# +# Copyright (C) 2017 FreeIPA Contributors see COPYING for license +# + +raise ImportError("ipatests is not yet supported as PyPI package.") diff --git a/pypi/ipatests/setup.cfg b/pypi/ipatests/setup.cfg new file mode 100644 index 0000000..62f65c7 --- /dev/null +++ b/pypi/ipatests/setup.cfg @@ -0,0 +1,6 @@ +[bdist_wheel] +universal = 1 + +[aliases] +packages = clean --all egg_info bdist_wheel +release = packages register upload diff --git a/pypi/ipatests/setup.py b/pypi/ipatests/setup.py new file mode 100755 index 0000000..808e510 --- /dev/null +++ b/pypi/ipatests/setup.py @@ -0,0 +1,26 @@ +# +# Copyright (C) 2017 FreeIPA Contributors see COPYING for license +# +"""Dummy package for FreeIPA + +ipatests is not yet available as PyPI package. +""" + +from os.path import abspath, dirname +import sys + +if __name__ == '__main__': + # include ../../ for ipasetup.py + sys.path.append(dirname(dirname(dirname(abspath(__file__))))) + from ipasetup import ipasetup # noqa: E402 + + ipasetup( + name='ipatests', + doc = __doc__, + packages=[ + "ipatests", + ], + install_requires=[ + "ipaclient", + ] + ) From 8911acc5d97e1d2e914c6282ca7b8d59dc6be3c8 Mon Sep 17 00:00:00 2001 From: Christian Heimes <chei...@redhat.com> Date: Fri, 17 Feb 2017 17:46:42 +0100 Subject: [PATCH 4/6] Add placeholders for ipaplatform, ipaserver and ipatests I also renamed the base directory to pypi and added a new build target pypi_packages. Signed-off-by: Christian Heimes <chei...@redhat.com> --- Makefile.am | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile.am b/Makefile.am index 4826b93..03d562b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,7 +1,10 @@ ACLOCAL_AMFLAGS = -I m4 IPACLIENT_SUBDIRS = ipaclient ipalib ipapython +<<<<<<< ce38000d583b9e75cf0c80a6044dd63caf6eb408 IPA_PLACEHOLDERS = freeipa ipa ipaplatform ipaserver ipatests +======= +>>>>>>> Add placeholders for ipaplatform, ipaserver and ipatests SUBDIRS = asn1 util client contrib daemons init install $(IPACLIENT_SUBDIRS) ipaplatform ipaserver ipatests pypi po MOSTLYCLEANFILES = ipasetup.pyc ipasetup.pyo \ From c10b6803111378f9c73c9fcfb1a021deb30ad0a3 Mon Sep 17 00:00:00 2001 From: Christian Heimes <chei...@redhat.com> Date: Mon, 9 Jan 2017 11:02:25 +0100 Subject: [PATCH 5/6] Packaging: Add placeholder and IPA commands packages The ipacommands package contains ipa-getkeytab and ipa-rmkeytab for installation in a virtual env. The programs are compiled with distutils / setuptools. The ipa and freeipa packages are placeholders to prevent PyPI squashing attacks and reserve the names for future use. `pip install ipa` installs ipaclient. https://fedorahosted.org/freeipa/ticket/6484 Signed-off-by: Christian Heimes <chei...@redhat.com> --- .gitignore | 7 ++ Makefile.am | 1 + configure.ac | 1 + pypi/Makefile.am | 1 + pypi/ipacommands/MANIFEST.in | 25 ++++++ pypi/ipacommands/Makefile.am | 79 ++++++++++++++++++ pypi/ipacommands/setup.cfg | 5 ++ pypi/ipacommands/setup.py | 194 +++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 313 insertions(+) create mode 100644 pypi/ipacommands/MANIFEST.in create mode 100644 pypi/ipacommands/Makefile.am create mode 100644 pypi/ipacommands/setup.cfg create mode 100644 pypi/ipacommands/setup.py diff --git a/.gitignore b/.gitignore index 04553fd..6421fd4 100644 --- a/.gitignore +++ b/.gitignore @@ -112,3 +112,10 @@ freeipa2-dev-doc /ipaplatform/paths.py /ipaplatform/services.py /ipaplatform/tasks.py + +/pypi/ipacommands/COPYING +/pypi/ipacommands/Contributors.txt +/pypi/ipacommands/asn1 +/pypi/ipacommands/client +/pypi/ipacommands/ipasetup.py +/pypi/ipacommands/util diff --git a/Makefile.am b/Makefile.am index 03d562b..20ec2cd 100644 --- a/Makefile.am +++ b/Makefile.am @@ -210,6 +210,7 @@ $(WHEELBUNDLEDIR): mkdir -p $(WHEELBUNDLEDIR) bdist_wheel: $(WHEELDISTDIR) + $(MAKE) $(AM_MAKEFLAGS) -C pypi/ipacommands sdist || exit 1; for dir in $(IPACLIENT_SUBDIRS); do \ $(MAKE) $(AM_MAKEFLAGS) -C $${dir} $@ || exit 1; \ done diff --git a/configure.ac b/configure.ac index b633cba..2e27efc 100644 --- a/configure.ac +++ b/configure.ac @@ -580,6 +580,7 @@ AC_CONFIG_FILES([ pypi/Makefile pypi/freeipa/Makefile pypi/ipa/Makefile + pypi/ipacommands/Makefile pypi/ipaplatform/Makefile pypi/ipaserver/Makefile pypi/ipatests/Makefile diff --git a/pypi/Makefile.am b/pypi/Makefile.am index 5d8be9c..be572c6 100644 --- a/pypi/Makefile.am +++ b/pypi/Makefile.am @@ -7,6 +7,7 @@ NULL = SUBDIRS = \ freeipa \ ipa \ + ipacommands \ ipaplatform \ ipaserver \ ipatests \ diff --git a/pypi/ipacommands/MANIFEST.in b/pypi/ipacommands/MANIFEST.in new file mode 100644 index 0000000..659a1f5 --- /dev/null +++ b/pypi/ipacommands/MANIFEST.in @@ -0,0 +1,25 @@ +include asn1/*.c +include asn1/*.h +include asn1/asn1c/*.c +include asn1/asn1c/*.h +include asn1/asn1c/ipa.asn1 + +include client/config.c +include client/config.h +include client/ipa-client-common.c +include client/ipa-client-common.h +include client/ipa-getkeytab.c +include client/ipa-join.c +include client/ipa-rmkeytab.c + +include util/ipa_krb5.c +include util/ipa_krb5.h + +prune client/asn1 +prune client/client +prune client/util + +include Contributors.txt COPYING +include config.h +include ipasetup.py +include setup.cfg diff --git a/pypi/ipacommands/Makefile.am b/pypi/ipacommands/Makefile.am new file mode 100644 index 0000000..645ce7a --- /dev/null +++ b/pypi/ipacommands/Makefile.am @@ -0,0 +1,79 @@ +# This file will be processed with automake-1.7 to create Makefile.in +# +AUTOMAKE_OPTIONS = 1.7 + +NULL = + +pkgname = $(shell basename "$(abs_srcdir)") + +# hack to handle back-in-the-hierarchy depedency on ipasetup.py +.PHONY: $(top_builddir)/ipasetup.py +$(top_builddir)/ipasetup.py: + (cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) ipasetup.py) + +DEPENDENCIES = \ + asn1 \ + client \ + util \ + COPYING \ + Contributors.txt \ + config.h \ + ipasetup.py \ + $(NULL) + +# Python setup.py can handle symlinks to directories fine +asn1: $(top_srcdir)/asn1 + if [ ! -e "$@" ]; then ln -rs "$<"; fi + +client: $(top_srcdir)/client + if [ ! -e "$@" ]; then ln -rs "$<"; fi + +util: $(top_srcdir)/util + if [ ! -e "$@" ]; then ln -rs "$<"; fi + +# On the other hand files must be copied to create proper sdist +COPYING: $(top_srcdir)/COPYING + cp -p "$<" "$@" + +Contributors.txt: $(top_srcdir)/Contributors.txt + cp -p "$<" "$@" + +ipasetup.py: $(top_builddir)/ipasetup.py + cp -p "$<" "$@" + +config.h: $(top_builddir)/config.h + cp -p "$<" "$@" + + +all-local: $(DEPENDENCIES) + + +check-local: $(DEPENDENCIES) + cd $(srcdir); $(PYTHON) setup.py \ + $(VERBOSITY) \ + build \ + --build-base "$(abs_builddir)/build" + +clean-local: $(DEPENDENCIES) + $(PYTHON) "$(srcdir)/setup.py" clean --all + rm -rf "$(srcdir)/build" "$(srcdir)/dist" "$(srcdir)/MANIFEST" + find "$(srcdir)" \ + -name "*.py[co]" -delete -o \ + -name "__pycache__" -delete -o \ + -name "*.egg-info" -exec rm -rf {} + + rm -f $(DEPENDENCIES) + +dist-hook: $(DEPENDENCIES) + $(PYTHON) "$(srcdir)/setup.py" egg_info + PYTHON_SOURCES=$$(cat "$(srcdir)/$(pkgname).egg-info/SOURCES.txt") || exit $$?; \ + for FILEN in $${PYTHON_SOURCES}; \ + do \ + if test -x "$(srcdir)/$${FILEN}"; then MODE=755; else MODE=644; fi; \ + $(INSTALL) -D -m $${MODE} "$(srcdir)/$${FILEN}" "$(distdir)/$${FILEN}" || exit $$?; \ + done + +WHEELDISTDIR = $(top_builddir)/dist/wheels +.PHONY: sdist +sdist: $(DEPENDENCIES) + rm -rf $(WHEELDISTDIR)/$(pkgname)*.tar.gz + $(PYTHON) "$(srcdir)/setup.py" sdist --format=gztar --dist-dir=$(WHEELDISTDIR) diff --git a/pypi/ipacommands/setup.cfg b/pypi/ipacommands/setup.cfg new file mode 100644 index 0000000..ccffb47 --- /dev/null +++ b/pypi/ipacommands/setup.cfg @@ -0,0 +1,5 @@ +[bdist_wheel] +universal = 0 + +[metadata] +license_file = COPYING diff --git a/pypi/ipacommands/setup.py b/pypi/ipacommands/setup.py new file mode 100644 index 0000000..e50ee50 --- /dev/null +++ b/pypi/ipacommands/setup.py @@ -0,0 +1,194 @@ +"""IPA commands +""" +import glob +import os +import shlex +import subprocess +import sys + +from distutils import unixccompiler +from distutils.command.build_scripts import build_scripts \ + as distutils_build_scripts +from setuptools import Extension +from setuptools.command.build_ext import build_ext as setuptools_build_ext +from setuptools.command.install_lib import install_lib \ + as setuptools_install_lib + + +class CustomUnixCCompiler(unixccompiler.UnixCCompiler): + """Custom unix C compiler + + Redirect link_shared_object to link_executable + """ + + def link_shared_object(self, objects, output_filename, output_dir=None, + libraries=None, library_dirs=None, + runtime_library_dirs=None, export_symbols=None, + debug=0, extra_preargs=None, extra_postargs=None, + build_temp=None, target_lang=None): + # unused: export_symbols, build_temp + # remove pythonX.Y lib + libraries = list( + lib for lib in libraries + if not lib.startswith('python') + ) + return self.link_executable( + objects, + output_progname=output_filename, + output_dir=output_dir, + libraries=libraries, library_dirs=library_dirs, + runtime_library_dirs=runtime_library_dirs, + debug=debug, extra_preargs=extra_preargs, + extra_postargs=extra_postargs, + target_lang=target_lang) + + def _fix_lib_args(self, libraries, library_dirs, runtime_library_dirs): + return libraries, library_dirs, runtime_library_dirs + + +# distutils does not have an API to override compiler class. +# Let's monkey patch! +unixccompiler.UnixCCompiler = CustomUnixCCompiler + + +class build_ext(setuptools_build_ext): + """Custom build_ext + + Don't add '.so' extension + """ + def get_ext_filename(self, ext_name): + return ext_name + + +class build_scripts(distutils_build_scripts): + """Custom build_scripts + + Copy executables form build_lib to script dir. + """ + def run(self): + # run and get build_ext + self.run_command('build_ext') + build_ext = self.get_finalized_command('build_ext') + for i, name in enumerate(self.scripts): + libfile = os.path.join(build_ext.build_lib, name) + # add binary as script + self.scripts[i] = libfile + distutils_build_scripts.run(self) + + def copy_scripts(self): + # simple version of copy_script that does not try to read the + # executable as Python scripts. + self.mkpath(self.build_dir) + outfiles = [] + for script in self.scripts: + outfile = os.path.join(self.build_dir, os.path.basename(script)) + self.copy_file(script, outfile) + os.chmod(outfile, 0o755) + outfiles.append(outfile) + return outfiles, outfiles + + +class install_lib(setuptools_install_lib): + """Custom install_lib + + Don't install the executables as libraries. + """ + def install(self): + return [] + + +def pkgconfig(flags, *pkgs): + cmd = ['pkg-config', flags] + cmd.extend(pkgs) + out = subprocess.check_output(cmd) + if isinstance(out, bytes): + out = out.decode(sys.getfilesystemencoding()) + return shlex.split(out) + + +def get_extensions(ipajoin=False): + cfiles = [ + 'asn1/ipa_asn1.c', + 'client/config.c', + 'client/ipa-client-common.c', + 'util/ipa_krb5.c' + ] + glob.glob('asn1/asn1c/*.c') + + headers = [ + 'config.h', + 'asn1/ipa_asn1.h', + 'client/config.h', + 'client/ipa-client-common.h', + 'util/ipa_krb5.h' + ] + glob.glob('asn1/asn1c/*.h') + + include_dirs = ['.', 'asn1', 'asn1/asn1c', 'client', 'util'] + + pkgs = ('nss', 'krb5', 'libcrypto', 'popt', 'libsasl2', 'ini_config') + + extra_compile_args = [] + extra_compile_args.extend(pkgconfig('--cflags', *pkgs)) + + extra_link_args = ['-lldap_r', '-llber'] # OpenLDAP has no .pc + extra_link_args.extend(pkgconfig('--libs', *pkgs)) + + macros = [ + ('IPACONFFILE', '"/etc/ipa/default.conf"'), + ('LOCALEDIR', '"/usr/share/locale"'), + ] + + extensions = [ + Extension( + 'ipa-getkeytab', + sources=['client/ipa-getkeytab.c'] + cfiles, + depends=headers, + extra_compile_args=extra_compile_args, + extra_link_args=extra_link_args, + include_dirs=include_dirs, + define_macros=macros, + ), + Extension( + 'ipa-rmkeytab', + sources=['client/ipa-rmkeytab.c'] + cfiles, + depends=headers, + extra_compile_args=extra_compile_args, + extra_link_args=extra_link_args, + include_dirs=include_dirs, + define_macros=macros, + ), + ] + + if ipajoin: + xmlrpc_compile_args = pkgconfig('--cflags', 'xmlrpc_client') + xmlrpc_link_args = pkgconfig('--libs', 'xmlrpc_client') + extensions.append( + Extension( + 'ipa-join', + sources=['client/ipa-join.c'] + cfiles, + depends=headers, + extra_compile_args=extra_compile_args + xmlrpc_compile_args, + extra_link_args=extra_link_args + xmlrpc_link_args, + include_dirs=include_dirs, + define_macros=macros, + ) + ) + + return extensions + + +if __name__ == '__main__': + from ipasetup import ipasetup # noqa: E402 + + exts = get_extensions(ipajoin=False) + + ipasetup( + name='ipacommands', + doc=__doc__, + ext_modules=exts, + cmdclass={ + 'build_ext': build_ext, + 'build_scripts': build_scripts, + 'install_lib': install_lib, + }, + scripts=[ext.name for ext in exts], + ) From ecbd5f7226330fdbaf396d3620776274247e44e9 Mon Sep 17 00:00:00 2001 From: Christian Heimes <chei...@redhat.com> Date: Tue, 21 Feb 2017 17:11:37 +0100 Subject: [PATCH 6/6] Fix makefile --- Makefile.am | 3 --- 1 file changed, 3 deletions(-) diff --git a/Makefile.am b/Makefile.am index 20ec2cd..86af96d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,10 +1,7 @@ ACLOCAL_AMFLAGS = -I m4 IPACLIENT_SUBDIRS = ipaclient ipalib ipapython -<<<<<<< ce38000d583b9e75cf0c80a6044dd63caf6eb408 IPA_PLACEHOLDERS = freeipa ipa ipaplatform ipaserver ipatests -======= ->>>>>>> Add placeholders for ipaplatform, ipaserver and ipatests SUBDIRS = asn1 util client contrib daemons init install $(IPACLIENT_SUBDIRS) ipaplatform ipaserver ipatests pypi po MOSTLYCLEANFILES = ipasetup.pyc ipasetup.pyo \
-- Manage your subscription for the Freeipa-devel mailing list: https://www.redhat.com/mailman/listinfo/freeipa-devel Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code