Ticket #549: config-package-dev_trac549.diff

File config-package-dev_trac549.diff, 5.3 KB (added by broder, 14 years ago)
  • divert.mk

     
    5353# foo.divert.divert-orig 
    5454divert_files_replace_name = $(shell echo $(1) | perl -pe 's/(.*)\Q$(DEB_DIVERT_EXTENSION)\E/$$1$(2)/') 
    5555 
     56# Transform a full path into the path it should be diverted to if it's 
     57# removed 
     58remove_files_name = /usr/share/$(cdbs_curpkg)/$(shell $(DEB_DIVERT_ENCODER) $(1)) 
     59 
    5660debian-divert/%: package = $(subst debian-divert/,,$@) 
    5761debian-divert/%: divert_files = $(DEB_DIVERT_FILES_$(package)) $(DEB_TRANSFORM_FILES_$(package)) 
    5862debian-divert/%: divert_remove_files = $(DEB_REMOVE_FILES_$(package)) 
     
    7074            $(if $(divert_files_all), \ 
    7175                echo 'if [ "$$1" = "configure" ]; then'; \ 
    7276                $(foreach file,$(divert_undivert_files), \ 
    73                     $(if $(DEB_UNDIVERT_VERSION_$(file)),,\ 
    74                         echo "ERROR!  Missing undivert version for $(file)!">&2; exit 1;) \ 
    75                     echo -n "    if [ -n \"\$$2\" ] && dpkg --compare-versions \"\$$2\" '<<' "; \ 
    76                     echo "'$(DEB_UNDIVERT_VERSION_$(file))'; then"; \ 
    77                     echo "        undivert_unlink $(call divert_files_replace_name,$(file), )"; \ 
    78                     echo "    fi";) \ 
     77                    echo "    check_undivert_unlink $(call divert_files_replace_name,$(file), )"; )\ 
    7978                $(foreach file,$(divert_unremove_files), \ 
    80                     $(if $(DEB_UNREMOVE_VERSION_$(file)),,\ 
    81                         echo "ERROR!  Missing unremove version for $(file)!">&2; exit 1;) \ 
    82                     echo -n "    if [ -n \"\$$2\" ] && dpkg --compare-versions \"\$$2\" '<<' "; \ 
    83                     echo "'$(DEB_UNREMOVE_VERSION_$(file))'; then"; \ 
    84                     echo "        undivert_unremove $(file)"; \ 
    85                     echo "    fi";) \ 
     79                    echo "    check_undivert_unremove $(file) $(call remove_files_name,$(file))"; )\ 
    8680                $(foreach file,$(divert_files), \ 
    8781                    echo "    divert_link $(call divert_files_replace_name,$(file), )";) \ 
    8882                $(foreach file,$(divert_remove_files), \ 
    8983                    mkdir -p debian/$(cdbs_curpkg)/usr/share/$(cdbs_curpkg); \ 
    90                     echo "    divert_remove $(file) /usr/share/$(cdbs_curpkg)/`$(DEB_DIVERT_ENCODER) $(file)`";) \ 
     84                    echo "    divert_remove $(file) $(call remove_files_name,$(file))";) \ 
    9185                echo 'fi'; \ 
    9286            ) \ 
    9387        } >> $(CURDIR)/debian/$(cdbs_curpkg).postinst.debhelper 
  • config-package.mk

     
    8585# DEB_DIVERT_FILES. 
    8686# 
    8787# DEB_UNDIVERT_FILES_package += /path/file.divert 
    88 # DEB_UNDIVERT_VERSION_/path/file.divert = 1.0-1 
    8988# 
    9089#   List of absolute paths to files whose diversions caused by 
    91 # DEB_DIVERT_FILES are to be removed upon installing this package. 
    92 # This is primarily useful for removing a now-unecessary diversion 
    93 # provided by a previous version of this package on an upgrade. 
     90# DEB_DIVERT_FILES are to be removed upon installing this package, if 
     91# the diversions have been made on the target system.  This is 
     92# primarily useful for removing a now-unecessary diversion provided by 
     93# a previous version of this package on an upgrade. 
    9494# 
    95 #   The DEB_UNDIVERT_VERSION_file variable should be set to the 
    96 # version number of this package at which you added 
    97 # DEB_UNDIVERT_FILES_path/file.divert; it is used to avoid attempting 
    98 # to remove the diversions again on future upgrades. 
    99 # 
    10095# DEB_UNREMOVE_FILES_package += /path/file 
    101 # DEB_UNREMOVE_VERSION_/path/file = 1.0-1 
    10296# 
    10397#   This works like DEB_UNDIVERT_FILES_package, except that it only 
    104 # removes the diversion (not a symlink) and the version number is 
    105 # specified with DEB_UNREMOVE_VERSION_/path/file. 
     98# removes the diversion (not a symlink). 
    10699 
    107100ifndef _cdbs_rules_config_package 
    108101_cdbs_rules_config_package = 1 
  • divert.sh.in

     
    107107    undivert_unlink_divert "$file" 
    108108} 
    109109 
     110check_undivert_unlink() 
     111{ 
     112    prefix=$1 
     113    suffix=$2 
     114 
     115    file=$prefix$suffix 
     116    ourfile=$prefix$ours$suffix 
     117    theirfile=$prefix$theirs$suffix 
     118 
     119    if dpkg-divert --list "$package" | \ 
     120        grep -xFq "diversion of $file to $theirfile by $package"; then 
     121        undivert_unlink "$prefix" "$suffix" 
     122    fi 
     123} 
     124 
     125check_undivert_unremove() 
     126{ 
     127    file=$1 
     128    removedfile=$2 
     129    if dpkg-divert --list "$package" | \ 
     130        grep -xFq "diversion of $file to $removedfile by $package"; then 
     131        undivert_unremove "$file" 
     132    fi 
     133} 
  • examples/debathena-bin-example-1.1/debian/rules

     
    1313DEB_DH_LINK_debathena-bin-example += \ 
    1414        /usr/share/man/man1/less.debathena-orig.1.gz /usr/share/man/man1/less.debathena.1.gz 
    1515 
    16 # Remove elinks diversion on upgrade from version(s) prior to 1.1 
     16# Remove elinks diversion on upgrade if it was previously in place on 
     17# the target system 
    1718DEB_UNDIVERT_FILES_debathena-bin-example += /usr/bin/elinks.debathena 
    18 DEB_UNDIVERT_VERSION_/usr/bin/elinks.debathena = 1.1 
    1919# and the man page 
    2020DEB_UNDIVERT_FILES_debathena-bin-example += /usr/share/man/man1/elinks.debathena.1.gz 
    21 DEB_UNDIVERT_VERSION_/usr/share/man/man1/elinks.debathena.1.gz = 1.1 
    2221 
    2322include /usr/share/cdbs/1/rules/debhelper.mk 
    2423include /usr/share/cdbs/1/rules/config-package.mk