diff options
Diffstat (limited to 'debian/cdbs/1/class')
-rw-r--r-- | debian/cdbs/1/class/python-sugar.mk | 95 | ||||
-rw-r--r-- | debian/cdbs/1/class/python-vars.mk | 110 |
2 files changed, 205 insertions, 0 deletions
diff --git a/debian/cdbs/1/class/python-sugar.mk b/debian/cdbs/1/class/python-sugar.mk new file mode 100644 index 0000000..584a07c --- /dev/null +++ b/debian/cdbs/1/class/python-sugar.mk @@ -0,0 +1,95 @@ +# -*- mode: makefile; coding: utf-8 -*- +# Copyright © 2008 Jonas Smedegaard <dr@jones.dk> +# Description: Class to build and install Sugar packages +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +# 02111-1307 USA. +# + +_cdbs_scripts_path ?= /usr/lib/cdbs +_cdbs_rules_path ?= /usr/share/cdbs/1/rules +_cdbs_class_path ?= /usr/share/cdbs/1/class + +ifndef _cdbs_class_python_sugar +_cdbs_class_python_sugar = 1 + +#include $(_cdbs_class_path)/python-vars.mk$(_cdbs_makefile_suffix) +include debian/cdbs/1/class/python-vars.mk +include $(_cdbs_rules_path)/debhelper.mk$(_cdbs_makefile_suffix) + +# Declare Build-Deps for packages using this file +CDBS_BUILD_DEPENDS := $(CDBS_BUILD_DEPENDS), python-sugar, python-sugar-toolkit, unzip +# FIXME: Resolve DEB_PYTHON_PACKAGES in build targets only +ifeq (,$(cdbs_python_pkg_check)$(DEB_PYTHON_ARCH_PACKAGES)) + ifneq (, $(cdbs_python_compile_version)) + CDBS_BUILD_DEPENDS := $(CDBS_BUILD_DEPENDS), python$(cdbs_python_compile_version)-dev, python (>= 2.3.5-11) + else + CDBS_BUILD_DEPENDS := $(CDBS_BUILD_DEPENDS), python-dev (>= 2.3.5-11) + endif +else +CDBS_BUILD_DEPENDS := $(CDBS_BUILD_DEPENDS), python-all-dev (>= 2.3.5-11) +endif +ifeq (pysupport, $(DEB_PYTHON_SYSTEM)) +CDBS_BUILD_DEPENDS := $(CDBS_BUILD_DEPENDS), python-support (>= 0.6) +else +CDBS_BUILD_DEPENDS := $(CDBS_BUILD_DEPENDS), python-central (>= 0.6) +endif + +# Files or `find -name`-compatible search patterns to add to temp MANIFEST +#DEB_PYTHON_SUGAR_MANIFEST = *.py *.po *.pot *.svg + +DEB_PYTHON_SUGAR_MANIFEST_REGEX = +DEB_PYTHON_SUGAR_MANIFEST_IGNORE_REGEX = ^debian/.* + +cdbs_python_sugar_manifest_files_tmp = $(patsubst %,-or -name '%',$(DEB_PYTHON_SUGAR_MANIFEST)) +cdbs_python_sugar_manifest_files = $(wordlist 2, $(words $(cdbs_python_sugar_manifest_files_tmp)), $(cdbs_python_sugar_manifest_files_tmp)) + +common-configure-arch common-configure-indep:: common-configure-impl +common-configure-impl:: + $(if $(DEB_PYTHON_SUGAR_MANIFEST),i=$(DEB_SRCDIR)/MANIFEST; if [ -e $$i ] && [ ! -e $$i.cdbs-orig ]; then mv $$i $$i.cdbs-orig; fi) + $(if $(DEB_PYTHON_SUGAR_MANIFEST),cd $(DEB_SRCDIR) && find * -type f $(cdbs_python_sugar_manifest_files) $(if $(DEB_PYTHON_SUGAR_MANIFEST_REGEX),-regex '$(DEB_PYTHON_SUGAR_MANIFEST_REGEX)') $(if $(DEB_PYTHON_SUGAR_MANIFEST_IGNORE_REGEX),-not -regex '$(DEB_PYTHON_SUGAR_MANIFEST_IGNORE_REGEX))' > MANIFEST) + +$(patsubst %,build/%,$(DEB_PACKAGES)) :: build/%: + for pythonver in $(cdbs_python_build_versions); do \ + /usr/bin/python$$ver setup.py dist; \ + done + +$(patsubst %,install/%,$(DEB_PACKAGES)) :: install/%: + mkdir -p $(DEB_DESTDIR)usr/share/activities + for pythonver in $(cdbs_python_build_versions); do \ + /usr/bin/python$$ver setup.py install $(DEB_DESTDIR)usr; \ + done + +$(patsubst %,binary-install/%,$(DEB_PACKAGES)) :: binary-install/%: +ifeq (pysupport, $(DEB_PYTHON_SYSTEM)) + dh_pysupport -p$(cdbs_curpkg) $(DEB_PYTHON_PRIVATE_MODULES_DIRS) $(DEB_PYTHON_PRIVATE_MODULES_DIRS_$(cdbs_curpkg)) +else + dh_pycentral -p$(cdbs_curpkg) +endif + +clean:: + for pythonver in $(cdbs_python_build_versions); do \ + /usr/bin/python$$ver setup.py clean; \ + done + $(if $(DEB_PYTHON_SUGAR_MANIFEST),i=$(DEB_SRCDIR)/MANIFEST; if test -e $$i.cdbs-orig ; then mv -f $$i.cdbs-orig $$i; fi) +ifeq (, $(cdbs_selected_pycompat)) + echo "$(cdbs_pycompat)" >debian/pycompat +endif # use pycompat + +## TODO: Drop this when DEB_PYTHON_PACKAGES is only resolved in build targets +pre-build clean:: + $(cdbs_python_pkgresolve_check) + +endif diff --git a/debian/cdbs/1/class/python-vars.mk b/debian/cdbs/1/class/python-vars.mk new file mode 100644 index 0000000..3f78176 --- /dev/null +++ b/debian/cdbs/1/class/python-vars.mk @@ -0,0 +1,110 @@ +# -*- mode: makefile; coding: utf-8 -*- +# Copyright © 2008 Jonas Smedegaard <dr@jones.dk> +# Copyright © 2008 Jonas Smedegaard <dr@jones.dk> +# Description: Defines useful variables for Python packages +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +# 02111-1307 USA. +# + + +_cdbs_scripts_path ?= /usr/lib/cdbs +_cdbs_rules_path ?= /usr/share/cdbs/1/rules +_cdbs_class_path ?= /usr/share/cdbs/1/class + +ifndef _cdbs_class_python_vars +_cdbs_class_python_vars = 1 + +include $(_cdbs_rules_path)/buildvars.mk$(_cdbs_makefile_suffix) + +DEB_PYTHON_PACKAGES = $(filter-out %-doc %-dev %-common, $(DEB_PACKAGES)) + +DEB_PYTHON_ARCH_PACKAGES = $(filter $(DEB_PYTHON_PACKAGES), $(DEB_ARCH_PACKAGES)) +DEB_PYTHON_INDEP_PACKAGES = $(filter $(DEB_PYTHON_PACKAGES), $(DEB_INDEP_PACKAGES)) + +## FIXME: Resolve DEB_PYTHON_PACKAGES in build targets only +# Avoid including buildcore.mk to not risk breaking when hopefully removing again +cdbs_python_streq = $(if $(filter-out xx,x$(subst $1,,$2)$(subst $2,,$1)x),,yes) +cdbs_python_packages_pre := $(DEB_PYTHON_ARCH_PACKAGES)$(DEB_PYTHON_INDEP_PACKAGES) +cdbs_python_pkgresolve_check = $(if $(call cdbs_python_streq,$(DEB_PYTHON_ARCH_PACKAGES)$(DEB_PYTHON_INDEP_PACKAGES),$(cdbs_python_packages_pre)),, $(warning Setting DEB_PYTHON_*PACKAGES after python-vars in included is currently unsupported)) +## TODO: Rephrase when DEB_PYTHON_PACKAGES is only resolved in build targets +cdbs_python_pkg_check = $(if $(DEB_PYTHON_ARCH_PACKAGES)$(DEB_PYTHON_INDEP_PACKAGES),, $(warning No Python packages found or declared - either rename binary packages or set DEB_PYTHON_PACKAGES (or one or both of DEB_PYTHON_ARCH_PACKAGES and DEB_PYTHON_INDEP_PACKAGES) before including python-vars.mk)) + +# check python system +cdbs_use_xs_field := $(shell grep -q "^XS-Python-Version:" debian/control && echo yes) +cdbs_selected_pycompat := $(shell if [ -e debian/pycompat ]; then cat debian/pycompat; fi) +cdbs_pycompat = $(cdbs_selected_pycompat) +ifeq (pysupport, $(DEB_PYTHON_SYSTEM)) + ifeq (, $(cdbs_selected_pycompat)) + cdbs_pycompat = 2 + endif # use pycompat + # warning pysupport compatibility mode + ifneq (, $(cdbs_use_xs_field)) + $(warning Use of XS-Python-Version and XB-Python-Version fields in 'debian/control' is deprecated with pysupport method, use 'debian/pyversions' if you need to specify specific versions) + endif # use XS field (compat) +else + ifeq (pycentral, $(DEB_PYTHON_SYSTEM)) + ifeq (, $(cdbs_selected_pycompat)) + cdbs_pycompat = 2 + endif # use pycompat + else + ifneq (, $(DEB_PYTHON_SYSTEM)) + $(error unsupported Python system: $(DEB_PYTHON_SYSTEM) (select either pysupport or pycentral)) + else + ifneq (, $(cdbs_use_xs_field)) + $(error Your package uses the new Python policy; you must set DEB_PYTHON_SYSTEM to "pysupport" or "pycentral".) + endif + ifneq (, $(cdbs_selected_pycompat)) + ifeq (yes, $(shell expr $(cdbs_selected_pycompat) \> 1 >/dev/null && echo yes)) + $(error Your package uses the new Python policy; you must set DEB_PYTHON_SYSTEM to "pysupport" or "pycentral".) + endif + endif # use pycompat + endif # unknown method + endif # pycentral +endif # pysupport + +# Calculate cdbs_python_build_versions +cdbs_python_current_version := $(shell pyversions -vd) +## FIXME: Resolve DEB_PYTHON_PACKAGES in build targets only +ifeq (,$(cdbs_python_pkg_check)$(DEB_PYTHON_ARCH_PACKAGES)) + # check if current is in build versions + ifneq ($(cdbs_python_current_version), $(filter $(cdbs_python_current_version), $(shell pyversions -vr))) + cdbs_python_compile_version := $(firstword $(strip $(sort $(shell pyversions -vr)))) + cdbs_python_build_versions := $(cdbs_python_compile_version) + else + cdbs_python_build_versions := $(cdbs_python_current_version) + endif +else +cdbs_python_build_versions := $(shell pyversions -vr) +endif # archall + +# check if build is possible +ifeq (, $(cdbs_python_build_versions)) +ifeq (pysupport, $(DEB_PYTHON_SYSTEM)) +$(error invalid setting in 'debian/pyversions') +else +$(error invalid setting for XS-Python-Version) +endif # system selected +endif # build versions empty + +# TODO: Support multiple python programs built for different python versions +# FIXME: Understand the above sentence and rephrase it +cdbs_python_curpkg_build_versions = $(cdbs_python_build_versions) + +## TODO: Drop this when DEB_PYTHON_PACKAGES is only resolved in build targets +pre-build clean:: + $(cdbs_python_pkgresolve_check) + +endif |