File: python-sugar.mk.in

package info (click to toggle)
cdbs 0.4.130
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 1,348 kB
  • sloc: sh: 4,534; xml: 2,159; makefile: 178; perl: 138; python: 94; ansic: 7; java: 5
file content (129 lines) | stat: -rw-r--r-- 6,385 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# -*- mode: makefile; coding: utf-8 -*-
# Copyright © 2008-2011 Jonas Smedegaard <dr@jones.dk>
# Description: Class to build and install Python-based 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, see <http://www.gnu.org/licenses/>.

#PATH_RULES#

ifndef _cdbs_class_python_sugar
_cdbs_class_python_sugar = 1

# Space-delimited list of supported branches, lowest listed first
# (comment out if all current branches are supported)
# NB! This variable must be declared *above* inclusion of this snippet
#DEB_SUGAR_BRANCHES = 0.84 0.86

# Primary branch to use when DEB_SUGAR_BRANCHES is unset
# to ensure depending on virtual packages only as fallback
#DEB_SUGAR_PRIMARY_BRANCH ?= 0.88

# include both simple and versioned activity packages by default
# NB! This variable must be declared *above* inclusion of this snippet
DEB_PYTHON_SUGAR_PACKAGES ?= $(filter sugar-%-activity $(call cdbs_expand_branches,sugar-%-activity,$(DEB_SUGAR_BRANCHES), , ), $(DEB_PACKAGES))

DEB_PYTHON_MODULE_PACKAGES = $(if $(DEB_PYTHON_SYSTEM),$(DEB_PYTHON_SUGAR_PACKAGES))
DEB_PYTHON2_MODULE_PACKAGES = $(if $(DEB_PYTHON_SYSTEM),,$(DEB_PYTHON_SUGAR_PACKAGES))
# FIXME: support multiple Python packaging systems in same binary package
#DEB_PYTHON3_MODULE_PACKAGES = $(if $(DEB_PYTHON_SYSTEM),,$(DEB_PYTHON_SUGAR_PACKAGES))

include $(_cdbs_class_path)/python-module.mk$(_cdbs_makefile_suffix)
include $(_cdbs_rules_path)/debhelper.mk$(_cdbs_makefile_suffix)

# Convenience variable for e.g. conflicts/provides/replaces
DEB_SUGAR_SOURCE_PKGBASE = $(and $(DEB_SOURCE_PACKAGE),$(firstword $(subst -0.,$(space),$(DEB_SOURCE_PACKAGE))))

# prepare sanity checks
cdbs_python_sugar_packages_pre := $(DEB_PYTHON_SUGAR_PACKAGES)
cdbs_python_sugar_pkgresolve_check = $(strip $(if \
	$(call cdbs_streq,$(strip \
		$(DEB_PYTHON_SUGAR_PACKAGES)),$(strip \
		$(cdbs_python_sugar_packages_pre))),\
	,\
	$(call cdbs_warn,\
		Redefining DEB_PYTHON_SUGAR_PACKAGES late is \
		currently unsupported: set DEB_PYTHON_SUGAR_PACKAGES \
		before including python-sugar.mk)))
## TODO: Rephrase when DEB_PYTHON_SUGAR_PACKAGES is only expanded inside rules
cdbs_python_sugar_pkg_check = $(strip $(if \
	$(DEB_PYTHON_SUGAR_PACKAGES),\
	,\
	$(call cdbs_warn,\
		No Python-based Sugar packages found or declared \
		- either rename binary packages or set \
		DEB_PYTHON_SUGAR_PACKAGES before including python-sugar.mk)))

# convenience wrappers to expand Sugar branches for package dependencies
cdbs_sugar_allbranchdeps = $(call cdbs_expand_branches,$1,$(DEB_SUGAR_BRANCHES),$(comma) ,$(comma) ,$(DEB_SUGAR_PRIMARY_BRANCH))
cdbs_sugar_anybranchdeps = $(call cdbs_expand_branches,$1,$(DEB_SUGAR_BRANCHES),$(comma) , | ,$(DEB_SUGAR_PRIMARY_BRANCH))

CDBS_BUILD_DEPENDS_class_python-sugar ?= $(cdbs_python_builddeps_cdbs)
CDBS_BUILD_DEPENDS += , $(CDBS_BUILD_DEPENDS_class_python-sugar)

# Python-related dependencies according to Python policy, appendix A
CDBS_BUILD_DEPENDS_class_python-sugar_python ?= $(cdbs_python_builddeps)
CDBS_BUILD_DEPENDS += , $(CDBS_BUILD_DEPENDS_class_python-sugar_python)

# warn about wrong number of resolved packages
CDBS_BUILD_DEPENDS += $(cdbs_python_sugar_pkg_check)

# Sugar-related dependencies
CDBS_BUILD_DEPENDS_class_python-sugar_sugar ?= $(call cdbs_sugar_anybranchdeps,python-sugar python-sugar-toolkit), unzip
CDBS_BUILD_DEPENDS += $(comma) $(CDBS_BUILD_DEPENDS_class_python-sugar_sugar)

# warn early about late changes to DEB_PYTHON_SUGAR_PACKAGES
testsanity::
	$(cdbs_python_sugar_pkgresolve_check)

pre-build::
	mkdir -p debian/stamps-configure

$(patsubst %,build/%,$(DEB_PYTHON_SUGAR_PACKAGES)) :: build/%:
	[ ! -e $(cdbs_cursrcdir)/MANIFEST ] || [ -e $(cdbs_cursrcdir)/MANIFEST.upstream ] || mv $(cdbs_cursrcdir)/MANIFEST $(cdbs_cursrcdir)/MANIFEST.upstream
	[ ! -e $(cdbs_cursrcdir)/MANIFEST.upstream ] || egrep -v '^locale/.*/(.*\.mo|activity\.linfo)$$' $(cdbs_cursrcdir)/MANIFEST.upstream > $(cdbs_cursrcdir)/MANIFEST
	set -e; \
	$(foreach buildver,$(cdbs_curpythonbuildversions),\
		$(call cdbs_python_binary,python$(buildver)) \
			$(cdbs_cursrcdir)/setup.py build; )
	[ ! -e $(cdbs_cursrcdir)/MANIFEST.upstream ] || IFS="`printf '\n'`" find "$(cdbs_cursrcdir)/locale" -type f \( -name '*.mo' -or -name 'activity.linfo' \) | while read path; do \
		echo "$$path" | sed 's!^$(cdbs_cursrcdir)/!!' >> $(cdbs_cursrcdir)/MANIFEST; \
	done

$(patsubst %,install/%,$(DEB_PYTHON_SUGAR_PACKAGES)) :: install/%:
	mkdir -p $(DEB_DESTDIR)usr/share/sugar/activities
	set -e; \
	$(foreach buildver,$(cdbs_curpythonbuildversions),\
		LANG=C XDG_DATA_HOME="$(DEB_DESTDIR)/usr/share" \
			$(call cdbs_python_binary,python$(buildver)) \
			$(cdbs_cursrcdir)/setup.py install \
			--prefix="$(DEB_DESTDIR)/usr"; )

# Replace superfluous COPYING files with symlinks
$(patsubst %,binary-post-install/%,$(DEB_PYTHON_SUGAR_PACKAGES)) :: binary-post-install/%:
	! test -f $(DEB_DESTDIR)/usr/share/sugar/activities/*.activity/COPYING \
	|| ! diff -wq /usr/share/common-licenses/GPL-2 $(DEB_DESTDIR)/usr/share/sugar/activities/*.activity/COPYING \
	|| ln -sfT ../../../common-licenses/GPL-2 $(DEB_DESTDIR)/usr/share/sugar/activities/*.activity/COPYING

reverse-config:: $(patsubst %,cleanpythonsugar-reverse-config/%,$(DEB_PYTHON_SUGAR_PACKAGES))
$(patsubst %,cleanpythonsugar-reverse-config/%,$(DEB_PYTHON_SUGAR_PACKAGES)) :: cleanpythonsugar-reverse-config/% : 
	[ ! -e $(cdbs_cursrcdir)/MANIFEST.upstream ] || mv -f $(cdbs_cursrcdir)/MANIFEST.upstream $(cdbs_cursrcdir)/MANIFEST

$(patsubst %,cleanpythonsugar/%,$(DEB_PYTHON_SUGAR_PACKAGES)) :: cleanpythonsugar/% : 
	-IFS="`printf '\n'`" find "$(cdbs_cursrcdir)/locale" -type f \( -name '*.mo' -or -name 'activity.linfo' \) | while read path; do \
		rm -f "$$path"; \
		rmdir --ignore-fail-on-non-empty "`dirname "$$path"`"; \
	done
	-rmdir --ignore-fail-on-non-empty "$(cdbs_cursrcdir)/locale"

endif