File: rules

package info (click to toggle)
php-twig 2.14.3-1%2Bdeb11u2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 5,240 kB
  • sloc: php: 18,830; makefile: 215; sh: 42; python: 33
file content (122 lines) | stat: -rwxr-xr-x 4,819 bytes parent folder | download
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
#!/usr/bin/make -f

include /usr/share/dpkg/default.mk
TWIG_VERSION := $(shell echo $(DEB_VERSION_UPSTREAM) | sed -r 's/^([0-9]+\.[0-9]+).*/\1/')

%:
	dh $@ --with phpcomposer,sphinxdoc

execute_after_dh_auto_build:
	# php-twig-doc
	sphinx-build -C \
	 -b html \
	 -D source_suffix='.rst' \
	 -D master_doc='index' \
	 -D project='php-twig-doc' \
	 -D copyright='by the Twig Team' \
	 -D version='${TWIG_VERSION}' \
	 -D release='$(DEB_VERSION_UPSTREAM)' \
	 -D pygments_style='sphinx' \
	 -D html_theme='default' \
	 doc debian/build-tmp/php-twig-doc
	cp -a lib/Twig src/psr-0
	# php-twig
	phpab --output src/autoload.php src
	# php-twig testsuite
	mkdir --parents vendor src/Extra
	phpab 	--output vendor/autoload.php \
		--template debian/autoload.tests.php.tpl \
		tests extra/*/Tests
	# Mimic install path
	ln -s src Twig
	ln -s ../../extra/cssinliner-extra Twig/Extra/CssInliner
	ln -s ../../extra/html-extra Twig/Extra/Html
	ln -s ../../extra/inky-extra Twig/Extra/Inky
	ln -s ../../extra/intl-extra Twig/Extra/Intl
	ln -s ../../extra/markdown-extra Twig/Extra/Markdown
	# ln -s ../../extra/string-extra Twig/Extra/String
	ln -s ../../extra/twig-extra-bundle Twig/Extra/TwigExtraBundle
	# php-twig extra
	# Parts from the symfony package’s debian/rules.
	mkdir --parents debian/packages_to_build debian/autoloaders
	# Walk through the parts of upstream's code that should be packaged into
	# separate Debian binary packages and write down a package-to-build info
	# file containing shell variables for each package.
	# Those files will be traverse later on in different targets of this
	# makefile (debian/rules). They solely exists to not repeat the extraction
	# of those variables in each of those target over and over again.
	# Then, build a class loader for the package, using the template in
	# debian/$deb_pkg_name.autoload.php.tpl if it exists (to load dependencies).
	set -e;\
	 for src_path in $$(find -L Twig/Extra/ -mindepth 1 -maxdepth 1 -type d); do \
	  if [ -e $$src_path/composer.json ]; then \
	   deb_pkg_name=php-$$(cat $$src_path/composer.json | jq -r '.name | tostring' | sed -r 's|/|-|'); \
	   if [ $$(grep -c -E -e "^Package: $$deb_pkg_name\$$" debian/control) -ne 1 ]; then \
	    echo "W: No Debian package '$$deb_pkg_name' defined in debian/control," 1>&2; \
	    echo "   therefor not considering Symfony $$src_path," 1>&2; \
	    continue; \
	   fi; \
	   echo "# This file contains some variables sourced" > debian/packages_to_build/$$deb_pkg_name; \
	   echo "# by various targets in debian/rules" >> debian/packages_to_build/$$deb_pkg_name; \
	   echo "deb_pkg_name='$$deb_pkg_name'" >> debian/packages_to_build/$$deb_pkg_name; \
	   echo "src_path='$$src_path'" >> debian/packages_to_build/$$deb_pkg_name; \
	   echo "twig $${deb_pkg_name#php-twig-} $$src_path/autoload.php" > debian/autoloaders/$$deb_pkg_name; \
	   if [ -e debian/$$deb_pkg_name.autoload.php.tpl ]; then \
	    phpab \
	        --blacklist '*\\tests\\*' \
		--output $$src_path/autoload.php \
		--template debian/$$deb_pkg_name.autoload.php.tpl \
		$$src_path; \
	   else \
	    phpab \
	        --blacklist '*\\tests\\*' \
		--output $$src_path/autoload.php \
		$$src_path; \
	   fi; \
	  fi; \
	 done

override_dh_auto_test:
	phpunit
	# testsuite for extra packages
	set -e; \
	 for package_info_file in $$(find debian/packages_to_build/ -mindepth 1 -maxdepth 1 -type f); do \
	  . $$package_info_file; \
	  if [ -f $$src_path/phpunit.xml.dist ]; then \
	   LC_ALL=en_US phpunit $$src_path; \
	  fi; \
	 done

override_dh_install:
	dh_install --package=php-twig --package=php-twig-doc -XExtra
	# In debian/packages_to_build/ a file containing shell variables exists
	# for each package that should be build. Source one file after another
	# to make the shell variables available and run dh_install in order to
	# provide the PHP runtime code for each package.
	set -e; \
	 for package_info_file in $$(find debian/packages_to_build/ -mindepth 1 -maxdepth 1 -type f); do \
	  . $$package_info_file; \
	  dh_install --package=$$deb_pkg_name \
		debian/autoloaders/$$deb_pkg_name usr/share/pkg-php-tools/autoloaders; \
	  dh_install \
		-X.md \
		-Xcomposer.json \
		-XLICENSE \
		-Xphpunit.xml.dist \
		-XTests \
		--package=$$deb_pkg_name \
		$$src_path/* \
		usr/share/php/$$src_path/; \
	 done

override_dh_phpcomposer:
	dh_phpcomposer --package=php-twig
	# In debian/packages_to_build/ a file containing shell variables exists
	# for each package that should be build. Source one file after another
	# to make the shell variables available and run dh_phpcomposer for each
	# package.
	set -e;\
	 for package_info_file in $$(find debian/packages_to_build/ -mindepth 1 -maxdepth 1 -type f); do \
	  . $$package_info_file; \
	  dh_phpcomposer --package=$$deb_pkg_name --sourcedirectory=$$src_path; \
	 done