├── .gitignore ├── debian ├── compat ├── docs ├── examples ├── manpages ├── debhelper.install ├── source │ ├── format │ ├── local-options │ └── lintian-overrides ├── tests │ └── pkg-perl │ │ ├── skip-syntax │ │ ├── smoke-files │ │ └── smoke-skip ├── libdebhelper-perl.install ├── gen-provides ├── rules └── control ├── t ├── syntax │ ├── syntax-libs.t │ └── syntax-progs.t ├── dh_missing │ ├── template │ │ ├── file-for-foo │ │ ├── debian │ │ │ ├── foo.install │ │ │ ├── changelog │ │ │ └── control │ │ └── Makefile │ ├── 01-no-missing.t │ ├── 03-dh_install-redirection.t │ ├── 02-fail-on-missing.t │ └── 04-not-installed-glob.t ├── dh_installdocs │ ├── debian │ │ ├── copyright │ │ ├── docfile │ │ ├── changelog │ │ └── control │ ├── 01-868204-ignore-broken-symlinks.t │ └── dh_installdocs.t ├── dh_installsystemd │ ├── debian │ │ ├── foo.init │ │ ├── foo.service │ │ ├── foo2.service │ │ ├── changelog │ │ └── control │ ├── simple │ │ └── debian │ │ │ ├── foo.service │ │ │ ├── changelog │ │ │ └── control │ └── dh_installsystemd_tmpfiles.t ├── dh_installinit │ ├── debian │ │ ├── foo.service │ │ ├── bar.other.init │ │ ├── changelog │ │ └── control │ └── dh_installinit.t ├── dh_installsystemduser │ ├── debian │ │ ├── baz.user.service │ │ ├── foo.user.service │ │ ├── changelog │ │ └── control │ └── dh_installsystemduser.t ├── Dh_Lib │ ├── debian │ │ ├── changelog │ │ └── control │ ├── 00-use.t │ ├── path.t │ └── control-parsing.t ├── dh_installgsettings │ ├── debian │ │ ├── changelog │ │ └── control │ └── dh_installgsettings.t ├── buildsystems │ ├── debian │ │ ├── changelog │ │ └── control │ ├── load-bs.pl │ ├── parallel.mk │ ├── 01-build-system-basic-api.t │ ├── 06-buildsystem-mkdir-rmdir.t │ ├── 02-make-jobserver-makeflags.t │ ├── 05-load-build-system.t │ ├── autoconf │ │ └── configure │ └── 04-dh_auto_do_autoconf.t ├── pod.t ├── debhelper-compat │ ├── debian │ │ └── control │ └── syntax.t ├── dh_installman │ ├── manpage-compressed.pod │ ├── manpage-uncompressed.pod │ └── 01-basics.t ├── dh_install │ ├── 03-866570-dont-install-from-host.t │ ├── 01-basics.t │ ├── 02-bugs-53XXXX.t │ └── 04-sourcedir.t ├── dh_link │ ├── 02-346405.t │ ├── 03-894229.t │ └── 01-basic.t ├── size.t ├── override_target.t ├── dh-lib.t ├── maintscript.t ├── dh_compress.t └── dh_usrlocal │ └── 01-basic.t ├── .gitattributes ├── examples └── rules.tiny ├── doc ├── README ├── SUPPORT-POLICY └── TODO ├── autoscripts ├── maintscript-helper ├── postinst-xfonts ├── postrm-menu ├── postrm-sgmlcatalog ├── postrm-xfonts ├── postrm-init ├── prerm-alternatives ├── prerm-wm ├── postrm-icons ├── postinst-menu ├── prerm-systemd ├── postrm-modules ├── postrm-systemd-reload-only ├── prerm-init ├── prerm-usrlocal ├── postrm-debconf ├── postinst-ucf ├── prerm-systemd-restart ├── prerm-init-norestart ├── postinst-menu-method ├── postrm-menu-method ├── postinst-alternatives ├── prerm-emacsen ├── postinst-icons ├── postinst-wm-noman ├── postinst-modules ├── postinst-init-nostart ├── preinst-emacsen ├── postinst-init ├── postinst-systemd-start ├── postrm-ucf ├── postinst-wm ├── postinst-emacsen ├── postinst-systemd-restartnostart ├── postinst-init-tmpfiles ├── postrm-systemd ├── postinst-init-restart ├── postrm-systemd-user ├── postinst-systemd-restart ├── postinst-systemd-dont-enable ├── postinst-systemd-user-dont-enable ├── postinst-usrlocal ├── postinst-systemd-enable └── postinst-systemd-user-enable ├── man └── po4a │ ├── add1.es │ ├── add2.es │ ├── add3.es │ ├── add.pt │ ├── add.fr │ └── add.de ├── .mailmap ├── .dir-locals.el ├── lib └── Debian │ └── Debhelper │ ├── Buildsystem │ ├── qmake_qt4.pm │ ├── ant.pm │ ├── ninja.pm │ ├── perl_build.pm │ ├── autoconf.pm │ ├── qmake.pm │ └── perl_makemaker.pm │ ├── Sequence │ ├── python_support.pm │ ├── build_stamp.pm │ ├── dwz.pm │ ├── elf_tools.pm │ ├── installinitramfs.pm │ ├── systemd.pm │ └── root_sequence.pm │ └── DH │ └── SequenceState.pm ├── strings-kept-translations.pod ├── run ├── .gitlab-ci.yml ├── dh_listpackages ├── dh_installlogrotate ├── dh_installpam ├── dh_lintian ├── dh_testdir ├── dh_installmime ├── dh_auto_build ├── dh_installppp ├── dh_auto_clean ├── dh_installifupdown ├── dh_auto_configure ├── dh_auto_test ├── dh_installcron ├── dh_prep ├── dh_update_autotools_config ├── dh_installlogcheck ├── dh_icons ├── dh_installmenu ├── dh_installudev ├── dh_installgsettings ├── dh_ucf ├── dh_installinitramfs ├── debhelper-obsolete-compat.pod ├── dh_installmodules ├── dh_installxfonts ├── dh_auto_install ├── dh_gconf ├── dh_testroot ├── dh_installinfo ├── dh_installdirs ├── dh_installtmpfiles ├── dh_installdebconf └── dh_installcatalogs /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | -------------------------------------------------------------------------------- /debian/compat: -------------------------------------------------------------------------------- 1 | 14 2 | -------------------------------------------------------------------------------- /debian/docs: -------------------------------------------------------------------------------- 1 | doc/* 2 | -------------------------------------------------------------------------------- /debian/examples: -------------------------------------------------------------------------------- 1 | examples/* 2 | -------------------------------------------------------------------------------- /debian/manpages: -------------------------------------------------------------------------------- 1 | *.1 2 | *.7 3 | -------------------------------------------------------------------------------- /debian/debhelper.install: -------------------------------------------------------------------------------- 1 | usr/bin 2 | -------------------------------------------------------------------------------- /debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (native) 2 | -------------------------------------------------------------------------------- /t/syntax/syntax-libs.t: -------------------------------------------------------------------------------- 1 | syntax-progs.t -------------------------------------------------------------------------------- /t/dh_missing/template/file-for-foo: -------------------------------------------------------------------------------- 1 | file content -------------------------------------------------------------------------------- /debian/tests/pkg-perl/skip-syntax: -------------------------------------------------------------------------------- 1 | Dummy/Entry.pm 2 | -------------------------------------------------------------------------------- /t/dh_missing/template/debian/foo.install: -------------------------------------------------------------------------------- 1 | usr/bin/*-for-foo -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | debian/changelog merge=dpkg-mergechangelogs 2 | -------------------------------------------------------------------------------- /examples/rules.tiny: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | %: 3 | dh $@ 4 | -------------------------------------------------------------------------------- /t/dh_installdocs/debian/copyright: -------------------------------------------------------------------------------- 1 | Some test copyright file 2 | -------------------------------------------------------------------------------- /debian/source/local-options: -------------------------------------------------------------------------------- 1 | tar-ignore 2 | tar-ignore=debhelper/.idea 3 | -------------------------------------------------------------------------------- /doc/README: -------------------------------------------------------------------------------- 1 | Please see the debhelper(7) man page for documentation. 2 | -------------------------------------------------------------------------------- /autoscripts/maintscript-helper: -------------------------------------------------------------------------------- 1 | dpkg-maintscript-helper #PARAMS# -- "$@" 2 | -------------------------------------------------------------------------------- /debian/libdebhelper-perl.install: -------------------------------------------------------------------------------- 1 | usr/share/debhelper 2 | usr/share/perl5 3 | -------------------------------------------------------------------------------- /t/dh_installsystemd/debian/foo.init: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | some script 4 | 5 | -------------------------------------------------------------------------------- /man/po4a/add1.es: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debian/debhelper/master/man/po4a/add1.es -------------------------------------------------------------------------------- /man/po4a/add2.es: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debian/debhelper/master/man/po4a/add2.es -------------------------------------------------------------------------------- /man/po4a/add3.es: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debian/debhelper/master/man/po4a/add3.es -------------------------------------------------------------------------------- /autoscripts/postinst-xfonts: -------------------------------------------------------------------------------- 1 | if which update-fonts-dir >/dev/null 2>&1; then 2 | #CMDS# 3 | fi 4 | -------------------------------------------------------------------------------- /autoscripts/postrm-menu: -------------------------------------------------------------------------------- 1 | if [ -x "`which update-menus 2>/dev/null`" ]; then update-menus ; fi 2 | -------------------------------------------------------------------------------- /autoscripts/postrm-sgmlcatalog: -------------------------------------------------------------------------------- 1 | if [ "$1" = "purge" ]; then 2 | rm -f #CENTRALCAT#.old 3 | fi 4 | -------------------------------------------------------------------------------- /debian/tests/pkg-perl/smoke-files: -------------------------------------------------------------------------------- 1 | t/ 2 | debian/compat 3 | debian/control 4 | debian/changelog 5 | -------------------------------------------------------------------------------- /autoscripts/postrm-xfonts: -------------------------------------------------------------------------------- 1 | if [ -x "`which update-fonts-dir 2>/dev/null`" ]; then 2 | #CMDS# 3 | fi 4 | -------------------------------------------------------------------------------- /t/dh_installdocs/debian/docfile: -------------------------------------------------------------------------------- 1 | This file must not be empty, or dh_installdocs won't install it. 2 | -------------------------------------------------------------------------------- /autoscripts/postrm-init: -------------------------------------------------------------------------------- 1 | if [ "$1" = "purge" ] ; then 2 | update-rc.d #SCRIPT# remove >/dev/null 3 | fi 4 | -------------------------------------------------------------------------------- /autoscripts/prerm-alternatives: -------------------------------------------------------------------------------- 1 | if [ "$1" = "remove" ]; then 2 | update-alternatives #RM_OPTIONS# 3 | fi 4 | -------------------------------------------------------------------------------- /t/dh_installinit/debian/foo.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=A unit 3 | 4 | [Service] 5 | ExecStart=/bin/true 6 | -------------------------------------------------------------------------------- /autoscripts/prerm-wm: -------------------------------------------------------------------------------- 1 | if [ "$1" = "remove" ]; then 2 | update-alternatives --remove x-window-manager #WM# 3 | fi 4 | -------------------------------------------------------------------------------- /autoscripts/postrm-icons: -------------------------------------------------------------------------------- 1 | if which update-icon-caches >/dev/null 2>&1 ; then 2 | update-icon-caches #DIRLIST# 3 | fi 4 | -------------------------------------------------------------------------------- /autoscripts/postinst-menu: -------------------------------------------------------------------------------- 1 | if [ "$1" = "configure" ] && [ -x "`which update-menus 2>/dev/null`" ]; then 2 | update-menus 3 | fi 4 | -------------------------------------------------------------------------------- /autoscripts/prerm-systemd: -------------------------------------------------------------------------------- 1 | if [ -d /run/systemd/system ]; then 2 | deb-systemd-invoke stop #UNITFILES# >/dev/null || true 3 | fi 4 | -------------------------------------------------------------------------------- /debian/source/lintian-overrides: -------------------------------------------------------------------------------- 1 | debhelper source: no-dh-sequencer 2 | debhelper source: package-does-not-use-debhelper-or-cdbs 3 | -------------------------------------------------------------------------------- /.mailmap: -------------------------------------------------------------------------------- 1 | Joey Hess 2 | Joey Hess 3 | Valéry Perrin 4 | Valéry Perrin 5 | -------------------------------------------------------------------------------- /autoscripts/postrm-modules: -------------------------------------------------------------------------------- 1 | if [ -e /boot/System.map-#KVERS# ]; then 2 | depmod -a -F /boot/System.map-#KVERS# #KVERS# || true 3 | fi 4 | -------------------------------------------------------------------------------- /autoscripts/postrm-systemd-reload-only: -------------------------------------------------------------------------------- 1 | if [ -d /run/systemd/system ]; then 2 | systemctl --system daemon-reload >/dev/null || true 3 | fi 4 | -------------------------------------------------------------------------------- /autoscripts/prerm-init: -------------------------------------------------------------------------------- 1 | if [ -x "/etc/init.d/#SCRIPT#" ]; then 2 | invoke-rc.d #INVOKE_RCD_PARAMS##SCRIPT# stop || #ERROR_HANDLER# 3 | fi 4 | -------------------------------------------------------------------------------- /autoscripts/prerm-usrlocal: -------------------------------------------------------------------------------- 1 | ( 2 | while read dir; do 3 | rmdir "$dir" 2>/dev/null || true 4 | done 5 | ) << DATA 6 | #JUSTDIRS# 7 | DATA 8 | -------------------------------------------------------------------------------- /autoscripts/postrm-debconf: -------------------------------------------------------------------------------- 1 | if [ "$1" = purge ] && [ -e /usr/share/debconf/confmodule ]; then 2 | . /usr/share/debconf/confmodule 3 | db_purge 4 | fi 5 | -------------------------------------------------------------------------------- /t/dh_installinit/debian/bar.other.init: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cat << 'EOF' 3 | I am init script to be installed into package "bar" into /etc/init.d/other path. 4 | EOF -------------------------------------------------------------------------------- /autoscripts/postinst-ucf: -------------------------------------------------------------------------------- 1 | if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ]; then 2 | ucf "#UCFSRC#" "#UCFDEST#" 3 | ucfr #PACKAGE# "#UCFDEST#" 4 | fi 5 | -------------------------------------------------------------------------------- /autoscripts/prerm-systemd-restart: -------------------------------------------------------------------------------- 1 | if [ -d /run/systemd/system ] && [ "$1" = remove ]; then 2 | deb-systemd-invoke stop #UNITFILES# >/dev/null || true 3 | fi 4 | -------------------------------------------------------------------------------- /t/dh_installsystemd/debian/foo.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=A unit 3 | 4 | [Service] 5 | ExecStart=/bin/true 6 | 7 | [Install] 8 | WantedBy=multi-user.target 9 | -------------------------------------------------------------------------------- /autoscripts/prerm-init-norestart: -------------------------------------------------------------------------------- 1 | if [ -x "/etc/init.d/#SCRIPT#" ] && [ "$1" = remove ]; then 2 | invoke-rc.d #INVOKE_RCD_PARAMS##SCRIPT# stop || #ERROR_HANDLER# 3 | fi 4 | -------------------------------------------------------------------------------- /t/dh_installsystemd/debian/foo2.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Another unit 3 | 4 | [Service] 5 | ExecStart=/bin/true 6 | 7 | [Install] 8 | WantedBy=multi-user.target 9 | -------------------------------------------------------------------------------- /t/dh_installsystemd/simple/debian/foo.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=A unit 3 | 4 | [Service] 5 | ExecStart=/bin/true 6 | 7 | [Install] 8 | WantedBy=multi-user.target 9 | -------------------------------------------------------------------------------- /t/dh_installsystemduser/debian/baz.user.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Baz User Unit 3 | 4 | [Service] 5 | ExecStart=/bin/true 6 | 7 | [Install] 8 | WantedBy=default.target 9 | -------------------------------------------------------------------------------- /t/dh_installsystemduser/debian/foo.user.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Foo User Unit 3 | 4 | [Service] 5 | ExecStart=/bin/true 6 | 7 | [Install] 8 | WantedBy=default.target 9 | -------------------------------------------------------------------------------- /.dir-locals.el: -------------------------------------------------------------------------------- 1 | ((perl-mode 2 | (tab-width . 4) 3 | (indent-tabs-mode . t)) 4 | (cperl-mode 5 | (cperl-indent-level . 4) 6 | (tab-width . 4) 7 | (indent-tabs-mode . t))) 8 | -------------------------------------------------------------------------------- /t/Dh_Lib/debian/changelog: -------------------------------------------------------------------------------- 1 | foo (1.0-1) unstable; urgency=low 2 | 3 | * Initial release. (Closes: #XXXXXX) 4 | 5 | -- Test Mon, 11 Jul 2016 18:10:59 +0200 6 | -------------------------------------------------------------------------------- /t/dh_installdocs/debian/changelog: -------------------------------------------------------------------------------- 1 | foo (1.0-1) unstable; urgency=low 2 | 3 | * Initial release. (Closes: #XXXXXX) 4 | 5 | -- Test Mon, 11 Jul 2016 18:10:59 +0200 6 | -------------------------------------------------------------------------------- /t/dh_installinit/debian/changelog: -------------------------------------------------------------------------------- 1 | foo (1.0-1) unstable; urgency=low 2 | 3 | * Initial release. (Closes: #XXXXXX) 4 | 5 | -- Test Mon, 11 Jul 2016 18:10:59 +0200 6 | -------------------------------------------------------------------------------- /t/dh_installgsettings/debian/changelog: -------------------------------------------------------------------------------- 1 | foo (1.0-1) unstable; urgency=low 2 | 3 | * Initial release. (Closes: #XXXXXX) 4 | 5 | -- Test Mon, 11 Jul 2016 18:10:59 +0200 6 | -------------------------------------------------------------------------------- /t/dh_installsystemd/debian/changelog: -------------------------------------------------------------------------------- 1 | foo (1.0-1) unstable; urgency=low 2 | 3 | * Initial release. (Closes: #XXXXXX) 4 | 5 | -- Test Mon, 11 Jul 2016 18:10:59 +0200 6 | -------------------------------------------------------------------------------- /t/dh_missing/template/debian/changelog: -------------------------------------------------------------------------------- 1 | foo (1.0-1) unstable; urgency=low 2 | 3 | * Initial release. (Closes: #XXXXXX) 4 | 5 | -- Test Mon, 11 Jul 2016 18:10:59 +0200 6 | -------------------------------------------------------------------------------- /t/buildsystems/debian/changelog: -------------------------------------------------------------------------------- 1 | testpackage (1.0-1) unstable; urgency=low 2 | 3 | * Initial release. (Closes: #XXXXXX) 4 | 5 | -- Test Tue, 09 Jun 2009 15:35:32 +0300 6 | -------------------------------------------------------------------------------- /t/dh_installsystemduser/debian/changelog: -------------------------------------------------------------------------------- 1 | foo (1.0-1) unstable; urgency=low 2 | 3 | * Initial release. (Closes: #XXXXXX) 4 | 5 | -- Test Mon, 11 Jul 2016 18:10:59 +0200 6 | -------------------------------------------------------------------------------- /t/dh_installsystemd/simple/debian/changelog: -------------------------------------------------------------------------------- 1 | foo (1.0-1) unstable; urgency=low 2 | 3 | * Initial release. (Closes: #XXXXXX) 4 | 5 | -- Test Mon, 11 Jul 2016 18:10:59 +0200 6 | -------------------------------------------------------------------------------- /autoscripts/postinst-menu-method: -------------------------------------------------------------------------------- 1 | inst=/etc/menu-methods/#PACKAGE# 2 | if [ -f $inst ]; then 3 | chmod a+x $inst 4 | if [ -x "`which update-menus 2>/dev/null`" ]; then 5 | update-menus 6 | fi 7 | fi 8 | -------------------------------------------------------------------------------- /autoscripts/postrm-menu-method: -------------------------------------------------------------------------------- 1 | inst=/etc/menu-methods/#PACKAGE# 2 | if [ "$1" = "remove" ] && [ -f "$inst" ]; then chmod a-x $inst ; fi 3 | if [ -x "`which update-menus 2>/dev/null`" ]; then update-menus ; fi 4 | -------------------------------------------------------------------------------- /autoscripts/postinst-alternatives: -------------------------------------------------------------------------------- 1 | if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ]; then 2 | update-alternatives #INSTALL_OPTIONS# 3 | fi 4 | -------------------------------------------------------------------------------- /autoscripts/prerm-emacsen: -------------------------------------------------------------------------------- 1 | if [ -e /var/lib/emacsen-common/state/package/installed/emacsen-common -a -x /usr/lib/emacsen-common/emacs-package-remove ] ; then 2 | /usr/lib/emacsen-common/emacs-package-remove --prerm #PACKAGE# 3 | fi 4 | -------------------------------------------------------------------------------- /autoscripts/postinst-icons: -------------------------------------------------------------------------------- 1 | if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then 2 | if which update-icon-caches >/dev/null 2>&1 ; then 3 | update-icon-caches #DIRLIST# 4 | fi 5 | fi 6 | -------------------------------------------------------------------------------- /autoscripts/postinst-wm-noman: -------------------------------------------------------------------------------- 1 | if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then 2 | update-alternatives --install /usr/bin/x-window-manager \ 3 | x-window-manager #WM# #PRIORITY# 4 | fi 5 | -------------------------------------------------------------------------------- /t/dh_installsystemd/simple/debian/control: -------------------------------------------------------------------------------- 1 | Source: foo 2 | Section: misc 3 | Priority: optional 4 | Maintainer: Test 5 | Standards-Version: 3.9.8 6 | 7 | Package: foo 8 | Architecture: all 9 | Description: package foo 10 | Package foo 11 | -------------------------------------------------------------------------------- /t/dh_installsystemduser/debian/control: -------------------------------------------------------------------------------- 1 | Source: foo 2 | Section: misc 3 | Priority: optional 4 | Maintainer: Test 5 | Standards-Version: 3.9.8 6 | 7 | Package: foo 8 | Architecture: all 9 | Description: package foo 10 | Package foo 11 | -------------------------------------------------------------------------------- /autoscripts/postinst-modules: -------------------------------------------------------------------------------- 1 | if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then 2 | if [ -e /boot/System.map-#KVERS# ]; then 3 | depmod -a -F /boot/System.map-#KVERS# #KVERS# || true 4 | fi 5 | fi 6 | -------------------------------------------------------------------------------- /t/pod.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | use Test::More; 6 | 7 | eval { require Test::Pod; Test::Pod->import; }; 8 | plan skip_all => 'Test::Pod required' if $@; 9 | 10 | all_pod_files_ok('debhelper.pod', grep { -x $_ } 'dh', glob 'dh_*'); 11 | -------------------------------------------------------------------------------- /debian/tests/pkg-perl/smoke-skip: -------------------------------------------------------------------------------- 1 | # If we set the path to /usr/bin when run under autopkgtest, 2 | # other dh_* commands are tested as well. This might be nice 3 | # or not but it currently fails for dh_autotools-dev_updateconfig. 4 | # So let's skip t/size.t for now. 5 | t/size.t 6 | -------------------------------------------------------------------------------- /autoscripts/postinst-init-nostart: -------------------------------------------------------------------------------- 1 | if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then 2 | if [ -x "/etc/init.d/#SCRIPT#" ]; then 3 | update-rc.d #SCRIPT# #INITPARMS# >/dev/null || #ERROR_HANDLER# 4 | fi 5 | fi 6 | -------------------------------------------------------------------------------- /autoscripts/preinst-emacsen: -------------------------------------------------------------------------------- 1 | if ( [ "$1" = "install" ] || [ "$1" = "upgrade" ] ) \ 2 | && [ -e /var/lib/emacsen-common/state/package/installed/emacsen-common -a -x /usr/lib/emacsen-common/emacs-package-install ] 3 | then 4 | /usr/lib/emacsen-common/emacs-package-install --preinst #PACKAGE# 5 | fi 6 | -------------------------------------------------------------------------------- /t/debhelper-compat/debian/control: -------------------------------------------------------------------------------- 1 | Source: foo 2 | Section: misc 3 | Priority: optional 4 | Build-Depends: BUILD_DEPENDS 5 | Maintainer: Test 6 | Rules-Requires-Root: no 7 | Standards-Version: 3.9.8 8 | 9 | Package: foo 10 | Architecture: all 11 | Description: package foo 12 | Package foo 13 | -------------------------------------------------------------------------------- /t/dh_missing/template/Makefile: -------------------------------------------------------------------------------- 1 | install: 2 | install -m 755 -d debian/tmp/usr/bin 3 | install -m 644 file-for-foo debian/tmp/usr/bin/file-for-foo 4 | 5 | installmore: install 6 | install -m 644 file-for-foo debian/tmp/usr/bin/file-for-foo-more 7 | install -m 644 file-for-foo debian/tmp/usr/bin/file-for-foo-lots 8 | -------------------------------------------------------------------------------- /t/dh_installman/manpage-compressed.pod: -------------------------------------------------------------------------------- 1 | =head1 NAME 2 | 3 | manpage - Something very exciting 4 | 5 | =head1 SYNOPSIS 6 | 7 | This tool does not exist but would be awesome. 8 | 9 | =head1 SEE ALSO 10 | 11 | L 12 | 13 | =head1 AUTHORS 14 | 15 | Niels Thykier 16 | 17 | =cut 18 | -------------------------------------------------------------------------------- /autoscripts/postinst-init: -------------------------------------------------------------------------------- 1 | if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then 2 | if [ -x "/etc/init.d/#SCRIPT#" ]; then 3 | update-rc.d #SCRIPT# #INITPARMS# >/dev/null 4 | invoke-rc.d #INVOKE_RCD_PARAMS##SCRIPT# start || #ERROR_HANDLER# 5 | fi 6 | fi 7 | -------------------------------------------------------------------------------- /autoscripts/postinst-systemd-start: -------------------------------------------------------------------------------- 1 | if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then 2 | if [ -d /run/systemd/system ]; then 3 | systemctl --system daemon-reload >/dev/null || true 4 | deb-systemd-invoke start #UNITFILES# >/dev/null || true 5 | fi 6 | fi 7 | -------------------------------------------------------------------------------- /lib/Debian/Debhelper/Buildsystem/qmake_qt4.pm: -------------------------------------------------------------------------------- 1 | package Debian::Debhelper::Buildsystem::qmake_qt4; 2 | 3 | use strict; 4 | use warnings; 5 | use parent qw(Debian::Debhelper::Buildsystem::qmake); 6 | 7 | sub DESCRIPTION { 8 | "qmake for QT 4 (*.pro)"; 9 | } 10 | 11 | sub _qmake { 12 | return 'qmake-qt4'; 13 | } 14 | 15 | 1 16 | -------------------------------------------------------------------------------- /man/po4a/add.pt: -------------------------------------------------------------------------------- 1 | PO4A-HEADER:mode=after;position=AUTOR;beginboundary=\=head1 2 | 3 | =head1 TRADUÇÃO 4 | 5 | Américo Monteiro 6 | 7 | Se encontrar algum erro na tradução deste documento, por favor comunique para 8 | Américo Monteiro I 9 | ou 10 | Equipa Debian de Tradução Portuguesa I. 11 | -------------------------------------------------------------------------------- /t/dh_installman/manpage-uncompressed.pod: -------------------------------------------------------------------------------- 1 | =head1 NAME 2 | 3 | manpage-uncompressed - Something very exciting 4 | 5 | =head1 SYNOPSIS 6 | 7 | This tool does not exist but would be awesome. 8 | 9 | =head1 SEE ALSO 10 | 11 | L 12 | 13 | =head1 AUTHORS 14 | 15 | Niels Thykier 16 | 17 | =cut 18 | -------------------------------------------------------------------------------- /autoscripts/postrm-ucf: -------------------------------------------------------------------------------- 1 | if [ "$1" = "purge" ]; then 2 | for ext in .ucf-new .ucf-old .ucf-dist ""; do 3 | rm -f "#UCFDEST#$ext" 4 | done 5 | 6 | if [ -x "`which ucf 2>/dev/null`" ]; then 7 | ucf --purge "#UCFDEST#" 8 | fi 9 | if [ -x "`which ucfr 2>/dev/null`" ]; then 10 | ucfr --purge #PACKAGE# "#UCFDEST#" 11 | fi 12 | fi 13 | -------------------------------------------------------------------------------- /autoscripts/postinst-wm: -------------------------------------------------------------------------------- 1 | if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ]; then 2 | update-alternatives --install /usr/bin/x-window-manager \ 3 | x-window-manager #WM# #PRIORITY# \ 4 | --slave /usr/share/man/man1/x-window-manager.1.gz \ 5 | x-window-manager.1.gz #WMMAN# 6 | fi 7 | -------------------------------------------------------------------------------- /t/buildsystems/debian/control: -------------------------------------------------------------------------------- 1 | Source: testsrcpackage 2 | Section: devel 3 | Priority: optional 4 | Maintainer: Test 5 | Standards-Version: 3.8.1 6 | Build-Depends: debhelper-compat (= 12) 7 | Rules-Requires-Root: no 8 | 9 | Package: testpackage 10 | Architecture: all 11 | Description: short description 12 | Long description 13 | -------------------------------------------------------------------------------- /lib/Debian/Debhelper/Sequence/python_support.pm: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # Obsolete debhelper sequence file for python-support 3 | 4 | use warnings; 5 | use strict; 6 | use Debian::Debhelper::Dh_Lib qw(deprecated_functionality); 7 | 8 | deprecated_functionality('python_support sequence does nothing as dh_pysupport is no longer available', 11); 9 | 10 | 1 11 | -------------------------------------------------------------------------------- /lib/Debian/Debhelper/Sequence/build_stamp.pm: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | add_command_at_end('create-stamp debian/debhelper-build-stamp', 'build'); 7 | add_command_at_end('create-stamp debian/debhelper-build-stamp', 'build-arch'); 8 | add_command_at_end('create-stamp debian/debhelper-build-stamp', 'build-indep'); 9 | 10 | 1 11 | -------------------------------------------------------------------------------- /lib/Debian/Debhelper/Sequence/dwz.pm: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # Enable dh_dwz 3 | 4 | use strict; 5 | use warnings; 6 | use Debian::Debhelper::Dh_Lib qw(compat error); 7 | 8 | if (not compat(11)) { 9 | error("In compat 12, dh_dwz is run by default and the dwz-sequence is no longer required."); 10 | } 11 | 12 | insert_before('dh_strip', 'dh_dwz'); 13 | 14 | 1; 15 | -------------------------------------------------------------------------------- /autoscripts/postinst-emacsen: -------------------------------------------------------------------------------- 1 | if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then 2 | if [ -e /var/lib/emacsen-common/state/package/installed/emacsen-common -a -x /usr/lib/emacsen-common/emacs-package-install ] ; then 3 | /usr/lib/emacsen-common/emacs-package-install --postinst #PACKAGE# 4 | fi 5 | fi 6 | -------------------------------------------------------------------------------- /lib/Debian/Debhelper/Sequence/elf_tools.pm: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | use Debian::Debhelper::Dh_Lib qw(compat); 6 | 7 | insert_after('dh_missing', 'dh_strip'); 8 | if (not compat(11)) { 9 | insert_before('dh_strip', 'dh_dwz'); 10 | } 11 | insert_after('dh_strip', 'dh_makeshlibs'); 12 | insert_after('dh_makeshlibs', 'dh_shlibdeps'); 13 | 14 | 1; -------------------------------------------------------------------------------- /autoscripts/postinst-systemd-restartnostart: -------------------------------------------------------------------------------- 1 | if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then 2 | if [ -d /run/systemd/system ]; then 3 | systemctl --system daemon-reload >/dev/null || true 4 | if [ -n "$2" ]; then 5 | deb-systemd-invoke #RESTART_ACTION# #UNITFILES# >/dev/null || true 6 | fi 7 | fi 8 | fi 9 | -------------------------------------------------------------------------------- /autoscripts/postinst-init-tmpfiles: -------------------------------------------------------------------------------- 1 | if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then 2 | # In case this system is running systemd, we need to ensure that all 3 | # necessary tmpfiles (if any) are created before starting. 4 | if [ -d /run/systemd/system ] ; then 5 | systemd-tmpfiles --create #TMPFILES# >/dev/null || true 6 | fi 7 | fi 8 | -------------------------------------------------------------------------------- /autoscripts/postrm-systemd: -------------------------------------------------------------------------------- 1 | if [ "$1" = "remove" ]; then 2 | if [ -x "/usr/bin/deb-systemd-helper" ]; then 3 | deb-systemd-helper mask #UNITFILES# >/dev/null || true 4 | fi 5 | fi 6 | 7 | if [ "$1" = "purge" ]; then 8 | if [ -x "/usr/bin/deb-systemd-helper" ]; then 9 | deb-systemd-helper purge #UNITFILES# >/dev/null || true 10 | deb-systemd-helper unmask #UNITFILES# >/dev/null || true 11 | fi 12 | fi 13 | -------------------------------------------------------------------------------- /strings-kept-translations.pod: -------------------------------------------------------------------------------- 1 | # This document contains strings that has been previously translated 2 | # and will (almost certainly) re-occur later. They are kept here 3 | # to avoid needing to have them re-translated. 4 | 5 | =pod 6 | 7 | This compatibility level is open for beta testing; changes may occur. 8 | 9 | This compatibility level is still open for development; use with caution. 10 | 11 | =cut 12 | 13 | -------------------------------------------------------------------------------- /t/Dh_Lib/debian/control: -------------------------------------------------------------------------------- 1 | # Comment before the source field 2 | 3 | Source: foo 4 | Section: misc 5 | Priority: optional 6 | Maintainer: Test 7 | Standards-Version: 3.9.8 8 | 9 | Package: foo-any 10 | Section: devel 11 | Architecture: linux-any 12 | Description: package foo-any 13 | Package foo-any 14 | 15 | Package: foo-all 16 | Architecture: all 17 | Description: package foo-all 18 | Package foo-all 19 | 20 | -------------------------------------------------------------------------------- /t/dh_installinit/debian/control: -------------------------------------------------------------------------------- 1 | Source: foo 2 | Section: misc 3 | Priority: optional 4 | Maintainer: Test 5 | Standards-Version: 3.9.8 6 | 7 | Package: foo 8 | Architecture: all 9 | Description: package foo 10 | Package foo 11 | 12 | Package: bar 13 | Architecture: all 14 | Description: package bar 15 | Package bar 16 | 17 | Package: baz 18 | Architecture: all 19 | Description: package baz 20 | Package baz 21 | -------------------------------------------------------------------------------- /lib/Debian/Debhelper/Sequence/installinitramfs.pm: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # Enable dh_installinitramfs 3 | 4 | use strict; 5 | use warnings; 6 | use Debian::Debhelper::Dh_Lib qw(compat error); 7 | 8 | if (not compat(11)) { 9 | error("In compat 12, dh_installinitramfs is run by default and the installinitramfs-sequence is no longer required."); 10 | } 11 | 12 | insert_after('dh_installgsettings', 'dh_installinitramfs'); 13 | 14 | 1; 15 | -------------------------------------------------------------------------------- /t/dh_installsystemd/debian/control: -------------------------------------------------------------------------------- 1 | Source: foo 2 | Section: misc 3 | Priority: optional 4 | Maintainer: Test 5 | Standards-Version: 3.9.8 6 | 7 | Package: foo 8 | Architecture: all 9 | Description: package foo 10 | Package foo 11 | 12 | Package: bar 13 | Architecture: all 14 | Description: package bar 15 | Package bar 16 | 17 | Package: baz 18 | Architecture: all 19 | Description: package baz 20 | Package baz 21 | -------------------------------------------------------------------------------- /t/dh_missing/template/debian/control: -------------------------------------------------------------------------------- 1 | Source: foo 2 | Section: misc 3 | Priority: optional 4 | Maintainer: Test 5 | Standards-Version: 3.9.8 6 | 7 | Package: foo 8 | Architecture: all 9 | Description: package foo 10 | Package foo 11 | 12 | Package: bar 13 | Architecture: all 14 | Description: package bar 15 | Package bar 16 | 17 | Package: baz 18 | Architecture: all 19 | Description: package baz 20 | Package baz 21 | -------------------------------------------------------------------------------- /autoscripts/postinst-init-restart: -------------------------------------------------------------------------------- 1 | if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then 2 | if [ -x "/etc/init.d/#SCRIPT#" ]; then 3 | update-rc.d #SCRIPT# #INITPARMS# >/dev/null 4 | if [ -n "$2" ]; then 5 | _dh_action=restart 6 | else 7 | _dh_action=start 8 | fi 9 | invoke-rc.d #INVOKE_RCD_PARAMS##SCRIPT# $_dh_action || #ERROR_HANDLER# 10 | fi 11 | fi 12 | -------------------------------------------------------------------------------- /autoscripts/postrm-systemd-user: -------------------------------------------------------------------------------- 1 | if [ "$1" = "remove" ]; then 2 | if [ -x "/usr/bin/deb-systemd-helper" ] ; then 3 | deb-systemd-helper --user mask #UNITFILES# >/dev/null || true 4 | fi 5 | fi 6 | 7 | if [ "$1" = "purge" ]; then 8 | if [ -x "/usr/bin/deb-systemd-helper" ] ; then 9 | deb-systemd-helper --user purge #UNITFILES# >/dev/null || true 10 | deb-systemd-helper --user unmask #UNITFILES# >/dev/null || true 11 | fi 12 | fi 13 | -------------------------------------------------------------------------------- /autoscripts/postinst-systemd-restart: -------------------------------------------------------------------------------- 1 | if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then 2 | if [ -d /run/systemd/system ]; then 3 | systemctl --system daemon-reload >/dev/null || true 4 | if [ -n "$2" ]; then 5 | _dh_action=#RESTART_ACTION# 6 | else 7 | _dh_action=start 8 | fi 9 | deb-systemd-invoke $_dh_action #UNITFILES# >/dev/null || true 10 | fi 11 | fi 12 | -------------------------------------------------------------------------------- /t/buildsystems/load-bs.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | use Debian::Debhelper::Dh_Buildsystems; 6 | 7 | buildsystems_init(); 8 | my $system = $ENV{'TEST_DH_SYSTEM'}; 9 | my $step = $ENV{'TEST_DH_STEP'}; 10 | my $bs = load_buildsystem($system, $step); 11 | if (defined $bs) { 12 | print 'NAME=', $bs->NAME(), "\n"; 13 | print $_, "=", (defined $bs->{$_}) ? $bs->{$_} : 'undef', "\n" 14 | foreach (sort keys %$bs); 15 | } 16 | 17 | -------------------------------------------------------------------------------- /t/dh_installdocs/debian/control: -------------------------------------------------------------------------------- 1 | Source: foo 2 | Section: misc 3 | Priority: optional 4 | Maintainer: Test 5 | Rules-Requires-Root: no 6 | Standards-Version: 3.9.8 7 | 8 | Package: foo 9 | Architecture: all 10 | Description: package foo 11 | Package foo 12 | 13 | Package: bar 14 | Architecture: all 15 | Description: package bar 16 | Package bar 17 | 18 | Package: baz 19 | Architecture: all 20 | Description: package baz 21 | Package baz 22 | -------------------------------------------------------------------------------- /t/dh_installgsettings/debian/control: -------------------------------------------------------------------------------- 1 | Source: foo 2 | Section: misc 3 | Priority: optional 4 | Maintainer: Test 5 | Standards-Version: 3.9.8 6 | 7 | Package: has-settings 8 | Architecture: all 9 | Depends: ${misc:Depends} 10 | Description: package has-settings 11 | This package has a GSettings schema. 12 | 13 | Package: no-settings 14 | Architecture: all 15 | Depends: ${misc:Depends} 16 | Description: package no-settings 17 | This package doesn't have a GSettings schema. 18 | -------------------------------------------------------------------------------- /t/Dh_Lib/00-use.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | use Cwd; 6 | use Test::More tests => 2; 7 | 8 | use File::Temp qw(tempdir); 9 | use File::Basename qw(dirname); 10 | use lib dirname(dirname(__FILE__)); 11 | 12 | my $test_dir = tempdir(CLEANUP => 1); 13 | 14 | chdir($test_dir); 15 | 16 | # Packages that need to be able to (at least) load without requring 17 | # d/control or d/compat. 18 | 19 | use_ok('Debian::Debhelper::Dh_Lib', '!dirname'); 20 | use_ok('Debian::Debhelper::Buildsystem'); 21 | -------------------------------------------------------------------------------- /run: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Run a debhelper command using files from this directory. 3 | 4 | # Run items from current directory by preference. 5 | PATH=.:$PATH 6 | export PATH 7 | 8 | # Ensure that builds are self-hosting, which means I have to use the .pm 9 | # files in this package, not any that may be on the system. 10 | export PERL5LIB=$(pwd)/lib 11 | 12 | # If any automatic script generation is done in building this package, 13 | # be sure to use the new templates from this package. 14 | export DH_DATAFILES=$(pwd) 15 | 16 | exec "$@" 17 | -------------------------------------------------------------------------------- /t/buildsystems/parallel.mk: -------------------------------------------------------------------------------- 1 | all: FIRST SECOND 2 | 3 | TMPFILE ?= $(CURDIR)/parallel.mk.lock 4 | 5 | rmtmpfile: 6 | @rm -f "$(TMPFILE)" 7 | 8 | FIRST: rmtmpfile 9 | @c=0; \ 10 | while [ $$c -le 5 ] && \ 11 | ([ ! -e "$(TMPFILE)" ] || [ "`cat "$(TMPFILE)"`" != "SECOND" ]); do \ 12 | c=$$(($$c+1)); \ 13 | sleep 0.1; \ 14 | done; \ 15 | rm -f "$(TMPFILE)"; \ 16 | if [ $$c -gt 5 ]; then exit 10; else exit 0; fi 17 | 18 | SECOND: rmtmpfile 19 | @echo $@ > "$(TMPFILE)" 20 | 21 | .PHONY: all FIRST SECOND rmtmpfile 22 | -------------------------------------------------------------------------------- /man/po4a/add.fr: -------------------------------------------------------------------------------- 1 | PO4A-HEADER:mode=after;position=AUTEUR;beginboundary=\=head1 2 | 3 | =head1 TRADUCTION 4 | 5 | Cette traduction est maintenue à l'aide de l'outil po4a 6 | par l'équipe francophone de traduction 7 | de Debian. 8 | 9 | Veuillez signaler toute erreur de traduction en écrivant à 10 | ou par un rapport de bogue sur le paquet 11 | debhelper. 12 | 13 | Vous pouvez toujours avoir accès à la version anglaise de ce document en 14 | utilisant la commande « man -L C
 ». 15 | 16 | =cut 17 | 18 | -------------------------------------------------------------------------------- /man/po4a/add.de: -------------------------------------------------------------------------------- 1 | PO4A-HEADER:mode=after;position=SIEHE\ AUCH;beginboundary=\=head1 2 | 3 | =head1 ÜBERSETZUNG 4 | 5 | Diese Übersetzung wurde mit dem Werkzeug 6 | B 7 | L 8 | durch Chris Leick 9 | I 10 | und das deutsche Debian-Übersetzer-Team im 11 | Dezember 2011 erstellt. 12 | 13 | 14 | Bitte melden Sie alle Fehler in der Übersetzung an 15 | I 16 | oder als Fehlerbericht an das Paket 17 | I. 18 | 19 | Sie können mit dem folgenden Befehl das englische 20 | Original anzeigen 21 | S 22 | 23 | =cut 24 | -------------------------------------------------------------------------------- /t/Dh_Lib/path.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | use Test::More; 6 | 7 | use Cwd qw(abs_path); 8 | use File::Basename qw(dirname); 9 | use File::Temp qw(tempdir); 10 | 11 | BEGIN { 12 | my $dir = dirname(abs_path(__FILE__)); 13 | unshift(@INC, dirname($dir)); 14 | chdir($dir) or error("chdir($dir) failed: $!"); 15 | }; 16 | 17 | use Test::DH; 18 | use Debian::Debhelper::Dh_Lib qw(!dirname); 19 | 20 | plan(tests => 3); 21 | 22 | ok(!is_empty_dir(__FILE__), "is_empty_dir(file) is false"); 23 | ok(!is_empty_dir(dirname(__FILE__)), "is_empty_dir(non-empty) is false"); 24 | 25 | my $tempdir = tempdir(CLEANUP => 1); 26 | ok(is_empty_dir($tempdir), "is_empty_dir(new-temp-dir) is true"); 27 | -------------------------------------------------------------------------------- /lib/Debian/Debhelper/Sequence/systemd.pm: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use warnings; 3 | use strict; 4 | use Debian::Debhelper::Dh_Lib qw(compat error); 5 | 6 | if (not compat(10)) { 7 | error("The systemd-sequence is no longer provided in compat >= 11, please rely on dh_installsystemd instead"); 8 | } 9 | 10 | 11 | # dh_systemd_enable runs unconditionally, and before dh_installinit, so that 12 | # the latter can use invoke-rc.d and all symlinks are already in place. 13 | insert_before("dh_installinit", "dh_systemd_enable"); 14 | 15 | # dh_systemd_start handles the case where there is no corresponding init 16 | # script, so it runs after dh_installinit. 17 | insert_after("dh_installinit", "dh_systemd_start"); 18 | 19 | 1 20 | -------------------------------------------------------------------------------- /debian/gen-provides: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | use Debian::Debhelper::Dh_Lib qw(error); 6 | 7 | my @provides; 8 | my $lowest = Debian::Debhelper::Dh_Lib::LOWEST_VIRTUAL_DEBHELPER_COMPAT_LEVEL 9 | // error("LOWEST_VIRTUAL_DEBHELPER_COMPAT_LEVEL is undef"); 10 | my $highest = Debian::Debhelper::Dh_Lib::HIGHEST_STABLE_COMPAT_LEVEL 11 | // error("HIGHEST_STABLE_COMPAT_LEVEL is undef"); 12 | 13 | if ($highest < $lowest) { 14 | error("HIGHEST_STABLE_COMPAT_LEVEL is lower than LOWEST_VIRTUAL_DEBHELPER_COMPAT_LEVEL"); 15 | } 16 | 17 | for (my $i = $lowest ; $i <= $highest ; $i++) { 18 | push(@provides, "debhelper-compat (= $i)"); 19 | } 20 | print "dh:CompatLevels=" . join(", ", @provides) . "\n"; 21 | 22 | -------------------------------------------------------------------------------- /autoscripts/postinst-systemd-dont-enable: -------------------------------------------------------------------------------- 1 | if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then 2 | if deb-systemd-helper debian-installed #UNITFILE#; then 3 | # This will only remove masks created by d-s-h on package removal. 4 | deb-systemd-helper unmask #UNITFILE# >/dev/null || true 5 | 6 | if deb-systemd-helper --quiet was-enabled #UNITFILE#; then 7 | # Create new symlinks, if any. 8 | deb-systemd-helper enable #UNITFILE# >/dev/null || true 9 | fi 10 | fi 11 | 12 | # Update the statefile to add new symlinks (if any), which need to be cleaned 13 | # up on purge. Also remove old symlinks. 14 | deb-systemd-helper update-state #UNITFILE# >/dev/null || true 15 | fi 16 | -------------------------------------------------------------------------------- /t/dh_missing/01-no-missing.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use warnings; 4 | use Test::More; 5 | 6 | use File::Basename qw(dirname); 7 | use lib dirname(dirname(__FILE__)); 8 | use Test::DH; 9 | 10 | our $TEST_DH_FIXTURE_DIR = 'template'; 11 | our @TEST_DH_EXTRA_TEMPLATE_FILES = (qw( 12 | debian/changelog 13 | debian/control 14 | debian/foo.install 15 | file-for-foo 16 | Makefile 17 | )); 18 | 19 | plan(tests => 1); 20 | 21 | each_compat_subtest { 22 | # Verify dh_missing does not fail when all files are installed. 23 | ok(run_dh_tool('dh_clean')); 24 | is(system('make', 'install'), 0); 25 | ok(run_dh_tool('dh_install', '--sourcedir', 'debian/tmp')); 26 | ok(run_dh_tool('dh_missing', '--fail-missing'), 'dh_missing failed'); 27 | }; 28 | 29 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | tests-stable-backports: 2 | stage: test 3 | image: debian:stable-backports 4 | script: 5 | - apt-get update 6 | - apt-get build-dep -y . 7 | - dpkg-buildpackage -us -uc -tc 8 | 9 | tests-testing: 10 | stage: test 11 | image: debian:testing 12 | script: 13 | - apt-get update 14 | - apt-get build-dep -y . 15 | - dpkg-buildpackage -us -uc -tc 16 | 17 | tests-unstable-all: 18 | stage: test 19 | image: debian:unstable 20 | script: 21 | - apt-get update 22 | - apt-get build-dep -y -Ppkg.debhelper.ci . 23 | - dpkg-buildpackage -us -uc -tc 24 | 25 | tests-unstable: 26 | stage: test 27 | image: debian:unstable 28 | script: 29 | - apt-get update 30 | - apt-get build-dep -y . 31 | - dpkg-buildpackage -us -uc -tc 32 | -------------------------------------------------------------------------------- /autoscripts/postinst-systemd-user-dont-enable: -------------------------------------------------------------------------------- 1 | if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then 2 | if deb-systemd-helper --user debian-installed #UNITFILE# ; then 3 | # This will only remove masks created by d-s-h on package removal. 4 | deb-systemd-helper --user unmask #UNITFILE# >/dev/null || true 5 | 6 | if deb-systemd-helper --quiet --user was-enabled #UNITFILE# ; then 7 | # Create new symlinks, if any. 8 | deb-systemd-helper --user enable #UNITFILE# >/dev/null || true 9 | fi 10 | fi 11 | 12 | # Update the statefile to add new symlinks (if any), which need to be cleaned 13 | # up on purge. Also remove old symlinks. 14 | deb-systemd-helper --user update-state #UNITFILE# >/dev/null || true 15 | fi 16 | -------------------------------------------------------------------------------- /autoscripts/postinst-usrlocal: -------------------------------------------------------------------------------- 1 | if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ]; then 2 | ( 3 | default_mode=0755 4 | default_user=root 5 | default_group=root 6 | if [ -e /etc/staff-group-for-usr-local ]; then 7 | default_mode=02775 8 | default_group=staff 9 | fi 10 | while read line; do 11 | set -- $line 12 | dir="$1"; mode="$2"; user="$3"; group="$4" 13 | if [ "$mode" = "default" ]; then 14 | mode="$default_mode" 15 | user="$default_user" 16 | group="$default_group" 17 | fi 18 | if [ ! -e "$dir" ]; then 19 | if mkdir "$dir" 2>/dev/null; then 20 | if chown "$user":"$group" "$dir" ; then 21 | chmod "$mode" "$dir" || true 22 | fi 23 | fi 24 | fi 25 | done 26 | ) << DATA 27 | #DIRS# 28 | DATA 29 | fi 30 | -------------------------------------------------------------------------------- /t/dh_install/03-866570-dont-install-from-host.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use warnings; 4 | use Test::More; 5 | 6 | use File::Basename qw(dirname); 7 | use lib dirname(dirname(__FILE__)); 8 | use Test::DH; 9 | use File::Path qw(remove_tree make_path); 10 | use Debian::Debhelper::Dh_Lib qw(!dirname); 11 | 12 | plan(tests => 1); 13 | 14 | each_compat_subtest { 15 | my ($compat) = @_; 16 | # #866570 - leading slashes must *not* pull things from the root FS. 17 | make_path('bin'); 18 | create_empty_file('bin/grep-i-licious'); 19 | ok(run_dh_tool('dh_install', '/bin/grep*')); 20 | ok(-e "debian/debhelper/bin/grep-i-licious", "#866570 [${compat}]"); 21 | ok(!-e "debian/debhelper/bin/grep", "#866570 [${compat}]"); 22 | remove_tree('debian/debhelper', 'debian/tmp'); 23 | }; 24 | 25 | -------------------------------------------------------------------------------- /t/syntax/syntax-progs.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use warnings; 4 | use Test::More; 5 | 6 | use File::Basename qw(dirname); 7 | use lib dirname(dirname(__FILE__)); 8 | # Need Test::More to set PERL5LIB 9 | use Test::DH; 10 | 11 | use Config; 12 | my $binpath = $ENV{AUTOPKGTEST_TMP} ? '/usr/bin' : '.'; 13 | my $libpath = $ENV{AUTOPKGTEST_TMP} ? $Config{vendorlib} : 'lib'; 14 | 15 | my @targets; 16 | if ($0 =~ m{syntax-progs\.t$}) { 17 | @targets = grep { -x $_ } glob("$binpath/dh_*"), "$binpath/dh"; 18 | } else { 19 | @targets = (glob("$libpath/Debian/Debhelper/*.pm"), glob("$libpath/Debian/Debhelper/*/*.pm")); 20 | } 21 | 22 | plan(tests => scalar(@targets)); 23 | 24 | foreach my $file (@targets) { 25 | is(system("perl -c $file >/dev/null 2>&1"), 0) 26 | or diag("$file failed syntax check"); 27 | } 28 | 29 | -------------------------------------------------------------------------------- /autoscripts/postinst-systemd-enable: -------------------------------------------------------------------------------- 1 | if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then 2 | # This will only remove masks created by d-s-h on package removal. 3 | deb-systemd-helper unmask #UNITFILE# >/dev/null || true 4 | 5 | # was-enabled defaults to true, so new installations run enable. 6 | if deb-systemd-helper --quiet was-enabled #UNITFILE#; then 7 | # Enables the unit on first installation, creates new 8 | # symlinks on upgrades if the unit file has changed. 9 | deb-systemd-helper enable #UNITFILE# >/dev/null || true 10 | else 11 | # Update the statefile to add new symlinks (if any), which need to be 12 | # cleaned up on purge. Also remove old symlinks. 13 | deb-systemd-helper update-state #UNITFILE# >/dev/null || true 14 | fi 15 | fi 16 | -------------------------------------------------------------------------------- /autoscripts/postinst-systemd-user-enable: -------------------------------------------------------------------------------- 1 | if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then 2 | # This will only remove masks created by d-s-h on package removal. 3 | deb-systemd-helper --user unmask #UNITFILE# >/dev/null || true 4 | 5 | # was-enabled defaults to true, so new installations run enable. 6 | if deb-systemd-helper --quiet --user was-enabled #UNITFILE# ; then 7 | # Enables the unit on first installation, creates new 8 | # symlinks on upgrades if the unit file has changed. 9 | deb-systemd-helper --user enable #UNITFILE# >/dev/null || true 10 | else 11 | # Update the statefile to add new symlinks (if any), which need to be 12 | # cleaned up on purge. Also remove old symlinks. 13 | deb-systemd-helper --user update-state #UNITFILE# >/dev/null || true 14 | fi 15 | fi 16 | -------------------------------------------------------------------------------- /doc/SUPPORT-POLICY: -------------------------------------------------------------------------------- 1 | SUPPORT POLICY FOR DEBHELPER COMPAT LEVELS 2 | ========================================== 3 | 4 | The current policy for supporting compat levels is: 5 | 6 | * A compat level may be deprecated once the latest oldoldstable release 7 | supports a /newer/ compat level. (E.g. compat 9 can be deprecated once 8 | jessie becomes oldoldstable). 9 | 10 | * Alternatively, a compat level may be deprecated if a debhelper version 11 | supporting a newer compat level is backported to oldoldstable-backports/ 12 | oldoldstable-backports-sloppy and the oldest supported Ubuntu LTS release. 13 | 14 | * These rules are independent of whether Debian oldoldstable is still 15 | supported. 16 | 17 | * Deprecated compat levels may be removed in unstable once it as been released 18 | in Debian stable as deprecated (provided that the deprecation has been 19 | announced at least one year prior to the freeze of said stable release). 20 | 21 | -------------------------------------------------------------------------------- /t/dh_missing/03-dh_install-redirection.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use warnings; 4 | use Test::More; 5 | 6 | use File::Basename qw(dirname); 7 | use lib dirname(dirname(__FILE__)); 8 | use Test::DH; 9 | 10 | our $TEST_DH_FIXTURE_DIR = 'template'; 11 | our @TEST_DH_EXTRA_TEMPLATE_FILES = (qw( 12 | debian/changelog 13 | debian/control 14 | debian/foo.install 15 | file-for-foo 16 | Makefile 17 | )); 18 | 19 | plan(tests => 1); 20 | 21 | each_compat_up_to_and_incl_subtest(10, sub { 22 | # Verify that dh_install -X --fail-missing is passed through to dh_missing (#863447) 23 | # dh_install -Xfile makes file-for-foo not be installed. Then we shouldn't 24 | # complain about it not being missing. 25 | ok(run_dh_tool('dh_clean')); 26 | is(system('make', 'install'), 0); 27 | ok(run_dh_tool({ 'quiet' => 1 }, 'dh_install', '--sourcedir', 'debian/tmp', 28 | '-X', 'more', '--exclude', 'lots', '--fail-missing')); 29 | }); 30 | 31 | -------------------------------------------------------------------------------- /t/dh_link/02-346405.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use Test::More; 7 | plan(tests => 1); 8 | 9 | use File::Path qw(remove_tree); 10 | use File::Basename qw(dirname); 11 | use lib dirname(dirname(__FILE__)); 12 | use Test::DH; 13 | 14 | each_compat_subtest { 15 | 16 | remove_tree('debian/debhelper'); 17 | 18 | # Check links to the current directory and below, they used to be 19 | # unnecessarily long (#346405). 20 | ok(run_dh_tool('dh_link', 'usr/lib/geant4', 'usr/lib/geant4/a')); 21 | ok(readlink("debian/debhelper/usr/lib/geant4/a"), "."); 22 | ok(run_dh_tool('dh_link', 'usr/lib', 'usr/lib/geant4/b')); 23 | ok(readlink("debian/debhelper/usr/lib/geant4/b"), ".."); 24 | ok(run_dh_tool('dh_link', 'usr', 'usr/lib/geant4/c')); 25 | ok(readlink("debian/debhelper/usr/lib/geant4/c"), "../.."); 26 | ok(run_dh_tool('dh_link', '/', 'usr/lib/geant4/d')); 27 | ok(readlink("debian/debhelper/usr/lib/geant4/d"), "/"); 28 | }; 29 | 30 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # If you're looking for an example debian/rules that uses debhelper, see 3 | # the examples directory. 4 | # 5 | # Each debhelper command in this rules file has to be run using ./run, 6 | # to ensure that the commands and libraries in the source tree are used, 7 | # rather than the installed ones. 8 | # 9 | # We disable autoreconf to avoid build-depending on it (it does 10 | # nothing for debhelper and it keeps the set of B-D smaller) 11 | 12 | PERL ?= perl 13 | 14 | %: 15 | ./run dh $@ --without autoreconf --with build-stamp 16 | 17 | # Disable as they are unneeded (and we can then be sure debhelper 18 | # builds without needing autotools-dev, dh-strip-nondetermism etc.) 19 | override_dh_update_autotools_config override_dh_strip_nondeterminism: 20 | 21 | execute_before_dh_install: 22 | PERLLIBDIR=$$($(PERL) -MConfig -e 'print $$Config{vendorlib}')/ ; \ 23 | $(PERL) -I"debian/tmp/$${PERLLIBDIR}" debian/gen-provides > debian/debhelper.substvars 24 | -------------------------------------------------------------------------------- /t/size.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # This may appear arbitrary, but DO NOT CHANGE IT. 3 | # Debhelper is supposed to consist of small, simple, easy to understand 4 | # programs. Programs growing in size and complexity without bounds is a 5 | # bug. 6 | use strict; 7 | use warnings; 8 | use Test::More; 9 | 10 | my $binpath = $ENV{AUTOPKGTEST_TMP} ? '/usr/bin' : '.'; 11 | my @progs=grep { -x $_ } glob("$binpath/dh_*"); 12 | 13 | plan(tests => (@progs + @progs)); 14 | 15 | foreach my $file (@progs) { 16 | 17 | my $lines=0; 18 | my $maxlength=0; 19 | open(my $fd, '<', $file) || die "open($file): $!"; 20 | my $cutting=0; 21 | while (<$fd>) { 22 | $cutting=1 if /^=/; 23 | $cutting=0 if /^=cut/; 24 | next if $cutting || /^(?:=|\s*(?:\#.*|[}]\s*)?$)/; 25 | $lines++; 26 | $maxlength=length($_) if length($_) > $maxlength; 27 | } 28 | close($fd); 29 | print "# $file has $lines lines, max length is $maxlength\n"; 30 | ok($lines < 200, $file); 31 | ok($maxlength < 160, $file); 32 | } 33 | -------------------------------------------------------------------------------- /t/dh_missing/02-fail-on-missing.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use warnings; 4 | use Test::More; 5 | 6 | use File::Basename qw(dirname); 7 | use lib dirname(dirname(__FILE__)); 8 | use Test::DH; 9 | 10 | our $TEST_DH_FIXTURE_DIR = 'template'; 11 | our @TEST_DH_EXTRA_TEMPLATE_FILES = (qw( 12 | debian/changelog 13 | debian/control 14 | debian/foo.install 15 | file-for-foo 16 | Makefile 17 | )); 18 | 19 | plan(tests => 1); 20 | 21 | each_compat_subtest { 22 | # Verify dh_missing does fail when not all files are installed. 23 | ok(run_dh_tool('dh_clean')); 24 | is(system('make', 'installmore'), 0); 25 | ok(run_dh_tool('dh_install', '--sourcedir', 'debian/tmp')); 26 | ok(!run_dh_tool({ 'quiet' => 1 }, 'dh_missing', '--fail-missing')); 27 | 28 | isnt($?, -1, 'dh_missing was executed'); 29 | ok(! ($? & 127), 'dh_missing did not die due to a signal'); 30 | my $exitcode = ($? >> 8); 31 | is($exitcode, 255, 'dh_missing exited with exit code 255'); 32 | }; 33 | 34 | -------------------------------------------------------------------------------- /t/override_target.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use warnings; 4 | use Test::More; 5 | plan(tests => 1); 6 | 7 | # This test is here to detect breakage in 8 | # dh's rules_explicit_target, which parses 9 | # slightly internal make output. 10 | system("mkdir -p t/tmp/debian"); 11 | system("cp debian/control debian/compat debian/changelog t/tmp/debian"); 12 | open (OUT, ">", "t/tmp/debian/rules") || die "$!"; 13 | my $binpath = $ENV{AUTOPKGTEST_TMP} ? '/usr/bin' : '../..'; 14 | print OUT <&1`; 27 | ok(grep { m/override called/ } @output) or do { 28 | diag($_) for @output; 29 | }; 30 | system("rm -rf t/tmp"); 31 | -------------------------------------------------------------------------------- /doc/TODO: -------------------------------------------------------------------------------- 1 | v10: 2 | 3 | * escaping in config files (for whitespace)? 4 | 5 | Deprecated: 6 | 7 | * dh_installmanpages. 8 | * dh_movefiles. I won't hold my breath. Have not added deprecation 9 | docs or message yet. 10 | * dh_installinit --init-script (make it warn) 11 | * dh_clean -k 12 | * -s flag, not formally deprecated yet; remove eventually 13 | * -u flag; add a warning on use and remove eventually 14 | * delsubstvar() and the last parameter to addsubstvar that makes it remove 15 | a string are not used in debhelper itself, but have been left in the 16 | library in case other things use them. Deprecate and remove. 17 | * debian/compress files 18 | * deprecate dh_gconf for dh_installgsettings (stuff should be migrating 19 | away from gconf, and then I can just remove it -- have not added warning 20 | or depreaction docs yet) 21 | 22 | Also, grep the entire archive for all dh_* command lines, 23 | and check to see what other switches are not being used, and maybe remove 24 | some of them. 25 | -------------------------------------------------------------------------------- /dh_listpackages: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | =head1 NAME 4 | 5 | dh_listpackages - list binary packages debhelper will act on 6 | 7 | =cut 8 | 9 | use strict; 10 | use warnings; 11 | use Debian::Debhelper::Dh_Lib; 12 | 13 | our $VERSION = DH_BUILTIN_VERSION; 14 | 15 | =head1 SYNOPSIS 16 | 17 | B [S>] 18 | 19 | =head1 DESCRIPTION 20 | 21 | B is a debhelper program that outputs a list of all binary 22 | packages debhelper commands will act on. If you pass it some options, it 23 | will change the list to match the packages other debhelper commands would 24 | act on if passed the same options. 25 | 26 | Packages are listed in the order they appear in F. 27 | 28 | =cut 29 | 30 | $dh{BLOCK_NOOP_WARNINGS}=1; 31 | init(inhibit_log => 1); 32 | print join("\n",@{$dh{DOPACKAGES}})."\n"; 33 | 34 | =head1 SEE ALSO 35 | 36 | L 37 | 38 | This program is a part of debhelper. 39 | 40 | =head1 AUTHOR 41 | 42 | Joey Hess 43 | 44 | =cut 45 | -------------------------------------------------------------------------------- /t/dh_install/01-basics.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use warnings; 4 | use Test::More; 5 | 6 | use File::Basename qw(dirname); 7 | use lib dirname(dirname(__FILE__)); 8 | use Test::DH; 9 | use File::Path qw(remove_tree make_path); 10 | use Debian::Debhelper::Dh_Lib qw(!dirname); 11 | 12 | plan(tests => 2); 13 | 14 | 15 | each_compat_subtest { 16 | my ($compat) = @_; 17 | # regular specification of file not in debian/tmp 18 | create_empty_file('dh_install'); 19 | ok(run_dh_tool('dh_install', 'dh_install', 'usr/bin')); 20 | ok(-e "debian/debhelper/usr/bin/dh_install"); 21 | remove_tree('debian/debhelper', 'debian/tmp'); 22 | }; 23 | 24 | each_compat_subtest { 25 | my ($compat) = @_; 26 | # specification of file in subdir, not in debian/tmp 27 | make_path('bar/usr/bin'); 28 | create_empty_file('bar/usr/bin/foo'); 29 | ok(run_dh_tool('dh_install', 'bar/usr/bin/foo')); 30 | ok(-e "debian/debhelper/bar/usr/bin/foo"); 31 | remove_tree('debian/debhelper', 'debian/tmp'); 32 | }; 33 | 34 | -------------------------------------------------------------------------------- /lib/Debian/Debhelper/DH/SequenceState.pm: -------------------------------------------------------------------------------- 1 | # Defines dh sequence state variables 2 | # 3 | # License: GPL-2+ 4 | 5 | package Debian::Debhelper::DH::SequenceState; 6 | use strict; 7 | use warnings; 8 | 9 | our ( 10 | # Definitions of sequences. 11 | %sequences, 12 | # Additional command options 13 | %command_opts, 14 | # Track commands added by (which) addons 15 | %commands_added_by_addon, 16 | # Removed commands 17 | %obsolete_command, 18 | # Commands that can be skipped due to DEB_BUILD_OPTIONS=X flags 19 | %commands_skippable_via_deb_build_options, 20 | # Options passed that should be passed on to underlying helpers (in order) 21 | @options, 22 | # Options passed by name (to assist can_skip with which options are used) 23 | %seen_options, 24 | # Whether there were sequences of options that inhibit certain optimizations 25 | # * $unoptimizable_option_bundle => can skip iff cli-options hint is present and empty 26 | # * $unoptimizable_user_option => We can never skip anything (non-option seen) 27 | $unoptimizable_option_bundle, 28 | $unoptimizable_user_option, 29 | ); 30 | 31 | 1; 32 | -------------------------------------------------------------------------------- /t/dh_installdocs/01-868204-ignore-broken-symlinks.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use warnings; 4 | use Test::More; 5 | 6 | use File::Basename qw(dirname); 7 | use lib dirname(dirname(__FILE__)); 8 | use Test::DH; 9 | use File::Path qw(remove_tree make_path); 10 | use Debian::Debhelper::Dh_Lib qw(!dirname); 11 | 12 | plan(tests => 1); 13 | 14 | each_compat_subtest { 15 | my ($compat) = @_; 16 | # #868204 - dh_installdocs did not replace dangling symlink 17 | make_path('debian/debhelper/usr/share/doc/debhelper'); 18 | make_symlink_raw_target('../to/nowhere/bar', 19 | 'debian/debhelper/usr/share/doc/debhelper/README.Debian'); 20 | create_empty_file('debian/README.Debian'); 21 | 22 | ok(-l 'debian/debhelper/usr/share/doc/debhelper/README.Debian'); 23 | ok(!-e 'debian/debhelper/usr/share/doc/debhelper/README.Debian'); 24 | 25 | ok(run_dh_tool('dh_installdocs')); 26 | ok(!-l 'debian/debhelper/usr/share/doc/debhelper/README.Debian', "#868204 [${compat}]"); 27 | ok(-f 'debian/debhelper/usr/share/doc/debhelper/README.Debian', "#868204 [${compat}]"); 28 | remove_tree('debian/debhelper', 'debian/tmp'); 29 | }; 30 | 31 | -------------------------------------------------------------------------------- /t/dh_missing/04-not-installed-glob.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use warnings; 4 | use Test::More; 5 | 6 | use File::Basename qw(dirname); 7 | use lib dirname(dirname(__FILE__)); 8 | use Test::DH; 9 | use Debian::Debhelper::Dh_Lib qw(!dirname); 10 | 11 | our $TEST_DH_FIXTURE_DIR = 'template'; 12 | our @TEST_DH_EXTRA_TEMPLATE_FILES = (qw( 13 | debian/changelog 14 | debian/control 15 | debian/foo.install 16 | file-for-foo 17 | Makefile 18 | )); 19 | 20 | plan(tests => 1); 21 | 22 | each_compat_subtest { 23 | rm_files('debian/not-installed'); 24 | open(my $fd, '>', 'debian/not-installed') or error("open(d/not-installed): $!"); 25 | # Non-glob match 26 | print {$fd} "usr/bin/file-for-foo\n"; 27 | # Glob match (note that it must not match the above) 28 | print {$fd} "usr/bin/file-for-foo-*\n"; 29 | # Non-matches (silently ignored) 30 | print {$fd} "usr/bin/does-not-exist\n"; 31 | print {$fd} "usr/bin/does-not-exist-*\n"; 32 | close($fd) or error("close(d/not-installed: $!"); 33 | ok(run_dh_tool('dh_clean')); 34 | is(system('make', 'installmore'), 0); 35 | ok(run_dh_tool('dh_missing', '--fail-missing')); 36 | }; 37 | 38 | -------------------------------------------------------------------------------- /t/Dh_Lib/control-parsing.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | use Test::More; 6 | 7 | use Cwd qw(abs_path); 8 | use File::Basename qw(dirname); 9 | 10 | BEGIN { 11 | my $dir = dirname(abs_path(__FILE__)); 12 | unshift(@INC, dirname($dir)); 13 | chdir($dir) or error("chdir($dir) failed: $!"); 14 | }; 15 | 16 | use Test::DH; 17 | 18 | use Debian::Debhelper::Dh_Lib qw(!dirname); 19 | 20 | plan(tests => 10); 21 | 22 | is_deeply([getpackages()], [qw(foo-any foo-all)], 'packages list correct and in order'); 23 | is_deeply([getpackages('both')], [qw(foo-any foo-all)], 'packages list correct and in order'); 24 | is_deeply([getpackages('arch')], [qw(foo-any)], 'arch:linux-any'); 25 | is_deeply([getpackages('indep')], [qw(foo-all)], 'arch:all'); 26 | 27 | 28 | is(package_section('foo-any'), 'devel', 'binary section'); 29 | is(package_section('foo-all'), 'misc', 'binary section (inherit from source)'); 30 | 31 | 32 | is(package_declared_arch('foo-any'), 'linux-any', 'binary architecture (linux-any'); 33 | is(package_declared_arch('foo-all'), 'all', 'binary architecture (all)'); 34 | 35 | ok(! package_is_arch_all('foo-any'), 'foo-any is not arch:all'); 36 | ok(package_is_arch_all('foo-all'), 'foo-all is arch:all'); 37 | -------------------------------------------------------------------------------- /lib/Debian/Debhelper/Buildsystem/ant.pm: -------------------------------------------------------------------------------- 1 | # A debhelper build system class for handling Ant based projects. 2 | # 3 | # Copyright: © 2009 Joey Hess 4 | # License: GPL-2+ 5 | 6 | package Debian::Debhelper::Buildsystem::ant; 7 | 8 | use strict; 9 | use warnings; 10 | use parent qw(Debian::Debhelper::Buildsystem); 11 | 12 | sub DESCRIPTION { 13 | "Ant (build.xml)" 14 | } 15 | 16 | sub check_auto_buildable { 17 | my $this=shift; 18 | return (-e $this->get_sourcepath("build.xml")) ? 1 : 0; 19 | } 20 | 21 | sub new { 22 | my $class=shift; 23 | my $this=$class->SUPER::new(@_); 24 | $this->enforce_in_source_building(); 25 | return $this; 26 | } 27 | 28 | sub build { 29 | my $this=shift; 30 | my $d_ant_prop = $this->get_sourcepath('debian/ant.properties'); 31 | my @args; 32 | if ( -f $d_ant_prop ) { 33 | push(@args, '-propertyfile', $d_ant_prop); 34 | } 35 | 36 | # Set the username to improve the reproducibility 37 | push(@args, "-Duser.name", "debian"); 38 | 39 | $this->doit_in_sourcedir("ant", @args, @_); 40 | } 41 | 42 | sub clean { 43 | my $this=shift; 44 | my $d_ant_prop = $this->get_sourcepath('debian/ant.properties'); 45 | my @args; 46 | if ( -f $d_ant_prop ) { 47 | push(@args, '-propertyfile', $d_ant_prop); 48 | } 49 | $this->doit_in_sourcedir("ant", @args, "clean", @_); 50 | } 51 | 52 | 1 53 | -------------------------------------------------------------------------------- /t/dh_installinit/dh_installinit.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use Test::More; 4 | 5 | use File::Basename qw(dirname); 6 | use lib dirname(dirname(__FILE__)); 7 | use Test::DH; 8 | use File::Path qw(remove_tree make_path); 9 | use Debian::Debhelper::Dh_Lib qw(!dirname); 10 | 11 | our @TEST_DH_EXTRA_TEMPLATE_FILES = (qw( 12 | debian/changelog 13 | debian/control 14 | debian/foo.service 15 | debian/bar.other.init 16 | )); 17 | 18 | plan(tests => 2); 19 | 20 | each_compat_up_to_and_incl_subtest(10, sub { 21 | make_path(qw(debian/foo debian/bar debian/baz)); 22 | ok(run_dh_tool('dh_installinit')); 23 | ok(-e "debian/foo/lib/systemd/system/foo.service"); 24 | ok(find_script('foo', 'postinst')); 25 | ok(run_dh_tool('dh_clean')); 26 | 27 | }); 28 | 29 | each_compat_from_and_above_subtest(11, sub { 30 | make_path(qw(debian/foo debian/bar debian/baz)); 31 | 32 | ok(run_dh_tool('dh_installinit')); 33 | ok(run_dh_tool({'quiet' => 1}, 'dh_installinit', '--name=other')); 34 | ok(! -e "debian/foo/lib/systemd/system/foo.service"); 35 | ok(!find_script('foo', 'postinst')); 36 | ok(run_dh_tool('dh_clean')); 37 | 38 | make_path(qw(debian/foo/lib/systemd/system/ debian/bar debian/baz)); 39 | install_file('debian/foo.service', 'debian/foo/lib/systemd/system/foo.service'); 40 | ok(run_dh_tool('dh_installinit')); 41 | ok(!find_script('foo', 'postinst')); 42 | ok(run_dh_tool('dh_clean')); 43 | }); 44 | 45 | -------------------------------------------------------------------------------- /dh_installlogrotate: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | =head1 NAME 4 | 5 | dh_installlogrotate - install logrotate config files 6 | 7 | =cut 8 | 9 | use strict; 10 | use warnings; 11 | use Debian::Debhelper::Dh_Lib; 12 | 13 | our $VERSION = DH_BUILTIN_VERSION; 14 | 15 | =head1 SYNOPSIS 16 | 17 | B [S>] [B<--name=>I] 18 | 19 | =head1 DESCRIPTION 20 | 21 | B is a debhelper program that is responsible for installing 22 | logrotate config files into F in package build directories. 23 | Files named F are installed. 24 | 25 | =head1 OPTIONS 26 | 27 | =over 4 28 | 29 | =item B<--name=>I 30 | 31 | Look for files named F and install them as 32 | F, instead of using the usual files and installing them 33 | as the package name. 34 | 35 | =back 36 | 37 | =cut 38 | 39 | init(); 40 | 41 | # PROMISE: DH NOOP WITHOUT logrotate cli-options() 42 | 43 | foreach my $package (@{$dh{DOPACKAGES}}) { 44 | my $tmp=tmpdir($package); 45 | my $file=pkgfile($package,"logrotate"); 46 | 47 | if ($file) { 48 | install_dir("$tmp/etc/logrotate.d"); 49 | install_file($file,"$tmp/etc/logrotate.d/".pkgfilename($package)); 50 | } 51 | } 52 | 53 | =head1 SEE ALSO 54 | 55 | L 56 | 57 | This program is a part of debhelper. 58 | 59 | =head1 AUTHOR 60 | 61 | Joey Hess 62 | 63 | =cut 64 | -------------------------------------------------------------------------------- /dh_installpam: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | =head1 NAME 4 | 5 | dh_installpam - install pam support files 6 | 7 | =cut 8 | 9 | use strict; 10 | use warnings; 11 | use Debian::Debhelper::Dh_Lib; 12 | 13 | our $VERSION = DH_BUILTIN_VERSION; 14 | 15 | =head1 SYNOPSIS 16 | 17 | B [S>] [B<--name=>I] 18 | 19 | =head1 DESCRIPTION 20 | 21 | B is a debhelper program that is responsible for installing 22 | files used by PAM into package build directories. 23 | 24 | =head1 FILES 25 | 26 | =over 4 27 | 28 | =item debian/I.pam 29 | 30 | Installed into etc/pam.d/I in the package build directory. 31 | 32 | =back 33 | 34 | =head1 OPTIONS 35 | 36 | =over 4 37 | 38 | =item B<--name=>I 39 | 40 | Look for files named debian/I.I.pam and install them as 41 | etc/pam.d/I, instead of using the usual files and installing them 42 | using the package name. 43 | 44 | =back 45 | 46 | =cut 47 | 48 | init(); 49 | 50 | # PROMISE: DH NOOP WITHOUT pam cli-options() 51 | 52 | foreach my $package (@{$dh{DOPACKAGES}}) { 53 | my $tmp=tmpdir($package); 54 | my $pam=pkgfile($package,"pam"); 55 | 56 | if ($pam ne '') { 57 | install_dir("$tmp/etc/pam.d"); 58 | install_file($pam,"$tmp/etc/pam.d/".pkgfilename($package)); 59 | } 60 | } 61 | 62 | =head1 SEE ALSO 63 | 64 | L 65 | 66 | This program is a part of debhelper. 67 | 68 | =head1 AUTHOR 69 | 70 | Joey Hess 71 | 72 | =cut 73 | -------------------------------------------------------------------------------- /t/dh_installgsettings/dh_installgsettings.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use Test::More tests => 1; 4 | 5 | use autodie; 6 | use File::Basename qw(dirname); 7 | use lib dirname(dirname(__FILE__)); 8 | use Test::DH; 9 | use File::Path qw(remove_tree make_path); 10 | use Debian::Debhelper::Dh_Lib qw(!dirname); 11 | 12 | our @TEST_DH_EXTRA_TEMPLATE_FILES = (qw( 13 | debian/changelog 14 | debian/control 15 | )); 16 | 17 | my $SCHEMAS = 'usr/share/glib-2.0/schemas'; 18 | 19 | sub touch { 20 | my $path = shift; 21 | open(my $fh, '>>', $path); 22 | close $fh; 23 | } 24 | 25 | sub slurp { 26 | my $path = shift; 27 | local $/ = undef; 28 | open(my $fh, '<', $path); 29 | my $contents = <$fh>; 30 | close $fh; 31 | return $contents; 32 | } 33 | 34 | each_compat_subtest { 35 | make_path("debian/has-settings/$SCHEMAS"); 36 | touch("debian/has-settings/$SCHEMAS/com.example.HasSettings.xml"); 37 | make_path("debian/has-unimportant-settings/$SCHEMAS"); 38 | touch("debian/no-settings.substvars"); 39 | ok(run_dh_tool('dh_installgsettings', '-phas-settings'), 'run for has-settings'); 40 | ok(run_dh_tool('dh_installgsettings', '-pno-settings'), 'run for no-settings'); 41 | remove_tree(qw(debian/has-settings debian/has-unimportant-settings)); 42 | like(slurp('debian/has-settings.substvars'), 43 | qr{^misc:Depends=dconf-gsettings-backend \| gsettings-backend$}m, 44 | 'has-settings should depend on a backend'); 45 | unlike(slurp('debian/no-settings.substvars'), 46 | qr{^misc:Depends=dconf-gsettings-backend \| gsettings-backend$}m, 47 | 'no-settings should not depend on a backend'); 48 | }; 49 | 50 | -------------------------------------------------------------------------------- /t/dh_link/03-894229.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use Test::More; 7 | plan(tests => 1); 8 | 9 | use File::Path qw(remove_tree); 10 | use File::Basename qw(dirname); 11 | use lib dirname(dirname(__FILE__)); 12 | use Debian::Debhelper::Dh_Lib qw(!dirname); 13 | use Test::DH; 14 | 15 | 16 | sub test_tricky { 17 | my ($link_name, $denoted_dest, $expected_link_target) = @_; 18 | my $tmpdir = 'debian/debhelper'; 19 | my $link_path = "${tmpdir}/${link_name}"; 20 | 21 | make_symlink($link_name, $denoted_dest, $tmpdir); 22 | if (ok(-l $link_path, 'Link made in correct directory')) { 23 | my $target = readlink($link_path); 24 | is($target, $expected_link_target, 'Link points correctly') 25 | or diag("Expected ${expected_link_target}, actual ${target}"); 26 | rm_files($link_path); 27 | } 28 | return; 29 | } 30 | 31 | sub test_invalid { 32 | my ($link_name, $denoted_dest) = @_; 33 | eval { 34 | make_symlink($link_name, $denoted_dest); 35 | }; 36 | like($@, qr{^(?:\S*:(?: error:)?\s*)?Invalid destination/link name}); 37 | } 38 | 39 | each_compat_subtest { 40 | 41 | remove_tree('debian/debhelper/a/b/c'); 42 | 43 | install_dir('debian/debhelper/a/b/c'); 44 | 45 | test_invalid('../../wow', 'a'); 46 | # This is a can be made valid but at the moment we do not support 47 | # it. 48 | test_invalid('a/b/../link21', 'a'); 49 | 50 | 51 | test_tricky('//a/b/link03', 'a/b/c', 'c'); 52 | test_tricky('./a/link18', 'a', '.'); 53 | test_tricky('a/./b/link19', 'a/b', '.'); 54 | }; 55 | 56 | -------------------------------------------------------------------------------- /dh_lintian: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | =head1 NAME 4 | 5 | dh_lintian - install lintian override files into package build directories 6 | 7 | =cut 8 | 9 | use strict; 10 | use warnings; 11 | use Debian::Debhelper::Dh_Lib; 12 | 13 | our $VERSION = DH_BUILTIN_VERSION; 14 | 15 | =head1 SYNOPSIS 16 | 17 | B [S>] 18 | 19 | =head1 DESCRIPTION 20 | 21 | B is a debhelper program that is responsible for installing 22 | override files used by lintian into package build directories. 23 | 24 | =head1 FILES 25 | 26 | =over 4 27 | 28 | =item debian/I.lintian-overrides 29 | 30 | Installed into usr/share/lintian/overrides/I in the package 31 | build directory. This file is used to suppress erroneous lintian 32 | diagnostics. 33 | 34 | =item F 35 | 36 | These files are not installed, but will be scanned by lintian to provide 37 | overrides for the source package. 38 | 39 | =back 40 | 41 | =cut 42 | 43 | init(); 44 | 45 | # PROMISE: DH NOOP WITHOUT lintian-overrides cli-options() 46 | 47 | foreach my $package (@{$dh{DOPACKAGES}}) { 48 | next if is_udeb($package); 49 | 50 | my $tmp=tmpdir($package); 51 | my $or_dir = "$tmp/usr/share/lintian/overrides"; 52 | my $overrides=pkgfile($package,"lintian-overrides"); 53 | 54 | if ($overrides ne '') { 55 | install_dir($or_dir); 56 | install_dh_config_file($overrides, "$or_dir/$package"); 57 | } 58 | } 59 | 60 | =head1 SEE ALSO 61 | 62 | L 63 | 64 | This program is a part of debhelper. 65 | 66 | L 67 | 68 | =head1 AUTHOR 69 | 70 | Steve Robbins 71 | 72 | =cut 73 | -------------------------------------------------------------------------------- /dh_testdir: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | =head1 NAME 4 | 5 | dh_testdir - test directory before building Debian package 6 | 7 | =cut 8 | 9 | use strict; 10 | use warnings; 11 | use Debian::Debhelper::Dh_Lib; 12 | 13 | our $VERSION = DH_BUILTIN_VERSION; 14 | 15 | =head1 SYNOPSIS 16 | 17 | B [S>] [S ...>] 18 | 19 | =head1 DESCRIPTION 20 | 21 | B tries to make sure that you are in the correct directory when 22 | building a Debian package. It makes sure that the file F 23 | exists, as well as any other files you specify. If not, 24 | it exits with an error. 25 | 26 | =head1 OPTIONS 27 | 28 | =over 4 29 | 30 | =item I ... 31 | 32 | Test for the existence of these files too. 33 | 34 | =back 35 | 36 | =cut 37 | 38 | # This command is completely useless when called from dh(1) as dh will 39 | # have attempted to read d/control before it even constructs the 40 | # command sequences. Accordingly, there is no doubt that the 41 | # following is unconditionally true: 42 | # 43 | # PROMISE: DH NOOP 44 | 45 | # Run before init because init will try to read debian/control and 46 | # we want a nicer error message. 47 | checkfile('debian/control'); 48 | 49 | init(inhibit_log => 1); 50 | 51 | foreach my $file (@ARGV) { 52 | checkfile($file); 53 | } 54 | 55 | sub checkfile { 56 | my $file=shift; 57 | if (! -e $file) { 58 | error("\"$file\" not found. Are you sure you are in the correct directory?"); 59 | } 60 | } 61 | 62 | =head1 SEE ALSO 63 | 64 | L 65 | 66 | This program is a part of debhelper. 67 | 68 | =head1 AUTHOR 69 | 70 | Joey Hess 71 | 72 | =cut 73 | -------------------------------------------------------------------------------- /dh_installmime: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | =head1 NAME 4 | 5 | dh_installmime - install mime files into package build directories 6 | 7 | =cut 8 | 9 | use strict; 10 | use warnings; 11 | use Debian::Debhelper::Dh_Lib; 12 | 13 | our $VERSION = DH_BUILTIN_VERSION; 14 | 15 | =head1 SYNOPSIS 16 | 17 | B [S>] 18 | 19 | =head1 DESCRIPTION 20 | 21 | B is a debhelper program that is responsible for installing 22 | mime files into package build directories. 23 | 24 | =head1 FILES 25 | 26 | =over 4 27 | 28 | =item debian/I.mime 29 | 30 | Installed into usr/lib/mime/packages/I in the package build 31 | directory. 32 | 33 | =item debian/I.sharedmimeinfo 34 | 35 | Installed into /usr/share/mime/packages/I.xml in the package build 36 | directory. 37 | 38 | =back 39 | 40 | =cut 41 | 42 | init(); 43 | 44 | # PROMISE: DH NOOP WITHOUT mime sharedmimeinfo cli-options() 45 | 46 | foreach my $package (@{$dh{DOPACKAGES}}) { 47 | my $tmp=tmpdir($package); 48 | 49 | my $mime=pkgfile($package,"mime"); 50 | if ($mime ne '') { 51 | install_dir("$tmp/usr/lib/mime/packages"); 52 | install_file($mime, "$tmp/usr/lib/mime/packages/$package"); 53 | } 54 | 55 | my $sharedmimeinfo=pkgfile($package,"sharedmimeinfo"); 56 | if ($sharedmimeinfo ne '') { 57 | install_dir("$tmp/usr/share/mime/packages"); 58 | install_file($sharedmimeinfo, 59 | "$tmp/usr/share/mime/packages/$package.xml"); 60 | } 61 | } 62 | 63 | =head1 SEE ALSO 64 | 65 | L 66 | 67 | This program is a part of debhelper. 68 | 69 | =head1 AUTHOR 70 | 71 | Joey Hess 72 | 73 | =cut 74 | -------------------------------------------------------------------------------- /dh_auto_build: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | =head1 NAME 4 | 5 | dh_auto_build - automatically builds a package 6 | 7 | =cut 8 | 9 | use strict; 10 | use warnings; 11 | use Debian::Debhelper::Dh_Lib; 12 | use Debian::Debhelper::Dh_Buildsystems; 13 | 14 | our $VERSION = DH_BUILTIN_VERSION; 15 | 16 | =head1 SYNOPSIS 17 | 18 | B [S>] [S>] [S I>] 19 | 20 | =head1 DESCRIPTION 21 | 22 | B is a debhelper program that tries to automatically build a 23 | package. It does so by running the appropriate command for the build system 24 | it detects the package uses. For example, if a F is found, this is 25 | done by running B (or B, if the environment variable is set). If 26 | there's a F, or F, it is run to build the package. 27 | 28 | This is intended to work for about 90% of packages. If it doesn't work, 29 | you're encouraged to skip using B at all, and just run the 30 | build process manually. 31 | 32 | =head1 OPTIONS 33 | 34 | See L> for a list of common build 35 | system selection and control options. 36 | 37 | =over 4 38 | 39 | =item B<--> I 40 | 41 | Pass I to the program that is run, after the parameters that 42 | B usually passes. 43 | 44 | =back 45 | 46 | =cut 47 | 48 | # PROMISE: DH NOOP WITHOUT cli-options(BUILDSYSTEM) buildsystem(build) 49 | 50 | buildsystems_init(); 51 | buildsystems_do(); 52 | 53 | =head1 SEE ALSO 54 | 55 | L 56 | 57 | This program is a part of debhelper. 58 | 59 | =head1 AUTHOR 60 | 61 | Joey Hess 62 | 63 | =cut 64 | -------------------------------------------------------------------------------- /dh_installppp: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | =head1 NAME 4 | 5 | dh_installppp - install ppp ip-up and ip-down files 6 | 7 | =cut 8 | 9 | use strict; 10 | use warnings; 11 | use Debian::Debhelper::Dh_Lib; 12 | 13 | our $VERSION = DH_BUILTIN_VERSION; 14 | 15 | =head1 SYNOPSIS 16 | 17 | B [S>] [B<--name=>I] 18 | 19 | =head1 DESCRIPTION 20 | 21 | B is a debhelper program that is responsible for installing 22 | ppp ip-up and ip-down scripts into package build directories. 23 | 24 | =head1 FILES 25 | 26 | =over 4 27 | 28 | =item debian/I.ppp.ip-up 29 | 30 | Installed into etc/ppp/ip-up.d/I in the package build directory. 31 | 32 | =item debian/I.ppp.ip-down 33 | 34 | Installed into etc/ppp/ip-down.d/I in the package build directory. 35 | 36 | =back 37 | 38 | =head1 OPTIONS 39 | 40 | =over 4 41 | 42 | =item B<--name=>I 43 | 44 | Look for files named F and install them as 45 | F, instead of using the usual files and installing them 46 | as the package name. 47 | 48 | =back 49 | 50 | =cut 51 | 52 | init(); 53 | 54 | # PROMISE: DH NOOP WITHOUT ppp.ip-up ppp.ip-down cli-options() 55 | 56 | foreach my $package (@{$dh{DOPACKAGES}}) { 57 | my $tmp=tmpdir($package); 58 | 59 | foreach my $script (qw(up down)) { 60 | my $file=pkgfile($package, "ppp.ip-$script"); 61 | if ($file ne '') { 62 | install_dir("$tmp/etc/ppp/ip-$script.d"); 63 | install_prog($file,"$tmp/etc/ppp/ip-$script.d/".pkgfilename($package)); 64 | } 65 | } 66 | } 67 | 68 | =head1 SEE ALSO 69 | 70 | L 71 | 72 | This program is a part of debhelper. 73 | 74 | =head1 AUTHOR 75 | 76 | Joey Hess 77 | 78 | =cut 79 | -------------------------------------------------------------------------------- /t/buildsystems/01-build-system-basic-api.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | use Test::More tests => 12; 6 | 7 | use File::Basename qw(dirname); 8 | use lib dirname(dirname(__FILE__)); 9 | use Test::DH; 10 | use Debian::Debhelper::Dh_Lib qw(!dirname); 11 | use Debian::Debhelper::Buildsystem; 12 | 13 | my $BS_CLASS = 'Debian::Debhelper::Buildsystem'; 14 | 15 | 16 | build_system_path_apis(); 17 | 18 | # Bulk tests 19 | sub build_system_path_apis { 20 | ### Test Buildsystem class API methods 21 | is( $BS_CLASS->canonpath("path/to/the/./nowhere/../../somewhere"), 22 | "path/to/somewhere", "canonpath no1" ); 23 | is( $BS_CLASS->canonpath("path/to/../forward/../../somewhere"), 24 | "somewhere","canonpath no2" ); 25 | is( $BS_CLASS->canonpath("path/to/../../../somewhere"), 26 | "../somewhere","canonpath no3" ); 27 | is( $BS_CLASS->canonpath("./"), ".", "canonpath no4" ); 28 | is( $BS_CLASS->canonpath("/absolute/path/./somewhere/../to/nowhere"), 29 | "/absolute/path/to/nowhere", "canonpath no5" ); 30 | is( $BS_CLASS->_rel2rel("path/my/file", "path/my", "/tmp"), 31 | "file", "_rel2rel no1" ); 32 | is( $BS_CLASS->_rel2rel("path/dir/file", "path/my", "/tmp"), 33 | "../dir/file", "_rel2rel no2" ); 34 | is( $BS_CLASS->_rel2rel("file", "/root/path/my", "/root"), 35 | "/root/file", "_rel2rel abs no3" ); 36 | is( $BS_CLASS->_rel2rel(".", ".", "/tmp"), ".", "_rel2rel no4" ); 37 | is( $BS_CLASS->_rel2rel("path", "path/", "/tmp"), ".", "_rel2rel no5" ); 38 | is( $BS_CLASS->_rel2rel("/absolute/path", "anybase", "/tmp"), 39 | "/absolute/path", "_rel2rel abs no6"); 40 | is( $BS_CLASS->_rel2rel("relative/path", "/absolute/base", "/tmp"), 41 | "/tmp/relative/path", "_rel2rel abs no7"); 42 | } 43 | 44 | -------------------------------------------------------------------------------- /dh_auto_clean: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | =head1 NAME 4 | 5 | dh_auto_clean - automatically cleans up after a build 6 | 7 | =cut 8 | 9 | use strict; 10 | use warnings; 11 | use Debian::Debhelper::Dh_Lib; 12 | use Debian::Debhelper::Dh_Buildsystems; 13 | 14 | our $VERSION = DH_BUILTIN_VERSION; 15 | 16 | =head1 SYNOPSIS 17 | 18 | B [S>] [S>] [S I>] 19 | 20 | =head1 DESCRIPTION 21 | 22 | B is a debhelper program that tries to automatically clean up 23 | after a package build. It does so by running the appropriate command for 24 | the build system it detects the package uses. For example, if there's a 25 | F and it contains a B, B, or B target, 26 | then this is done by running B (or B, if the environment variable is 27 | set). If there is a F or F, it is run to clean the package. 28 | 29 | This is intended to work for about 90% of packages. If it doesn't work, or 30 | tries to use the wrong clean target, you're encouraged to skip using 31 | B at all, and just run B manually. 32 | 33 | =head1 OPTIONS 34 | 35 | See L> for a list of common build 36 | system selection and control options. 37 | 38 | =over 4 39 | 40 | =item B<--> I 41 | 42 | Pass I to the program that is run, after the parameters that 43 | B usually passes. 44 | 45 | =back 46 | 47 | =cut 48 | 49 | # PROMISE: DH NOOP WITHOUT cli-options(BUILDSYSTEM) buildsystem(clean) 50 | 51 | inhibit_log(); 52 | buildsystems_init(); 53 | buildsystems_do(); 54 | 55 | =head1 SEE ALSO 56 | 57 | L 58 | 59 | This program is a part of debhelper. 60 | 61 | =head1 AUTHOR 62 | 63 | Joey Hess 64 | 65 | =cut 66 | -------------------------------------------------------------------------------- /t/dh_link/01-basic.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use Test::More; 7 | plan(tests => 1); 8 | 9 | use File::Path qw(remove_tree); 10 | use File::Basename qw(dirname); 11 | use lib dirname(dirname(__FILE__)); 12 | use Test::DH; 13 | 14 | each_compat_subtest { 15 | 16 | remove_tree('debian/debhelper'); 17 | 18 | # It used to not make absolute links in this situation, and it should. 19 | # #37774 20 | ok(run_dh_tool('dh_link', 'etc/foo', 'usr/lib/bar')); 21 | ok(readlink("debian/debhelper/usr/lib/bar"), "/etc/foo"); 22 | 23 | 24 | # let's make sure it makes simple relative links ok. 25 | ok(run_dh_tool('dh_link', 'usr/bin/foo', 'usr/bin/bar')); 26 | ok(readlink("debian/debhelper/usr/bin/bar"), "foo"); 27 | ok(run_dh_tool('dh_link', 'sbin/foo', 'sbin/bar')); 28 | ok(readlink("debian/debhelper/sbin/bar"), "foo"); 29 | 30 | # ok, more complex relative links. 31 | ok(run_dh_tool('dh_link', 'usr/lib/1', 'usr/bin/2')); 32 | ok(readlink("debian/debhelper/usr/bin/2"),"../lib/1"); 33 | 34 | # Check conversion of relative symlink to different top-level directory 35 | # into absolute symlink. (#244157) 36 | system("mkdir -p debian/debhelper/usr/lib; mkdir -p debian/debhelper/lib; touch debian/debhelper/lib/libm.so; cd debian/debhelper/usr/lib; ln -sf ../../lib/libm.so"); 37 | ok(run_dh_tool('dh_link')); 38 | ok(readlink("debian/debhelper/usr/lib/libm.so"), "/lib/libm.so"); 39 | 40 | # Link to self. 41 | ok(run_dh_tool({ 'quiet' => 1 }, 'dh_link', 'usr/lib/foo', 'usr/lib/foo')); 42 | ok(! -l "debian/debhelper/usr/lib/foo"); 43 | 44 | # Make sure the link conversion didn't change any of the 45 | # previously made links. 46 | ok(readlink("debian/debhelper/usr/lib/bar"), "/etc/foo"); 47 | ok(readlink("debian/debhelper/usr/bin/bar"), "foo"); 48 | ok(readlink("debian/debhelper/usr/bin/2"),"../lib/1"); 49 | }; 50 | 51 | -------------------------------------------------------------------------------- /dh_installifupdown: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | =head1 NAME 4 | 5 | dh_installifupdown - install if-up and if-down hooks 6 | 7 | =cut 8 | 9 | use strict; 10 | use warnings; 11 | use Debian::Debhelper::Dh_Lib; 12 | 13 | our $VERSION = DH_BUILTIN_VERSION; 14 | 15 | =head1 SYNOPSIS 16 | 17 | B [S>] [B<--name=>I] 18 | 19 | =head1 DESCRIPTION 20 | 21 | B is a debhelper program that is responsible for installing 22 | F, F, F, and F hook scripts into package build 23 | directories. 24 | 25 | =head1 FILES 26 | 27 | =over 4 28 | 29 | =item debian/I.if-up 30 | 31 | =item debian/I.if-down 32 | 33 | =item debian/I.if-pre-up 34 | 35 | =item debian/I.if-post-down 36 | 37 | These files are installed into etc/network/if-*.d/I in 38 | the package build directory. 39 | 40 | =back 41 | 42 | =head1 OPTIONS 43 | 44 | =over 4 45 | 46 | =item B<--name=>I 47 | 48 | Look for files named F and install them as 49 | F, instead of using the usual files and installing them 50 | as the package name. 51 | 52 | =back 53 | 54 | =cut 55 | 56 | init(); 57 | 58 | # PROMISE: DH NOOP WITHOUT if-pre-up if-up if-down if-post-down cli-options() 59 | 60 | foreach my $package (@{$dh{DOPACKAGES}}) { 61 | my $tmp=tmpdir($package); 62 | 63 | foreach my $script (qw(pre-up up down post-down)) { 64 | my $file=pkgfile($package, "if-$script"); 65 | if ($file ne '') { 66 | install_dir("$tmp/etc/network/if-$script.d"); 67 | install_prog($file,"$tmp/etc/network/if-$script.d/".pkgfilename($package)); 68 | } 69 | } 70 | } 71 | 72 | =head1 SEE ALSO 73 | 74 | L 75 | 76 | This program is a part of debhelper. 77 | 78 | =head1 AUTHOR 79 | 80 | Joey Hess 81 | 82 | =cut 83 | -------------------------------------------------------------------------------- /t/buildsystems/06-buildsystem-mkdir-rmdir.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | use Cwd; 6 | use Test::More tests => 6; 7 | 8 | use File::Temp qw(tempdir); 9 | use File::Basename qw(dirname); 10 | use lib dirname(dirname(__FILE__)); 11 | use File::Path qw(make_path); 12 | use Test::DH; 13 | use Debian::Debhelper::Dh_Lib qw(!dirname); 14 | use Debian::Debhelper::Buildsystem; 15 | 16 | chdir(dirname($0)) or die("chdir: $!"); 17 | my $TEMP_DIR = tempdir('tmp.XXXXXXX', CLEANUP => 1); 18 | my $sourcedir = $TEMP_DIR; 19 | my $builddir = "${TEMP_DIR}/build"; 20 | my $BS_CLASS = 'Debian::Debhelper::Buildsystem'; 21 | 22 | # Tests 23 | 24 | do_rmdir_builddir($sourcedir, $builddir); 25 | ok ( ! -e $builddir, "testing rmdir_builddir() 1: builddir parent '$builddir' deleted" ); 26 | ok ( -d $sourcedir, "testing rmdir_builddir() 1: sourcedir '$sourcedir' remains" ); 27 | 28 | $builddir = "$sourcedir/bld"; 29 | do_rmdir_builddir($sourcedir, "$builddir/dir"); 30 | ok ( ! -e $builddir, "testing rmdir_builddir() 2: builddir parent '$builddir' deleted" ); 31 | ok ( -d $sourcedir, "testing rmdir_builddir() 2: sourcedir '$sourcedir' remains" ); 32 | 33 | $builddir = "$sourcedir/bld"; 34 | 35 | make_path($builddir, "$builddir/dir"); 36 | create_empty_file("$builddir/afile"); 37 | create_empty_file("$builddir/dir/afile2"); 38 | do_rmdir_builddir($sourcedir, "$builddir/dir"); 39 | ok ( ! -e "$builddir/dir", "testing rmdir_builddir() 3: builddir '$builddir/dir' not empty, but deleted" ); 40 | ok ( -d $builddir, "testing rmdir_builddir() 3: builddir parent '$builddir' not empty, remains" ); 41 | 42 | 43 | ### Test Buildsystem::rmdir_builddir() 44 | sub do_rmdir_builddir { 45 | my ($sourcedir, $builddir) = @_; 46 | my $system; 47 | $system = $BS_CLASS->new(builddir => $builddir, sourcedir => $sourcedir); 48 | $system->mkdir_builddir(); 49 | $system->rmdir_builddir(); 50 | } 51 | 52 | -------------------------------------------------------------------------------- /dh_auto_configure: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | =head1 NAME 4 | 5 | dh_auto_configure - automatically configure a package prior to building 6 | 7 | =cut 8 | 9 | use strict; 10 | use warnings; 11 | use Debian::Debhelper::Dh_Lib; 12 | use Debian::Debhelper::Dh_Buildsystems; 13 | 14 | our $VERSION = DH_BUILTIN_VERSION; 15 | 16 | =head1 SYNOPSIS 17 | 18 | B [S>] [S>] [S I>] 19 | 20 | =head1 DESCRIPTION 21 | 22 | B is a debhelper program that tries to automatically 23 | configure a package prior to building. It does so by running the 24 | appropriate command for the build system it detects the package uses. 25 | For example, it looks for and runs a F<./configure> script, F, 26 | F, or F. A standard set of parameters is determined and passed 27 | to the program that is run. Some build systems, such as make, do not 28 | need a configure step; for these B will exit without 29 | doing anything. 30 | 31 | This is intended to work for about 90% of packages. If it doesn't work, 32 | you're encouraged to skip using B at all, and just run 33 | F<./configure> or its equivalent manually. 34 | 35 | =head1 OPTIONS 36 | 37 | See L> for a list of common build 38 | system selection and control options. 39 | 40 | =over 4 41 | 42 | =item B<--> I 43 | 44 | Pass I to the program that is run, after the parameters that 45 | B usually passes. For example: 46 | 47 | dh_auto_configure -- --with-foo --enable-bar 48 | 49 | =back 50 | 51 | =cut 52 | 53 | # PROMISE: DH NOOP WITHOUT cli-options(BUILDSYSTEM) buildsystem(configure) 54 | 55 | buildsystems_init(); 56 | buildsystems_do(); 57 | 58 | =head1 SEE ALSO 59 | 60 | L 61 | 62 | This program is a part of debhelper. 63 | 64 | =head1 AUTHOR 65 | 66 | Joey Hess 67 | 68 | =cut 69 | -------------------------------------------------------------------------------- /dh_auto_test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | =head1 NAME 4 | 5 | dh_auto_test - automatically runs a package's test suites 6 | 7 | =cut 8 | 9 | use strict; 10 | use warnings; 11 | use Debian::Debhelper::Dh_Lib; 12 | use Debian::Debhelper::Dh_Buildsystems; 13 | 14 | our $VERSION = DH_BUILTIN_VERSION; 15 | 16 | =head1 SYNOPSIS 17 | 18 | B [S>] [S>] [S I>] 19 | 20 | =head1 DESCRIPTION 21 | 22 | B is a debhelper program that tries to automatically run a 23 | package's test suite. It does so by running the appropriate command for the 24 | build system it detects the package uses. For example, if there's a 25 | Makefile and it contains a B or B target, then this is done by 26 | running B (or B, if the environment variable is set). If the test 27 | suite fails, the command will exit nonzero. If there's no test suite, it 28 | will exit zero without doing anything. 29 | 30 | This is intended to work for about 90% of packages with a test suite. If it 31 | doesn't work, you're encouraged to skip using B at all, and 32 | just run the test suite manually. 33 | 34 | =head1 OPTIONS 35 | 36 | See L> for a list of common build 37 | system selection and control options. 38 | 39 | =over 4 40 | 41 | =item B<--> I 42 | 43 | Pass I to the program that is run, after the parameters that 44 | B usually passes. 45 | 46 | =back 47 | 48 | =head1 NOTES 49 | 50 | If the B environment variable contains B, no 51 | tests will be performed. 52 | 53 | =cut 54 | 55 | # PROMISE: DH NOOP WITHOUT cli-options(BUILDSYSTEM) buildsystem(test) 56 | 57 | if (get_buildoption("nocheck")) { 58 | exit 0; 59 | } 60 | 61 | buildsystems_init(); 62 | buildsystems_do(); 63 | 64 | =head1 SEE ALSO 65 | 66 | L 67 | 68 | This program is a part of debhelper. 69 | 70 | =head1 AUTHOR 71 | 72 | Joey Hess 73 | 74 | =cut 75 | -------------------------------------------------------------------------------- /dh_installcron: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | =head1 NAME 4 | 5 | dh_installcron - install cron scripts into etc/cron.* 6 | 7 | =cut 8 | 9 | use strict; 10 | use warnings; 11 | use Debian::Debhelper::Dh_Lib; 12 | 13 | our $VERSION = DH_BUILTIN_VERSION; 14 | 15 | =head1 SYNOPSIS 16 | 17 | B [S>] [B<--name=>I] 18 | 19 | =head1 DESCRIPTION 20 | 21 | B is a debhelper program that is responsible for installing 22 | cron scripts. 23 | 24 | =head1 FILES 25 | 26 | =over 4 27 | 28 | =item debian/I.cron.daily 29 | 30 | =item debian/I.cron.weekly 31 | 32 | =item debian/I.cron.monthly 33 | 34 | =item debian/I.cron.hourly 35 | 36 | =item debian/I.cron.d 37 | 38 | Installed into the appropriate F directory in the package 39 | build directory. 40 | 41 | =back 42 | 43 | =head1 OPTIONS 44 | 45 | =over 4 46 | 47 | =item B<--name=>I 48 | 49 | Look for files named F and install them as 50 | F, instead of using the usual files and installing them 51 | as the package name. 52 | 53 | =back 54 | 55 | =cut 56 | 57 | init(); 58 | 59 | # PROMISE: DH NOOP WITHOUT cron.hourly cron.daily cron.weekly cron.monthly cron.d cli-options() 60 | 61 | foreach my $package (@{$dh{DOPACKAGES}}) { 62 | my $tmp=tmpdir($package); 63 | foreach my $type (qw{hourly daily weekly monthly}) { 64 | my $cron=pkgfile($package,"cron.$type"); 65 | if ($cron) { 66 | install_dir("$tmp/etc/cron.$type"); 67 | install_prog($cron,"$tmp/etc/cron.$type/".pkgfilename($package)); 68 | } 69 | } 70 | # Separate because this needs to be mode 644. 71 | my $cron=pkgfile($package,"cron.d"); 72 | if ($cron) { 73 | install_dir("$tmp/etc/cron.d"); 74 | install_file($cron,"$tmp/etc/cron.d/".pkgfilename($package)); 75 | } 76 | } 77 | 78 | =head1 SEE ALSO 79 | 80 | L 81 | 82 | This program is a part of debhelper. 83 | 84 | =head1 AUTHOR 85 | 86 | Joey Hess 87 | 88 | =cut 89 | -------------------------------------------------------------------------------- /lib/Debian/Debhelper/Buildsystem/ninja.pm: -------------------------------------------------------------------------------- 1 | # A debhelper build system class for handling ninja based projects. 2 | # 3 | # Copyright: © 2017 Michael Biebl 4 | # License: GPL-2+ 5 | 6 | package Debian::Debhelper::Buildsystem::ninja; 7 | 8 | use strict; 9 | use warnings; 10 | use Debian::Debhelper::Dh_Lib qw(%dh dpkg_architecture_value); 11 | use parent qw(Debian::Debhelper::Buildsystem); 12 | 13 | sub DESCRIPTION { 14 | "Ninja (build.ninja)" 15 | } 16 | 17 | sub new { 18 | my $class=shift; 19 | my $this=$class->SUPER::new(@_); 20 | $this->{buildcmd} = "ninja"; 21 | return $this; 22 | } 23 | 24 | sub check_auto_buildable { 25 | my $this=shift; 26 | my ($step) = @_; 27 | 28 | if (-e $this->get_buildpath("build.ninja")) 29 | { 30 | # This is always called in the source directory, but generally 31 | # Ninja files are created (or live) in the build directory. 32 | return 1; 33 | } 34 | return 0; 35 | } 36 | 37 | sub build { 38 | my $this=shift; 39 | my %options = ( 40 | update_env => { 41 | 'LC_ALL' => 'C.UTF-8', 42 | } 43 | ); 44 | if (!$dh{QUIET}) { 45 | unshift @_, "-v"; 46 | } 47 | if ($this->get_parallel() > 0) { 48 | unshift @_, "-j" . $this->get_parallel(); 49 | } 50 | $this->doit_in_builddir(\%options, $this->{buildcmd}, @_); 51 | } 52 | 53 | sub test { 54 | my $this=shift; 55 | my %options = ( 56 | update_env => { 57 | 'LC_ALL' => 'C.UTF-8', 58 | } 59 | ); 60 | if ($this->get_parallel() > 0) { 61 | $options{update_env}{MESON_TESTTHREADS} = $this->get_parallel(); 62 | } 63 | $this->doit_in_builddir(\%options, $this->{buildcmd}, "test", @_); 64 | } 65 | 66 | sub install { 67 | my $this=shift; 68 | my $destdir=shift; 69 | my %options = ( 70 | update_env => { 71 | 'LC_ALL' => 'C.UTF-8', 72 | 'DESTDIR' => $destdir, 73 | } 74 | ); 75 | $this->doit_in_builddir(\%options, $this->{buildcmd}, "install", @_); 76 | } 77 | 78 | sub clean { 79 | my $this=shift; 80 | if (!$this->rmdir_builddir()) { 81 | my %options = ( 82 | update_env => { 83 | 'LC_ALL' => 'C.UTF-8', 84 | } 85 | ); 86 | $this->doit_in_builddir(\%options, $this->{buildcmd}, "clean", @_); 87 | } 88 | } 89 | 90 | 1 91 | -------------------------------------------------------------------------------- /t/buildsystems/02-make-jobserver-makeflags.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | use Test::More tests => 9; 6 | 7 | use File::Basename qw(dirname); 8 | use lib dirname(dirname(__FILE__)); 9 | use Test::DH; 10 | use Debian::Debhelper::Dh_Lib qw(!dirname); 11 | 12 | # Test clean_jobserver_makeflags. 13 | 14 | test_clean_jobserver_makeflags('--jobserver-fds=103,104 -j', 15 | undef, 16 | 'unset makeflags'); 17 | 18 | test_clean_jobserver_makeflags('-a --jobserver-fds=103,104 -j -b', 19 | '-a -b', 20 | 'clean makeflags'); 21 | 22 | test_clean_jobserver_makeflags(' --jobserver-fds=1,2 -j ', 23 | undef, 24 | 'unset makeflags'); 25 | 26 | test_clean_jobserver_makeflags('-a -j -b', 27 | '-a -j -b', 28 | 'clean makeflags does not remove -j'); 29 | 30 | test_clean_jobserver_makeflags('-a --jobs -b', 31 | '-a --jobs -b', 32 | 'clean makeflags does not remove --jobs'); 33 | 34 | test_clean_jobserver_makeflags('-j6', 35 | '-j6', 36 | 'clean makeflags does not remove -j6'); 37 | 38 | test_clean_jobserver_makeflags('-a -j6 --jobs=7', 39 | '-a -j6 --jobs=7', 40 | 'clean makeflags does not remove -j or --jobs'); 41 | 42 | test_clean_jobserver_makeflags('-j6 --jobserver-fds=103,104 --jobs=8', 43 | '-j6 --jobs=8', 44 | 'jobserver options removed'); 45 | 46 | test_clean_jobserver_makeflags('-j6 --jobserver-auth=103,104 --jobs=8', 47 | '-j6 --jobs=8', 48 | 'jobserver options removed'); 49 | 50 | sub test_clean_jobserver_makeflags { 51 | my ($orig, $expected, $test) = @_; 52 | 53 | local $ENV{MAKEFLAGS} = $orig; 54 | clean_jobserver_makeflags(); 55 | is($ENV{MAKEFLAGS}, $expected, $test); 56 | } 57 | 58 | -------------------------------------------------------------------------------- /dh_prep: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | =head1 NAME 4 | 5 | dh_prep - perform cleanups in preparation for building a binary package 6 | 7 | =cut 8 | 9 | use strict; 10 | use warnings; 11 | use Debian::Debhelper::Dh_Lib; 12 | 13 | our $VERSION = DH_BUILTIN_VERSION; 14 | 15 | =head1 SYNOPSIS 16 | 17 | B [S>] [B<-X>I] 18 | 19 | =head1 DESCRIPTION 20 | 21 | B is a debhelper program that performs some file cleanups in 22 | preparation for building a binary package. (This is what B 23 | used to do.) It removes the package build directories, F, 24 | and some temp files that are generated when building a binary package. 25 | 26 | It is typically run at the top of the B and B targets, 27 | or at the top of a target such as install that they depend on. 28 | 29 | =head1 OPTIONS 30 | 31 | =over 4 32 | 33 | =item B<-X>I B<--exclude=>I 34 | 35 | Exclude files that contain F anywhere in their filename from being 36 | deleted, even if they would normally be deleted. You may use this option 37 | multiple times to build up a list of things to exclude. 38 | 39 | =back 40 | 41 | =cut 42 | 43 | init(); 44 | 45 | my (@clean_files, @clean_dirs, %seen); 46 | 47 | foreach my $package (@{$dh{DOPACKAGES}}) { 48 | my $tmp=tmpdir($package); 49 | my $ext=pkgext($package); 50 | my $source_dir = default_sourcedir($package); 51 | 52 | push(@clean_files, "debian/${ext}substvars") 53 | unless excludefile("debian/${ext}substvars"); 54 | 55 | # These are all debhelper temp files, and so it is safe to 56 | # wildcard them. 57 | my @temp = glob("debian/$ext*.debhelper"); 58 | push(@clean_files, @temp); 59 | push(@clean_dirs, "debian/.debhelper/generated/${package}/"); 60 | push(@clean_dirs , "${tmp}/") 61 | unless excludefile($tmp); 62 | 63 | push(@clean_dirs, "${source_dir}/") 64 | if (not $seen{$source_dir}++ and not excludefile($source_dir)); 65 | } 66 | 67 | xargs(\@clean_files, 'rm', '-f', '--') if @clean_files; 68 | xargs(\@clean_dirs, 'rm', '-fr', '--') if @clean_dirs; 69 | 70 | =head1 SEE ALSO 71 | 72 | L 73 | 74 | This program is a part of debhelper. 75 | 76 | =head1 AUTHOR 77 | 78 | Joey Hess 79 | 80 | =cut 81 | -------------------------------------------------------------------------------- /dh_update_autotools_config: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | =head1 NAME 4 | 5 | dh_update_autotools_config - Update autotools config files 6 | 7 | =cut 8 | 9 | use strict; 10 | use warnings; 11 | use Debian::Debhelper::Dh_Lib; 12 | 13 | our $VERSION = DH_BUILTIN_VERSION; 14 | 15 | =head1 SYNOPSIS 16 | 17 | B [S>] 18 | 19 | =head1 DESCRIPTION 20 | 21 | B replaces all occurrences of B 22 | and B in the source tree by the up-to-date versions 23 | found in the autotools-dev package. The original files are backed up 24 | and restored by B. 25 | 26 | =cut 27 | 28 | init(); 29 | 30 | for my $basename (qw(config.guess config.sub)) { 31 | my $new_version = "/usr/share/misc/$basename"; 32 | open(my $fd, '-|', 'find', '-mindepth', '1', 33 | '(', '-type', 'd', '-name', '.*', '-prune', ')', 34 | '-o', '-type', 'f', '-name', $basename, '-print') 35 | or error("Cannot run find -type f -name $basename: $!"); 36 | while (my $filename = <$fd>) { 37 | chomp($filename); 38 | next if not is_autotools_config_file($filename); 39 | restore_file_on_clean($filename); 40 | doit('cp', '-f', $new_version, $filename); 41 | } 42 | close($fd); 43 | } 44 | 45 | sub is_autotools_config_file { 46 | my ($file) = @_; 47 | my ($is_autoconf_file); 48 | open(my $fd, '<', $file) or error("open $file for reading failed: $!"); 49 | while (my $line = <$fd>) { 50 | chomp($line); 51 | # This is the test lintian uses. 52 | if ($line =~ m{^timestamp=['"]\d{4}-\d{2}-\d{2}['"]\s*$}) { 53 | $is_autoconf_file = 1; 54 | last; 55 | } 56 | $line =~ s/\s++$//; 57 | if ($line eq q{# Attempt to guess a canonical system name.} 58 | or $line =~ q{^# Configuration validation subroutine script}) { 59 | # Very old scripts do not have that timestamp line, but 60 | # they do have these headers (which even new files also 61 | # have). 62 | $is_autoconf_file = 1; 63 | last; 64 | } 65 | last if $. >= 10; 66 | } 67 | close($fd); 68 | return $is_autoconf_file; 69 | } 70 | 71 | 72 | =head1 SEE ALSO 73 | 74 | L 75 | 76 | This program is a part of debhelper. 77 | 78 | =head1 AUTHOR 79 | 80 | Niels Thykier 81 | 82 | =cut 83 | -------------------------------------------------------------------------------- /t/dh-lib.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | package Debian::Debhelper::Dh_Lib::Test; 3 | use strict; 4 | use warnings; 5 | use Test::More; 6 | 7 | use File::Basename qw(dirname); 8 | use lib dirname(__FILE__); 9 | use Test::DH; 10 | 11 | use Debian::Debhelper::Dh_Lib qw(!dirname); 12 | 13 | plan(tests => 2); 14 | 15 | 16 | sub ok_autoscript_result { 17 | ok(-f 'debian/testpackage.postinst.debhelper'); 18 | open(my $fd, '<', 'debian/testpackage.postinst.debhelper') or die("open test-poinst: $!"); 19 | my (@c) = <$fd>; 20 | close($fd); 21 | like(join('',@c), qr{update-rc\.d test-script test parms with"quote >/dev/null}); 22 | } 23 | 24 | 25 | each_compat_subtest { 26 | 27 | ok(autoscript('testpackage', 'postinst', 'postinst-init', 28 | 's/#SCRIPT#/test-script/g; s/#INITPARMS#/test parms with\\"quote/g')); 29 | ok_autoscript_result; 30 | 31 | ok(rm_files('debian/testpackage.postinst.debhelper')); 32 | 33 | ok(autoscript('testpackage', 'postinst', 'postinst-init', 34 | sub { s/\#SCRIPT\#/test-script/g; s/\#INITPARMS\#/test parms with"quote/g } )); 35 | ok_autoscript_result; 36 | 37 | ok(rm_files('debian/testpackage.postinst.debhelper')); 38 | 39 | ok(autoscript('testpackage', 'postinst', 'postinst-init', 40 | { 'SCRIPT' => 'test-script', 'INITPARMS' => 'test parms with"quote' } )); 41 | ok_autoscript_result; 42 | 43 | ok(rm_files('debian/testpackage.postinst.debhelper')); 44 | }; 45 | 46 | $ENV{'FOO'} = "test"; 47 | my @SUBST_TEST_OK = ( 48 | ['unchanged', 'unchanged'], 49 | ["unchanged\${\n}", "unchanged\${\n}"], # Newline is not an allowed part of ${} 50 | ['raw dollar-sign ${}', 'raw dollar-sign $'], 51 | ['${Dollar}${Space}${Dollar}', '$ $'], 52 | ['Hello ${env:FOO}', 'Hello test'], 53 | ['${Dollar}{Space}${}{Space}', '${Space}${Space}'], # We promise that ${Dollar}/${} never cause recursion 54 | ['/usr/lib/${DEB_HOST_MULTIARCH}', '/usr/lib/' . dpkg_architecture_value('DEB_HOST_MULTIARCH')], 55 | ); 56 | 57 | each_compat_subtest { 58 | for my $test (@SUBST_TEST_OK) { 59 | my ($input, $expected_output) = @{$test}; 60 | my $actual_output = Debian::Debhelper::Dh_Lib::_variable_substitution($input, 'test'); 61 | is($actual_output, $expected_output, qq{${input}" => "${actual_output}" (should be: "${expected_output})"}); 62 | } 63 | }; 64 | -------------------------------------------------------------------------------- /t/dh_installdocs/dh_installdocs.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use warnings; 4 | use Test::More; 5 | 6 | 7 | use File::Path qw(remove_tree); 8 | use File::Basename qw(dirname); 9 | use lib dirname(dirname(__FILE__)); 10 | use Test::DH; 11 | 12 | our @TEST_DH_EXTRA_TEMPLATE_FILES = (qw( 13 | debian/changelog 14 | debian/control 15 | debian/docfile 16 | debian/copyright 17 | )); 18 | 19 | plan(tests => 5); 20 | 21 | 22 | my $NODOC_PROFILE = { 23 | 'env' => { 24 | 'DEB_BUILD_PROFILES' => 'nodoc', 25 | }, 26 | }; 27 | 28 | my $doc = "debian/docfile"; 29 | 30 | each_compat_subtest { 31 | ok(run_dh_tool('dh_installdocs', '-pbar', $doc)); 32 | ok(-e "debian/bar/usr/share/doc/bar/docfile"); 33 | remove_tree(qw(debian/foo debian/bar debian/baz)); 34 | }; 35 | 36 | each_compat_subtest { 37 | #regression in debhelper 9.20160702 (#830309) 38 | ok(run_dh_tool('dh_installdocs', '-pbaz', '--link-doc=foo', $doc)); 39 | 40 | ok(-l "debian/baz/usr/share/doc/baz"); 41 | ok(readlink("debian/baz/usr/share/doc/baz") eq 'foo'); 42 | ok(-e "debian/baz/usr/share/doc/foo/docfile"); 43 | remove_tree(qw(debian/foo debian/bar debian/baz)); 44 | }; 45 | 46 | each_compat_subtest { 47 | ok(run_dh_tool('dh_installdocs', '-pfoo', '--link-doc=bar', $doc)); 48 | 49 | ok(-l "debian/foo/usr/share/doc/foo"); 50 | ok(readlink("debian/foo/usr/share/doc/foo") eq 'bar'); 51 | ok(-e "debian/foo/usr/share/doc/bar/docfile"); 52 | remove_tree(qw(debian/foo debian/bar debian/baz)); 53 | }; 54 | 55 | # ... and with nodoc 56 | 57 | each_compat_subtest { 58 | # docs are ignored, but copyright file is still there 59 | ok(run_dh_tool($NODOC_PROFILE, 'dh_installdocs', $doc)); 60 | for my $pkg (qw(foo bar baz)) { 61 | ok(! -e "debian/$pkg/usr/share/doc/$pkg/docfile"); 62 | ok(-e "debian/$pkg/usr/share/doc/$pkg/copyright"); 63 | } 64 | remove_tree(qw(debian/foo debian/bar debian/baz)); 65 | }; 66 | 67 | each_compat_subtest { 68 | # docs are ignored, but symlinked doc dir is still there 69 | ok(run_dh_tool($NODOC_PROFILE, 'dh_installdocs', '-pfoo', '--link-doc=bar', $doc)); 70 | ok(-l "debian/foo/usr/share/doc/foo"); 71 | ok(readlink("debian/foo/usr/share/doc/foo") eq 'bar'); 72 | ok(! -e "debian/foo/usr/share/doc/bar/docfile"); 73 | remove_tree(qw(debian/foo debian/bar debian/baz)); 74 | }; 75 | 76 | -------------------------------------------------------------------------------- /t/buildsystems/05-load-build-system.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | use Cwd; 6 | use Test::More tests => 3; 7 | 8 | use File::Temp qw(tempdir); 9 | use File::Basename qw(dirname); 10 | use lib dirname(dirname(__FILE__)); 11 | use Test::DH; 12 | use File::Path qw(remove_tree make_path); 13 | use Debian::Debhelper::Dh_Lib qw(!dirname); 14 | use Debian::Debhelper::Buildsystem; 15 | 16 | my $DIR = dirname($0); 17 | my $SCRIPT = './load-bs.pl'; # relative to $DIR 18 | my $BS_CWD = Cwd::realpath($DIR) or error("cannot resolve ${DIR}: $!"); 19 | my $BS_CLASS = 'Debian::Debhelper::Buildsystem'; 20 | my $bs = $BS_CLASS->new(); 21 | my $default_builddir = $bs->DEFAULT_BUILD_DIRECTORY(); 22 | delete($ENV{'TEST_DH_SYSTEM'}); 23 | delete($ENV{'TEST_DH_STEP'}); 24 | 25 | # NOTE: disabling parallel building explicitly (it might get automatically 26 | # enabled if run under dpkg-buildpackage -jX) to make output deterministic. 27 | is_deeply( try_load_bs(undef, 'configure', '--builddirectory=autoconf/bld dir', '--sourcedirectory', 28 | 'autoconf', '--max-parallel=1'), 29 | [ 'NAME=autoconf', 'builddir=autoconf/bld dir', "cwd=$BS_CWD", 'makecmd=make', 'parallel=1', 'sourcedir=autoconf' ], 30 | "autoconf autoselection and sourcedir/builddir" ); 31 | 32 | is_deeply( try_load_bs('autoconf', 'build', '-Sautoconf', '-D', 'autoconf', '--max-parallel=1'), 33 | [ 'NAME=autoconf', 'builddir=undef', "cwd=$BS_CWD", 'makecmd=make', 'parallel=1', 'sourcedir=autoconf' ], 34 | "forced autoconf and sourcedir" ); 35 | 36 | is_deeply( try_load_bs('autoconf', 'build', '-B', '-Sautoconf', '--max-parallel=1'), 37 | [ 'NAME=autoconf', "builddir=$default_builddir", "cwd=$BS_CWD", 'makecmd=make', 'parallel=1', 'sourcedir=.' ], 38 | "forced autoconf and default build directory" ); 39 | 40 | sub try_load_bs { 41 | my ($system, $step, @params) = @_; 42 | my @lines; 43 | my $pid = open(my $fd, '-|') // die("fork: $!"); 44 | 45 | if (not $pid) { 46 | chdir($DIR) or die("chdir($DIR): $!"); 47 | $ENV{'TEST_DH_SYSTEM'} = $system if defined($system); 48 | $ENV{'TEST_DH_STEP'} = $step if defined($step); 49 | exec($^X, $SCRIPT, @params); 50 | } 51 | @lines = map { chomp; $_ } <$fd>; 52 | close($fd); # Ignore error 53 | return \@lines; 54 | } 55 | 56 | -------------------------------------------------------------------------------- /dh_installlogcheck: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | =head1 NAME 4 | 5 | dh_installlogcheck - install logcheck rulefiles into etc/logcheck/ 6 | 7 | =cut 8 | 9 | use strict; 10 | use warnings; 11 | use Debian::Debhelper::Dh_Lib; 12 | 13 | our $VERSION = DH_BUILTIN_VERSION; 14 | 15 | =head1 SYNOPSIS 16 | 17 | B [S>] 18 | 19 | =head1 DESCRIPTION 20 | 21 | B is a debhelper program that is responsible for 22 | installing logcheck rule files. 23 | 24 | =head1 FILES 25 | 26 | =over 4 27 | 28 | =item debian/I.logcheck.cracking 29 | 30 | =item debian/I.logcheck.violations 31 | 32 | =item debian/I.logcheck.violations.ignore 33 | 34 | =item debian/I.logcheck.ignore.workstation 35 | 36 | =item debian/I.logcheck.ignore.server 37 | 38 | =item debian/I.logcheck.ignore.paranoid 39 | 40 | Each of these files, if present, are installed into corresponding 41 | subdirectories of F in package build directories. 42 | 43 | =back 44 | 45 | =head1 OPTIONS 46 | 47 | =over 4 48 | 49 | =item B<--name=>I 50 | 51 | Look for files named F and install 52 | them into the corresponding subdirectories of F, but 53 | use the specified name instead of that of the package. 54 | 55 | =back 56 | 57 | =cut 58 | 59 | init(); 60 | 61 | # PROMISE: DH NOOP WITHOUT logcheck.cracking logcheck.violations logcheck.violations.ignore logcheck.ignore.workstation logcheck.ignore.server logcheck.ignore.paranoid cli-options() 62 | 63 | foreach my $package (@{$dh{DOPACKAGES}}) { 64 | my $tmp=tmpdir($package); 65 | 66 | foreach my $type (qw{ignore.d.workstation ignore.d.server 67 | ignore.d.paranoid cracking.d 68 | violations.d violations.ignore.d}) { 69 | my $typenod=$type; 70 | $typenod=~s/\.d//; 71 | my $logcheck=pkgfile($package,"logcheck.$typenod"); 72 | if ($logcheck) { 73 | my $packagenodot=pkgfilename($package); # run-parts.. 74 | $packagenodot=~s/\./_/g; 75 | install_dir("$tmp/etc/logcheck/$type"); 76 | install_file($logcheck, "$tmp/etc/logcheck/$type/$packagenodot"); 77 | } 78 | } 79 | } 80 | 81 | =head1 SEE ALSO 82 | 83 | L 84 | 85 | This program is a part of debhelper. 86 | 87 | =head1 AUTHOR 88 | 89 | Jon Middleton 90 | 91 | =cut 92 | -------------------------------------------------------------------------------- /t/buildsystems/autoconf/configure: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | # Emulate autoconf behaviour and do some checks 4 | 5 | use strict; 6 | use warnings; 7 | 8 | my @OPTIONS=qw( 9 | ^--build=.*$ 10 | ^--prefix=/usr$ 11 | ^--includedir=\$\{prefix\}/include$ 12 | ^--mandir=\$\{prefix\}/share/man$ 13 | ^--infodir=\$\{prefix\}/share/info$ 14 | ^--sysconfdir=/etc$ 15 | ^--localstatedir=/var$ 16 | ^--libdir=\$\{prefix\}/lib/.*$ 17 | ^--disable-option-checking$ 18 | ^--disable-silent-rules$ 19 | ^--disable-maintainer-mode$ 20 | ^--disable-dependency-tracking$ 21 | ); 22 | 23 | # Not always passed (e.g. --libexecdir is skipped in compat 12) 24 | my @OPTIONAL_ARGUMENTS = qw( 25 | ^--libexecdir=\$\{prefix\}/lib/.*$ 26 | ); 27 | 28 | # Verify if all command line arguments were passed 29 | my @options = map { { regex => qr/$_/, 30 | str => $_, 31 | found => 0 } } @OPTIONS; 32 | push(@options, map { { regex => qr/$_/, 33 | str => $_, 34 | found => 1 } } @OPTIONAL_ARGUMENTS); 35 | my @extra_args; 36 | ARGV_LOOP: foreach my $arg (@ARGV) { 37 | foreach my $opt (@options) { 38 | if ($arg =~ $opt->{regex}) { 39 | $opt->{found} = 1; 40 | next ARGV_LOOP; 41 | } 42 | } 43 | # Extra / unrecognized argument 44 | push @extra_args, $arg; 45 | } 46 | 47 | my @notfound = grep { ! $_->{found} and $_ } @options; 48 | if (@notfound) { 49 | print STDERR "Error: the following default options were NOT passed\n"; 50 | print STDERR " ", $_->{str}, "\n" foreach (@notfound); 51 | exit 1; 52 | } 53 | 54 | # Create a simple Makefile 55 | open(MAKEFILE, ">", "Makefile"); 56 | print MAKEFILE < stamp_build 60 | 61 | # Tests if dh_auto_test executes 'check' target if 'test' does not exist 62 | check: \$(CONFIGURE) stamp_build 63 | \@echo VERBOSE=\$(VERBOSE) > stamp_test 64 | 65 | install: stamp_build 66 | \@echo DESTDIR=\$(DESTDIR) > stamp_install 67 | 68 | # Tests whether dh_auto_clean executes distclean but does not touch 69 | # this target 70 | clean: 71 | echo "This should not have been executed" >&2 && exit 1 72 | 73 | distclean: 74 | \@rm -f stamp_* Makefile 75 | 76 | .PHONY: all check install clean distclean 77 | EOF 78 | close MAKEFILE; 79 | 80 | open(STAMP, ">", "stamp_configure"); 81 | print STAMP $_, "\n" foreach (@extra_args); 82 | close STAMP; 83 | 84 | exit 0; 85 | -------------------------------------------------------------------------------- /dh_icons: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | =head1 NAME 4 | 5 | dh_icons - Update caches of Freedesktop icons 6 | 7 | =cut 8 | 9 | use strict; 10 | use warnings; 11 | use File::Find; 12 | use Debian::Debhelper::Dh_Lib; 13 | 14 | our $VERSION = DH_BUILTIN_VERSION; 15 | 16 | =head1 SYNOPSIS 17 | 18 | B [S>] [B<-n>] 19 | 20 | =head1 DESCRIPTION 21 | 22 | B is a debhelper program that updates caches of Freedesktop icons 23 | when needed, using the B program provided by GTK+2.12. 24 | Currently this program does not handle installation of the files, though it 25 | may do so at a later date, so should be run after icons are installed in 26 | the package build directories. 27 | 28 | It takes care of adding maintainer script fragments to call 29 | B for icon directories. (This is not done for gnome and 30 | hicolor icons, as those are handled by triggers.) 31 | These commands are inserted into the maintainer scripts by L. 32 | 33 | =head1 OPTIONS 34 | 35 | =over 4 36 | 37 | =item B<-n>, B<--no-scripts> 38 | 39 | Do not modify maintainer scripts. 40 | 41 | =back 42 | 43 | =cut 44 | 45 | init(); 46 | 47 | # PROMISE: DH NOOP WITHOUT tmp(usr/share/icons) cli-options() 48 | my $baseicondir="/usr/share/icons"; 49 | 50 | foreach my $package (@{$dh{DOPACKAGES}}) { 51 | my $tmp=tmpdir($package); 52 | my $icondir="$tmp$baseicondir"; 53 | if (-d $icondir) { 54 | my @dirlist; 55 | opendir(my $dirfd, $icondir) or error("Cannot opendir($icondir): $!"); 56 | while (my $subdir = readdir($dirfd)) { 57 | next if $subdir =~ /^\./; 58 | next if $subdir eq "gnome"; 59 | next if $subdir eq "hicolor"; 60 | my $needs_cache = 0; 61 | find sub { 62 | $needs_cache = 1 if -f and (/\.png$/ or /\.svg$/ or /\.xpm$/ or /\.icon$/); 63 | }, "$icondir/$subdir" ; 64 | push @dirlist, "$baseicondir/$subdir" if $needs_cache; 65 | } 66 | closedir($dirfd); 67 | if (@dirlist and ! $dh{NOSCRIPTS}) { 68 | my $list=join(" ", sort @dirlist); 69 | autoscript($package, 'postinst', 'postinst-icons', { 'DIRLIST' => $list }); 70 | autoscript($package, 'postrm', 'postrm-icons', { 'DIRLIST' => $list }); 71 | } 72 | } 73 | } 74 | 75 | =head1 SEE ALSO 76 | 77 | L 78 | 79 | This program is a part of debhelper. 80 | 81 | =head1 AUTHOR 82 | 83 | Ross Burton 84 | Jordi Mallach 85 | Josselin Mouette 86 | 87 | =cut 88 | -------------------------------------------------------------------------------- /t/debhelper-compat/syntax.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use warnings; 4 | use Test::More; 5 | 6 | use File::Basename qw(dirname); 7 | use File::Temp qw(tempdir); 8 | use lib dirname(dirname(__FILE__)); 9 | use Test::DH; 10 | 11 | use Debian::Debhelper::Dh_Lib qw(!dirname); 12 | 13 | my $TEST_DIR = dirname(__FILE__); 14 | 15 | sub test_build_depends { 16 | my ($level, $build_depends) = @_; 17 | my $dir = tempdir(CLEANUP => 1); 18 | if (not mkdir("$dir/debian", 0777)) { 19 | error("mkdir $dir/debian failed: $!"); 20 | } 21 | open my $in, '<', "$TEST_DIR/debian/control" or 22 | error("open $TEST_DIR/debian/control failed: $!"); 23 | open my $out, '>', "$dir/debian/control" or 24 | error("open $dir/debian/control failed: $!"); 25 | while (<$in>) { 26 | s/BUILD_DEPENDS/$build_depends/; 27 | print $out $_ or 28 | error("write to $dir/debian/control failed: $!"); 29 | } 30 | close($out) or 31 | error("close $dir/debian/control failed: $!"); 32 | close($in); 33 | 34 | my $start_dir = Test::DH::getcwd(); 35 | chdir($dir) or error("chdir($dir): $!"); 36 | 37 | plan(tests => 5); 38 | 39 | local $ENV{DH_INTERNAL_TESTSUITE_SILENT_WARNINGS} = 1; 40 | Debian::Debhelper::Dh_Lib::resetpackages; 41 | Debian::Debhelper::Dh_Lib::resetcompat; 42 | my @pkgs = getpackages; 43 | ok(scalar @pkgs == 1); 44 | ok($pkgs[0] eq 'foo'); 45 | 46 | ok(compat($level)); 47 | ok(compat($level + 1)); 48 | ok(!compat($level - 1)); 49 | 50 | chdir($start_dir) or 51 | error("chdir($start_dir): $!"); 52 | } 53 | 54 | my @levels = non_deprecated_compat_levels; 55 | plan(tests => scalar @levels); 56 | 57 | for my $level (@levels) { 58 | subtest "compat $level" => sub { 59 | plan(tests => 7); 60 | subtest 'only' => sub { 61 | test_build_depends($level, "debhelper-compat (= $level)"); 62 | }; 63 | subtest 'first' => sub { 64 | test_build_depends($level, "debhelper-compat (= $level), bar"); 65 | }; 66 | subtest 'second' => sub { 67 | test_build_depends($level, "bar, debhelper-compat (= $level)"); 68 | }; 69 | subtest 'first-nl' => sub { 70 | test_build_depends($level, "debhelper-compat (= $level),\n bar"); 71 | }; 72 | subtest 'second-nl' => sub { 73 | test_build_depends($level, "bar,\n debhelper-compat (= $level)"); 74 | }; 75 | subtest 'nl-first' => sub { 76 | test_build_depends($level, "\n debhelper-compat (= $level),\n bar"); 77 | }; 78 | subtest 'nl-second' => sub { 79 | test_build_depends($level, "\n bar,\n debhelper-compat (= $level)"); 80 | }; 81 | }; 82 | } 83 | -------------------------------------------------------------------------------- /t/dh_installsystemduser/dh_installsystemduser.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use Test::More; 4 | use File::Path qw(make_path); 5 | use File::Basename qw(dirname); 6 | use lib dirname(dirname(__FILE__)); 7 | use Test::DH; 8 | use Debian::Debhelper::Dh_Lib qw(!dirname); 9 | 10 | plan(tests => 1); 11 | 12 | our @TEST_DH_EXTRA_TEMPLATE_FILES = (qw( 13 | debian/changelog 14 | debian/control 15 | debian/foo.user.service 16 | debian/baz.user.service 17 | )); 18 | 19 | 20 | sub read_script { 21 | my ($package, $name) = @_; 22 | my @lines; 23 | 24 | foreach my $script (find_script($package, $name)) { 25 | open(my $fh, '<', $script) or die("open($script): $!"); 26 | push @lines, $_ for <$fh>; 27 | close($fh); 28 | } 29 | 30 | return @lines; 31 | } 32 | 33 | sub _unit_check_user_enabled { 34 | my ($package, $unit, $enabled) = @_; 35 | my $verb = $enabled ? "is" : "isnt"; 36 | my $matches; 37 | 38 | my @postinst = read_script($package, 'postinst'); 39 | # Match exactly one tab character. The "dont-enable" script has 40 | # an "enable" line for re-enabling the service if the admin had it 41 | # enabled, but we do not want to include that in our count. 42 | $matches = grep { m{^\tif deb-systemd-helper( --\w+)* --user was-enabled.*'\Q$unit'} } @postinst; 43 | is($matches, $enabled, "$unit $verb enabled"); 44 | 45 | my @postrm = read_script($package, 'postrm'); 46 | $matches = grep { m{deb-systemd-helper( --\w+)* --user mask.*'\Q$unit'} } @postrm; 47 | is($matches, $enabled, "$unit $verb masked"); 48 | } 49 | 50 | sub is_enabled { _unit_check_user_enabled(@_, 1); } 51 | sub isnt_enabled { _unit_check_user_enabled(@_, 0); } 52 | 53 | each_compat_subtest { 54 | make_path('debian/foo/usr/lib/systemd/user/'); 55 | install_file('debian/foo.user.service', 'debian/foo/usr/lib/systemd/user/bar.service'); 56 | ok(run_dh_tool('dh_installsystemduser')); 57 | ok(-e 'debian/foo/usr/lib/systemd/user/foo.service'); 58 | is_enabled('foo', 'foo.service'); 59 | is_enabled('foo', 'bar.service'); 60 | ok(run_dh_tool('dh_clean')); 61 | 62 | ok(run_dh_tool('dh_installsystemduser')); 63 | ok(-e 'debian/foo/usr/lib/systemd/user/foo.service'); 64 | ok(! -e 'debian/foo/usr/lib/systemd/user/baz.service'); 65 | is_enabled('foo', 'foo.service'); 66 | isnt_enabled('foo', 'baz.service'); 67 | ok(run_dh_tool('dh_clean')); 68 | 69 | ok(run_dh_tool('dh_installsystemduser', '--name', 'baz')); 70 | ok(! -e 'debian/foo/usr/lib/systemd/user/foo.service'); 71 | ok(-e 'debian/foo/usr/lib/systemd/user/baz.service'); 72 | isnt_enabled('foo', 'foo.service'); 73 | is_enabled('foo', 'baz.service'); 74 | ok(run_dh_tool('dh_clean')); 75 | }; 76 | -------------------------------------------------------------------------------- /t/maintscript.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use warnings; 4 | use Test::More; 5 | 6 | use File::Path qw(remove_tree); 7 | use File::Basename qw(dirname); 8 | use lib dirname(__FILE__); 9 | use Test::DH; 10 | use Debian::Debhelper::Dh_Lib qw(!dirname); 11 | 12 | plan(tests => 2); 13 | 14 | each_compat_up_to_and_incl_subtest(10, sub { 15 | my @scripts = qw{postinst preinst prerm postrm}; 16 | my $file = 'debian/maintscript'; 17 | 18 | remove_tree('debian/debhelper', 'debian/tmp'); 19 | rm_files(@scripts, $file); 20 | 21 | open(my $fd, ">", $file) || die("open($file): $!"); 22 | print {$fd} <", $file) or die("open($file): $!"); 44 | print {$fd} < 1 }, 'dh_installdeb'); 50 | 51 | remove_tree('debian/debhelper', 'debian/tmp', 'debian/.debhelper'); 52 | rm_files(@scripts); 53 | 54 | return $res; 55 | } 56 | 57 | # Negative tests 58 | each_compat_from_and_above_subtest(12, sub { 59 | ok(!test_maintscript_syntax('rm_conffile foo 1.0~'), "rm_conffile absolute path check"); 60 | ok(!test_maintscript_syntax('rm_conffile /foo 1.0\~'), "rm_conffile version check"); 61 | ok(!test_maintscript_syntax('rm_conffile /foo 1.0~ some_pkg'), "rm_conffile package name check"); 62 | ok(!test_maintscript_syntax('rm_conffile /foo 1.0~ some-pkg --'), "rm_conffile separator check"); 63 | 64 | ok(!test_maintscript_syntax('mv_conffile foo /bar 1.0~'), "mv_conffile absolute (current) path check"); 65 | ok(!test_maintscript_syntax('mv_conffile /foo bar 1.0~'), "mv_conffile absolute (current) path check"); 66 | ok(!test_maintscript_syntax('mv_conffile /foo /bar 1.0\~'), "mv_conffile version check"); 67 | ok(!test_maintscript_syntax('mv_conffile /foo /bar 1.0~ some_pkg'), "mv_conffile package name check"); 68 | ok(!test_maintscript_syntax('mv_conffile /foo /bar 1.0~ some-pkg -- '), "mv_conffile separator check "); 69 | }); 70 | 71 | -------------------------------------------------------------------------------- /dh_installmenu: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | =head1 NAME 4 | 5 | dh_installmenu - install Debian menu files into package build directories 6 | 7 | =cut 8 | 9 | use strict; 10 | use warnings; 11 | use Debian::Debhelper::Dh_Lib; 12 | 13 | our $VERSION = DH_BUILTIN_VERSION; 14 | 15 | =head1 SYNOPSIS 16 | 17 | B [S>] [B<-n>] 18 | 19 | =head1 DESCRIPTION 20 | 21 | B is a debhelper program that is responsible for installing 22 | files used by the Debian B package into package build directories. 23 | 24 | It also automatically generates the F and F commands needed to 25 | interface with the Debian B package. These commands are inserted into 26 | the maintainer scripts by L. 27 | 28 | =head1 FILES 29 | 30 | =over 4 31 | 32 | =item debian/I.menu 33 | 34 | Debian menu files, installed into usr/share/menu/I in the package 35 | build directory. See L for its format. 36 | 37 | =item debian/I.menu-method 38 | 39 | Debian menu method files, installed into etc/menu-methods/I 40 | in the package build directory. 41 | 42 | =back 43 | 44 | =head1 OPTIONS 45 | 46 | =over 4 47 | 48 | =item B<-n>, B<--no-scripts> 49 | 50 | Do not modify F/F scripts. 51 | 52 | =back 53 | 54 | =cut 55 | 56 | init(); 57 | 58 | # PROMISE: DH NOOP WITHOUT menu menu-method cli-options() 59 | 60 | foreach my $package (@{$dh{DOPACKAGES}}) { 61 | my $tmp=tmpdir($package); 62 | my $menu=pkgfile($package,"menu"); 63 | my $menu_method=pkgfile($package,"menu-method"); 64 | 65 | if ($menu ne '') { 66 | install_dir("$tmp/usr/share/menu"); 67 | install_file($menu,"$tmp/usr/share/menu/$package"); 68 | 69 | # Add the scripts if a menu-method file doesn't exist. 70 | # The scripts for menu-method handle everything these do, too. 71 | if ($menu_method eq "" && ! $dh{NOSCRIPTS}) { 72 | autoscript($package,"postinst","postinst-menu"); 73 | autoscript($package,"postrm","postrm-menu") 74 | } 75 | } 76 | 77 | if ($menu_method ne '') { 78 | install_dir("$tmp/etc/menu-methods"); 79 | install_file($menu_method,"$tmp/etc/menu-methods/$package"); 80 | 81 | if (! $dh{NOSCRIPTS}) { 82 | autoscript($package, 'postinst', 'postinst-menu-method', { 'PACKAGE' => $package }); 83 | autoscript($package, 'postrm', 'postrm-menu-method', { 'PACKAGE' => $package }); 84 | } 85 | } 86 | } 87 | 88 | =head1 SEE ALSO 89 | 90 | L 91 | L 92 | L 93 | 94 | This program is a part of debhelper. 95 | 96 | =head1 AUTHOR 97 | 98 | Joey Hess 99 | 100 | =cut 101 | -------------------------------------------------------------------------------- /lib/Debian/Debhelper/Buildsystem/perl_build.pm: -------------------------------------------------------------------------------- 1 | # A build system class for handling Perl Build based projects. 2 | # 3 | # Copyright: © 2008-2009 Joey Hess 4 | # © 2008-2009 Modestas Vainius 5 | # License: GPL-2+ 6 | 7 | package Debian::Debhelper::Buildsystem::perl_build; 8 | 9 | use strict; 10 | use warnings; 11 | use Debian::Debhelper::Dh_Lib qw(compat is_cross_compiling perl_cross_incdir); 12 | use parent qw(Debian::Debhelper::Buildsystem); 13 | use Config; 14 | 15 | sub DESCRIPTION { 16 | "Perl Module::Build (Build.PL)" 17 | } 18 | 19 | sub check_auto_buildable { 20 | my ($this, $step) = @_; 21 | 22 | # Handles everything 23 | my $ret = -e $this->get_sourcepath("Build.PL"); 24 | if ($step ne "configure") { 25 | $ret &&= -e $this->get_sourcepath("Build"); 26 | } 27 | return $ret ? 1 : 0; 28 | } 29 | 30 | sub do_perl { 31 | my $this=shift; 32 | my %options; 33 | if (is_cross_compiling()) { 34 | my $cross_incdir = perl_cross_incdir(); 35 | if (defined $cross_incdir) { 36 | my $perl5lib = $cross_incdir; 37 | $perl5lib .= $Config{path_sep} . $ENV{PERL5LIB} 38 | if defined $ENV{PERL5LIB}; 39 | $options{update_env} = { PERL5LIB => $perl5lib }; 40 | } else { 41 | warning("cross Config.pm does not exist (missing build dependency on perl-xs-dev?)"); 42 | } 43 | } 44 | $this->doit_in_sourcedir(\%options, "perl", @_); 45 | } 46 | 47 | sub new { 48 | my $class=shift; 49 | my $this= $class->SUPER::new(@_); 50 | $this->enforce_in_source_building(); 51 | return $this; 52 | } 53 | 54 | sub configure { 55 | my $this=shift; 56 | my (@flags, @perl_flags); 57 | $ENV{PERL_MM_USE_DEFAULT}=1; 58 | if ($ENV{CFLAGS} && ! compat(8)) { 59 | push @flags, "--config", "optimize=$ENV{CFLAGS} $ENV{CPPFLAGS}"; 60 | } 61 | if ($ENV{LDFLAGS} && ! compat(8)) { 62 | my $ld = $Config{ld}; 63 | if (is_cross_compiling()) { 64 | my $incdir = perl_cross_incdir(); 65 | $ld = qx/perl -I$incdir -MConfig -e 'print \$Config{ld}'/ 66 | if defined $incdir; 67 | } 68 | push @flags, "--config", "ld=$ld $ENV{CFLAGS} $ENV{LDFLAGS}"; 69 | } 70 | push(@perl_flags, '-I.') if compat(10); 71 | $this->do_perl(@perl_flags, "Build.PL", "--installdirs", "vendor", @flags, @_); 72 | } 73 | 74 | sub build { 75 | my $this=shift; 76 | $this->do_perl("Build", @_); 77 | } 78 | 79 | sub test { 80 | my $this=shift; 81 | $this->do_perl("Build", "test", "--verbose", 1, @_); 82 | } 83 | 84 | sub install { 85 | my $this=shift; 86 | my $destdir=shift; 87 | $this->do_perl("Build", "install", "--destdir", "$destdir", "--create_packlist", 0, @_); 88 | } 89 | 90 | sub clean { 91 | my $this=shift; 92 | if (-e $this->get_sourcepath("Build")) { 93 | $this->do_perl("Build", "realclean", "--allow_mb_mismatch", 1, @_); 94 | } 95 | } 96 | 97 | 1 98 | -------------------------------------------------------------------------------- /dh_installudev: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | =head1 NAME 4 | 5 | dh_installudev - install udev rules files 6 | 7 | =cut 8 | 9 | use strict; 10 | use warnings; 11 | use Debian::Debhelper::Dh_Lib; 12 | 13 | our $VERSION = DH_BUILTIN_VERSION; 14 | 15 | =head1 SYNOPSIS 16 | 17 | B [S>] [B<-n>] [B<--name=>I] [B<--priority=>I] 18 | 19 | =head1 DESCRIPTION 20 | 21 | B is a debhelper program that is responsible for 22 | installing B rules files. 23 | 24 | =head1 FILES 25 | 26 | =over 4 27 | 28 | =item debian/I.udev 29 | 30 | Installed into F in the package build directory. 31 | 32 | =back 33 | 34 | =head1 OPTIONS 35 | 36 | =over 4 37 | 38 | =item B<--name=>I 39 | 40 | When this parameter is used, B looks for and 41 | installs files named debian/I.I.udev instead of the usual 42 | debian/I.udev. 43 | 44 | =item B<--priority=>I 45 | 46 | Sets the priority the file. Default is 60. 47 | 48 | =back 49 | 50 | =head1 NOTES 51 | 52 | Note that this command is not idempotent. L should be called 53 | between invocations of this command. Otherwise, it may cause multiple 54 | instances of the same text to be added to maintainer scripts. 55 | 56 | =cut 57 | 58 | init(options => { 59 | "priority=s" => \$dh{PRIORITY}, 60 | }); 61 | 62 | # The priority used to look like z60_; 63 | # we need to calculate that old value to handle 64 | # conffile moves correctly. 65 | my $old_priority=$dh{PRIORITY}; 66 | 67 | # In case a caller still uses the `z` prefix, remove it. 68 | if (defined $dh{PRIORITY}) { 69 | $dh{PRIORITY}=~s/^z//; 70 | } 71 | 72 | if (! defined $dh{PRIORITY}) { 73 | $dh{PRIORITY}="60"; 74 | $old_priority="z60"; 75 | } 76 | if ($dh{PRIORITY}) { 77 | $dh{PRIORITY}.="-"; 78 | $old_priority.="_"; 79 | } 80 | 81 | # PROMISE: DH NOOP WITHOUT udev cli-options() 82 | 83 | foreach my $package (@{$dh{DOPACKAGES}}) { 84 | my $tmp=tmpdir($package); 85 | my $rules_file=pkgfile($package,"udev"); 86 | my $filename=basename($rules_file); 87 | if ($filename eq 'udev') { 88 | $filename = "$package.udev"; 89 | } 90 | $filename=~s/\.udev$/.rules/; 91 | if (defined $dh{NAME}) { 92 | $filename="$dh{NAME}.rules"; 93 | } 94 | 95 | if ($rules_file) { 96 | my $rule="/lib/udev/rules.d/$dh{PRIORITY}$filename"; 97 | install_dir("$tmp/lib/udev/rules.d"); 98 | install_file($rules_file, "${tmp}${rule}"); 99 | } 100 | } 101 | 102 | =head1 SEE ALSO 103 | 104 | L 105 | 106 | This program is a part of debhelper. 107 | 108 | =head1 AUTHOR 109 | 110 | Joey Hess 111 | 112 | =cut 113 | -------------------------------------------------------------------------------- /t/dh_install/02-bugs-53XXXX.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use warnings; 4 | use Test::More; 5 | 6 | use File::Basename qw(dirname); 7 | use lib dirname(dirname(__FILE__)); 8 | use Test::DH; 9 | use File::Path qw(remove_tree make_path); 10 | use Debian::Debhelper::Dh_Lib qw(!dirname); 11 | 12 | plan(tests => 4); 13 | 14 | each_compat_from_and_above_subtest(7, sub { 15 | my ($compat) = @_; 16 | # #537140: debian/tmp is explcitly specified despite being searched by 17 | # default in v7+ 18 | 19 | make_path('debian/tmp/usr/bin'); 20 | create_empty_file('debian/tmp/usr/bin/foo'); 21 | create_empty_file('debian/tmp/usr/bin/bar'); 22 | ok(run_dh_tool('dh_install', 'debian/tmp/usr/bin/foo')); 23 | ok(-e "debian/debhelper/usr/bin/foo", "#537140 [${compat}]"); 24 | ok(! -e "debian/debhelper/usr/bin/bar", "#537140 [${compat}]"); 25 | remove_tree('debian/debhelper', 'debian/tmp'); 26 | }); 27 | 28 | each_compat_from_and_above_subtest(7, sub { 29 | my ($compat) = @_; 30 | # #534565: glob expands to dangling symlink -> should install the dangling link 31 | make_path('debian/tmp/usr/bin'); 32 | make_symlink_raw_target('broken', 'debian/tmp/usr/bin/foo'); 33 | create_empty_file('debian/tmp/usr/bin/bar'); 34 | ok(run_dh_tool('dh_install', 'usr/bin/*')); 35 | ok(-l "debian/debhelper/usr/bin/foo", "#534565 [${compat}]"); 36 | ok(!-e "debian/debhelper/usr/bin/foo", "#534565 [${compat}]"); 37 | ok(-e "debian/debhelper/usr/bin/bar", "#534565 [${compat}]"); 38 | ok(!-l "debian/debhelper/usr/bin/bar", "#534565 [${compat}]"); 39 | remove_tree('debian/debhelper', 'debian/tmp'); 40 | }); 41 | 42 | each_compat_subtest { 43 | my ($compat) = @_; 44 | # #537017: --sourcedir=debian/tmp/foo is used 45 | make_path('debian/tmp/foo/usr/bin'); 46 | create_empty_file('debian/tmp/foo/usr/bin/foo'); 47 | create_empty_file('debian/tmp/foo/usr/bin/bar'); 48 | ok(run_dh_tool('dh_install', '--sourcedir=debian/tmp/foo', 'usr/bin/bar')); 49 | ok(-e "debian/debhelper/usr/bin/bar", "#537017 [${compat}]"); 50 | ok(!-e "debian/debhelper/usr/bin/foo", "#537017 [${compat}]"); 51 | remove_tree('debian/debhelper', 'debian/tmp'); 52 | }; 53 | 54 | each_compat_from_and_above_subtest(7, sub { 55 | my ($compat) = @_; 56 | # #535367: installation of entire top-level directory from debian/tmp 57 | make_path('debian/tmp/usr/bin'); 58 | create_empty_file('debian/tmp/usr/bin/foo'); 59 | create_empty_file('debian/tmp/usr/bin/bar'); 60 | ok(run_dh_tool('dh_install', 'usr')); 61 | ok(-e "debian/debhelper/usr/bin/foo", "#535367 [${compat}]"); 62 | ok(-e "debian/debhelper/usr/bin/bar", "#535367 [${compat}]"); 63 | remove_tree('debian/debhelper', 'debian/tmp'); 64 | }); 65 | 66 | -------------------------------------------------------------------------------- /dh_installgsettings: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | =head1 NAME 4 | 5 | dh_installgsettings - install GSettings overrides and set dependencies 6 | 7 | =cut 8 | 9 | use strict; 10 | use warnings; 11 | use Debian::Debhelper::Dh_Lib; 12 | 13 | our $VERSION = DH_BUILTIN_VERSION; 14 | 15 | =head1 SYNOPSIS 16 | 17 | B [S>] [B<--priority=>] 18 | 19 | =head1 DESCRIPTION 20 | 21 | B is a debhelper program that is responsible for installing 22 | GSettings override files and generating appropriate dependencies on the 23 | GSettings backend. 24 | 25 | The dependency on the backend will be generated in B<${misc:Depends}>. 26 | 27 | =head1 FILES 28 | 29 | =over 4 30 | 31 | =item debian/I.gsettings-override 32 | 33 | Installed into usr/share/glib-2.0/schemas/10_I.gschema.override in 34 | the package build directory, with "I" replaced by the package name. 35 | 36 | The format of the file is the following: 37 | 38 | [org.gnome.mypackage] 39 | boolean-setting=true 40 | string-setting='string' 41 | ... 42 | 43 | =back 44 | 45 | =head1 OPTIONS 46 | 47 | =over 4 48 | 49 | =item B<--priority> I 50 | 51 | Use I (which should be a 2-digit number) as the override 52 | priority instead of 10. Higher values than ten can be used by 53 | derived distributions (20), blend distributions (50), or site-specific 54 | packages (90). 55 | 56 | =cut 57 | 58 | init(options => { 59 | "priority=s" => \$dh{PRIORITY}, 60 | }); 61 | 62 | my $priority=10; 63 | if (defined $dh{PRIORITY}) { 64 | $priority=$dh{PRIORITY}; 65 | } 66 | 67 | # PROMISE: DH NOOP WITHOUT gsettings-override tmp(usr/share/glib-2.0/schemas) cli-options() 68 | 69 | foreach my $package (@{$dh{DOPACKAGES}}) { 70 | my $tmp=tmpdir($package); 71 | 72 | my $gsettings_schemas_dir = "$tmp/usr/share/glib-2.0/schemas/"; 73 | 74 | my $override = pkgfile($package,"gsettings-override"); 75 | if ($override ne '') { 76 | install_dir($gsettings_schemas_dir); 77 | install_file($override, 78 | "$gsettings_schemas_dir/${priority}_$package.gschema.override"); 79 | } 80 | 81 | if (-d "$gsettings_schemas_dir") { 82 | # Get a list of the schemas 83 | my $schemas = qx_cmd('find', $gsettings_schemas_dir, '-type', 'f', 84 | '(', '-name', '*.xml', '-o', '-name', '*.override', 85 | ')', '-printf', '%P'); 86 | if ($schemas ne '') { 87 | addsubstvar($package, "misc:Depends", "dconf-gsettings-backend | gsettings-backend"); 88 | } 89 | } 90 | } 91 | 92 | =back 93 | 94 | =head1 SEE ALSO 95 | 96 | L 97 | 98 | This program is a part of debhelper. 99 | 100 | =head1 AUTHOR 101 | 102 | Laurent Bigonville , 103 | Josselin Mouette 104 | 105 | =cut 106 | 107 | -------------------------------------------------------------------------------- /t/dh_installman/01-basics.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use warnings; 4 | use Test::More; 5 | 6 | use File::Basename qw(dirname); 7 | use lib dirname(dirname(__FILE__)); 8 | use Test::DH; 9 | use File::Path qw(remove_tree make_path); 10 | use Debian::Debhelper::Dh_Lib qw(!dirname); 11 | 12 | sub has_man_db_tool { 13 | my ($tool) = @_; 14 | open(my $old_stderr, '>&', *STDERR) or error("dup(STDERR, tmp_fd): $!"); 15 | open(*STDERR, '>', '/dev/null') or error("re-open stderr as /dev/null: $!"); 16 | 17 | my $res = defined(`$tool --version`); 18 | open(*STDERR, '>&', $old_stderr) or error("dup(tmp_fd, STDERR): $!"); 19 | close($old_stderr); 20 | return $res; 21 | } 22 | 23 | if (has_man_db_tool('man') || has_man_db_tool('man-recode')) { 24 | plan(tests => 2); 25 | } else { 26 | plan(skip_all => 'Test requires man or man-recode'); 27 | } 28 | 29 | our @TEST_DH_EXTRA_TEMPLATE_FILES = (qw( 30 | manpage-uncompressed.pod 31 | manpage-compressed.pod 32 | )); 33 | 34 | each_compat_subtest { 35 | my ($compat) = @_; 36 | if (! -d 'generated-manpages') { 37 | # Static data that can be reused. Generate only in the first test 38 | make_path('generated-manpages'); 39 | for my $basename (qw(manpage-uncompressed manpage-compressed)) { 40 | doit('pod2man', '--utf8', '-c', 'Debhelper', '-r', '1.0', "${basename}.pod", 41 | "generated-manpages/${basename}.1"); 42 | } 43 | doit('gzip', '-9n', 'generated-manpages/manpage-compressed.1'); 44 | } 45 | ok(run_dh_tool('dh_installman', 'generated-manpages/manpage-uncompressed.1', 46 | 'generated-manpages/manpage-compressed.1.gz')); 47 | ok(-e 'debian/debhelper/usr/share/man/man1/manpage-uncompressed.1'); 48 | ok(-e 'debian/debhelper/usr/share/man/man1/manpage-compressed.1'); 49 | remove_tree('debian/debhelper', 'debian/tmp', 'debian/.debhelper'); 50 | }; 51 | 52 | each_compat_subtest { 53 | my ($compat) = @_; 54 | if (! -d 'generated-manpages') { 55 | # Static data that can be reused. Generate only in the first test 56 | make_path('generated-manpages'); 57 | for my $basename (qw(manpage-uncompressed manpage-compressed)) { 58 | doit('pod2man', '--utf8', '-c', 'Debhelper', '-r', '1.0', "${basename}.pod", 59 | "generated-manpages/${basename}.1"); 60 | } 61 | doit('gzip', '-9n', 'generated-manpages/manpage-compressed.1'); 62 | } 63 | install_dir('debian/debhelper/usr/share/man/man1'); 64 | install_file('generated-manpages/manpage-uncompressed.1', 'debian/debhelper/usr/share/man/man1/manpage-uncompressed.1'); 65 | install_file('generated-manpages/manpage-compressed.1.gz', 'debian/debhelper/usr/share/man/man1/manpage-compressed.1.gz'); 66 | ok(run_dh_tool('dh_installman')); 67 | ok(-e 'debian/debhelper/usr/share/man/man1/manpage-uncompressed.1'); 68 | ok(-e 'debian/debhelper/usr/share/man/man1/manpage-compressed.1'); 69 | remove_tree('debian/debhelper', 'debian/tmp', 'debian/.debhelper'); 70 | }; 71 | 72 | -------------------------------------------------------------------------------- /dh_ucf: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | =head1 NAME 4 | 5 | dh_ucf - register configuration files with ucf 6 | 7 | =cut 8 | 9 | use strict; 10 | use warnings; 11 | use Debian::Debhelper::Dh_Lib; 12 | 13 | our $VERSION = DH_BUILTIN_VERSION; 14 | 15 | =head1 SYNOPSIS 16 | 17 | B [S>] [B<-A>] [B<-n>] [S ...>] 18 | 19 | =head1 DESCRIPTION 20 | 21 | B is a debhelper program that is responsible for generating the 22 | F and F commands that register files with ucf(1) and ucfr(1). 23 | 24 | =head1 FILES 25 | 26 | =over 4 27 | 28 | =item debian/I.ucf 29 | 30 | List pairs of source and destination files to register with ucf. Each pair 31 | should be put on its own line, with the source and destination separated by 32 | whitespace. Both source and destination must be absolute paths. The source 33 | should be a file that is provided by your package, typically in /usr/share/, 34 | while the destination is typically a file in /etc/. 35 | 36 | A dependency on ucf will be generated in B<${misc:Depends}>. 37 | 38 | Supports substitution variables in compat 13 and later as 39 | documented in L. 40 | 41 | =back 42 | 43 | =head1 OPTIONS 44 | 45 | =over 4 46 | 47 | =item B<-A>, B<--all> 48 | 49 | Install all files specified by command line parameters in ALL packages 50 | acted on. 51 | 52 | =item B<-n>, B<--no-scripts> 53 | 54 | Do not modify F/F scripts. Turns this command into a no-op. 55 | 56 | =item I ... 57 | 58 | Install these info files into the first package acted on. (Or in 59 | all packages if B<-A> is specified). 60 | 61 | =back 62 | 63 | =head1 NOTES 64 | 65 | Note that this command is not idempotent. L should be called 66 | between invocations of this command. Otherwise, it may cause multiple 67 | instances of the same text to be added to maintainer scripts. 68 | 69 | =cut 70 | 71 | init(); 72 | 73 | # PROMISE: DH NOOP WITHOUT ucf cli-options() 74 | 75 | foreach my $package (@{$dh{DOPACKAGES}}) { 76 | my $file=pkgfile($package,"ucf"); 77 | 78 | my @ucf; 79 | if ($file) { 80 | @ucf=filedoublearray($file); 81 | } 82 | 83 | if (($package eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) { 84 | push @ucf, [@ARGV]; 85 | } 86 | 87 | if (! $dh{NOSCRIPTS}) { 88 | if (@ucf) { 89 | addsubstvar($package, "misc:Depends", "ucf"); 90 | } 91 | foreach my $set (@ucf) { 92 | my $src = $set->[0]; 93 | my $dest = $set->[1]; 94 | autoscript($package,"postinst","postinst-ucf","s:#UCFSRC#:$src:g;s:#UCFDEST#:$dest:g;s/#PACKAGE#/$package/g",); 95 | autoscript($package,"postrm","postrm-ucf","s:#UCFDEST#:$dest:g;s/#PACKAGE#/$package/g"); 96 | } 97 | } 98 | } 99 | 100 | =head1 SEE ALSO 101 | 102 | L 103 | 104 | This program is a part of debhelper. 105 | 106 | =head1 AUTHOR 107 | 108 | Joey Hess 109 | Jeroen Schot 110 | 111 | =cut 112 | -------------------------------------------------------------------------------- /lib/Debian/Debhelper/Buildsystem/autoconf.pm: -------------------------------------------------------------------------------- 1 | # A debhelper build system class for handling Autoconf based projects 2 | # 3 | # Copyright: © 2008 Joey Hess 4 | # © 2008-2009 Modestas Vainius 5 | # License: GPL-2+ 6 | 7 | package Debian::Debhelper::Buildsystem::autoconf; 8 | 9 | use strict; 10 | use warnings; 11 | use Debian::Debhelper::Dh_Lib qw(%dh dpkg_architecture_value sourcepackage compat); 12 | use parent qw(Debian::Debhelper::Buildsystem::makefile); 13 | 14 | sub DESCRIPTION { 15 | "GNU Autoconf (configure)" 16 | } 17 | 18 | sub check_auto_buildable { 19 | my $this=shift; 20 | my ($step)=@_; 21 | 22 | return 0 unless -f $this->get_sourcepath("configure") && 23 | -x _; 24 | 25 | # Handle configure explicitly; inherit the rest 26 | return 1 if $step eq "configure"; 27 | return $this->SUPER::check_auto_buildable(@_); 28 | } 29 | 30 | sub configure { 31 | my $this=shift; 32 | 33 | # Standard set of options for configure. 34 | my @opts; 35 | push @opts, "--build=" . dpkg_architecture_value("DEB_BUILD_GNU_TYPE"); 36 | push @opts, "--prefix=/usr"; 37 | push @opts, "--includedir=\${prefix}/include"; 38 | push @opts, "--mandir=\${prefix}/share/man"; 39 | push @opts, "--infodir=\${prefix}/share/info"; 40 | push @opts, "--sysconfdir=/etc"; 41 | push @opts, "--localstatedir=/var"; 42 | # We pass --disable/enable-* options that might be unknown, so we 43 | # should not emit warnings. 44 | push @opts, "--disable-option-checking"; 45 | if ($dh{QUIET}) { 46 | push @opts, "--enable-silent-rules"; 47 | } else { 48 | push @opts, "--disable-silent-rules"; 49 | } 50 | my $multiarch=dpkg_architecture_value("DEB_HOST_MULTIARCH"); 51 | if (! compat(8)) { 52 | if (defined $multiarch) { 53 | push @opts, "--libdir=\${prefix}/lib/$multiarch"; 54 | push(@opts, "--libexecdir=\${prefix}/lib/$multiarch") if compat(11); 55 | } 56 | else { 57 | push(@opts, "--libexecdir=\${prefix}/lib") if compat(11); 58 | } 59 | } 60 | else { 61 | push @opts, "--libexecdir=\${prefix}/lib/" . sourcepackage(); 62 | } 63 | push @opts, "--runstatedir=/run" if not compat(10); 64 | push @opts, "--disable-maintainer-mode"; 65 | push @opts, "--disable-dependency-tracking"; 66 | # Provide --host only if different from --build, as recommended in 67 | # autotools-dev README.Debian: When provided (even if equal) 68 | # autoconf 2.52+ switches to cross-compiling mode. 69 | if (dpkg_architecture_value("DEB_BUILD_GNU_TYPE") 70 | ne dpkg_architecture_value("DEB_HOST_GNU_TYPE")) { 71 | push @opts, "--host=" . dpkg_architecture_value("DEB_HOST_GNU_TYPE"); 72 | } 73 | 74 | $this->mkdir_builddir(); 75 | eval { 76 | $this->doit_in_builddir($this->get_source_rel2builddir("configure"), @opts, @_); 77 | }; 78 | if ($@) { 79 | if (-e $this->get_buildpath("config.log")) { 80 | $this->doit_in_builddir('tail', '-v', '-n', '+0', 'config.log'); 81 | } 82 | die $@; 83 | } 84 | } 85 | 86 | sub test { 87 | my $this=shift; 88 | $this->make_first_existing_target(['test', 'check'], 89 | "VERBOSE=1", @_); 90 | } 91 | 92 | 1 93 | -------------------------------------------------------------------------------- /lib/Debian/Debhelper/Buildsystem/qmake.pm: -------------------------------------------------------------------------------- 1 | # A debhelper build system class for Qt projects 2 | # (based on the makefile class). 3 | # 4 | # Copyright: © 2010 Kelvin Modderman 5 | # License: GPL-2+ 6 | 7 | package Debian::Debhelper::Buildsystem::qmake; 8 | 9 | use strict; 10 | use warnings; 11 | use Debian::Debhelper::Dh_Lib qw(dpkg_architecture_value error is_cross_compiling); 12 | use parent qw(Debian::Debhelper::Buildsystem::makefile); 13 | 14 | my %OS_MKSPEC_MAPPING = ( 15 | 'linux' => 'linux-g++', 16 | 'kfreebsd' => 'gnukfreebsd-g++', 17 | 'hurd' => 'hurd-g++', 18 | ); 19 | 20 | sub DESCRIPTION { 21 | "qmake (*.pro)"; 22 | } 23 | 24 | sub check_auto_buildable { 25 | my $this=shift; 26 | my @projects=glob($this->get_sourcepath('*.pro')); 27 | my $ret=0; 28 | 29 | if (@projects > 0) { 30 | $ret=1; 31 | # Existence of a Makefile generated by qmake indicates qmake 32 | # class has already been used by a prior build step, so should 33 | # be used instead of the parent makefile class. 34 | my $mf=$this->get_buildpath("Makefile"); 35 | if (-e $mf) { 36 | $ret = $this->SUPER::check_auto_buildable(@_); 37 | open(my $fh, '<', $mf) 38 | or error("unable to open Makefile: $mf"); 39 | while(<$fh>) { 40 | if (m/^# Generated by qmake/i) { 41 | $ret++; 42 | last; 43 | } 44 | } 45 | close($fh); 46 | } 47 | } 48 | 49 | return $ret; 50 | } 51 | 52 | sub configure { 53 | my $this=shift; 54 | my @options; 55 | my @flags; 56 | 57 | push @options, '-makefile'; 58 | if (is_cross_compiling()) { 59 | my $host_os = dpkg_architecture_value("DEB_HOST_ARCH_OS"); 60 | 61 | if (defined(my $spec = $OS_MKSPEC_MAPPING{$host_os})) { 62 | push(@options, "-spec", $spec); 63 | } else { 64 | error("Cannot cross-compile: Missing entry for HOST OS ${host_os} for qmake's -spec option"); 65 | } 66 | } 67 | 68 | if ($ENV{CFLAGS}) { 69 | push @flags, "QMAKE_CFLAGS_RELEASE=$ENV{CFLAGS} $ENV{CPPFLAGS}"; 70 | push @flags, "QMAKE_CFLAGS_DEBUG=$ENV{CFLAGS} $ENV{CPPFLAGS}"; 71 | } 72 | if ($ENV{CXXFLAGS}) { 73 | push @flags, "QMAKE_CXXFLAGS_RELEASE=$ENV{CXXFLAGS} $ENV{CPPFLAGS}"; 74 | push @flags, "QMAKE_CXXFLAGS_DEBUG=$ENV{CXXFLAGS} $ENV{CPPFLAGS}"; 75 | } 76 | if ($ENV{LDFLAGS}) { 77 | push @flags, "QMAKE_LFLAGS_RELEASE=$ENV{LDFLAGS}"; 78 | push @flags, "QMAKE_LFLAGS_DEBUG=$ENV{LDFLAGS}"; 79 | } 80 | push @flags, "QMAKE_STRIP=:"; 81 | push @flags, "PREFIX=/usr"; 82 | 83 | $this->mkdir_builddir(); 84 | $this->doit_in_builddir($this->_qmake(), @options, @flags, @_); 85 | } 86 | 87 | sub install { 88 | my $this=shift; 89 | my $destdir=shift; 90 | 91 | # qmake generated Makefiles use INSTALL_ROOT in install target 92 | # where one would expect DESTDIR to be used. 93 | $this->SUPER::install($destdir, "INSTALL_ROOT=$destdir", @_); 94 | } 95 | 96 | sub _qmake { 97 | if (is_cross_compiling()) { 98 | return dpkg_architecture_value("DEB_HOST_GNU_TYPE") . "-qmake"; 99 | } 100 | return 'qmake'; 101 | } 102 | 103 | 1 104 | -------------------------------------------------------------------------------- /dh_installinitramfs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | =head1 NAME 4 | 5 | dh_installinitramfs - install initramfs hooks and setup maintscripts 6 | 7 | =cut 8 | 9 | use strict; 10 | use warnings; 11 | use Debian::Debhelper::Dh_Lib; 12 | 13 | our $VERSION = DH_BUILTIN_VERSION; 14 | 15 | =head1 SYNOPSIS 16 | 17 | B [S>] [B<-n>] 18 | 19 | =head1 DESCRIPTION 20 | 21 | B is a debhelper program that is responsible for 22 | installing Debian package provided initramfs hooks. 23 | 24 | If B installs or detects one or more initramfs 25 | hooks in the package, then it also automatically generates the noawait 26 | trigger B command needed to interface with the 27 | Debian initramfs system. This trigger is inserted into the 28 | packaging by L. 29 | 30 | =head1 FILES 31 | 32 | =over 4 33 | 34 | =item debian/I.initramfs-hook 35 | 36 | Assumed to be an initramfs hook that will be installed into F<< 37 | usr/share/initramfs-tools/hooks/I >> in the package build 38 | directory. See B in L for more 39 | information about initramfs hooks. 40 | 41 | =back 42 | 43 | =head1 OPTIONS 44 | 45 | =over 4 46 | 47 | =item B<-n>, B<--no-scripts> 48 | 49 | Do not add the B trigger even if it seems like the package 50 | might need it. The option is called B<--no-scripts> for historical 51 | reasons as B would previously generate maintainer 52 | scripts that called B. 53 | 54 | Use this option, if you need to interface with the B 55 | system that is not satisfied by the noawait trigger (e.g. because you need 56 | the extra guarantees and head-aches of a await trigger). 57 | 58 | =back 59 | 60 | =head1 NOTES 61 | 62 | Note that this command is not idempotent. L should be called 63 | between invocations of this command. Otherwise, it may cause multiple 64 | instances of the same text to be added to triggers file. 65 | 66 | =cut 67 | 68 | init(); 69 | 70 | # PROMISE: DH NOOP WITHOUT initramfs-hook tmp(usr/share/initramfs-tools/hooks) cli-options() 71 | 72 | foreach my $package (@{$dh{DOPACKAGES}}) { 73 | my $tmp = tmpdir($package); 74 | my $hook_script = pkgfile($package, 'initramfs-hook'); 75 | my $has_hooks; 76 | my $hook_dir = "${tmp}/usr/share/initramfs-tools/hooks"; 77 | 78 | if ($hook_script ne '') { 79 | install_dir($hook_dir); 80 | install_prog($hook_script, "${hook_dir}/${package}"); 81 | $has_hooks = 1; 82 | } elsif (-d $hook_dir and not is_empty_dir($hook_dir)) { 83 | $has_hooks = 1; 84 | } 85 | 86 | if ($has_hooks && ! $dh{NOSCRIPTS}) { 87 | autotrigger($package, 'activate-noawait', 'update-initramfs'); 88 | } 89 | } 90 | 91 | =head1 SEE ALSO 92 | 93 | L 94 | L 95 | L 96 | 97 | This program is a part of debhelper. 98 | 99 | =head1 AUTHOR 100 | 101 | Niels Thykier 102 | 103 | =cut 104 | -------------------------------------------------------------------------------- /lib/Debian/Debhelper/Sequence/root_sequence.pm: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use Debian::Debhelper::Dh_Lib qw(compat); 5 | use Debian::Debhelper::SequencerUtil; 6 | 7 | my $include_if_compat_X_or_newer = sub { 8 | my ($compat, @commands) = @_; 9 | return if compat($compat - 1, 1); 10 | return @commands; 11 | }; 12 | 13 | my @obsolete_command = ( 14 | $include_if_compat_X_or_newer->(11, 'dh_systemd_enable', 'dh_systemd_start'), 15 | ); 16 | 17 | my @commands_controlled_by_deb_build_options = ( 18 | $include_if_compat_X_or_newer->(13, ['dh_auto_test', 'nocheck'], ['dh_dwz', 'nostrip'], ['dh_strip', 'nostrip']), 19 | ); 20 | 21 | my @bd_minimal = qw{ 22 | dh_testdir 23 | }; 24 | my @bd = (@bd_minimal, qw{ 25 | dh_update_autotools_config 26 | dh_auto_configure 27 | dh_auto_build 28 | dh_auto_test 29 | }); 30 | my @i = (qw{ 31 | dh_testroot 32 | dh_prep 33 | dh_installdirs 34 | dh_auto_install 35 | 36 | dh_install 37 | dh_installdocs 38 | dh_installchangelogs 39 | dh_installexamples 40 | dh_installman 41 | 42 | dh_installcatalogs 43 | dh_installcron 44 | dh_installdebconf 45 | dh_installemacsen 46 | dh_installifupdown 47 | dh_installinfo 48 | dh_installinit 49 | }, 50 | $include_if_compat_X_or_newer->(13, 'dh_installtmpfiles'), 51 | $include_if_compat_X_or_newer->(11, 'dh_installsystemd'), 52 | $include_if_compat_X_or_newer->(12, 'dh_installsystemduser'), 53 | qw{ 54 | dh_installmenu 55 | dh_installmime 56 | dh_installmodules 57 | dh_installlogcheck 58 | dh_installlogrotate 59 | dh_installpam 60 | dh_installppp 61 | dh_installudev 62 | dh_installgsettings 63 | }, 64 | (!compat(11) ? qw(dh_installinitramfs) : qw()), 65 | qw{ 66 | dh_installalternatives 67 | dh_bugfiles 68 | dh_ucf 69 | dh_lintian 70 | dh_gconf 71 | dh_icons 72 | dh_perl 73 | dh_usrlocal 74 | 75 | dh_link 76 | dh_installwm 77 | dh_installxfonts 78 | dh_strip_nondeterminism 79 | dh_compress 80 | dh_fixperms 81 | dh_missing 82 | }); 83 | 84 | # Looking for dh_dwz, dh_strip, dh_makeshlibs, dh_shlibdeps (et al)? They are 85 | # in the elf-tools addon. 86 | my @b=qw{ 87 | dh_installdeb 88 | dh_gencontrol 89 | dh_md5sums 90 | dh_builddeb 91 | }; 92 | 93 | _add_sequence('build', SEQUENCE_ARCH_INDEP_SUBSEQUENCES, @bd); 94 | _add_sequence('install', SEQUENCE_ARCH_INDEP_SUBSEQUENCES, to_rules_target("build"), @i); 95 | _add_sequence('binary', SEQUENCE_ARCH_INDEP_SUBSEQUENCES, to_rules_target("install"), @b); 96 | _add_sequence('clean', SEQUENCE_NO_SUBSEQUENCES, @bd_minimal, qw{ 97 | dh_auto_clean 98 | dh_clean 99 | }); 100 | 101 | for my $command (@obsolete_command) { 102 | declare_command_obsolete($command); 103 | } 104 | 105 | for my $entry (@commands_controlled_by_deb_build_options) { 106 | my ($command, $dbo_flag) = @{$entry}; 107 | # Dear reader; Should you be in doubt, then this is internal API that is 108 | # subject to change without notice. If you need this feature, please 109 | # make an explicit feature request, so we can implement a better solution. 110 | _skip_cmd_if_deb_build_options_contains($command, $dbo_flag); 111 | } 112 | 113 | 1; 114 | -------------------------------------------------------------------------------- /t/buildsystems/04-dh_auto_do_autoconf.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | use Test::More tests => 31; 6 | 7 | use File::Temp qw(tempdir); 8 | use File::Basename qw(dirname); 9 | use lib dirname(dirname(__FILE__)); 10 | use Test::DH; 11 | use File::Path qw(remove_tree make_path); 12 | use Debian::Debhelper::Dh_Lib qw(!dirname); 13 | use Debian::Debhelper::Dh_Buildsystems; 14 | 15 | # Let the tests to be run from anywhere but currect directory 16 | # is expected to be the one where this test lives in. 17 | chdir File::Basename::dirname($0) or die "Unable to chdir to ".File::Basename::dirname($0); 18 | 19 | $Test::DH::TEST_DH_COMPAT = 10; 20 | 21 | # Build the autoconf test package 22 | sub dh_auto_do_autoconf { 23 | my ($sourcedir, $builddir, %args) = @_; 24 | 25 | my (@lines, @extra_args); 26 | my $buildpath = $sourcedir; 27 | my @dh_auto_args = ("-D", $sourcedir); 28 | my $dh_auto_str = "-D $sourcedir"; 29 | if ($builddir) { 30 | push @dh_auto_args, "-B", $builddir; 31 | $dh_auto_str .= " -B $builddir"; 32 | $buildpath = $builddir; 33 | } 34 | 35 | my $do_dh_auto = sub { 36 | my ($step) = @_; 37 | my @extra_args; 38 | my $extra_str = ""; 39 | if (exists $args{"${step}_args"}) { 40 | push @extra_args, @{$args{"${step}_args"}}; 41 | $extra_str .= " $_" foreach (@extra_args); 42 | } 43 | ok(run_dh_tool({ 'quiet' => 1 }, "dh_auto_${step}", @dh_auto_args, '--', @extra_args), 44 | "dh_auto_$step $dh_auto_str$extra_str"); 45 | return @extra_args; 46 | }; 47 | 48 | @extra_args = &$do_dh_auto('configure'); 49 | ok ( -f "$buildpath/Makefile", "$buildpath/Makefile exists" ); 50 | @lines=(); 51 | if ( ok(open(FILE, '<', "$buildpath/stamp_configure"), "$buildpath/stamp_configure exists") ) { 52 | @lines = @{readlines(\*FILE)}; 53 | close(FILE); 54 | } 55 | is_deeply( \@lines, \@extra_args, "$buildpath/stamp_configure contains extra args" ); 56 | 57 | &$do_dh_auto('build'); 58 | ok ( -f "$buildpath/stamp_build", "$buildpath/stamp_build exists" ); 59 | &$do_dh_auto('test'); 60 | @lines=(); 61 | if ( ok(open(FILE, '<', "$buildpath/stamp_test"), "$buildpath/stamp_test exists") ) { 62 | @lines = @{readlines(\*FILE)}; 63 | close(FILE); 64 | } 65 | is_deeply( \@lines, [ "VERBOSE=1" ], 66 | "$buildpath/stamp_test contains VERBOSE=1" ); 67 | &$do_dh_auto('install'); 68 | @lines=(); 69 | if ( ok(open(FILE, '<', "$buildpath/stamp_install"), "$buildpath/stamp_install exists") ) { 70 | @lines = @{readlines(\*FILE)}; 71 | close(FILE); 72 | } 73 | is_deeply( \@lines, [ "DESTDIR=".Cwd::getcwd()."/debian/testpackage" ], 74 | "$buildpath/stamp_install contains DESTDIR" ); 75 | &$do_dh_auto('clean'); 76 | if ($builddir) { 77 | ok ( ! -e "$buildpath", "builddir $buildpath was removed" ); 78 | } 79 | else { 80 | ok ( ! -e "$buildpath/Makefile" && ! -e "$buildpath/stamp_configure", "Makefile and stamps gone" ); 81 | } 82 | ok ( -x "$sourcedir/configure", "configure script renamins after clean" ); 83 | } 84 | 85 | dh_auto_do_autoconf('autoconf'); 86 | dh_auto_do_autoconf('autoconf', 'bld/dir', configure_args => [ "--extra-autoconf-configure-arg" ]); 87 | ok ( ! -e 'bld', "bld got deleted too" ); 88 | 89 | -------------------------------------------------------------------------------- /debhelper-obsolete-compat.pod: -------------------------------------------------------------------------------- 1 | =head1 NAME 2 | 3 | debhelper-obsolete-compat - List of no longer supported compat levels 4 | 5 | =head1 SYNOPSIS 6 | 7 | This document contains the upgrade guidelines from all compat levels 8 | which are no longer supported. Accordingly it is mostly for 9 | historical purposes and to assist people upgrading from a 10 | non-supported compat level to a supported level. 11 | 12 | For upgrades from supported compat levels, please see L. 13 | 14 | =head1 UPGRADE LIST FOR COMPAT LEVELS 15 | 16 | The following is the list of now obsolete compat levels and their 17 | changes. 18 | 19 | =over 4 20 | 21 | =item v1 22 | 23 | This is the original debhelper compatibility level, and so it is the default 24 | one. In this mode, debhelper will use F as the package tree 25 | directory for the first binary package listed in the control file, while using 26 | debian/I for all other packages listed in the F file. 27 | 28 | This mode is deprecated. 29 | 30 | =item v2 31 | 32 | In this mode, debhelper will consistently use debian/I 33 | as the package tree directory for every package that is built. 34 | 35 | This mode is deprecated. 36 | 37 | =item v3 38 | 39 | This mode works like v2, with the following additions: 40 | 41 | =over 8 42 | 43 | =item - 44 | 45 | Debhelper config files support globbing via B<*> and B, when appropriate. To 46 | turn this off and use those characters raw, just prefix with a backslash. 47 | 48 | =item - 49 | 50 | B makes the F and F scripts call B. 51 | 52 | =item - 53 | 54 | Every file in F is automatically flagged as a conffile by B. 55 | 56 | =back 57 | 58 | This mode is deprecated. 59 | 60 | =item v4 61 | 62 | Changes from v3 are: 63 | 64 | =over 8 65 | 66 | =item - 67 | 68 | B will not include the Debian part of the version number in 69 | the generated dependency line in the shlibs file. 70 | 71 | =item - 72 | 73 | You are encouraged to put the new B<${misc:Depends}> into F to 74 | supplement the B<${shlibs:Depends}> field. 75 | 76 | =item - 77 | 78 | B will make all files in F directories and in F 79 | executable. 80 | 81 | =item - 82 | 83 | B will correct existing links to conform with policy. 84 | 85 | =back 86 | 87 | This mode is deprecated. 88 | 89 | =item v5 90 | 91 | This is the lowest supported compatibility level. 92 | 93 | Changes from v4 are: 94 | 95 | =over 8 96 | 97 | =item - 98 | 99 | Comments are ignored in debhelper config files. 100 | 101 | =item - 102 | 103 | B now specifies the name of a package to put debugging 104 | symbols in, not the packages to take the symbols from. 105 | 106 | =item - 107 | 108 | B skips installing empty files. 109 | 110 | =item - 111 | 112 | B errors out if wildcards expand to nothing. 113 | 114 | =back 115 | 116 | =back 117 | 118 | =head1 SEE ALSO 119 | 120 | L 121 | 122 | =head1 AUTHORS 123 | 124 | Niels Thykier 125 | 126 | Joey Hess 127 | 128 | =cut 129 | -------------------------------------------------------------------------------- /lib/Debian/Debhelper/Buildsystem/perl_makemaker.pm: -------------------------------------------------------------------------------- 1 | # A debhelper build system class for handling Perl MakeMaker based projects. 2 | # 3 | # Copyright: © 2008-2009 Joey Hess 4 | # © 2008-2009 Modestas Vainius 5 | # License: GPL-2+ 6 | 7 | package Debian::Debhelper::Buildsystem::perl_makemaker; 8 | 9 | use strict; 10 | use warnings; 11 | use Debian::Debhelper::Dh_Lib qw(compat is_cross_compiling perl_cross_incdir warning); 12 | use parent qw(Debian::Debhelper::Buildsystem::makefile); 13 | use Config; 14 | 15 | sub DESCRIPTION { 16 | "Perl ExtUtils::MakeMaker (Makefile.PL)" 17 | } 18 | 19 | sub check_auto_buildable { 20 | my $this=shift; 21 | my ($step)=@_; 22 | 23 | # Handles everything if Makefile.PL exists. Otherwise - next class. 24 | if (-e $this->get_sourcepath("Makefile.PL")) { 25 | if ($step eq "configure") { 26 | return 1; 27 | } 28 | else { 29 | return $this->SUPER::check_auto_buildable(@_); 30 | } 31 | } 32 | return 0; 33 | } 34 | 35 | sub new { 36 | my $class=shift; 37 | my $this=$class->SUPER::new(@_); 38 | $this->enforce_in_source_building(); 39 | return $this; 40 | } 41 | 42 | sub configure { 43 | my $this=shift; 44 | my (@flags, @perl_flags); 45 | # If set to a true value then MakeMaker's prompt function will 46 | # # always return the default without waiting for user input. 47 | $ENV{PERL_MM_USE_DEFAULT}=1; 48 | # This prevents Module::Install from interactive behavior. 49 | $ENV{PERL_AUTOINSTALL}="--skipdeps"; 50 | 51 | if ($ENV{CFLAGS} && ! compat(8)) { 52 | push @flags, "OPTIMIZE=$ENV{CFLAGS} $ENV{CPPFLAGS}"; 53 | } 54 | my $cross_flag; 55 | if (is_cross_compiling()) { 56 | my $incdir = perl_cross_incdir(); 57 | if (defined $incdir) { 58 | $cross_flag = "-I$incdir"; 59 | } else { 60 | warning("cross Config.pm does not exist (missing build dependency on perl-xs-dev?)"); 61 | } 62 | } 63 | if ($ENV{LDFLAGS} && ! compat(8)) { 64 | my $ld = $Config{ld}; 65 | $ld = qx/perl $cross_flag -MConfig -e 'print \$Config{ld}'/ 66 | if is_cross_compiling() and defined $cross_flag; 67 | push @flags, "LD=$ld $ENV{CFLAGS} $ENV{LDFLAGS}"; 68 | } 69 | 70 | push(@perl_flags, '-I.') if compat(10); 71 | 72 | push @perl_flags, $cross_flag 73 | if is_cross_compiling() and defined $cross_flag; 74 | 75 | $this->doit_in_sourcedir("perl", @perl_flags, "Makefile.PL", "INSTALLDIRS=vendor", 76 | # if perl_build is not tested first, need to pass packlist 77 | # option to handle fallthrough case 78 | (compat(7) ? "create_packlist=0" : ()), 79 | @flags, @_); 80 | } 81 | 82 | sub test { 83 | my $this=shift; 84 | # Make tests verbose 85 | $this->SUPER::test("TEST_VERBOSE=1", @_); 86 | } 87 | 88 | sub install { 89 | my $this=shift; 90 | my $destdir=shift; 91 | 92 | # Special case for Makefile.PL that uses 93 | # Module::Build::Compat. PREFIX should not be passed 94 | # for those; it already installs into /usr by default. 95 | my $makefile=$this->get_sourcepath("Makefile"); 96 | if (system(qq{grep -q "generated automatically by MakeMaker" $makefile}) != 0) { 97 | $this->SUPER::install($destdir, @_); 98 | } 99 | else { 100 | $this->SUPER::install($destdir, "PREFIX=/usr", @_); 101 | } 102 | } 103 | 104 | 1 105 | -------------------------------------------------------------------------------- /t/dh_install/04-sourcedir.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use warnings; 4 | use Test::More; 5 | 6 | use File::Basename qw(dirname); 7 | use lib dirname(dirname(__FILE__)); 8 | use Test::DH; 9 | use File::Path qw(remove_tree make_path); 10 | use Debian::Debhelper::Dh_Lib qw(!dirname); 11 | 12 | plan(tests => 6); 13 | 14 | 15 | each_compat_up_to_and_incl_subtest(6, sub { 16 | my ($compat) = @_; 17 | # debian/tmp explicitly specified in filenames in older compat level 18 | make_path('debian/tmp/usr/bin'); 19 | create_empty_file('debian/tmp/usr/bin/foo'); 20 | create_empty_file('debian/tmp/usr/bin/bar'); 21 | ok(run_dh_tool('dh_install', 'debian/tmp/usr/bin/foo')); 22 | ok(-e "debian/debhelper/usr/bin/foo"); 23 | ok(!-e "debian/debhelper/usr/bin/bar"); 24 | remove_tree('debian/debhelper', 'debian/tmp'); 25 | }); 26 | 27 | each_compat_up_to_and_incl_subtest(6, sub { 28 | my ($compat) = @_; 29 | # --sourcedir=debian/tmp in older compat level 30 | make_path('debian/tmp/usr/bin'); 31 | create_empty_file('debian/tmp/usr/bin/foo'); 32 | create_empty_file('debian/tmp/usr/bin/bar'); 33 | ok(run_dh_tool('dh_install', '--sourcedir=debian/tmp', 'usr/bin/foo')); 34 | ok(-e "debian/debhelper/usr/bin/foo"); 35 | ok(! -e "debian/debhelper/usr/bin/bar"); 36 | remove_tree('debian/debhelper', 'debian/tmp'); 37 | }); 38 | 39 | each_compat_from_and_above_subtest(7, sub { 40 | my ($compat) = @_; 41 | # redundant --sourcedir=debian/tmp in v7+ 42 | make_path('debian/tmp/usr/bin'); 43 | create_empty_file('debian/tmp/usr/bin/foo'); 44 | create_empty_file('debian/tmp/usr/bin/bar'); 45 | ok(run_dh_tool('dh_install', '--sourcedir=debian/tmp', 'usr/bin/foo')); 46 | ok(-e "debian/debhelper/usr/bin/foo"); 47 | ok(! -e "debian/debhelper/usr/bin/bar"); 48 | remove_tree('debian/debhelper', 'debian/tmp'); 49 | }); 50 | 51 | each_compat_from_and_above_subtest(7, sub { 52 | my ($compat) = @_; 53 | # #534565: fallback use of debian/tmp in v7+ 54 | make_path('debian/tmp/usr/bin'); 55 | create_empty_file('debian/tmp/usr/bin/foo'); 56 | create_empty_file('debian/tmp/usr/bin/bar'); 57 | ok(run_dh_tool('dh_install', 'usr')); 58 | ok(-e "debian/debhelper/usr/bin/foo", "#534565 [${compat}]"); 59 | ok(-e "debian/debhelper/usr/bin/bar", "#534565 [${compat}]"); 60 | remove_tree('debian/debhelper', 'debian/tmp'); 61 | }); 62 | 63 | each_compat_up_to_and_incl_subtest(6, sub { 64 | my ($compat) = @_; 65 | # no fallback to debian/tmp before v7 66 | make_path('debian/tmp/usr/bin'); 67 | create_empty_file('debian/tmp/usr/bin/foo'); 68 | create_empty_file('debian/tmp/usr/bin/bar'); 69 | ok(!run_dh_tool({ 'quiet' => 1 }, 'dh_install', 'usr')); 70 | ok(!-e "debian/debhelper/usr/bin/foo"); 71 | ok(!-e "debian/debhelper/usr/bin/bar"); 72 | remove_tree('debian/debhelper', 'debian/tmp'); 73 | }); 74 | 75 | 76 | each_compat_subtest { 77 | my ($compat) = @_; 78 | # specification of file in source directory not in debian/tmp 79 | make_path('bar/usr/bin'); 80 | create_empty_file('bar/usr/bin/foo'); 81 | ok(run_dh_tool('dh_install', '--sourcedir=bar', 'usr/bin/foo')); 82 | ok(-e "debian/debhelper/usr/bin/foo"); 83 | remove_tree('debian/debhelper', 'debian/tmp'); 84 | }; 85 | -------------------------------------------------------------------------------- /dh_installmodules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | =head1 NAME 4 | 5 | dh_installmodules - register kernel modules 6 | 7 | =cut 8 | 9 | use strict; 10 | use warnings; 11 | use Debian::Debhelper::Dh_Lib; 12 | use File::Find; 13 | 14 | our $VERSION = DH_BUILTIN_VERSION; 15 | 16 | =head1 SYNOPSIS 17 | 18 | B [S>] [B<-n>] [B<--name=>I] 19 | 20 | =head1 DESCRIPTION 21 | 22 | B is a debhelper program that is responsible for 23 | registering kernel modules. 24 | 25 | Kernel modules are searched for in the package build directory and if 26 | found, F, F and F commands are automatically generated to 27 | run B and register the modules when the package is installed. 28 | These commands are inserted into the maintainer scripts by 29 | L. 30 | 31 | =head1 FILES 32 | 33 | =over 4 34 | 35 | =item debian/I.modprobe 36 | 37 | Installed to etc/modprobe.d/I.conf in the package build directory. 38 | 39 | =back 40 | 41 | =head1 OPTIONS 42 | 43 | =over 4 44 | 45 | =item B<-n>, B<--no-scripts> 46 | 47 | Do not modify F/F/F scripts. 48 | 49 | =item B<--name=>I 50 | 51 | When this parameter is used, B looks for and 52 | installs files named debian/I.I.modprobe instead 53 | of the usual debian/I.modprobe 54 | 55 | =back 56 | 57 | =head1 NOTES 58 | 59 | Note that this command is not idempotent. L should be called 60 | between invocations of this command. Otherwise, it may cause multiple 61 | instances of the same text to be added to maintainer scripts. 62 | 63 | =cut 64 | 65 | init(); 66 | 67 | # Looks for kernel modules in the passed directory. If any are found, 68 | # returns the kernel version (or versions) that the modules seem to be for. 69 | sub find_kernel_modules { 70 | my $searchdir=shift; 71 | my %versions; 72 | 73 | return unless -d $searchdir; 74 | find(sub { 75 | if (m/ [.]k?o (?:[.](?:[gx]z|bz2))? $/x) { 76 | my ($kvers)=$File::Find::dir=~m!lib/modules/([^/]+)/!; 77 | if (! defined $kvers || ! length $kvers) { 78 | warning("Cannot determine kernel version for module $File::Find::name"); 79 | } 80 | else { 81 | $versions{$kvers}=1; 82 | } 83 | } 84 | }, $searchdir); 85 | 86 | return sort(keys(%versions)); 87 | } 88 | 89 | # PROMISE: DH NOOP WITHOUT modprobe tmp(lib/modules) cli-options() 90 | 91 | foreach my $package (@{$dh{DOPACKAGES}}) { 92 | my $tmp=tmpdir($package); 93 | my $modprobe_file=pkgfile($package,"modprobe"); 94 | 95 | if ($modprobe_file) { 96 | my $path = '/etc/modprobe.d/' . pkgfilename($package) . '.conf'; 97 | install_dir("$tmp/etc/modprobe.d"); 98 | install_file($modprobe_file, "$tmp/$path"); 99 | } 100 | 101 | if (! $dh{NOSCRIPTS}) { 102 | foreach my $kvers (find_kernel_modules("$tmp/lib/modules")) { 103 | autoscript($package, 'postinst', 'postinst-modules', { 'KVERS' => $kvers }); 104 | autoscript($package, 'postrm', 'postrm-modules', { 'KVERS' => $kvers }); 105 | } 106 | } 107 | } 108 | 109 | =head1 SEE ALSO 110 | 111 | L 112 | 113 | This program is a part of debhelper. 114 | 115 | =head1 AUTHOR 116 | 117 | Joey Hess 118 | 119 | =cut 120 | -------------------------------------------------------------------------------- /dh_installxfonts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | =head1 NAME 4 | 5 | dh_installxfonts - register X fonts 6 | 7 | =cut 8 | 9 | use strict; 10 | use warnings; 11 | use Debian::Debhelper::Dh_Lib; 12 | 13 | our $VERSION = DH_BUILTIN_VERSION; 14 | 15 | =head1 SYNOPSIS 16 | 17 | B [S>] 18 | 19 | =head1 DESCRIPTION 20 | 21 | B is a debhelper program that is responsible for 22 | registering X fonts, so their corresponding F, F, 23 | and F be rebuilt properly at install time. 24 | 25 | Before calling this program, you should have installed any X fonts provided 26 | by your package into the appropriate location in the package build 27 | directory, and if you have F or F files, you should 28 | install them into the correct location under F in your 29 | package build directory. 30 | 31 | Your package should depend on B so that the 32 | BI<*> commands are available. (This program adds that dependency to 33 | B<${misc:Depends}>.) 34 | 35 | This program automatically generates the F and F commands needed 36 | to register X fonts. These commands are inserted into the maintainer 37 | scripts by B. See L for an explanation of how 38 | this works. 39 | 40 | =head1 NOTES 41 | 42 | See L, L, and 43 | L for more information about X font installation. 44 | 45 | See Debian policy, section 11.8.5. for details about doing fonts the Debian 46 | way. 47 | 48 | =cut 49 | 50 | init(); 51 | 52 | # PROMISE: DH NOOP WITHOUT tmp(usr/share/fonts/X11) cli-options() 53 | 54 | foreach my $package (@{$dh{DOPACKAGES}}) { 55 | my $tmp=tmpdir($package); 56 | 57 | # Find all font directories in the package build directory. 58 | my @fontdirs; 59 | foreach my $parentdir ("$tmp/usr/share/fonts/X11/") { 60 | opendir(DIR, $parentdir) || next; 61 | @fontdirs = grep { -d "$parentdir/$_" && !/^\./ } (readdir DIR); 62 | closedir DIR; 63 | } 64 | 65 | if (@fontdirs) { 66 | # Figure out what commands the postinst and postrm will need 67 | # to call. 68 | my (@cmds, @cmds_postinst, @cmds_postrm); 69 | # Sort items for reproducible binary package contents. 70 | foreach my $f (sort @fontdirs) { 71 | # This must come before update-fonts-dir. 72 | push @cmds, "update-fonts-scale $f" 73 | if -f "$tmp/etc/X11/fonts/$f/$package.scale"; 74 | push @cmds, "update-fonts-dir --x11r7-layout $f"; 75 | if (-f "$tmp/etc/X11/fonts/$f/$package.alias") { 76 | push @cmds_postinst, "update-fonts-alias --include /etc/X11/fonts/$f/$package.alias $f"; 77 | push @cmds_postrm, "update-fonts-alias --exclude /etc/X11/fonts/$f/$package.alias $f"; 78 | } 79 | } 80 | 81 | autoscript($package, "postinst", "postinst-xfonts", 82 | { 'CMDS' => join(";", @cmds, @cmds_postinst) }); 83 | autoscript($package, "postrm", "postrm-xfonts", 84 | { 'CMDS' => join(";", @cmds, @cmds_postrm) }); 85 | 86 | addsubstvar($package, "misc:Depends", "xfonts-utils"); 87 | } 88 | } 89 | 90 | =head1 SEE ALSO 91 | 92 | L 93 | 94 | This program is a part of debhelper. 95 | 96 | =head1 AUTHOR 97 | 98 | Joey Hess 99 | 100 | =cut 101 | -------------------------------------------------------------------------------- /t/dh_installsystemd/dh_installsystemd_tmpfiles.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use strict; 3 | use Test::More; 4 | 5 | use File::Basename qw(dirname); 6 | use lib dirname(dirname(__FILE__)); 7 | use Test::DH; 8 | use File::Path qw(remove_tree make_path); 9 | use Debian::Debhelper::Dh_Lib qw(!dirname); 10 | 11 | our @TEST_DH_EXTRA_TEMPLATE_FILES = (qw( 12 | debian/changelog 13 | debian/control 14 | debian/foo.service 15 | debian/foo.init 16 | )); 17 | 18 | plan(tests => 3); 19 | 20 | 21 | # Units are installed and enabled 22 | each_compat_from_x_to_and_incl_y_subtest(11, 12, sub { 23 | make_path('debian/foo/usr/lib/tmpfiles.d'); 24 | create_empty_file('debian/foo/usr/lib/tmpfiles.d/foo.conf'); 25 | ok(run_dh_tool('dh_installinit')); 26 | ok(run_dh_tool('dh_installsystemd')); 27 | ok(-e "debian/foo/etc/init.d/foo"); 28 | ok(-e "debian/foo/lib/systemd/system/foo.service"); 29 | my @postinst = find_script('foo', 'postinst'); 30 | # We should have two snippets (one for the tmpfiles and one for the services). 31 | is(scalar(@postinst), 2); 32 | if (scalar(@postinst) == 2) { 33 | open(my $fd, '<', $postinst[0]) or error("open($postinst[0]) failed: $!"); 34 | my $early_snippet = readlines($fd); 35 | close($fd); 36 | open($fd, '<', $postinst[1]) or error("open($postinst[1]) failed: $!"); 37 | my $late_snippet = readlines($fd); 38 | close($fd); 39 | ok(! grep { m/(?:invoke|update)-rc.d|deb-systemd-invoke/ } @{$early_snippet}); 40 | ok(grep { m/(?:invoke|update)-rc.d|deb-systemd-invoke/ } @{$late_snippet}); 41 | ok(grep { m/systemd-tmpfiles/ } @{$early_snippet}); 42 | ok(! grep { m/systemd-tmpfiles/ } @{$late_snippet}); 43 | } 44 | ok(run_dh_tool('dh_clean')); 45 | 46 | }); 47 | 48 | each_compat_from_and_above_subtest(13, sub { 49 | make_path('debian/foo/usr/lib/tmpfiles.d'); 50 | create_empty_file('debian/foo/usr/lib/tmpfiles.d/foo.conf'); 51 | ok(run_dh_tool('dh_installinit')); 52 | ok(run_dh_tool('dh_installsystemd')); 53 | ok(-e "debian/foo/etc/init.d/foo"); 54 | ok(-e "debian/foo/lib/systemd/system/foo.service"); 55 | my @postinst = find_script('foo', 'postinst'); 56 | # We should have one snippet (one for the services). 57 | is(scalar(@postinst), 1); 58 | if (scalar(@postinst) == 1) { 59 | open(my $fd, '<', $postinst[0]) or error("open($postinst[0]) failed: $!"); 60 | my $snippet = readlines($fd); 61 | close($fd); 62 | ok(grep { m/(?:invoke|update)-rc.d|deb-systemd-invoke/ } @{$snippet}); 63 | ok(! grep { m/systemd-tmpfiles/ } @{$snippet}); 64 | } 65 | ok(run_dh_tool('dh_clean')); 66 | }); 67 | 68 | 69 | each_compat_from_and_above_subtest(13, sub { 70 | make_path('debian/foo/usr/lib/tmpfiles.d'); 71 | create_empty_file('debian/foo/usr/lib/tmpfiles.d/foo.conf'); 72 | ok(run_dh_tool('dh_installtmpfiles')); 73 | # dh_installtmpfiles do not install services 74 | ok(!-e "debian/foo/etc/init.d/foo"); 75 | ok(!-e "debian/foo/lib/systemd/system/foo.service"); 76 | my @postinst = find_script('foo', 'postinst'); 77 | # We should have too snippets (one for the tmpfiles and one for the services). 78 | is(scalar(@postinst), 1); 79 | if (scalar(@postinst) == 1) { 80 | open(my $fd, '<', $postinst[0]) or error("open($postinst[0]) failed: $!"); 81 | my $snippet = readlines($fd); 82 | close($fd); 83 | ok(! grep { m/(?:invoke|update)-rc.d|deb-systemd-invoke/ } @{$snippet}); 84 | ok(grep { m/systemd-tmpfiles/ } @{$snippet}); 85 | } 86 | ok(run_dh_tool('dh_clean')); 87 | }); 88 | -------------------------------------------------------------------------------- /dh_auto_install: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | =head1 NAME 4 | 5 | dh_auto_install - automatically runs make install or similar 6 | 7 | =cut 8 | 9 | use strict; 10 | use warnings; 11 | use Debian::Debhelper::Dh_Lib; 12 | use Debian::Debhelper::Dh_Buildsystems; 13 | use File::Spec; 14 | use Cwd; 15 | 16 | our $VERSION = DH_BUILTIN_VERSION; 17 | 18 | =head1 SYNOPSIS 19 | 20 | B [S>] [S>] [S I>] 21 | 22 | =head1 DESCRIPTION 23 | 24 | B is a debhelper program that tries to automatically install 25 | built files. It does so by running the appropriate command for the build 26 | system it detects the package uses. For example, if there's a F and 27 | it contains a B target, then this is done by running B (or B, 28 | if the environment variable is set). If there is a F or F, 29 | it is used. Note that the Ant build system does not support installation, 30 | so B will not install files built using Ant. 31 | 32 | Unless B<--destdir> option is specified, the files are installed into 33 | debian/I/ if there is only one binary package. In the multiple binary 34 | package case, the files are instead installed into F, and should be 35 | moved from there to the appropriate package build directory using 36 | L. 37 | 38 | B is used to tell make where to install the files. 39 | If the Makefile was generated by MakeMaker from a F, it will 40 | automatically set B too, since such Makefiles need that. 41 | 42 | This is intended to work for about 90% of packages. If it doesn't work, or 43 | tries to use the wrong install target, you're encouraged to skip using 44 | B at all, and just run make install manually. 45 | 46 | =head1 OPTIONS 47 | 48 | See L> for a list of common build 49 | system selection and control options. 50 | 51 | =over 4 52 | 53 | =item B<--destdir=>I 54 | 55 | Install files into the specified I. If this option is not specified, 56 | destination directory is determined automatically as described in the 57 | L> section. 58 | 59 | =item B<--> I 60 | 61 | Pass I to the program that is run, after the parameters that 62 | B usually passes. 63 | 64 | =back 65 | 66 | =cut 67 | 68 | my $destdir; 69 | 70 | buildsystems_init(options => { 71 | "destdir=s" => \$destdir, 72 | }); 73 | 74 | # PROMISE: DH NOOP WITHOUT cli-options(BUILDSYSTEM) buildsystem(install) 75 | 76 | # If destdir is not specified, determine it automatically 77 | if (!$destdir) { 78 | my @allpackages=getpackages(); 79 | if (@allpackages > 1) { 80 | $destdir="debian/tmp"; 81 | } 82 | else { 83 | $destdir=tmpdir($dh{MAINPACKAGE}); 84 | } 85 | } 86 | $destdir = File::Spec->rel2abs($destdir, getcwd()); 87 | 88 | if (compat(10)) { 89 | # Ensure that all debian/ directories exist 90 | install_dir(map { tmpdir($_) } @{$dh{DOPACKAGES}}); 91 | } else { 92 | install_dir($destdir); 93 | } 94 | 95 | buildsystems_do("install", $destdir); 96 | 97 | =head1 SEE ALSO 98 | 99 | L 100 | 101 | This program is a part of debhelper. 102 | 103 | =head1 AUTHOR 104 | 105 | Joey Hess 106 | 107 | =cut 108 | -------------------------------------------------------------------------------- /dh_gconf: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | =head1 NAME 4 | 5 | dh_gconf - install GConf defaults files and register schemas (deprecated) 6 | 7 | =cut 8 | 9 | use strict; 10 | use warnings; 11 | use Debian::Debhelper::Dh_Lib; 12 | 13 | our $VERSION = DH_BUILTIN_VERSION; 14 | 15 | =head1 SYNOPSIS 16 | 17 | B [S>] [B<--priority=>I] 18 | 19 | =head1 DESCRIPTION 20 | 21 | B is a debhelper program that is responsible for installing GConf 22 | defaults files and registering GConf schemas. 23 | 24 | An appropriate dependency on gconf2 will be generated in B<${misc:Depends}>. 25 | 26 | =head1 FILES 27 | 28 | =over 4 29 | 30 | =item debian/I.gconf-defaults 31 | 32 | Installed into F in the package build 33 | directory, with I replaced by the package name. 34 | 35 | =item debian/I.gconf-mandatory 36 | 37 | Installed into F in the package build 38 | directory, with I replaced by the package name. 39 | 40 | =back 41 | 42 | =head1 OPTIONS 43 | 44 | =over 4 45 | 46 | =item B<--priority> I 47 | 48 | Use I (which should be a 2-digit number) as the defaults 49 | priority instead of B<10>. Higher values than ten can be used by 50 | derived distributions (B<20>), CDD distributions (B<50>), or site-specific 51 | packages (B<90>). 52 | 53 | =back 54 | 55 | =cut 56 | 57 | init(options => { 58 | "priority=s" => \$dh{PRIORITY}, 59 | }); 60 | 61 | warning("Please migrate to dh_installgsettings; gconf + dh_gconf is scheduled for removal."); 62 | 63 | my $priority=10; 64 | if (defined $dh{PRIORITY}) { 65 | $priority=$dh{PRIORITY}; 66 | } 67 | 68 | # PROMISE: DH NOOP WITHOUT gconf-mandatory gconf-defaults tmp(etc/gconf/schemas) tmp(usr/share/gconf/schemas) cli-options() 69 | 70 | foreach my $package (@{$dh{DOPACKAGES}}) { 71 | my $tmp=tmpdir($package); 72 | 73 | my $mandatory = pkgfile($package, "gconf-mandatory"); 74 | if ($mandatory ne '') { 75 | install_dir("$tmp/usr/share/gconf/mandatory"); 76 | install_file($mandatory, 77 | "$tmp/usr/share/gconf/mandatory/${priority}_$package"); 78 | } 79 | my $defaults = pkgfile($package,"gconf-defaults"); 80 | if ($defaults ne '') { 81 | install_dir("$tmp/usr/share/gconf/defaults"); 82 | install_file($defaults, "$tmp/usr/share/gconf/defaults/${priority}_$package"); 83 | } 84 | 85 | my $old_schemas_dir = "$tmp/etc/gconf/schemas"; 86 | my $new_schemas_dir = "$tmp/usr/share/gconf/schemas"; 87 | 88 | # Migrate schemas from /etc/gconf/schemas to /usr/share/gconf/schemas 89 | if (-d $old_schemas_dir) { 90 | install_dir($new_schemas_dir); 91 | complex_doit("mv $old_schemas_dir/*.schemas $new_schemas_dir/"); 92 | doit("rmdir","-p","--ignore-fail-on-non-empty",$old_schemas_dir); 93 | } 94 | 95 | if (-d "$new_schemas_dir") { 96 | # Get a list of the schemas 97 | my $schemas = qx_cmd('find', $new_schemas_dir, '-type', 'f', '-name', '*.schemas', 98 | '-printf', '%P'); 99 | if ($schemas ne '') { 100 | addsubstvar($package, "misc:Depends", "gconf2 (>= 2.28.1-2)"); 101 | } 102 | } 103 | } 104 | 105 | =head1 SEE ALSO 106 | 107 | L 108 | 109 | This program is a part of debhelper. 110 | 111 | =head1 AUTHOR 112 | 113 | Ross Burton 114 | Josselin Mouette 115 | 116 | =cut 117 | -------------------------------------------------------------------------------- /dh_testroot: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | =encoding UTF-8 4 | 5 | =head1 NAME 6 | 7 | dh_testroot - ensure that a package is built with necessary level of root permissions 8 | 9 | =head1 SYNOPSIS 10 | 11 | B [S>] 12 | 13 | =head1 DESCRIPTION 14 | 15 | B is used to determine if the target is being run with 16 | suffient access to root(-like) features. 17 | 18 | The definition of sufficient access depends on whether the builder 19 | (the tool invoking the F target) supports the 20 | I (R³) field. If the builder supports R³, then 21 | it will set the environment variable I and 22 | B will validate that the builder followed the minimum 23 | requirements for the given value of I. 24 | 25 | If the builder does not support I, then it will 26 | not set the I environment variable. This 27 | will in turn make B (and the rest of debhelper) fall back 28 | to assuming that (fake)root is implied. 29 | 30 | The following is a summary of how B behaves based on the 31 | I environment variable (leading and trailing 32 | whitespace in the variable is ignored). 33 | 34 | =over 4 35 | 36 | =item - 37 | 38 | If unset, or set to C, then B asserts 39 | that it is run as root or under L. 40 | 41 | =item - 42 | 43 | If set to C, then B returns successfully (without 44 | performing any additional checks). 45 | 46 | =item - 47 | 48 | If set to any other value than the above, then B asserts 49 | that it is either run as root (or under L) or the builder 50 | has provided the B environment variable (e.g. via 51 | dpkg-buildpackage -r). 52 | 53 | =back 54 | 55 | Please note that B does I read the 56 | I field. Which implies that B may 57 | produce incorrect result if the builder lies in 58 | I. On the flip side, it also enables things 59 | like testing for what will happen when I is 60 | set to a given value. 61 | 62 | =cut 63 | 64 | use strict; 65 | use warnings; 66 | use Debian::Debhelper::Dh_Lib; 67 | 68 | our $VERSION = DH_BUILTIN_VERSION; 69 | 70 | inhibit_log(); 71 | 72 | my $requirements = Debian::Debhelper::Dh_Lib::root_requirements(); 73 | 74 | if (! -f 'debian/control') { 75 | warning('dh_testroot must be called from the source root'); 76 | } 77 | 78 | # By declaration; nothing requires root and this command must be a no-op in that case. 79 | exit 0 if $requirements eq 'none'; 80 | # The builder /can/ choose to ignore the requirements and just call us as root. 81 | # If so, we do not bother checking the requirements any further. 82 | exit 0 if $< == 0; 83 | if ($requirements eq 'legacy-root') { 84 | error("You must run this as root (or use fakeroot)."); 85 | } else { 86 | my $env = $ENV{DEB_GAIN_ROOT_CMD}; 87 | error("Package needs targeted root but builder has not provided a gain-root command via \${DEB_GAIN_ROOT_CMD}") 88 | if not $env; 89 | } 90 | 91 | =head1 SEE ALSO 92 | 93 | L 94 | 95 | This program is a part of debhelper. 96 | 97 | =head1 AUTHOR 98 | 99 | Joey Hess 100 | 101 | =cut 102 | -------------------------------------------------------------------------------- /dh_installinfo: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | =head1 NAME 4 | 5 | dh_installinfo - install info files 6 | 7 | =cut 8 | 9 | use strict; 10 | use warnings; 11 | use Debian::Debhelper::Dh_Lib; 12 | 13 | our $VERSION = DH_BUILTIN_VERSION; 14 | 15 | =head1 SYNOPSIS 16 | 17 | B [S>] [B<-A>] [S ...>] 18 | 19 | =head1 DESCRIPTION 20 | 21 | B is a debhelper program that is responsible for installing 22 | info files into F in the package build directory. 23 | 24 | From debhelper compatibility level 11 on, B will fall back to 25 | looking in F for files, if it does not find them in the current 26 | directory (or wherever you've told it to look using B<--sourcedir>). 27 | 28 | =head1 FILES 29 | 30 | =over 4 31 | 32 | =item debian/I.info 33 | 34 | List info files to be installed. 35 | 36 | Supports substitution variables in compat 13 and later as 37 | documented in L. 38 | 39 | =back 40 | 41 | =head1 OPTIONS 42 | 43 | =over 4 44 | 45 | =item B<-A>, B<--all> 46 | 47 | Install all files specified by command line parameters in ALL packages 48 | acted on. 49 | 50 | =item B<--sourcedir=>I 51 | 52 | Look in the specified directory for files to be installed. This option 53 | requires compat 11 or later (it is silently ignored in compat 10 or earlier). 54 | 55 | Note that this is not the same as the B<--sourcedirectory> option used 56 | by the BI<*> commands. You rarely need to use this option, since 57 | B automatically looks for files in F in debhelper 58 | compatibility level 11 and above. 59 | 60 | =item I ... 61 | 62 | Install these info files into the first package acted on. (Or in 63 | all packages if B<-A> is specified). 64 | 65 | =back 66 | 67 | =cut 68 | 69 | init(options => { 70 | "sourcedir=s" => \$dh{SOURCEDIR}, 71 | }); 72 | 73 | # PROMISE: DH NOOP WITHOUT pkgfile-logged(info) cli-options() 74 | 75 | my $default_error_handler = compat(10) ? \&glob_expand_error_handler_reject_nomagic_warn_discard : \&glob_expand_error_handler_reject; 76 | my $nodocs = is_build_profile_active('nodoc') || get_buildoption('nodoc') ? 1 : 0; 77 | # We cannot assume documentation is built under nodoc, but if it is we must flag it as handled 78 | # or dh_missing might make noise. 79 | $default_error_handler = \&glob_expand_error_handler_silently_ignore if $nodocs; 80 | 81 | foreach my $package (getpackages()) { 82 | my $tmp=tmpdir($package); 83 | my $file=pkgfile($package,"info"); 84 | my @search_dirs = ('.'); 85 | my $skip_install = process_pkg($package) ? 0 : 1; 86 | my $error_handler = $skip_install ? \&glob_expand_error_handler_silently_ignore : $default_error_handler; 87 | @search_dirs = ($dh{SOURCEDIR} // '.', default_sourcedir($package)) if not compat(10); 88 | 89 | my @info; 90 | 91 | if ($file) { 92 | @info = filearray($file, \@search_dirs, $error_handler) if $file; 93 | } 94 | 95 | if (($package eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) { 96 | push @info, @ARGV; 97 | } 98 | 99 | log_installed_files($package, @info); 100 | 101 | next if $skip_install or $nodocs; 102 | 103 | if (@info) { 104 | install_dir("$tmp/usr/share/info"); 105 | xargs(\@info, "cp", '--reflink=auto', XARGS_INSERT_PARAMS_HERE, "$tmp/usr/share/info"); 106 | doit("chmod","-R", "u+rw,go=rX","$tmp/usr/share/info/"); 107 | } 108 | } 109 | 110 | =head1 SEE ALSO 111 | 112 | L 113 | 114 | This program is a part of debhelper. 115 | 116 | =head1 AUTHOR 117 | 118 | Joey Hess 119 | 120 | =cut 121 | -------------------------------------------------------------------------------- /t/dh_compress.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use File::Basename qw(dirname); 7 | use lib dirname(__FILE__); 8 | use Test::DH; 9 | 10 | use File::Path qw(make_path remove_tree); 11 | use Test::More; 12 | use Debian::Debhelper::Dh_Lib qw(!dirname); 13 | 14 | my $PREFIX = 'debian/debhelper/usr/share/doc/debhelper'; 15 | 16 | plan tests => 2; 17 | 18 | each_compat_subtest { 19 | # we are testing compressing doc txt files 20 | # foo.txt is 2k and bar.txt is 5k 21 | mk_test_dir(); 22 | 23 | # default operation, bar.txt becomes bar.txt.gz and foo.txt is 24 | # unchanged 25 | ok(run_dh_tool('dh_compress')); 26 | 27 | is_deeply( 28 | [map { s{${PREFIX}/}{}; $_ } sort glob "$PREFIX/*"], 29 | [qw|bar.txt.gz foo.txt|], 30 | '5k txt doc compressed, 2k txt doc not compressed' 31 | ); 32 | 33 | mk_test_dir(); 34 | 35 | # now if I want to pass both on the command line to dh_compress, 36 | # it should compress both 37 | ok(run_dh_tool('dh_compress', '--', 38 | 'usr/share/doc/debhelper/foo.txt', 39 | 'usr/share/doc/debhelper/bar.txt')); 40 | 41 | is_deeply( 42 | [map { s{${PREFIX}/}{}; $_ } sort glob "$PREFIX/*"], 43 | [qw|bar.txt.gz foo.txt.gz|], 44 | 'both 5k and 2k txt docs compressed' 45 | ); 46 | 47 | mk_test_dir(); 48 | 49 | # absolute paths should also work 50 | ok(run_dh_tool('dh_compress', '--', 51 | '/usr/share/doc/debhelper/foo.txt', 52 | '/usr/share/doc/debhelper/bar.txt')); 53 | 54 | is_deeply( 55 | [map { s{${PREFIX}/}{}; $_ } sort glob "$PREFIX/*"], 56 | [qw|bar.txt.gz foo.txt.gz|], 57 | 'both 5k and 2k txt docs compressed by absolute path args' 58 | ); 59 | 60 | rm_test_dir(); 61 | 62 | mk_test_dir(); 63 | 64 | is(system('cp', '-la', "${PREFIX}/bar.txt", "${PREFIX}/hardlink.txt"), 0, 65 | 'create hardlink'); 66 | 67 | ok(run_dh_tool('dh_compress')); 68 | 69 | is_deeply( 70 | [map { s{${PREFIX}/}{}; $_ } sort glob "$PREFIX/*"], 71 | [qw|bar.txt.gz foo.txt hardlink.txt.gz|], 72 | 'the 5k and its hardlink txt docs compressed' 73 | ); 74 | 75 | # Verify that the hardlink is preserved. 76 | my ($dev1, $inode1) = stat("${PREFIX}/bar.txt.gz") // error("stat ${PREFIX}/bar.txt.gz: $!"); 77 | my ($dev2, $inode2) = stat("${PREFIX}/hardlink.txt.gz") // error("stat ${PREFIX}/hardlink.txt.gz: $!"); 78 | 79 | is($dev1, $dev2, 'Still hardlinked'); 80 | is($inode1, $inode2, 'Still hardlinked'); 81 | 82 | rm_test_dir(); 83 | }; 84 | 85 | each_compat_from_and_above_subtest(12, sub { 86 | make_path("${PREFIX}/examples"); 87 | create_file_of_size("${PREFIX}/examples/foo.py", 5120); 88 | ok(run_dh_tool('dh_compress')); 89 | ok(-f "${PREFIX}/examples/foo.py", "${PREFIX}/examples/foo.py is not compressed"); 90 | ok(! -f "${PREFIX}/examples/foo.py.gz", "${PREFIX}/examples/foo.py is not compressed"); 91 | }); 92 | 93 | sub create_file_of_size { 94 | my ($filename, $size) = @_; 95 | open(my $fh, '>', $filename) or error("open($filename) failed: $!"); 96 | print {$fh} 'X' x $size; 97 | close($fh) or error("close($filename) failed: $!"); 98 | } 99 | 100 | sub mk_test_dir { 101 | rm_test_dir(); 102 | 103 | make_path($PREFIX); 104 | 105 | create_file_of_size("${PREFIX}/foo.txt", 2048); 106 | create_file_of_size("${PREFIX}/bar.txt", 5120); 107 | } 108 | 109 | sub rm_test_dir { 110 | remove_tree('debian/debhelper'); 111 | 112 | rm_files('debian/debhelper.debhelper.log'); 113 | } 114 | 115 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: debhelper 2 | Section: devel 3 | Priority: optional 4 | Maintainer: Debhelper Maintainers 5 | Uploaders: Niels Thykier , 6 | Build-Depends: dpkg-dev (>= 1.18.0~), 7 | perl:any, 8 | po4a, 9 | man-db , 10 | libtest-pod-perl , 11 | Rules-Requires-Root: no 12 | Standards-Version: 4.5.0 13 | Testsuite: autopkgtest-pkg-perl 14 | Vcs-Git: https://salsa.debian.org/debian/debhelper.git 15 | Vcs-Browser: https://salsa.debian.org/debian/debhelper 16 | 17 | Package: debhelper 18 | Architecture: all 19 | Depends: autotools-dev, 20 | # Version 12 is where dh-autoreconf supports --sourcedirectory. 21 | # Version 16 fixes #887482, version 17 fixes #889567 22 | # Constraint can be relaxed if packages do not rely/require any of the 23 | # above fixes 24 | dh-autoreconf (>= 17~), 25 | # Version constraint is to get a version of dh-strip-nondeterminism 26 | # without several bugs. The constraint can be relaxed if an older 27 | # version is sufficient. 28 | dh-strip-nondeterminism (>= 0.028~), 29 | # dbgsym support landed in 1.18.0, 1.18.2 fixes a related nasty bug. 30 | dpkg (>= 1.18.0~), 31 | dpkg-dev (>= 1.18.2~), 32 | dwz, 33 | file (>= 3.23), 34 | libdpkg-perl (>= 1.17.14), 35 | man-db, 36 | libdebhelper-perl (= ${source:Version}), 37 | po-debconf, 38 | ${misc:Depends}, 39 | ${perl:Depends} 40 | Breaks: dh-systemd (<< 1.38), 41 | # To ensure cmake understands -DCMAKE_INSTALL_RUNSTATEDIR=/run as used in compat 11 42 | # - Can be dropped (with the caveat that cmake packages may behave differently 43 | # depending on the version of cmake). 44 | cmake (<< 3.9~), 45 | # meson build system uses --wrap-mode, which requires meson (>= 0.40.0) 46 | meson (<< 0.40.0~), 47 | # Re-add if qt5-qmake is added to stretch-backports 48 | # The qmake cross wrapper was introduced in 5.9.2+dfsg-5, but got some important 49 | # fixes in the subsequent uploads. It is only needed for cross-building. 50 | # qt5-qmake (<< 5.9.2+dfsg-8), 51 | Replaces: dh-systemd (<< 1.38) 52 | Suggests: dh-make 53 | Provides: ${dh:CompatLevels}, 54 | dh-sequence-dwz, 55 | dh-sequence-elf-tools, 56 | dh-sequence-installinitramfs, 57 | dh-sequence-systemd, 58 | Multi-Arch: foreign 59 | Description: helper programs for debian/rules 60 | A collection of programs that can be used in a debian/rules file to 61 | automate common tasks related to building Debian packages. Programs 62 | are included to install various files into your package, compress 63 | files, fix file permissions, integrate your package with the Debian 64 | menu system, debconf, doc-base, etc. Most Debian packages use debhelper 65 | as part of their build process. 66 | 67 | Package: libdebhelper-perl 68 | Section: perl 69 | Architecture: all 70 | Depends: ${misc:Depends}, 71 | ${perl:Depends} 72 | Replaces: debhelper (<< 12.6~) 73 | Breaks: debhelper (<< 12.6~) 74 | Multi-Arch: foreign 75 | Description: debhelper perl modules 76 | A collection of programs that can be used in a debian/rules file to 77 | automate common tasks related to building Debian packages. 78 | . 79 | This package provides the perl modules used by the scripts in debhelper. 80 | 81 | Package: dh-systemd 82 | Section: oldlibs 83 | Architecture: all 84 | Multi-Arch: foreign 85 | Depends: debhelper (>= 9.20160709), 86 | ${misc:Depends}, 87 | Description: debhelper add-on to handle systemd unit files - transitional package 88 | This package is for transitional purposes and can be removed safely. 89 | -------------------------------------------------------------------------------- /dh_installdirs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | =head1 NAME 4 | 5 | dh_installdirs - create subdirectories in package build directories 6 | 7 | =cut 8 | 9 | use strict; 10 | use warnings; 11 | use Debian::Debhelper::Dh_Lib; 12 | 13 | our $VERSION = DH_BUILTIN_VERSION; 14 | 15 | =head1 SYNOPSIS 16 | 17 | B [S>] [B<-A>] [B<--sourcedir=>I] [B<--create-in-sourcedir>] [S ...>] 18 | 19 | =head1 DESCRIPTION 20 | 21 | B is a debhelper program that is responsible for creating 22 | subdirectories in package build directories. 23 | 24 | Many packages can get away with omitting the call to B 25 | completely. Notably, other B commands are expected to create 26 | directories as needed. 27 | 28 | =head1 FILES 29 | 30 | =over 4 31 | 32 | =item debian/I.dirs 33 | 34 | Lists directories to be created in I. 35 | 36 | Generally, there is no need to list directories created by the 37 | upstream build system or directories needed by other B 38 | commands. 39 | 40 | Supports substitution variables in compat 13 and later as 41 | documented in L. 42 | 43 | =back 44 | 45 | =head1 OPTIONS 46 | 47 | =over 4 48 | 49 | =item B<-A>, B<--all> 50 | 51 | Create any directories specified by command line parameters in ALL packages 52 | acted on, not just the first. 53 | 54 | =item B<--create-in-sourcedir>, B<--no-create-in-sourcedir> 55 | 56 | Whether to create the specified directories in the source directory 57 | (usually F) I in the package build directory 58 | (usually F<< debian/I >>). 59 | 60 | The default is B<--no-create-in-sourcedir>. 61 | 62 | =item B<--sourcedir=>I 63 | 64 | Consider I the source directory for the packages acted on instead 65 | of the default (which is usually F). 66 | 67 | Please note that this option is dependent on the 68 | B<--create-in-sourcedir> option (when B<--no-create-in-sourcedir> is 69 | in effect, this option does nothing in B). 70 | 71 | =item I ... 72 | 73 | Create these directories in the package build directory of the first 74 | package acted on. (Or in all packages if B<-A> is specified.) 75 | 76 | =back 77 | 78 | =cut 79 | 80 | my $create_in_sourcedir = 0; 81 | 82 | init(options => { 83 | 'sourcedir=s' => \$dh{SOURCEDIR}, 84 | 'create-in-sourcedir!' => \$create_in_sourcedir, 85 | }); 86 | 87 | # PROMISE: DH NOOP WITHOUT dirs cli-options() 88 | 89 | foreach my $package (@{$dh{DOPACKAGES}}) { 90 | my $tmp=tmpdir($package); 91 | my $file=pkgfile($package,"dirs"); 92 | my $srcdir = $dh{SOURCEDIR} // default_sourcedir($package); 93 | 94 | install_dir($tmp) if compat(10); 95 | 96 | my @dirs; 97 | 98 | if ($file) { 99 | @dirs=filearray($file) 100 | } 101 | 102 | if (($package eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) { 103 | push @dirs, @ARGV; 104 | } 105 | 106 | if (@dirs) { 107 | # Stick the $tmp onto the front of all the dirs. 108 | # This is necessary, for 2 reasons, one to make them 109 | # be in the right directory, but more importantly, it 110 | # protects against the danger of absolute dirs being 111 | # specified. 112 | my @make_dirs; 113 | push(@make_dirs, map { 114 | my $dir = "$tmp/$_"; 115 | $dir =~ tr:/:/:s; # just beautification. 116 | $dir; 117 | } @dirs); 118 | if ($create_in_sourcedir) { 119 | push(@make_dirs, map { 120 | my $dir = "${srcdir}/$_"; 121 | $dir =~ tr:/:/:s; # just beautification. 122 | $dir; 123 | } @dirs); 124 | } 125 | 126 | # Create dirs. 127 | install_dir(@make_dirs); 128 | } 129 | } 130 | 131 | =head1 SEE ALSO 132 | 133 | L 134 | 135 | This program is a part of debhelper. 136 | 137 | =head1 AUTHOR 138 | 139 | Joey Hess 140 | 141 | =cut 142 | -------------------------------------------------------------------------------- /dh_installtmpfiles: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | 3 | =head1 NAME 4 | 5 | dh_installtmpfiles - install tmpfiles.d configuration files 6 | 7 | =cut 8 | 9 | use strict; 10 | use warnings; 11 | use Debian::Debhelper::Dh_Lib; 12 | use File::Find; 13 | 14 | our $VERSION = DH_BUILTIN_VERSION; 15 | 16 | =head1 SYNOPSIS 17 | 18 | B [S>][B<--name=>I] 19 | 20 | =head1 DESCRIPTION 21 | 22 | B is a debhelper program that is responsible for 23 | installing package maintainer supplied tmpfiles.d configuration files 24 | (e.g. for systemd-tmpfiles). 25 | 26 | It also finds the tmpfiles.d configuration files installed by a package 27 | and generates F code blocks for activting the tmpfiles.d 28 | configuration when the package is installed. These snippets are added 29 | to the maintainer scripts by L. 30 | 31 | 32 | =head1 OPTIONS 33 | 34 | =over 4 35 | 36 | This option controls both a prefix used for lookng up maintainer provided 37 | tmpfiles.d configuration files (those mentioned in the L section) 38 | and also the base name used for the installed version of the file. 39 | 40 | =back 41 | 42 | =head1 FILES 43 | 44 | =over 4 45 | 46 | =item debian/I.tmpfiles 47 | 48 | If this exists, it is installed into F in the 49 | package build directory. Note that the C mechanism is 50 | currently only used by systemd. 51 | 52 | =item debian/I.tmpfile 53 | 54 | Deprecated name for debian/I.tmpfiles. 55 | 56 | =back 57 | 58 | =head1 NOTES 59 | 60 | This command is not idempotent. L should be called between 61 | invocations of this command (with the same arguments). Otherwise, it 62 | may cause multiple instances of the same text to be added to 63 | maintainer scripts. 64 | 65 | =cut 66 | 67 | init(); 68 | 69 | sub uniq { 70 | my %seen; 71 | return grep { !$seen{$_}++ } @_; 72 | } 73 | 74 | # PROMISE: DH NOOP WITHOUT tmp(usr/lib/tmpfiles.d) tmp(etc/tmpfiles.d) pkgfile(tmpfiles) pkgfile(tmpfile) cli-options() 75 | 76 | # Install package maintainer supplied tmpfiles files 77 | foreach my $package (@{$dh{DOPACKAGES}}) { 78 | my $tmpdir = tmpdir($package); 79 | my $tmpfile = pkgfile($package, 'tmpfiles'); 80 | my $name = $dh{NAME} // $package; 81 | my $old_tmpfile = pkgfile($package, 'tmpfile'); 82 | my $dir; 83 | if (not $tmpfile) { 84 | my $new_name; 85 | next if not $old_tmpfile; 86 | $tmpfile = $old_tmpfile; 87 | $new_name = $old_tmpfile; 88 | $new_name =~ s{^(.+[./])tmpfile(\..+|)$}{$1tmpfiles$2}; 89 | warning("The name $tmpfile is deprecated; please use $new_name instead"); 90 | warning(qq{Possible fix: mv -f "${tmpfile}" "${new_name}"}); 91 | } elsif ($old_tmpfile) { 92 | warning("There is both a $tmpfile and a $old_tmpfile that is relevant for this package!?"); 93 | warning(qq{Possible fix: rm -f "${old_tmpfile}"}); 94 | error("Aborting; Please resolve the ambiguity between ${tmpfile} and ${old_tmpfile}."); 95 | } 96 | 97 | $dir = "$tmpdir/usr/lib/tmpfiles.d"; 98 | install_dir($dir); 99 | install_file($tmpfile, "${dir}/${name}.conf"); 100 | } 101 | 102 | # Add postinst code blocks to handle tmpfiles 103 | foreach my $package (@{$dh{DOPACKAGES}}) { 104 | my $tmpdir = tmpdir($package); 105 | my @tmpfiles; 106 | 107 | my @dirs = grep { -d } map { "${tmpdir}/$_" } qw(usr/lib/tmpfiles.d etc/tmpfiles.d); 108 | 109 | find({ 110 | wanted => sub { 111 | my $name = $File::Find::name; 112 | return unless -f $name; 113 | push(@tmpfiles, basename($name)); }, 114 | no_chdir => 1, 115 | }, @dirs) if @dirs; 116 | 117 | if (@tmpfiles) { 118 | autoscript($package, 'postinst', 'postinst-init-tmpfiles', { 'TMPFILES' => join(' ', uniq(sort(@tmpfiles))) }); 119 | } 120 | } 121 | 122 | =head1 SEE ALSO 123 | 124 | L 125 | 126 | =cut 127 | -------------------------------------------------------------------------------- /t/dh_usrlocal/01-basic.t: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use Test::More; 7 | plan(tests => 1); 8 | 9 | use File::Path qw(remove_tree); 10 | use File::Basename qw(dirname); 11 | use lib dirname(dirname(__FILE__)); 12 | use Test::DH; 13 | use Debian::Debhelper::Dh_Lib qw(!dirname); 14 | 15 | sub extract_generated_lines { 16 | my ($file) = @_; 17 | my (@lines, $marker); 18 | return if not -f $file; 19 | open(my $fd, '<', $file) or error("open($file) failed: $!"); 20 | while (my $line = <$fd>) { 21 | chomp($line); 22 | if (defined($marker)) { 23 | last if $line eq $marker; 24 | push(@lines, $line); 25 | next; 26 | } 27 | if ($line =~ m{\s*<<\s*(\S+)\s*$}) { 28 | $marker = $1; 29 | } 30 | } 31 | close($fd); 32 | return @lines; 33 | } 34 | 35 | 36 | sub perform_test { 37 | my ($install_dirs, $expected_dirs_postinst, $expected_dirs_prerm) = @_; 38 | my (@postinst, @prerm); 39 | my @scripts = qw( 40 | debian/debhelper.postinst.debhelper 41 | debian/debhelper.prerm.debhelper 42 | ); 43 | 44 | rm_files(@scripts); 45 | remove_tree('debian/debhelper'); 46 | install_dir(map { "debian/debhelper/$_" } @{$install_dirs}); 47 | 48 | ok(run_dh_tool('dh_usrlocal')); 49 | 50 | @postinst = extract_generated_lines("debian/debhelper.postinst.debhelper"); 51 | @prerm = extract_generated_lines("debian/debhelper.prerm.debhelper"); 52 | 53 | is_deeply(\@postinst, 54 | [map { "$_ default" } @{$expected_dirs_postinst}], 55 | "Correct postinst" 56 | ) or do { diag("postinst: $_") for @postinst; }; 57 | is_deeply(\@prerm, 58 | $expected_dirs_prerm, 59 | "Correct prerm" 60 | ) or do { diag("prerm: $_") for @prerm; }; 61 | } 62 | 63 | each_compat_subtest { 64 | 65 | perform_test( 66 | ['/usr/local/bar', '/usr/local/foo'], 67 | ['/usr/local/bar', '/usr/local/foo'], 68 | [] 69 | ); 70 | 71 | perform_test( 72 | [ 73 | '/usr/local/foo/bar', 74 | '/usr/local/foo/baz', 75 | ], 76 | [ 77 | '/usr/local/foo', 78 | '/usr/local/foo/bar', 79 | '/usr/local/foo/baz', 80 | ], 81 | [ 82 | '/usr/local/foo/bar', 83 | '/usr/local/foo/baz', 84 | ] 85 | ); 86 | 87 | perform_test( 88 | [qw( 89 | /usr/local/a/a/a 90 | /usr/local/a/a/b 91 | /usr/local/a/b/a 92 | /usr/local/a/b/b 93 | /usr/local/b/a/a 94 | /usr/local/b/a/b 95 | /usr/local/b/b/a 96 | /usr/local/b/b/b 97 | )], 98 | [qw( 99 | /usr/local/a 100 | /usr/local/a/a 101 | /usr/local/a/a/a 102 | /usr/local/a/a/b 103 | /usr/local/a/b 104 | /usr/local/a/b/a 105 | /usr/local/a/b/b 106 | /usr/local/b 107 | /usr/local/b/a 108 | /usr/local/b/a/a 109 | /usr/local/b/a/b 110 | /usr/local/b/b 111 | /usr/local/b/b/a 112 | /usr/local/b/b/b 113 | )], 114 | [qw( 115 | /usr/local/a/a/a 116 | /usr/local/a/a/b 117 | /usr/local/a/a 118 | /usr/local/a/b/a 119 | /usr/local/a/b/b 120 | /usr/local/a/b 121 | /usr/local/b/a/a 122 | /usr/local/b/a/b 123 | /usr/local/b/a 124 | /usr/local/b/b/a 125 | /usr/local/b/b/b 126 | /usr/local/b/b 127 | )] 128 | ); 129 | 130 | perform_test( 131 | [ 132 | '/usr/local/foo/dir/somewhere', 133 | '/usr/local/bar/another-dir/elsewhere', 134 | '/usr/local/baz/foo+bar/thing', 135 | ], 136 | [ 137 | '/usr/local/bar', 138 | '/usr/local/bar/another-dir', 139 | '/usr/local/bar/another-dir/elsewhere', 140 | '/usr/local/baz', 141 | '/usr/local/baz/foo+bar', 142 | '/usr/local/baz/foo+bar/thing', 143 | '/usr/local/foo', 144 | '/usr/local/foo/dir', 145 | '/usr/local/foo/dir/somewhere', 146 | ], 147 | [ 148 | '/usr/local/bar/another-dir/elsewhere', 149 | '/usr/local/bar/another-dir', 150 | '/usr/local/baz/foo+bar/thing', 151 | '/usr/local/baz/foo+bar', 152 | '/usr/local/foo/dir/somewhere', 153 | '/usr/local/foo/dir', 154 | ] 155 | ); 156 | }; 157 | 158 | -------------------------------------------------------------------------------- /dh_installdebconf: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | =head1 NAME 4 | 5 | dh_installdebconf - install files used by debconf in package build directories 6 | 7 | =cut 8 | 9 | use strict; 10 | use warnings; 11 | use Debian::Debhelper::Dh_Lib; 12 | 13 | our $VERSION = DH_BUILTIN_VERSION; 14 | 15 | =head1 SYNOPSIS 16 | 17 | B [S>] [B<-n>] [S I>] 18 | 19 | =head1 DESCRIPTION 20 | 21 | B is a debhelper program that is responsible for installing 22 | files used by debconf into package build directories. 23 | 24 | It also automatically generates the F commands needed to interface 25 | with debconf. The commands are added to the maintainer scripts by 26 | B. See L for an explanation of how that 27 | works. 28 | 29 | Note that if you use debconf, your package probably needs to depend on it 30 | (it will be added to B<${misc:Depends}> by this program). 31 | 32 | Note that for your config script to be called by B, your F 33 | needs to source debconf's confmodule. B does not 34 | install this statement into the F automatically as it is too 35 | hard to do it right. 36 | 37 | =head1 FILES 38 | 39 | =over 4 40 | 41 | =item debian/I.config 42 | 43 | This is the debconf F script, and is installed into the F 44 | directory in the package build directory. 45 | 46 | Inside the script, the token B<#DEBHELPER#> is replaced with 47 | shell script snippets generated by other debhelper commands. 48 | 49 | =item debian/I.templates 50 | 51 | This is the debconf F file, and is installed into the F 52 | directory in the package build directory. 53 | 54 | =item F 55 | 56 | If this directory is present, this program will automatically use 57 | L to generate merged templates 58 | files that include the translations from there. 59 | 60 | For this to work, your package should build-depend on F. 61 | 62 | =back 63 | 64 | =head1 OPTIONS 65 | 66 | =over 4 67 | 68 | =item B<-n>, B<--no-scripts> 69 | 70 | Do not modify F script. 71 | 72 | =item B<--> I 73 | 74 | Pass the params to B. 75 | 76 | =back 77 | 78 | =cut 79 | 80 | init(); 81 | 82 | my @extraparams; 83 | if (defined($dh{U_PARAMS})) { 84 | @extraparams=@{$dh{U_PARAMS}}; 85 | } 86 | 87 | # PROMISE: DH NOOP WITHOUT config templates cli-options() 88 | 89 | foreach my $package (@{$dh{DOPACKAGES}}) { 90 | my $tmp=tmpdir($package); 91 | my $config=pkgfile($package,"config"); 92 | my $templates=pkgfile($package,"templates"); 93 | 94 | install_dir("$tmp/DEBIAN"); 95 | 96 | if (! is_udeb($package)) { 97 | debhelper_script_subst($package, "config"); 98 | } 99 | 100 | if ($templates ne '') { 101 | # Are there old-style translated templates? 102 | if (glob("$templates.??"), glob("$templates.??_??")) { 103 | warning "Ignoring debian/templates.ll files. Switch to po-debconf!"; 104 | } 105 | 106 | umask(0022); # since I do a redirect below 107 | 108 | if (-d "debian/po") { 109 | complex_doit("po2debconf @extraparams $templates > $tmp/DEBIAN/templates"); 110 | } 111 | else { 112 | install_file($templates,"$tmp/DEBIAN/templates"); 113 | } 114 | } 115 | 116 | # I'm going with debconf 0.5 because it was the first 117 | # "modern" one. udebs just need cdebconf. 118 | my $debconfdep=is_udeb($package) ? "cdebconf-udeb" : "debconf (>= 0.5) | debconf-2.0"; 119 | if ($config ne '' || $templates ne '') { 120 | addsubstvar($package, "misc:Depends", $debconfdep); 121 | } 122 | 123 | if (($config ne '' || $templates ne '') && ! $dh{NOSCRIPTS}) { 124 | autoscript($package,"postrm","postrm-debconf"); 125 | } 126 | } 127 | 128 | =head1 SEE ALSO 129 | 130 | L 131 | 132 | This program is a part of debhelper. 133 | 134 | =head1 AUTHOR 135 | 136 | Joey Hess 137 | 138 | =cut 139 | -------------------------------------------------------------------------------- /dh_installcatalogs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | =head1 NAME 4 | 5 | dh_installcatalogs - install and register SGML Catalogs 6 | 7 | =cut 8 | 9 | use strict; 10 | use warnings; 11 | use Debian::Debhelper::Dh_Lib; 12 | 13 | our $VERSION = DH_BUILTIN_VERSION; 14 | 15 | my $sgmlbasever = "1.28"; 16 | 17 | =head1 SYNOPSIS 18 | 19 | B [S>] [B<-n>] 20 | 21 | =head1 DESCRIPTION 22 | 23 | B is a debhelper program that installs and 24 | registers SGML catalogs. It complies with the Debian XML/SGML policy. 25 | 26 | Catalogs will be registered in a supercatalog, in 27 | F.cat>. 28 | 29 | This command automatically adds maintainer script snippets for 30 | registering and unregistering the catalogs and supercatalogs (unless 31 | B<-n> is used). These snippets are inserted into the maintainer 32 | scripts and the B file by B; see 33 | L for an explanation of Debhelper maintainer script 34 | snippets. 35 | 36 | A dependency on B will be added to B<${misc:Depends}>, so be 37 | sure your package uses that variable in F. 38 | 39 | =head1 FILES 40 | 41 | =over 4 42 | 43 | =item debian/I.sgmlcatalogs 44 | 45 | Lists the catalogs to be installed per package. Each line in that file 46 | should be of the form C I>, where I indicates where the 47 | catalog resides in the source tree, and I indicates the destination 48 | location for the catalog under the package build area. I should 49 | start with F. 50 | 51 | Supports substitution variables in compat 13 and later as 52 | documented in L. 53 | 54 | =back 55 | 56 | =head1 OPTIONS 57 | 58 | =over 4 59 | 60 | =item B<-n>, B<--no-scripts> 61 | 62 | Do not modify F/F/F scripts nor add an 63 | activation trigger. 64 | 65 | =back 66 | 67 | =head1 NOTES 68 | 69 | Note that this command is not idempotent. L should be 70 | called between invocations of this command. Otherwise, it may cause 71 | multiple instances of the same text to be added to maintainer scripts. 72 | 73 | =cut 74 | 75 | init(); 76 | 77 | # PROMISE: DH NOOP WITHOUT sgmlcatalogs cli-options() 78 | 79 | foreach my $package (@{$dh{DOPACKAGES}}) { 80 | my $tmpdir = tmpdir($package); 81 | my $sgmlcatlistfile = pkgfile($package, "sgmlcatalogs"); 82 | my @sgmlinstalled; # catalogs we've installed 83 | if ($#ARGV >= 0) { 84 | error("extra command-line arguments"); 85 | } 86 | if ($sgmlcatlistfile) { 87 | foreach my $line (filedoublearray($sgmlcatlistfile)) { 88 | my $source = $line->[0]; 89 | my $dest = $line->[1]; 90 | my $fulldest = "$tmpdir/$dest"; 91 | $fulldest =~ s|//|/|g; # beautification 92 | 93 | if (! -d dirname($fulldest)) { 94 | # Ensure the parent exist 95 | install_dir($tmpdir."/".dirname($dest)); 96 | } 97 | 98 | install_file($source,$fulldest); 99 | 100 | push(@sgmlinstalled,$dest); 101 | } 102 | } 103 | if (@sgmlinstalled) { 104 | addsubstvar($package, "misc:Depends", "sgml-base", ">= $sgmlbasever"); 105 | 106 | install_dir("$tmpdir/etc/sgml"); 107 | 108 | my $centralcat = "/etc/sgml/$package.cat"; 109 | 110 | open(my $fd, ">", "$tmpdir$centralcat") || error("failed to write to $tmpdir$centralcat"); 111 | foreach my $sgmldest (@sgmlinstalled) { 112 | print {$fd} "CATALOG " . $sgmldest . "\n"; 113 | } 114 | close($fd) or error("close $tmpdir$centralcat: $!"); 115 | 116 | if (! $dh{NOSCRIPTS}) { 117 | autotrigger($package, "activate-await", "update-sgmlcatalog"); 118 | autoscript($package, "postrm", "postrm-sgmlcatalog", 119 | { 'CENTRALCAT' => $centralcat }); 120 | } 121 | } 122 | else { 123 | # remove the dependency 124 | addsubstvar($package, "misc:Depends", "sgml-base", ">= $sgmlbasever", 1); 125 | } 126 | } 127 | 128 | =head1 SEE ALSO 129 | 130 | L 131 | 132 | F 133 | 134 | =head1 AUTHOR 135 | 136 | Adam Di Carlo 137 | 138 | =cut 139 | --------------------------------------------------------------------------------