quilt-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Quilt-dev] [PATCH] Substitute sed with configured path


From: Kent R. Spillner
Subject: [Quilt-dev] [PATCH] Substitute sed with configured path
Date: Tue, 24 Dec 2013 08:42:57 -0600
User-agent: OpenSMTPD enqueuer (Demoostik)

configure.ac calls QUILT_COMPAT_PROG_PATH(SED, sed)
allowing users to provide their own path to sed via
--with-sed=.  However, nothing was actually using SED.
This patch updates Makefile.in to substitute @SED@ in
all .in files, and updates everything in bin/ and quilt/
to actually support this substitution.

With this change it is possible to configure quilt to
explicitly use GNU sed on systems where GNU sed is
available but not installed by default (e.g. OpenBSD).

Signed-off-by: Kent R. Spillner <address@hidden>
---
 Makefile.in               |  1 +
 bin/patch-wrapper.in      |  5 +++--
 bin/quilt.in              |  4 +++-
 quilt/annotate.in         |  6 ++++--
 quilt/diff.in             |  4 +++-
 quilt/grep.in             |  4 +++-
 quilt/header.in           |  4 +++-
 quilt/import.in           |  4 +++-
 quilt/mail.in             | 24 +++++++++++++-----------
 quilt/refresh.in          |  4 +++-
 quilt/scripts/inspect.in  |  4 +++-
 quilt/scripts/patchfns.in | 18 ++++++++++--------
 quilt/setup.in            |  8 +++++---
 13 files changed, 57 insertions(+), 33 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index 8040653..cd7c2b9 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -257,6 +257,7 @@ $(patsubst %.in,%,$(wildcard bin/*.in quilt/*.in 
quilt/scripts/*.in)) :: Makefil
                -e 's:@PERL''@:$(PERL):g'                               \
                -e 's:@BASH''@:$(BASH):g'                               \
                -e 's:@PATCH''@:$(PATCH):g'                             \
+               -e 's:@SED''@:$(SED):g'                         \
                -e 's:@STAT_HARDLINK''@:$(STAT_HARDLINK):g'             \
                -e 's:@VERSION''@:$(VERSION):g'                         \
                -e 's:@RELEASE''@:$(RELEASE):g'                         \
diff --git a/bin/patch-wrapper.in b/bin/patch-wrapper.in
index 358856a..489fbca 100755
--- a/bin/patch-wrapper.in
+++ b/bin/patch-wrapper.in
@@ -7,6 +7,7 @@
 # used directly, and no quilt metadata will get created.
 
 address@hidden@
address@hidden@
 original_options=("$@")
 
 # GNU patch recognizes these environment variables
@@ -69,9 +70,9 @@ find_pipe_patch() {
     patch=${patch//\[/\\[}
     patch=${patch//\]/\\]}
     set -- $(stat -c $'%a %N\n' /proc/*/fd/* 2>/dev/null \
-            | sed -nre "s,^300 \`(/proc/.*/fd)/.*' -> \`$patch'$,\\1,p")
+            | $SED -nre "s,^300 \`(/proc/.*/fd)/.*' -> \`$patch'$,\\1,p")
     set -- $(stat -c $'%a %N\n' $1/* 2>/dev/null \
-            | sed -nre "s,^500 \`.*' -> \`(.*)',\\1,p")
+            | $SED -nre "s,^500 \`.*' -> \`(.*)',\\1,p")
     [ $# -eq 1 ] || set -- "$patch"
     echo "$1"
 }
diff --git a/bin/quilt.in b/bin/quilt.in
index 2271833..51773a3 100644
--- a/bin/quilt.in
+++ b/bin/quilt.in
@@ -6,6 +6,8 @@
 #
 #  See the COPYING and AUTHORS files for more details.
 
address@hidden@
+
 # unset posix strict conformance variable since patch cannot be run
 # non-interactively when it's set.
 unset POSIXLY_CORRECT
@@ -44,7 +46,7 @@ usage()
        quilt_commands \
        | sort \
        | column | column -t \
-       | sed -e $'s/^/\t/'
+       | $SED -e $'s/^/\t/'
        echo $"
 Global options:
 
diff --git a/quilt/annotate.in b/quilt/annotate.in
index 0366f5a..c71e02b 100644
--- a/quilt/annotate.in
+++ b/quilt/annotate.in
@@ -6,6 +6,8 @@
 #
 #  See the COPYING and AUTHORS files for more details.
 
address@hidden@
+
 # Read in library functions
 if [ "$(type -t patch_file_name)" != function ]
 then
@@ -40,7 +42,7 @@ empty_file()
 {
        local file=$1
        [ -s "$file" ] \
-       && sed -e 's:.*::' "$file"
+       && $SED -e 's:.*::' "$file"
 }
 
 annotation_for()
@@ -140,7 +142,7 @@ fi
 
 if [ address@hidden = 0 ]
 then
-       sed -e 's:^:'$'\t'':' "address@hidden"
+       $SED -e 's:^:'$'\t'':' "address@hidden"
        exit 0
 fi
 
diff --git a/quilt/diff.in b/quilt/diff.in
index 6b4f9d6..4894fff 100644
--- a/quilt/diff.in
+++ b/quilt/diff.in
@@ -6,6 +6,8 @@
 #
 #  See the COPYING and AUTHORS files for more details.
 
address@hidden@
+
 # Read in library functions
 if [ "$(type -t patch_file_name)" != function ]
 then
@@ -82,7 +84,7 @@ included.
 colorize() {
        if [ -n "$opt_color" ]
        then
-               sed -e '
+               $SED -e '
                    s/^\(Index:\|---\|+++\|\*\*\*\) 
.*/'$color_diff_hdr'&'$color_clear'/
                t ; s/^+.*/'$color_diff_add'&'$color_clear'/
                t ; s/^-.*/'$color_diff_rem'&'$color_clear'/
diff --git a/quilt/grep.in b/quilt/grep.in
index 0c32fcf..81eb774 100644
--- a/quilt/grep.in
+++ b/quilt/grep.in
@@ -6,6 +6,8 @@
 #
 #  See the COPYING and AUTHORS files for more details.
 
address@hidden@
+
 # Read in library functions
 if [ "$(type -t patch_file_name)" != function ]
 then
@@ -120,7 +122,7 @@ find "address@hidden:-.}" \( \
        -type f -print0 \
 | xargs -0 grep $opt_H "address@hidden" \
 | if [ address@hidden -eq 0 ]; then
-       sed -e 's,^./,,'
+       $SED -e 's,^./,,'
 else
        cat
 fi
diff --git a/quilt/header.in b/quilt/header.in
index a3bbcbc..88daa11 100644
--- a/quilt/header.in
+++ b/quilt/header.in
@@ -6,6 +6,8 @@
 #
 #  See the COPYING and AUTHORS files for more details.
 
address@hidden@
+
 # Read in library functions
 if [ "$(type -t patch_file_name)" != function ]
 then
@@ -52,7 +54,7 @@ maybe_strip_trailing_whitespace()
 {
        if [ -n "$opt_strip_trailing_whitespace" ]
        then
-               sed -e 's:[ '$'\t'']*$::'
+               $SED -e 's:[ '$'\t'']*$::'
        else
                cat
        fi
diff --git a/quilt/import.in b/quilt/import.in
index cc9deed..5d68678 100644
--- a/quilt/import.in
+++ b/quilt/import.in
@@ -6,6 +6,8 @@
 #
 #  See the COPYING and AUTHORS files for more details.
 
address@hidden@
+
 # Read in library functions
 if [ "$(type -t patch_file_name)" != function ]
 then
@@ -65,7 +67,7 @@ merge_patches()
                if [ -z "$opt_desc" ]
                then
                        local diff=$(diff -u $old_desc $new_desc \
-                                    | sed -e '1,2d')
+                                    | $SED -e '1,2d')
                        if [ -n "$diff" ]
                        then
                                printf $"Patch headers differ:\n" >&2
diff --git a/quilt/mail.in b/quilt/mail.in
index 109782a..12fc2eb 100644
--- a/quilt/mail.in
+++ b/quilt/mail.in
@@ -6,6 +6,8 @@
 #
 #  See the COPYING and AUTHORS files for more details.
 
+SED = @SED@
+
 : ${EDITOR:=vi}
 
 # Read in library functions
@@ -146,7 +148,7 @@ process_mail()
        else
                local from_date=$(LC_ALL=POSIX date "+%a %b %e %H:%M:%S %Y")
                echo "From $opt_sender_address $from_date"
-               sed -e 's/^From />From /' $tmpfile
+               $SED -e 's/^From />From /' $tmpfile
                echo
        fi
        rm -f $tmpfile
@@ -305,7 +307,7 @@ Could not determine the envelope sender address. Please use 
--sender." >&2
                ;;
        esac
 fi
-opt_sender_address=$(echo "$opt_sender" | sed -re 's:.*<([^<>]+)>.*:\1:')
+opt_sender_address=$(echo "$opt_sender" | $SED -re 's:.*<([^<>]+)>.*:\1:')
 
 if [ -z "$opt_charset" ]
 then
@@ -360,7 +362,7 @@ then
                # Is the first paragraph short enough to be used as the subject?
                if [ -z "$subject" ]
                then
-                       local para=$(sed -e $'/^[ \t]*$/q' $tmpdir/header)
+                       local para=$($SED -e $'/^[ \t]*$/q' $tmpdir/header)
                        if [ ${#para} -gt 0 -a ${#para} -lt 150 ]
                        then
                                subject=$(echo "$para" | join_lines)
@@ -378,7 +380,7 @@ then
                fi
 
                subject=$(echo "$subject" \
-                         | sed -e 
$'s/^\\(\\(\\[[^]]*\\]\\|fwd:\\|fw:\\|re:\\|aw:\\|tr:\\)[ \t]*\\)*//i')
+                         | $SED -e 
$'s/^\\(\\(\\[[^]]*\\]\\|fwd:\\|fw:\\|re:\\|aw:\\|tr:\\)[ \t]*\\)*//i')
                echo "Replace-Subject: $subject"
 
                # Add recipients defined by some recognized keywords
@@ -391,7 +393,7 @@ then
                set -- "$*"
                set -- ${*// /\\|}
 
-               sed -n -e "/\<${LOGNAME:-$(whoami)}@/d" \
+               $SED -n -e "/\<${LOGNAME:-$(whoami)}@/d" \
                       -e 's/^\(\(To\|'"$*"'\):[ 
'$'\t'']*\)\([^"]*\(,[^"]*\)\+[^" '$'\t'']\)\([ '$'\t'']*<.*>\)/\1"\3"\5/I' \
                       -e 's/^To:\(address@hidden)/Recipient-To:\1/Ip' \
                       -e 's/^\('"$*"'\):\(address@hidden)/Recipient-Cc:\2/Ip' \
@@ -483,7 +485,7 @@ then
        if [ -z "$opt_subject" ]
        then
                opt_subject="Re: $(formail -x Subject: < "$opt_reply_to" \
-                             | sed -e 's/^ *\([rR][eE]: *\)*//')"
+                             | $SED -e 's/^ *\([rR][eE]: *\)*//')"
        fi
 fi
 
@@ -557,7 +559,7 @@ subject_prefix=${subject_prefix//\'/\'\'}
 subject_prefix=${subject_prefix//\//\\\/}
 p=${subject_prefix//@num@/$(printf %0*d ${#total} 0)}
 p=${p//@total@/$total}
-sed -e $'s/^\\(Subject:[ \t]\\)/\\1'"$p"'/' \
+$SED -e $'s/^\\(Subject:[ \t]\\)/\\1'"$p"'/' \
     -e '/^Subject-Prefix:/d' \
 $introduction \
 | $QUILT_DIR/scripts/edmail --charset $opt_charset \
@@ -573,7 +575,7 @@ fi
 # increment the timestamp by one second and wait with sending until
 # that time has arrived. This allows MUAs to show the messages in the
 # correct order.
-last_ts=$(date '+%s' -d "$(sed -ne $'s/^Date:[ \t]*//p' $introduction)")
+last_ts=$(date '+%s' -d "$($SED -ne $'s/^Date:[ \t]*//p' $introduction)")
 
 num=1
 for patch in "address@hidden"; do
@@ -607,7 +609,7 @@ for patch in "address@hidden"; do
                                    gsub(/'\''/, "'\'\''", s)
                                    print options[n] " " r "='\''" s "'\'' \\" 
} }
        ' $body)"
-#      echo "$modify" | sed -e 's/^/>> /' >&2
+#      echo "$modify" | $SED -e 's/^/>> /' >&2
        p=${subject_prefix//@num@/$(printf %0*d ${#total} $num)}
        p=${p//@total@/$total}
 
@@ -641,7 +643,7 @@ for patch in "address@hidden"; do
                --replace-header Date="\"$new_date\"" \
                To Cc Bcc \
                "$modify" \
-       | sed -e $'s/^\\(Subject:[ \t]\\)/\\1'"$p"'/' \
+       | $SED -e $'s/^\\(Subject:[ \t]\\)/\\1'"$p"'/' \
              -e '/^Subject-Prefix:/d' \
        | $QUILT_DIR/scripts/edmail --remove-empty-headers \
        | process_mail ) 2> $tmpdir/err
@@ -649,7 +651,7 @@ for patch in "address@hidden"; do
        status=$?
        if [ -s $tmpdir/err ]
        then
-               sed -e "s/^/${patch//\//\\/}: /" <  $tmpdir/err >&2
+               $SED -e "s/^/${patch//\//\\/}: /" <  $tmpdir/err >&2
        fi
        if [ $status -ne 0 ]
        then
diff --git a/quilt/refresh.in b/quilt/refresh.in
index 6c6b4d0..29cf57e 100644
--- a/quilt/refresh.in
+++ b/quilt/refresh.in
@@ -6,6 +6,8 @@
 #
 #  See the COPYING and AUTHORS files for more details.
 
address@hidden@
+
 # Read in library functions
 if [ "$(type -t patch_file_name)" != function ]
 then
@@ -285,7 +287,7 @@ then
            function print_diffstat(arr, i) {
              if (system("diffstat '"$QUILT_DIFFSTAT_OPTS \
                                     -p$num_strip_level \
-                                    $tmp_patch | sed -e s:^:"'" prefix ":"))
+                                    $tmp_patch | $SED -e s:^:"'" prefix ":"))
                exit 1
            }
                        { prefix=""
diff --git a/quilt/scripts/inspect.in b/quilt/scripts/inspect.in
index e8eff26..0d0b868 100644
--- a/quilt/scripts/inspect.in
+++ b/quilt/scripts/inspect.in
@@ -6,6 +6,8 @@
 #
 #  See the COPYING and AUTHORS files for more details.
 
address@hidden@
+
 : address@hidden@}
 
 if ! [ -r $QUILT_DIR/scripts/patchfns ]
@@ -162,7 +164,7 @@ cat <<-'EOF' > $tmpdir/bin/wrapper
                then
                        ( cd $RPM_BUILD_DIR
                        find . -type f \
-                       | sed -e 's:^.\/::' \
+                       | $SED -e 's:^.\/::' \
                        | xargs md5sum \
                        ) > $tmpdir/more-md5sums
                fi
diff --git a/quilt/scripts/patchfns.in b/quilt/scripts/patchfns.in
index e89474f..0a56090 100644
--- a/quilt/scripts/patchfns.in
+++ b/quilt/scripts/patchfns.in
@@ -7,6 +7,8 @@
 #
 #  See the COPYING and AUTHORS files for more details.
 
address@hidden@
+
 export TEXTDOMAIN=quilt
 export address@hidden@
 
@@ -79,19 +81,19 @@ trap run_exit_handlers EXIT
 # Quote a string for use in a basic regular expression.
 quote_bre()
 {
-       echo "$1" | sed -e 's:\([][^$/.*\\]\):\\\1:g'
+       echo "$1" | $SED -e 's:\([][^$/.*\\]\):\\\1:g'
 }
 
 # Quote a string for use in an extended regular expression.
 quote_re()
 {
-       echo "$1" | sed -e 's:\([][?{(|)}^$/.+*\\]\):\\\1:g'
+       echo "$1" | $SED -e 's:\([][?{(|)}^$/.+*\\]\):\\\1:g'
 }
 
 # Quote a string for use in a globing pattern.
 quote_glob()
 {
-       echo "$1" | sed -e 's:\([][*?\\]\):\\\1:g'
+       echo "$1" | $SED -e 's:\([][*?\\]\):\\\1:g'
 }
 
 patch_file_name()
@@ -326,7 +328,7 @@ cat_series()
 {
        if [ -e $SERIES ]
        then
-               sed -e '/^#/d' -e 's/^[ '$'\t'']*//' \
+               $SED -e '/^#/d' -e 's/^[ '$'\t'']*//' \
                    -e 's/[ '$'\t''].*//' -e '/^$/d' $SERIES
        else
                return 1
@@ -514,7 +516,7 @@ find_patch()
 
                local patch=${1#$SUBDIR_DOWN$QUILT_PATCHES/}
                local bre=$(quote_bre "$patch")
-               set -- $(sed -e 
"/^$bre\(\|\.patch\|\.diff\?\)\(\|\.gz\|\.bz2\|\.xz\|\.lzma\)\([ 
"$'\t'"]\|$\)/!d" \
+               set -- $($SED -e 
"/^$bre\(\|\.patch\|\.diff\?\)\(\|\.gz\|\.bz2\|\.xz\|\.lzma\)\([ 
"$'\t'"]\|$\)/!d" \
                               -e 's/[ '$'\t''].*//' $SERIES)
                if [ $# -eq 1 ]
                then
@@ -657,7 +659,7 @@ files_in_patch()
        then
                find "$path" -type f \
                               -a ! -path "$(quote_glob "$path")/.timestamp" |
-               sed -e "s/$(quote_bre "$path")\///"
+               $SED -e "s/$(quote_bre "$path")\///"
        fi
 }
 
@@ -918,8 +920,8 @@ next_filename()
 {
        local patch=$1 base num
         base=$(echo "$patch" \
-               | sed -r -e 's:(\.gz|\.bz2|\.xz|\.lzma)$::' -e 
's:(\.diff?|\.patch)$::')
-        num=$(echo "$base" | sed -nre 's:.*-([0-9]+)$:\1:'p)
+               | $SED -r -e 's:(\.gz|\.bz2|\.xz|\.lzma)$::' -e 
's:(\.diff?|\.patch)$::')
+        num=$(echo "$base" | $SED -nre 's:.*-([0-9]+)$:\1:'p)
         [ -n "$num" ] || num=1
         echo "${base%-$num}-$((num+1))${patch#$base}"
 }
diff --git a/quilt/setup.in b/quilt/setup.in
index 0930a89..fa4ad44 100644
--- a/quilt/setup.in
+++ b/quilt/setup.in
@@ -6,6 +6,8 @@
 #
 #  See the COPYING and AUTHORS files for more details.
 
address@hidden@
+
 # Read in library functions
 if [ "$(type -t patch_file_name)" != function ]
 then
@@ -75,12 +77,12 @@ create_symlink() {
        fi
 
        set -- "$(echo "$PWD/$target" | \
-                 sed -r -e 's://:/:g' \
+                 $SED -r -e 's://:/:g' \
                         -e ':again' \
                         -e 's:/[^/]+/\.\.(/|$):\1:g' \
                         -e 'tagain')" \
               "$(echo "$PWD/$link" | \
-                 sed -r -e 's://:/:g' \
+                 $SED -r -e 's://:/:g' \
                         -e ':again' \
                         -e 's:/[^/]+/\.\.(/|$):\1:g' \
                         -e 'tagain')"
@@ -88,7 +90,7 @@ create_symlink() {
        do
                set -- "${1#*/}" "${2#*/}"
        done
-       up=$(echo "${2%/*}" | sed -re 's:[^/]+:..:g')
+       up=$(echo "${2%/*}" | $SED -re 's:[^/]+:..:g')
        set -- "${up:+$up/}$1"
        set -- "${1%/}"
        ln -s "${1:-.}" "$link"
-- 
1.8.4.5




reply via email to

[Prev in Thread] Current Thread [Next in Thread]