diff options
Diffstat (limited to 'qt-kde-team')
-rw-r--r-- | qt-kde-team/3/README | 65 | ||||
-rw-r--r-- | qt-kde-team/3/commands | 89 | ||||
-rw-r--r-- | qt-kde-team/3/debian-qt-kde.mk | 107 | ||||
-rw-r--r-- | qt-kde-team/3/dhmk.mk | 136 | ||||
-rwxr-xr-x | qt-kde-team/3/dhmk.pl | 453 | ||||
-rw-r--r-- | qt-kde-team/3/library-packages.mk | 51 | ||||
-rw-r--r-- | qt-kde-team/3/list-missing.mk | 47 | ||||
-rw-r--r-- | qt-kde-team/3/policy.mk | 27 | ||||
-rw-r--r-- | qt-kde-team/3/policy/unstable.mk | 19 |
9 files changed, 994 insertions, 0 deletions
diff --git a/qt-kde-team/3/README b/qt-kde-team/3/README new file mode 100644 index 0000000..29648de --- /dev/null +++ b/qt-kde-team/3/README @@ -0,0 +1,65 @@ +What is dhmk? +------------- + +dhmk is yet another debhelper command sequencer. Unlike dh(1), it uses make(1) +to execute all commands. The perl part (dhmk.pl) is used to support dh(1) +addons and dynamically calculate override_* targets. + +dhmk aims to mimic the most useful features of dh(1) adding a couple of its +own. Some highlights include: + +1) Unlike dh(1), dhmk sequencer is based on the traditional debian/rules +layout. It means that progress tracking revolves around standard +targets/actions (configure, build, install, binary etc.) rather than on +per-(command+package) basis (i.e. debian/*.debhelper.log files) basis. +"per-(command+package)" tracking gets complicated giving not too much real +benefit, but makes it hard to fix bugs like #510855. + +2) Like dh(1), dhmk supports override_{dh_command} targets. + +3) dhmk should support most of dh(1) addons. + +4) Like dh(1), dhmk supports passing of additional options to all dh_commands. + +5) In addition to dh(1) addons, dhmk is extendable with makefile snippets as well. + +Altering default dhmk action sequences +-------------------------------------- + +1) If override_{dh_command} target exists in debian/rules, it will be executed +instead of the default dh_command command whenever the latter appears in the +action sequence (as dh(1) would do). + +2) In order to override the whole action (configure, build, install etc.), just +create a respective custom make target manually. The dhmk sequence is still +accessible via debian/dhmk_{action} target. + +3) In order to enable a dh(1) addon, append --with=addon (or --with addon) to +the "dh" variable *before* including dhmk.mk. + +4) In order to pass additional options to all dh_commands (dh(1) way), append +them to "dh" variable (preferably after --) *before* including dhmk.mk. +The command line interface is compatible with dh compat level 7 or higher. + +Extending dhmk with makefile snippets (templating recommendations) +------------------------------------------------------------------ + +dhmk sequences can be extented by include'ing additional makefile snippets in +debian/rules. + +1) Snippets may hook to the pre_{action}_{dh_command} target in order to do +additional work *before* dh_command runs at the specific action. + +2) Snippets may hook to the pre_{action}_{dh_command} target in order to do +additional work *after* dh_command runs at the specific action. + +3) Snippets may hook to the pre_{action} target in order to do additional work +at the beginning of the specific action sequence. + +4) Snippets may hook to the post_{action} target in order to do additional work +at the end of the specific action sequence. + +5) Snippets may alter the contents of the "{action}_{dh_command}" variable in +order to change command line (including the command itself) of the specified +dh_command whenever it runs during the specified action. Snippets should +preferably NOT use override_{dh_command} targets. diff --git a/qt-kde-team/3/commands b/qt-kde-team/3/commands new file mode 100644 index 0000000..5e7780c --- /dev/null +++ b/qt-kde-team/3/commands @@ -0,0 +1,89 @@ +# Standard target commands are defined here. +# File format is: +# target: prerequisite_target(s) ... +# command1 +# command2 +# command3 +# ... +# Use $targetname in place of a command to insert commands from the previously +# defined target. +configure: + dh_testdir + dh_auto_configure + +build: configure + dh_testdir + dh_auto_build + dh_auto_test + +build-indep: configure + $build + +build-arch: configure + $build + +clean: + dh_testdir + dh_auto_clean + dh_clean + +install: build + dh_testroot + dh_prep + dh_installdirs + dh_auto_install + + dh_install + dh_installdocs + dh_installchangelogs + dh_installexamples + dh_installman + + dh_installcatalogs + dh_installcron + dh_installdebconf + dh_installemacsen + dh_installifupdown + dh_installinfo + dh_installinit + dh_installmenu + dh_installmime + dh_installmodules + dh_installlogcheck + dh_installlogrotate + dh_installpam + dh_installppp + dh_installudev + dh_installwm + dh_installxfonts + dh_bugfiles + dh_lintian + dh_gconf + dh_icons + dh_perl + dh_usrlocal + + dh_link + dh_compress + dh_fixperms + +install-indep: build-indep + $install + +install-arch: build-arch + $install + +binary-indep: install-indep + dh_installdeb + dh_gencontrol + dh_md5sums + dh_builddeb + +binary-arch: install-arch + dh_strip + dh_makeshlibs + dh_shlibdeps + $binary-indep + +binary: install + $binary-arch diff --git a/qt-kde-team/3/debian-qt-kde.mk b/qt-kde-team/3/debian-qt-kde.mk new file mode 100644 index 0000000..33954f0 --- /dev/null +++ b/qt-kde-team/3/debian-qt-kde.mk @@ -0,0 +1,107 @@ +ifndef dqk_dir + +dqk_dir := $(dir $(lastword $(MAKEFILE_LIST))) + +# Include dhmk file +include $(dqk_dir)dhmk.mk + +# For performance reasons skip the rest in the override info mode. The slowdown +# is mostly caused by $(shell) functions (e.g. dpkg-parsechangelog). +ifneq ($(dhmk_override_info_mode),yes) + +dqk_sourcepkg := $(shell dpkg-parsechangelog | sed -n '/^Source:/{ s/^Source:[[:space:]]*//; p; q }') +dqk_upstream_version ?= $(shell dpkg-parsechangelog | sed -n '/^Version:/{ s/^Version:[[:space:]]*\(.*\)-.*/\1/g; p; q }') +dqk_destdir = $(CURDIR)/debian/tmp + +# We want to use kde and pkgkde-symbolshelper plugins by default +dh := --with=kde,pkgkde-symbolshelper $(dh) + +# dqk_disable_policy_check lists distributions for which policy check should be +# disabled +dqk_disable_policy_check ?= +include $(dqk_dir)policy.mk + +# Support list-missing target +include $(dqk_dir)list-missing.mk + +# KDE packages are parallel safe. Add --parallel to dh_auto_% commands +$(call set_command_options,dh_auto_%, += --parallel) + +# Use xz compression by default +$(call set_command_options,dh_builddeb, += -u-Zxz) + +# Link with --as-needed by default +# (subject to be moved to kde dh addon/debhelper buildsystem) +dqk_link_with_as_needed ?= yes +ifneq (,$(findstring yes, $(dqk_link_with_as_needed))) + dqk_link_with_as_needed := no + ifeq (,$(findstring no-as-needed, $(DEB_BUILD_OPTIONS))) + dqk_link_with_as_needed := yes + export LDFLAGS += -Wl,--as-needed + endif +endif + +# Set the link_with_no_undefined=no in order to disable linking with +# --no-undefined (default value is inherited from $(dqk_link_with_as_needed)) +dqk_link_with_no_undefined ?= $(dqk_link_with_as_needed) +ifneq (,$(findstring yes, $(dqk_link_with_no_undefined))) + dqk_link_with_no_undefined := no + ifeq (,$(findstring no-no-undefined, $(DEB_BUILD_OPTIONS))) + dqk_link_with_no_undefined := yes + export LDFLAGS += -Wl,--no-undefined + endif +endif + +# Since cmake 2.6.2 or higher is required from now on, enable relative paths to +# get more ccache hits. +$(call set_command_options,dh_auto_configure, += "-u-DCMAKE_USE_RELATIVE_PATHS=ON \ + -DCMAKE_INSTALL_QTPLUGINDIR=qt5/plugins \ + -DCMAKE_INSTALL_QTPLUGINDIR=qt5/imports \ + -DCMAKE_INSTALL_LIBDIR=qt5/qml \ + -DCMAKE_INSTALL_SYSCONFDIR=/etc") + +# Run dh_sameversiondep +run_dh_sameversiondep: + dh_sameversiondep +$(foreach t,$(dhmk_binary_targets),pre_$(t)_dh_gencontrol): run_dh_sameversiondep + +debian/stamp-man-pages: + if ! test -d debian/man/out; then mkdir -p debian/man/out; fi + for f in $$(find debian/man -name '*.sgml'); do \ + docbook-to-man $$f > debian/man/out/`basename $$f .sgml`.1; \ + done + for f in $$(find debian/man -name '*.man'); do \ + soelim -I debian/man $$f \ + > debian/man/out/`basename $$f .man`.`head -n1 $$f | awk '{print $$NF}'`; \ + done + touch debian/stamp-man-pages +$(foreach t,build-arch build-indep build,post_$(t)_dh_auto_build): debian/stamp-man-pages + +cleanup_manpages: + rm -rf debian/man/out + -rmdir debian/man + rm -f debian/stamp-man-pages +post_clean: cleanup_manpages + +# Install files to $(dqk_sourcepkg)-doc-html package if needed +dqk_doc-html_dir = $(CURDIR)/debian/$(dqk_sourcepkg)-doc-html +install_to_doc-html_package: + set -e; \ + if [ -d "$(dqk_doc-html_dir)" ]; then \ + for doc in `cd $(dqk_destdir)/usr/share/doc/kde/HTML/en; find . -name index.docbook`; do \ + pkg=$${doc%/index.docbook}; pkg=$${pkg#./}; \ + echo Building $$pkg HTML docs...; \ + mkdir -p $(dqk_doc-html_dir)/usr/share/doc/kde/HTML/en/$$pkg; \ + cd $(dqk_doc-html_dir)/usr/share/doc/kde/HTML/en/$$pkg; \ + meinproc4 $(dqk_destdir)/usr/share/doc/kde/HTML/en/$$pkg/index.docbook; \ + done; \ + for pkg in $(DOC_HTML_PRUNE) ; do \ + rm -rf $(dqk_doc-html_dir)/usr/share/doc/kde/HTML/en/$$pkg; \ + done; \ + fi +$(foreach t,install-indep install,post_$(t)_dh_install): install_to_doc-html_package + +.PHONY: run_dh_sameversiondep cleanup_manpages install_to_doc-html_package + +endif # ifneq ($(dhmk_override_info_mode),yes) +endif # ifndef dqk_dir diff --git a/qt-kde-team/3/dhmk.mk b/qt-kde-team/3/dhmk.mk new file mode 100644 index 0000000..8d8b265 --- /dev/null +++ b/qt-kde-team/3/dhmk.mk @@ -0,0 +1,136 @@ +# Copyright (C) 2011 Modestas Vainius <modax@debian.org> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/> + +ifndef dhmk_this_makefile + +dhmk_this_makefile := $(lastword $(MAKEFILE_LIST)) +dhmk_top_makefile := $(firstword $(MAKEFILE_LIST)) +dhmk_stamped_targets = configure build-indep build-arch build +dhmk_dynamic_targets = install-indep install-arch install binary-indep binary-arch binary clean +dhmk_standard_targets = $(dhmk_stamped_targets) $(dhmk_dynamic_targets) +dhmk_indeparch_targets = build install binary +dhmk_rules_mk = debian/dhmk_rules.mk +dhmk_env_mk = debian/dhmk_env.mk +dhmk_dhmk_pl := $(dir $(dhmk_this_makefile))dhmk.pl + +# Variables holding all (incl. -indep, -arch) targets for each action +$(foreach t,$(dhmk_indeparch_targets),$(eval dhmk_$(t)_targets = $(t)-indep $(t)-arch)) +$(foreach t,$(filter-out %-arch %-indep,$(dhmk_standard_targets)),\ + $(eval dhmk_$(t)_targets += $(t))) + +# A helper routine to set additional command options +set_command_options = $(foreach t,$(filter $(or $3,%),$(dhmk_standard_targets)),\ + $(foreach c,$(filter $1,$(dhmk_$(t)_commands)),\ + $(eval $(t)_$(c) $2))) + +# $(call butfirstword,TEXT,DELIMITER) +butfirstword = $(patsubst $(firstword $(subst $2, ,$1))$2%,%,$1) + +# Use this to retrieve full command line to the overridden command in the +# override_% targets +overridden_command = $($(DHMK_TARGET)_$(call butfirstword,$@,_)) $(DHMK_OPTIONS) + +# Create an out-of-date temporary mk file if it does not exist. Avoids make warning +dhmk_include_cmd = $(shell test ! -f $1 && touch -t 197001030000 $1; echo $1) + +# This makefile is not parallel compatible by design (e.g. command chains +# below) +.NOTPARALLEL: + +# FORCE target is used in the prerequsite lists to imitiate .PHONY behaviour +.PHONY: FORCE + +############ Handle override calculation ############ +ifeq ($(dhmk_override_info_mode),yes) + +# Emit magic directives for commands which are not overriden +override_%: FORCE + ##dhmk_no_override##$* + +else +############ Do all sequencing ###################### + +# Generate and include a dhmk rules file +$(dhmk_rules_mk): $(MAKEFILE_LIST) $(dhmk_dhmk_pl) + $(dhmk_dhmk_pl) $(dh) + +# Export build flags +$(dhmk_env_mk): $(MAKEFILE_LIST) + dpkg-buildflags --export=make > $@ + +include $(call dhmk_include_cmd,$(dhmk_env_mk)) +include $(call dhmk_include_cmd,$(dhmk_rules_mk)) + +# Add CPPFLAGS to CFLAGS/CXXFLAGS, this is a workaround for a cmake bug, +# which ignores CPPFLAGS, see: +# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=653916 +export CFLAGS += $(CPPFLAGS) +export CXXFLAGS += $(CPPFLAGS) + +# Routine used to run an override target if there is one ($1 should be +# override_{command}) +define dhmk_override_cmd +$(if $(dhmk_$1), + # Running override target ($1) + test -z "`ls debian/*.debhelper.log 2>/dev/null`" || sed -i '/^$1[[:space:]]/d' debian/*.debhelper.log + $(MAKE) -f $(dhmk_top_makefile) $1 DH_INTERNAL_OVERRIDE="$(call butfirstword,$1,_)" \ +) +endef + +# Routine to run a specific command ($1 should be {target}_{command}) +dhmk_run_command = $(or $(call dhmk_override_cmd,override_$(call butfirstword,$1,_)),$($1) $(DHMK_OPTIONS)) + +# Generate {pre,post}_{target}_{command} targets for each target+command +$(foreach t,$(dhmk_standard_targets),$(foreach c,$(dhmk_$(t)_commands),pre_$(t)_$(c))): pre_%: + $(call dhmk_run_command,$*) $(and $(DH_INTERNAL_OPTIONS),# [$(DH_INTERNAL_OPTIONS)]) +$(foreach t,$(dhmk_standard_targets),$(foreach c,$(dhmk_$(t)_commands),post_$(t)_$(c))): post_%: + +# Export -a/-i options for indep/arch specific targets +$(foreach t,$(dhmk_indeparch_targets),debian/dhmk_$(t)-indep): export DH_INTERNAL_OPTIONS := -i +$(foreach t,$(dhmk_indeparch_targets),debian/dhmk_$(t)-arch): export DH_INTERNAL_OPTIONS := -a + +# Mark dynamic standard targets as PHONY +.PHONY: $(foreach t,$(dhmk_dynamic_targets),debian/dhmk_$(t)) + +# Create debian/dhmk_{action} targets. +# NOTE: dhmk_run_{target}_commands are defined below +$(foreach t,$(dhmk_standard_targets),debian/dhmk_$(t)): debian/dhmk_%: + $(MAKE) -f $(dhmk_top_makefile) dhmk_run_$*_commands DHMK_TARGET="$*" + $(if $(filter $*,$(dhmk_stamped_targets)),touch $@) + $(if $(filter clean,$*),rm -f $(dhmk_rules_mk) $(dhmk_env_mk)\ + $(foreach t,$(dhmk_stamped_targets),debian/dhmk_$(t))) + # "$*" target is done + +.PHONY: $(foreach t,$(dhmk_standard_targets),dhmk_run_$(t)_commands \ + pre_$(t) post_$(t) \ + $(foreach c,$(dhmk_$(t)_commands),pre_$(t)_$(c) post_$(t)_$(c))) + +# Implicitly delegate other targets to debian/dhmk_% ones. Hence the top +# targets (build, configure, install ...) are still cancellable. +%: debian/dhmk_% + @echo "-- SUCCESS making standard target '$@'." + +.SECONDEXPANSION: + +# Specify relationships (depends/prerequisites) and export DHMK_TARGET +# environment variable for each top target +$(foreach t,$(dhmk_standard_targets),debian/dhmk_$(t)): debian/dhmk_%: $$(foreach d,$$(dhmk_%_depends),debian/dhmk_$$d) + +# Generate command chains for the standard targets +$(foreach t,$(dhmk_standard_targets),dhmk_run_$(t)_commands): dhmk_run_%_commands: pre_% $$(foreach c,$$(dhmk_%_commands),pre_%_$$(c) post_%_$$(c)) post_% + +endif # ifeq (dhmk_override_info_mode,yes) + +endif # ifndef dhmk_this_makefile diff --git a/qt-kde-team/3/dhmk.pl b/qt-kde-team/3/dhmk.pl new file mode 100755 index 0000000..a65b9d1 --- /dev/null +++ b/qt-kde-team/3/dhmk.pl @@ -0,0 +1,453 @@ +#!/usr/bin/perl + +# Copyright (C) 2011 Modestas Vainius <modax@debian.org> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/> + +use strict; +use warnings; + +package Debian::PkgKde::Dhmk::DhCompat; + +my $targets; +my %extra_cmd_opts; + +sub _find_cmd_and_do { + # &$proc($cmd_array_ref, $cmd_index_ref) + my ($proc, $command) = @_; + foreach my $tname (keys %$targets) { + my $tcmds = $targets->{$tname}{cmds}; + for (my $i = 0; $i < @$tcmds; $i++) { + if (!defined($command) || $tcmds->[$i] eq $command) { + &$proc($tcmds, \$i); + } + } + } +} + +sub _escape_shell { + my @opts = @_; + s/'/'"'"'/g foreach @opts; + if (wantarray) { + return map({ "'$_'" } @opts); + } else { + return "'" . join("' '", @opts) . "'"; + } +} + +############### Dh Addon API ############################ + +# Insert $new_command in sequences before $existing_command +sub insert_before { + my ($existing_command, $new_command) = @_; + return _find_cmd_and_do(sub { + my ($cmds, $i) = ($_[0], ${$_[1]}); + if ($i == 0) { + unshift @$cmds, $new_command; + } else { + my @tail = splice(@$cmds, $i); + push @$cmds, $new_command, @tail; + } + ${$_[1]}++; + }, $existing_command); +} + +# Insert $new_command in sequences after $existing_command +sub insert_after { + my ($existing_command, $new_command) = @_; + return _find_cmd_and_do(sub { + my ($cmds, $i) = ($_[0], ${$_[1]}); + my @tail = ($i < $#{$cmds}) ? splice(@$cmds, $i+1) : (); +# print $#_, join("--", @tail), "\n"; + push @$cmds, $new_command, @tail; + ${$_[1]}++; + }, $existing_command); +} + +# Remove $existing_command from the list of commands to run in all sequences. +sub remove_command { + my ($existing_command) = @_; + return _find_cmd_and_do(sub { + my ($cmds, $i) = ($_[0], ${$_[1]}); + splice(@$cmds, $i, 1); + ${$_[1]}--; + }, $existing_command); +} + +# Add $new_command to the beginning of the specified sequence. If the sequence +# does not exist, it will be created. +sub add_command { + my ($new_command, $sequence) = @_; + if (exists $targets->{$sequence}) { + unshift @{$targets->{$sequence}{cmds}}, $new_command; + } else { + $targets->{$sequence} = { cmds => [ $new_command ], deps => "" }; + } +} + +# Append $opt1, $opt2 etc. to the list of additional options which dh passes +# when running the specified $command. +sub add_command_options { + my ($command, @opts) = @_; + push @{$extra_cmd_opts{$command}}, @opts; +} + +# Remove @opts from the list of additional options which dh passes when running +# the specified $command. If @opts is empty, remove all extra options +sub remove_command_options { + my ($command, @opts) = @_; + if (exists $extra_cmd_opts{$command}) { + if (!@opts) { + delete $extra_cmd_opts{$command}; + } else { + my $re = "(" . join("|", map {"\Q$_\E"} @opts) . ")"; + $extra_cmd_opts{$command} = [ grep { !/^$re$/ } @{$extra_cmd_opts{$command}} ]; + } + } +} + +########### Main module subroutines ################### + +# Initialize jail +sub init { + my %opts = @_; + $targets = $opts{targets}; +} + +# Load addons +sub load_addons { + my @addons = @_; + my %env_changes; + + # Backup current environment in order to export changes which addons have + # made to it + my %oldenv = %ENV; + + foreach my $addon (@addons) { + my $mod="Debian::Debhelper::Sequence::$addon"; + $mod=~s/-/_/g; + eval "use $mod"; + if ($@) { + die "unable to load addon $addon: $@"; + } + } + + # Compare environment and note changes + foreach my $e (keys %ENV) { + if (!exists $oldenv{$e} || (($ENV{$e} || "") ne ($oldenv{$e} || ""))) + { + $env_changes{$e} = { old => $oldenv{$e}, new => $ENV{$e} }; + } + } + + # Merge $extra_cmd_opts to $targets + foreach my $c (keys %extra_cmd_opts) { + next if !@{$extra_cmd_opts{$c}}; + _find_cmd_and_do(sub { + my ($cmds, $i) = ($_[0], ${$_[1]}); + $cmds->[$i] .= " " . _escape_shell(@{$extra_cmd_opts{$c}}); + }, $c); + } + + return \%env_changes; +} + +# Generate extra options from command line options +sub gen_extraopts { + my @opts; + # Convert "--option value" syntax to --option=value like dh(1) would do + foreach my $opt (@_) { + if ($opt =~ /^-/) { + push @opts, $opt; + } elsif (@opts && $opts[$#opts] =~ /^--/) { + $opts[$#opts] .= "=" . $opt; + } else { + push @opts, $opt; + } + } + return join(" ", map({ s/^'-/-O'-/; $_ } _escape_shell(@opts))); +} + +1; + +package main; + +sub basename { + my ($filename) = @_; + $filename =~ s,^.*/([^/]+)/*$,$1,; + return $filename; +} + +sub dirname { + my ($filename) = @_; + $filename =~ s,[^/]+/*$,,; + return $filename; +} + +sub parse_commands_file { + my ($filename) = @_; + my %targets; + my $t; + + open (my $fh, "<", $filename) or + die "unable to open dhmk commands file $filename: $!"; + + # File format is: + # target: + # command1 + # command2 + # command3 + # ... + # Use $targetname in place of a command to insert commands from the + # previously defined target. + while (my $line = <$fh>) { + chop $line; + if ($line =~ /^\s*#/ || $line =~ /^\s*$/) { + next; # comment or empty line + } elsif ($line =~ /^(\S.+):\s*(.*)$/) { + $t = $1; + $targets{$t}{deps} = $2 || ""; + $targets{$t}{cmds} = []; + } elsif (defined $t) { + if ($line =~ /^\s+(.*)$/) { + my $c = $1; + # If it's a variable, dereference it + if ($c =~ /^\s*\$(\S+)\s*$/) { + if (exists $targets{$1}) { + push @{$targets{$t}{cmds}}, @{$targets{$1}{cmds}}; + } else { + die "could not dereference variable \$$1. Target '$1' was not defined yet"; + } + } else { + push @{$targets{$t}{cmds}}, $c; + } + } else { + die "dangling command '$line'. Missing target definition"; + } + } else { + die "invalid commands file syntax"; + } + } + close($fh); + + return \%targets; +} + +sub parse_cmdline { + my @addons; + my @extraopts; + my $optname = ""; + my $optval; + my $opts_need_values = qr/with(?:out)?/; + my $opts_no_values = qr//; + foreach my $arg (@ARGV) { + if ($optname eq "--") { + $optval = $arg; + } elsif ($optname && !defined $optval) { + $optval = $arg; + } elsif ($arg eq "--") { + $optname = "--"; + $optval = undef; + } elsif ($arg =~ /^--($opts_need_values)=(.*)$/) { + $optname = $1; + $optval = $2 || ""; + } elsif ($arg =~ /^--($opts_need_values)$/) { + $optname = $1; + $optval = undef; + } elsif ($arg =~ /^--($opts_no_values)=(.*)$/) { + die "option $1 does not accept a value"; + } elsif ($arg =~ /^--($opts_no_values)$/) { + $optname = $1; + $optval = ""; + } else { + $optval = $arg; + } + if (defined $optval) { + if ($optname eq "" || $optname eq "--") { + push @extraopts, $optval; + # Do not reset $optname + } else { + if ($optname =~ /^$opts_need_values$/) { + if ($optval eq "") { + die "option $optname requires a value"; + } + if ($optname eq "with") { + push @addons, split(/,/, $optval); + } elsif ($optname eq "without") { + @addons = grep { $_ ne $optval } @addons; + } else { + die "internal bug: unrecognized dhmk.pl option: $optname (val: $optval)"; + } + } elsif ($optname =~ /^$opts_no_values$/) { + # No such options exist yet + } else { + die "unrecognized command line option: $optname"; + } + $optname = ""; + $optval = undef; + } + } + } + + return ( addons => \@addons, extraopts => \@extraopts ); +} + +sub get_commands { + my ($targets) = @_; + my %cmds; + foreach my $t (values %$targets) { + foreach my $c (@{$t->{cmds}}) { + $cmds{$1} = 1 if $c =~ /^(\S+)/; + } + } + return sort keys %cmds; +} + +sub get_override_info { + my ($rules_file, @commands) = @_; + my $magic = "##dhmk_no_override##"; + + # Initialize all overrides first + my %overrides; + my @override_targets; + foreach my $c (@commands) { + $overrides{$c} = 1; + push @override_targets, "override_$c"; + } + + # Now remove overrides based on the rules file output + my $saved_makeflags = $ENV{MAKEFLAGS}; + delete $ENV{MAKEFLAGS}; + open(my $make, "-|", "make", "-f", $rules_file, "-j1", "-n", + "--no-print-directory", + @override_targets, + "dhmk_override_info_mode=yes") or + die "unable to execute make for override calculation: $!"; + while (my $line = <$make>) { + if ($line =~ /^$magic(.*)$/ && exists $overrides{$1}) { + delete $overrides{$1}; + } + } + if (!close($make)) { + die "make (get_override_info) failed with $?"; + } + $ENV{MAKEFLAGS} = $saved_makeflags if defined $saved_makeflags; + + return \%overrides; +} + +sub write_definevar { + my ($fh, $name, $value, $escape) = @_; + $escape = 1 if !defined $escape; + + if ($value) { + $value =~ s/\$/\$\$/g if $escape; + print $fh "define $name", "\n", $value, "\n", "endef", "\n"; + } else { + print $fh "$name =", "\n"; + } +} + +sub write_exportvar { + my ($fh, $name,$export) = @_; + $export = "export" if !defined $export; + print $fh "$export $name", "\n"; +} + +sub write_dhmk_rules { + my ($dhmk_file, $rules_file, $targets, $overrides, + $extraopts, $env_changes) = @_; + + open (my $fh, ">", $dhmk_file) or + die "unable to open dhmk rules file ($dhmk_file) for writing: $!"; + print $fh "# This file was automatically generated by ", basename($0), "\n"; + print $fh "# DO NOT edit as your changes will eventually be lost.", "\n"; + print $fh "# DO NOT include this file in the source package.", "\n"; + print $fh "\n"; + print $fh "# Action command sequences", "\n"; + foreach my $tname (keys %$targets) { + my $t = $targets->{$tname}; + my @commands; + foreach my $cline (@{$t->{cmds}}) { + my $c = ($cline =~ /^(\S+)/) && $1; + push @commands, $c; + print $fh $tname, "_", $c, " = ", $cline, "\n"; + } + print $fh "dhmk_", $tname, "_commands = ", join(" ", @commands), "\n"; + print $fh "dhmk_", $tname, "_depends = ", $t->{deps}, "\n"; + print $fh "\n"; + } + + print $fh "# Overrides", "\n"; + foreach my $o (sort keys %$overrides) { + print $fh "dhmk_override_", $o, " = yes", "\n"; + } + print $fh "\n"; + + # Export specified extra options for debhelper programs (e.g. for use in + # overrides) + if ($extraopts) { + print $fh "# Export specified extra options for debhelper programs", "\n"; + write_definevar($fh, "DHMK_OPTIONS", $extraopts, 0); + write_exportvar($fh, "DHMK_OPTIONS"); + print $fh "\n"; + } + + if (keys %$env_changes) { + print $fh "# Export environment changes", "\n"; + foreach my $e (keys %$env_changes) { + print $fh "dhmk_envvar_orig_$e := \$($e)\n"; + if (defined ($env_changes->{$e}{new})) { + write_definevar($fh, $e, $env_changes->{$e}{new}); + } else { + write_export($fh, $e, "unexport"); + } + } + # Restore all modified environment variables when remaking $dhmk_file + foreach my $e (keys %$env_changes) { + print $fh "$dhmk_file: $e = \$(dhmk_envvar_orig_$e)", "\n"; + } + print $fh "\n"; + } + + close($fh); +} + +my $COMMANDS_FILE = dirname($0) . "/commands"; +my $DHMK_RULES_FILE = "debian/dhmk_rules.mk"; +my $RULES_FILE = "debian/rules"; + +eval { + my $targets = parse_commands_file($COMMANDS_FILE); + my %cmdopts = parse_cmdline(); + my $shextraopts; + my $env_changes; + + Debian::PkgKde::Dhmk::DhCompat::init(targets => $targets); + if (@{$cmdopts{addons}}) { + $env_changes = Debian::PkgKde::Dhmk::DhCompat::load_addons(@{$cmdopts{addons}}); + if (!$env_changes) { + die "unable to load requested dh addons: " . join(", ", @{$cmdopts{addons}}); + } + } + if (@{$cmdopts{extraopts}}) { + $shextraopts = Debian::PkgKde::Dhmk::DhCompat::gen_extraopts(@{$cmdopts{extraopts}}); + } + my $overrides = get_override_info($RULES_FILE, get_commands($targets)); + write_dhmk_rules($DHMK_RULES_FILE, $RULES_FILE, $targets, $overrides, + $shextraopts, $env_changes); +}; +if ($@) { + die "error: $@" +} diff --git a/qt-kde-team/3/library-packages.mk b/qt-kde-team/3/library-packages.mk new file mode 100644 index 0000000..96ff777 --- /dev/null +++ b/qt-kde-team/3/library-packages.mk @@ -0,0 +1,51 @@ +libpkgs_binver := $(shell dpkg-parsechangelog | grep '^Version: ' | sed 's/^Version: //') +libpkgs_arch_pkgs := $(shell dh_listpackages -a) +libpkgs_subst_hooks := $(foreach t,binary-arch binary,pre_$(t)_dh_gencontrol) + +# All library packages +libpkgs_all_packages := $(filter-out %-dev %-dbg, $(filter lib%,$(libpkgs_arch_pkgs))) + +ifneq (,$(libpkgs_addsubst_allLibraries)) + +libpkgs_allLibraries_subst := $(foreach pkg,$(libpkgs_all_packages),$(patsubst %,% (= $(libpkgs_binver)),,$(pkg))) + +libpkgs_addsubst_allLibraries: + echo 'allLibraries=$(libpkgs_allLibraries_subst)' | \ + tee -a $(foreach pkg,$(libpkgs_addsubst_allLibraries),debian/$(pkg).substvars) > /dev/null + +$(libpkgs_subst_hooks): libpkgs_addsubst_allLibraries +.PHONY: libpkgs_addsubst_allLibraries + +endif + +# KDE 4.3 library packages +ifneq (,$(libpkgs_kde43_packages)) +ifneq (,$(libpkgs_addsubst_kde43Libraries)) + +libpkgs_kde43Libraries_subst := $(foreach pkg,$(libpkgs_kde43_packages),$(patsubst %,% (= $(libpkgs_binver)),,$(pkg))) + +libpkgs_add_kde43Libraries: + echo 'kde43Libraries=$(libpkgs_kde43Libraries_subst)' | \ + tee -a $(foreach pkg,$(libpkgs_addsubst_kde43Libraries),debian/$(pkg).substvars) > /dev/null + +$(libpkgs_subst_hooks): libpkgs_addsubst_kde43Libraries +.PHONY: libpkgs_addsubst_kde43Libraries + +endif +endif + +# Generate strict local shlibs if requested +ifneq (,$(libpkgs_gen_strict_local_shlibs)) + +libpkgs_gen_strict_local_shlibs: libpkgs_re = $(subst \|_ ,\|,$(patsubst %,%\|_,$(libpkgs_gen_strict_local_shlibs))) +libpkgs_gen_strict_local_shlibs: + set -e; \ + if [ -n "`ls debian/*.substvars 2>/dev/null`" ]; then \ + echo "Generating strict local shlibs on packages: $(libpkgs_gen_strict_local_shlibs)"; \ + sed -i '/^shlibs:[^=]\+=/{ s/\(^shlibs:[^=]\+=[[:space:]]*\|,[[:space:]]*\)\($(libpkgs_re)\)\([[:space:]]*([[:space:]]*[><=]\+[^)]\+)\)\?/\1\2 (= $(libpkgs_binver))/g }' debian/*.substvars; \ + fi + +$(foreach t,binary-arch binary,post_$(t)_dh_shlibdeps): libpkgs_gen_strict_local_shlibs +.PHONY: libpkgs_gen_strict_local_shlibs + +endif diff --git a/qt-kde-team/3/list-missing.mk b/qt-kde-team/3/list-missing.mk new file mode 100644 index 0000000..8fb82ac --- /dev/null +++ b/qt-kde-team/3/list-missing.mk @@ -0,0 +1,47 @@ +# Copyright © 2003 Colin Walters <walters@debian.org> +# Copyright © 2005-2011 Jonas Smedegaard <dr@jones.dk> +# Copyright © 2010-2011 Modestas Vainius <modax@debian.org> +# Description: Defines various random rules, including a list-missing rule +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +ifdef dqk_dir + +list-missing: + @if test -d debian/tmp; then \ + (cd debian/tmp && find . -type f -o -type l | grep -v '/DEBIAN/' | sort) > debian/dhmk-install-list; \ + (for package in $(shell dh_listpackages); do \ + (cd debian/$$package && find . -type f -o -type l); \ + done; \ + test -e debian/not-installed && grep -v '^#' debian/not-installed; \ + ) | sort -u > debian/dhmk-package-list; \ + diff -u debian/dhmk-install-list debian/dhmk-package-list | sed '1,2d' | egrep '^-' || true; \ + else \ + echo "All files were installed into debian/$(shell dh_listpackages | head -n1)."; \ + fi + +check-not-installed: + @test -e debian/not-installed && \ + (for i in $(shell grep -v '^#' debian/not-installed); do \ + test -e debian/tmp/$$i || printf "File $$i not found in debian/tmp \n"; \ + done;) \ + || printf "ERROR: debian/not-installed not found.\n" + + +post_clean: + rm -f debian/dhmk-install-list debian/dhmk-package-list + +.PHONY: list-missing check-not-installed + +endif diff --git a/qt-kde-team/3/policy.mk b/qt-kde-team/3/policy.mk new file mode 100644 index 0000000..bef6af5 --- /dev/null +++ b/qt-kde-team/3/policy.mk @@ -0,0 +1,27 @@ +# policy.mk must be included from debian_qt_kde.mk +ifdef dqk_dir + +dqk_disable_policy_check ?= +dqk_distribution := $(shell dpkg-parsechangelog | sed -n '/^Distribution:/{ s/^Distribution:[[:space:]]*//g; p; q }') +dqk_kde_major_version := $(shell echo "$(dqk_upstream_version)" | cut -d. -f1-2) +dqk_maintainer_check := $(shell grep -e '^Maintainer:.*<debian-qt-kde@lists\.debian\.org>[[:space:]]*$$' \ + -e '^XSBC-Original-Maintainer:.*<debian-qt-kde@lists\.debian\.org>[[:space:]]*$$' debian/control) + +# Distribution-specific policy file may not exist. It is fine +ifeq (,$(filter $(dqk_distribution),$(dqk_disable_policy_check))) + dqk_distribution_policy = $(dqk_dir)/policy/$(dqk_distribution).mk + ifeq (yes,$(shell test -f "$(dqk_distribution_policy)" && echo yes)) + include $(dqk_dir)policy/$(dqk_distribution).mk + endif +endif + +# Reject packages not maintained by Debian Qt/KDE Maintainers +ifeq (,$(dqk_maintainer_check)) + $(info ### debian_qt_kde.mk can only be used with packages (originally) maintained by) + $(info ### Debian Qt/KDE Maintainers, please read /usr/share/pkg-kde-tools/qt-kde-team/README) + $(info ### for more details. Please read /usr/share/doc/pkg-kde-tools/README.Debian for more) + $(info ### information on how to use pkg-kde-tools with other KDE packages.) + $(error debian_qt_kde.mk usage denied by policy.) +endif + +endif diff --git a/qt-kde-team/3/policy/unstable.mk b/qt-kde-team/3/policy/unstable.mk new file mode 100644 index 0000000..df43468 --- /dev/null +++ b/qt-kde-team/3/policy/unstable.mk @@ -0,0 +1,19 @@ +dqk_upstream_version_check: +ifeq (srcpkg_ok,$(patsubst kde%,srcpkg_ok,$(dqk_sourcepkg))) +ifeq (version_ok,$(patsubst 4:4.%,version_ok,$(dqk_upstream_version))) + @\ + if dpkg --compare-versions "$(dqk_kde_major_version).60" le "$(dqk_upstream_version)" && \ + dpkg --compare-versions "$(dqk_upstream_version)" lt "$(dqk_kde_major_version).90"; then \ + echo >&2; \ + echo " ###" >&2; \ + echo " ### CAUTION: early KDE development releases (alpha or beta) ($(dqk_upstream_version))" >&2; \ + echo " ### should not be uploaded to unstable" >&2; \ + echo " ###" >&2; \ + echo >&2; \ + fi +endif +endif + +$(foreach t,$(dhmk_standard_targets),pre_$(t)): dqk_upstream_version_check + +.PHONY: dqk_upstream_version_check |