diff options
-rw-r--r-- | Makefile.in | 8 | ||||
-rw-r--r-- | quilt/scripts/backup-files.in | 3 | ||||
-rw-r--r-- | quilt/scripts/patchfns.in | 38 | ||||
-rw-r--r-- | quilt/scripts/utilfns | 44 |
4 files changed, 53 insertions, 40 deletions
diff --git a/Makefile.in b/Makefile.in index 050b2b0..6134197 100644 --- a/Makefile.in +++ b/Makefile.in @@ -109,7 +109,7 @@ DIRT += po/*.mo po/*~ SRC += $(wildcard test/*.test) test/run test/test.quiltrc SRC += changes2changelog -NON_EXEC_IN := doc/quilt.1 doc/README quilt/scripts/patchfns +NON_EXEC_IN := doc/quilt.1 doc/README quilt/scripts/patchfns quilt/scripts/utilfns GIT_DESC := $(shell ./git-desc | sed -e 's:^v::') @@ -206,7 +206,7 @@ doc/quilt.1: doc/quilt.1.in doc/reference $(COMPAT) esac; \ done < $< 2>&1 > $@ -doc/reference : bin/quilt $(QUILT:%=quilt/%) quilt/scripts/patchfns $(COMPAT) +doc/reference : bin/quilt $(QUILT:%=quilt/%) quilt/scripts/patchfns quilt/scripts/utilfns $(COMPAT) @unset LANG LC_MESSAGES LC_CTYPE LC_ALL; \ for i in $(QUILT); \ do \ @@ -302,7 +302,7 @@ install-main :: scripts $(INSTALL) -m 755 $(patsubst %,quilt/scripts/%, \ $(filter-out patchfns,$(SCRIPTS))) \ $(BUILD_ROOT)$(datadir)/$(PACKAGE)/scripts - $(INSTALL) -m 644 quilt/scripts/patchfns \ + $(INSTALL) -m 644 quilt/scripts/patchfns quilt/scripts/utilfns \ $(BUILD_ROOT)$(datadir)/$(PACKAGE)/scripts ifneq ($(PATCH_WRAPPER),) $(INSTALL) -d $(BUILD_ROOT)$(datadir)/$(PACKAGE)/wrapper @@ -369,7 +369,7 @@ test/.patch-wrapper.ok : bin/patch-wrapper # Include a run-time generated list of dependencies for each test case test/.depend : Makefile $(TESTS) - @( printf "%s : bin/quilt quilt/scripts/patchfns quilt/scripts/backup-files $(COMPAT)\n" $(TESTS); \ + @( printf "%s : bin/quilt quilt/scripts/patchfns quilt/scripts/utilfns quilt/scripts/backup-files $(COMPAT)\n" $(TESTS); \ $(AWK) 'sub(/.*\$$ *quilt /, "") \ { print FILENAME, ":", "quilt/"$$1}' $(TESTS); \ $(AWK) 'sub(/.*\<quilt_command /, "") && ($$1 !~ /[^a-z]/) \ diff --git a/quilt/scripts/backup-files.in b/quilt/scripts/backup-files.in index 34cd07f..74cfcad 100644 --- a/quilt/scripts/backup-files.in +++ b/quilt/scripts/backup-files.in @@ -44,6 +44,9 @@ usage () { " } +: ${QUILT_DIR=@QUILT_DIR@} +. $QUILT_DIR/scripts/utilfns + ensure_nolinks() { local filename="$1" local link_count tmpname diff --git a/quilt/scripts/patchfns.in b/quilt/scripts/patchfns.in index 6b788fd..8d19da6 100644 --- a/quilt/scripts/patchfns.in +++ b/quilt/scripts/patchfns.in @@ -41,6 +41,8 @@ if [ -n "$QUILT_COMMAND" ]; then unset args fi +. $QUILT_DIR/scripts/utilfns + # ======================================================== declare -a exit_handlers @@ -86,42 +88,6 @@ quote_re() echo "$1" | sed -e 's:\([][?{(|)}^$/.+*\\]\):\\\1:g' } -basename() -{ - local path=$1 - while [ "${path:(-1)}" = "/" ] - do - path=${path%/} - done - echo "${path##*/}" -} - -dirname() -{ - local path=$1 - while [ "${path:(-1)}" = "/" ] - do - path=${path%/} - done - local basename="${path##*/}" - path="${path:0:${#path}-${#basename}}" - while [ "${path:(-1)}" = "/" ] - do - path=${path%/} - done - if [ -n "$path" ] - then - echo "$path" - else - if [ ${1:0:1} = "/" ] - then - echo "/" - else - echo "." - fi - fi -} - patch_file_name() { echo "$QUILT_PATCHES/$1" diff --git a/quilt/scripts/utilfns b/quilt/scripts/utilfns new file mode 100644 index 0000000..8a082a6 --- /dev/null +++ b/quilt/scripts/utilfns @@ -0,0 +1,44 @@ +# This file contains the common functions used by patchfns and backup-files. +# It is meant to be sourced by bash scripts. + +# This script is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# See the COPYING and AUTHORS files for more details. + +basename() +{ + local path=$1 + while [ "${path:(-1)}" = "/" ] + do + path=${path%/} + done + echo "${path##*/}" +} + +dirname() +{ + local path=$1 + while [ "${path:(-1)}" = "/" ] + do + path=${path%/} + done + local basename="${path##*/}" + path="${path:0:${#path}-${#basename}}" + while [ "${path:(-1)}" = "/" ] + do + path=${path%/} + done + if [ -n "$path" ] + then + echo "$path" + else + if [ ${1:0:1} = "/" ] + then + echo "/" + else + echo "." + fi + fi +} |