From 1de4d541cede99e869b08d52456886041dbe5978 Mon Sep 17 00:00:00 2001 From: Jurij Smakov Date: Sun, 31 Jul 2005 00:08:59 +0000 Subject: [PATCH] The "I hope I did not break anything" commit. Move the control file generation to a separate script (debian/bin/gencontrol), unuglifying it along the way (hi, dilinger :-). This is a first step towards the solution for 319896. svn path=/trunk/kernel/source/linux-2.6/; revision=3637 --- debian/bin/gencontrol | 82 +++++++++++++++++++++++++++++++++++++++++++ debian/rules | 76 ++++++++------------------------------- 2 files changed, 96 insertions(+), 62 deletions(-) create mode 100755 debian/bin/gencontrol diff --git a/debian/bin/gencontrol b/debian/bin/gencontrol new file mode 100755 index 000000000..d7773aecd --- /dev/null +++ b/debian/bin/gencontrol @@ -0,0 +1,82 @@ +#!/bin/sh +# +# This is created by the debian/makevars target in the rules file. +# +. debian/makevars + +list_arches() { + find debian/arch -mindepth 1 -maxdepth 1 \ + ! -name '*.svn*' -type d -printf '%f\n' +} + +# +# Parameters: +# ${1} - architecture to list the subarches for +# +list_subarches() { + echo "none" + find debian/arch/${1} -mindepth 1 -maxdepth 1 \ + ! -name '*.svn*' -type d -printf '%f\n' +} + +# +# Parameters: +# ${1} - architecture +# ${2} - subarchitecture ('none' if there are no subarches) +# +list_flavours() { + find debian/arch/${1}/${2#none} -name 'config.*' \ + ! -name '*.svn*' -printf '%f\n' | sed 's/^config\.//' +} + +# +# Parameters: +# ${1} - filename to use as a template +# ${2} - arch +# ${3} - subarch ('none', if the subarch is empty) +# ${4} - flavour +# +substitute() { + if [ "${3}" = "none" ]; then + sa="" + sdir="debian/arch/${2}" + else + sa="${3}-" + sdir="debian/arch/${2}/${3}" + fi + class="${4}-class" + longclass="" + desc="" + [ -f "${sdir}/desc.${4}" ] && . "${sdir}/desc.${4}" + [ -z "${longclass}" ] && longclass="${class}" + cat debian/templates/control.${1} | \ + sed -e "s#@version@#${version}#g" \ + -e "s#@major@#${major}#g" \ + -e "s#@arch@#${2}#g" \ + -e "s#@subarch@#${sa}#g" \ + -e "s#@flavour@#${4}#g" \ + -e "s#@class@#${class}#g" \ + -e "s#@longclass@#${longclass}#g" \ + -e "s#@ltver@#${ltver}#g" \ + -e "s#@srcver@#${srcver}#g" \ + -e "s#@lt_depends@#${lt_depends}#g" \ + -e "s#@lt_provides@#${lt_provides}#g" \ + -e "s#@abiname@#${abiname}#g" + [ -z "${5}" ] || printf "${desc}\n" +} + +rm -f control.tmp 2>/dev/null +substitute source.in "" "none" >> control.tmp +substitute main.in "" "none" >> control.tmp +substitute headers.in "" "none" >> control.tmp +for a in $(list_arches); do + for s in $(list_subarches ${a}); do + for f in $(list_flavours ${a} ${s}); do + substitute headers.flavour.in ${a} ${s} ${f} >> control.tmp + substitute image.in ${a} ${s} ${f} "1" >> control.tmp + done + done +done +sed -e '/^[[:space:]]*$/d' control.tmp | \ +sed -e 's/^Package:/\n&/g' > debian/control +rm -rf control.tmp diff --git a/debian/rules b/debian/rules index b8b36be7e..36bf8c816 100755 --- a/debian/rules +++ b/debian/rules @@ -22,6 +22,7 @@ uver := $(subst .,_,$(version)) lt_depends += $(shell seq -f 'linux-source-$(version) (= $(version)-%g)' \ -s ' | ' 1 $(ltver)) lt_provides := $(shell seq -f 'linux-tree-$(version)-%g' -s ', ' 1 $(ltver)) +lt_provides := $(strip $(lt_provides)) # # If we are not passed a subarchs variable, we obtain the complete # subarch list as a list of subdirectories in arch/$(karch). We @@ -231,66 +232,17 @@ binary: binary-indep binary-arch # Makes the master debian/control file by substituting # variable values into the template. # -# I truly apologize for what I've created.. -dil -# -archs := $(shell find debian/arch/ -mindepth 1 -maxdepth 1 -type d ! -name '.svn' -printf '%f\n') -debian/control: $(wildcard debian/templates/control.*.in) - rm -f control.tmp 2>/dev/null - list_flavours() { \ - find debian/arch/$$1/ -name 'config.*' \ - ! -name '*.svn*' -printf '%f\n' | \ - sed 's/^config\.//'; \ - }; \ - get_all_headers_pkgs() { \ - result=""; \ - for flavour in `list_flavours $$1`; do \ - if [ -z "$$result" ]; then \ - comma=""; \ - else \ - comma=", "; \ - fi; \ - result="$${result}$${comma}linux-headers-$$2$(version)-$(abiname)-$$flavour"; \ - done; \ - echo $$result; \ - }; \ - all_headers_pkgs=`get_all_headers_pkgs`; \ - substitute() { \ - sa_tmp="debian/arch/$$2/*/config.$$3"; \ - sa=""; \ - [ -f $$sa_tmp ] && sa=$$(basename $$(dirname $$sa_tmp))-; \ - all_headers_pkgs=`get_all_headers_pkgs $$2 $$sa`; \ - class="$$3-class"; \ - longclass=""; \ - desc=""; \ - [ -f "debian/arch/$$2/$$sa/desc.$$3" ] && . "debian/arch/$$2/$$sa/desc.$$3"; \ - [ -z "$$longclass" ] && longclass="$$class"; \ - cat debian/templates/control.$$1 | \ - sed -e 's/@version@/$(version)/g' \ - -e 's/@major@/$(major)/g' \ - -e "s/@arch@/$$2/g" \ - -e "s/@subarch@/$$sa/g" \ - -e "s/@flavour@/$$3/g" \ - -e "s#@class@#$$class#g" \ - -e "s#@longclass@#$$longclass#g" \ - -e 's/@ltver@/$(ltver)/g' \ - -e 's/@srcver@/$(srcver)/g' \ - -e 's/@lt_depends@/$(lt_depends)/g' \ - -e 's/@lt_provides@/$(lt_provides)/g' \ - -e 's/@abiname@/$(abiname)/g' \ - -e "s/@allheaders@/$$all_headers_pkgs/g" | \ - sed '/^[[:space:]]*$$/d' | \ - sed 's/^Package:/\n&/g'; \ - [ -z "$$4" ] || printf "$$desc\n"; \ - }; \ - substitute source.in "" "" >> control.tmp; \ - substitute main.in "" "" >> control.tmp; \ - substitute headers.in "" "" >> control.tmp; \ - for a in $(archs); do \ - for f in $$(list_flavours $$a); do \ - substitute headers.flavour.in $$a $$f >> control.tmp; \ - substitute image.in $$a $$f "1" >> control.tmp; \ - done; \ - done - mv control.tmp debian/control - +debian/control: $(wildcard debian/templates/control.*.in) debian/makevars + debian/bin/gencontrol + +debian/makevars: + echo 'version='\''$(version)'\' > debian/makevars + echo 'major='\''$(major)'\' >> debian/makevars + echo 'srcver='\''$(srcver)'\' >> debian/makevars + echo 'ltver='\''$(ltver)'\' >> debian/makevars + echo 'lt_depends='\''$(srcver)'\' >> debian/makevars + echo 'lt_depends='\''$(lt_depends)'\' >> debian/makevars + echo 'lt_provides='\''$(lt_provides)'\' >> debian/makevars + echo 'abiname='\''$(abiname)'\' >> debian/makevars + .PHONY: clean build unpack binary-indep binary-arch binary patch unpatch source tree