Debian Codegraph @

debian/rules

raw
1 #!/usr/bin/make -f
2
3 TOPDIR=$(shell pwd)
4
5 # help for reproducible build
6 export LANG=C.UTF-8
7 export LC_ALL=C.UTF-8
8 export LC_CTYPE=C.UTF-8
9 export LC_MESSAGES=C.UTF-8
10 export LANGUAGE=
11
12 # building with python3
13 PYTHON=$(shell py3versions --default)
14 PYTHON_PATH=$(shell command -v $(PYTHON))
15 SETUP=$(PYTHON) setup.py
16
17 # build options
18 export DEB_BUILD_MAINT_OPTIONS=hardening=+all reproducible=+all
19
20 # display build commands while CMake build
21 export VERBOSE=1
22
23 # Set hash seed to Qt resource compiler output will deterministic one.
24 # See QHash class document on Qt document.
25 export QT_HASH_SEED=0
26
27 # Do all test by default
28 TEST_FLAGS =
29 CI_ENV =
30 DISABLE_FRAGILE_TEST =
31
32 # Disable fragile test in release build
33 ifneq ($(shell dpkg-parsechangelog --show-field=Distribution),UNRELEASED)
34 DISABLE_FRAGILE_TEST = true
35 endif
36 # Disable fragile test in CI environment
37 ifeq ($(GITLAB_CI),true)
38 DISABLE_FRAGILE_TEST = true
39 endif
40 ifeq ($(DISABLE_FRAGILE_TEST),true)
41 include debian/buildd-options.mak
42 CI_ENV += CI=true
43 endif
44
45 %:
46 dh $@ --with=python3 --buildsystem=makefile
47
48 .PHONY: calibre_auto_test calibre_auto_install blhc-note
49
50 DEB_DH_GENCONTROL_ARGS = -- -Vpyqt:Version=$(shell dpkg-query --showformat='$${source:Version}' --show python3-pyqt6)
51
52 # podofo: marge CPPFLAGS into CFLAGS/CXXFLAGS for cmake build
53 DEB_PODOFO_CPPFLAGS = $(shell dpkg-buildflags --get CPPFLAGS)
54
55 blhc-note:
56 # # Add false-positive info for blhc(1) check
57 @echo 'blhc: ignore-line-regexp: \tCompiling form /.+\.ui'
58 @echo 'blhc: ignore-line-regexp: .+ -dM -E -o moc_predefs\.h /usr/lib/[^/]+/qt6/mkspecs/features/data/dummy\.cpp'
59 @echo 'blhc: ignore-line-regexp: .+ -w -dM -E /usr/share/cmake-[0-9\.]+/Modules/CMakeCXXCompilerABI\.cpp .+'
60 @echo 'blhc: ignore-line-regexp: /usr/lib/qt6/libexec/moc .+\.cpp'
61
62 override_dh_auto_configure:
63 env CFLAGS="$(CFLAGS) $(DEB_PODOFO_CPPFLAGS) -fPIC" CXXFLAGS="$(CXXFLAGS) $(DEB_PODOFO_CPPFLAGS) -fPIC" cmake -B podofo-builder -S podofo -DPODOFO_BUILD_LIB_ONLY=TRUE -DPODOFO_BUILD_STATIC=TRUE -DCMAKE_INSTALL_PREFIX=$(TOPDIR)/podofo-dist
64
65 override_dh_auto_build: blhc-note
66 cmake --build podofo-builder
67 cmake --install podofo-builder
68 env PODOFO_INC_DIR=$(TOPDIR)/podofo-dist/include/podofo PODOFO_LIB_DIR=$(TOPDIR)/podofo-dist/lib $(SETUP) build
69 $(SETUP) liberation_fonts --system-liberation_fonts --path-to-liberation_fonts=/usr/share/fonts/truetype/liberation
70 $(SETUP) gui
71
72 # Invoke "calibre_auto_test" target with automatic "HOME" and "XDG_*" variables.
73 override_dh_auto_test:
74 dh_auto_test -O--buildsystem=makefile -- -f debian/calibre-builder.mak test
75
76 calibre_auto_test:
77 env TZ=UTC $(CI_ENV) $(SETUP) test $(TEST_FLAGS) --exclude-test-name=ajax_book --exclude-test-name=split_file
78 env TZ=UTC $(CI_ENV) $(SETUP) test --test-name=ajax_book $(TEST_FLAGS)
79 env TZ=UTC $(CI_ENV) $(SETUP) test --test-name=split_file $(TEST_FLAGS)
80
81 override_dh_auto_install:
82 dh_auto_install -O--buildsystem=makefile -- -f debian/calibre-builder.mak install
83
84 calibre_auto_install:
85 mkdir -p debian/tmp/usr/share/icons/hicolor
86 mkdir -p debian/tmp/usr/share/applications
87 mkdir -p debian/tmp/usr/share/mime/packages
88 mkdir -p debian/tmp/usr/share/zsh/vendor-completions
89 env XDG_DATA_DIRS=$(CURDIR)/debian/tmp/usr/share CALIBRE_CONFIG_DIRECTORY=debian/tmp/config PODOFO_INC_DIR=$(TOPDIR)/podofo-dist/include/podofo PODOFO_LIB_DIR=$(TOPDIR)/podofo-dist/lib $(SETUP) install --root=debian/tmp/usr
90 #
91 # # not needed
92 rm -v debian/tmp/usr/share/calibre/calibre-portable.*
93 rm -v debian/tmp/usr/lib/python*/site-packages/init_calibre.py
94 rmdir -v debian/tmp/usr/share/desktop-directories
95 #
96 # # do not install developer's script
97 rm -v debian/tmp/usr/lib/calibre/calibre/devices/mtp/unix/upstream/update.py
98 rmdir -v debian/tmp/usr/lib/calibre/calibre/devices/mtp/unix/upstream/
99 # # Debian package "python3-tinycss" doesn't installs test code
100 rm -v debian/tmp/usr/lib/calibre/tinycss/tests/*.py
101 rmdir -v debian/tmp/usr/lib/calibre/tinycss/tests/
102 #
103 # # Remove source path name from pyuic6 outputs
104 find debian/tmp/usr/lib/calibre/calibre/gui2 -type f -name '*_ui.py' -print | xargs --no-run-if-empty sed --separate --file=debian/tools/remove-ui-basepath.sed --in-place
105 #
106 # # Drop unused exec permission
107 chmod -x debian/tmp/usr/lib/calibre/calibre/devices/cli.py
108 chmod -x debian/tmp/usr/lib/calibre/calibre/gui2/fts/search.py
109 # # Remove unused shbang to avoid Lintian warning
110 find debian/tmp/usr/lib/calibre -type f -name '*.py' ! -executable -print | xargs --no-run-if-empty sed --separate --file=debian/tools/drop-python-shbang.sed --in-place
111
112 override_dh_installman:
113 debian/tools/install-manpages.sh
114
115 override_dh_auto_clean:
116 $(SETUP) build --clean
117 $(SETUP) liberation_fonts --clean
118 py3clean src/calibre/gui2
119 $(SETUP) gui --clean
120 py3clean setup src
121
122 override_dh_gencontrol:
123 dh_gencontrol $(DEB_DH_GENCONTROL_ARGS)
124
125 # No need to touch "calibre-bin".
126 override_dh_python3:
127 dh_python3 --no-package=calibre-bin --shebang=$(PYTHON_PATH)