* looking for dpatch@packages.qa.debian.org--archive/dpatch--mainline--2.0--patch-127 to compare with
* comparing to dpatch@packages.qa.debian.org--archive/dpatch--mainline--2.0--patch-127
M  scripts/dpatch-get-origtargz
M  dpep/dpatch-edit-patch.functions
M  dpep/dpatch-edit-patch.1
M  scripts/dpatch-get-origtargz.1
M  dpep/dpatch-edit-patch
M  debian/changelog
M  tests/log/02_create_patch.sh
M  tests/log/03_edit_patch.sh
M  tests/log/04_add_new_patch.sh
M  tests/log/05_edit_with_patched.sh
M  tests/log/06_dpatch_edit_patch_description.sh
M  tests/log/07_dpatch_edit_patch_description_preserve.sh
M  tests/08_dpatch_list_patch.sh
M  tests/log/08_dpatch_list_patch.sh
M  tests/10_dpep_debianonly.sh
M  tests/11_dpep_debianonly_origtargz_in_upstream.sh
M  tests/log/10_dpep_debianonly.sh
M  tests/log/11_dpep_debianonly_origtargz_in_upstream.sh
M  tests/run-test.sh
M  tests/test.log.summary

* modified files

--- orig/debian/changelog
+++ mod/debian/changelog
@@ -16,14 +16,20 @@
   - This is also a response for request of OOo patch system. 
     Rather than taking that approach, we check more rigorously.
     (Closes: #290820)
-  - dpep: Check for debian/patched/patch.dpatch, and require --clean option to be 
-    specified in that case.
+  - dpep: Check for debian/patched/patch.dpatch, 
+    and require --clean option to be specified in that case.
   - tests/05_edit_with_patched now passes.
-  * dpep; debianonly: when failing, it gives a shell error, 317757 cannot be reproduced?
   * dpatch-edit-patch does not give out an error message when --debianonly flag is given a nonexisting file, patch from mh. (closes: #317758)
     tests/10_dpep_debianonly.sh output is fixed.
+  * Feature implementation:
+    "dpatch-get-origtargz does not found upstream tarballs in
+    ../upstream", thanks to Stefano Zacchiroli (Closes: #315719)
+
+  TODO items before release:
+  * dpep; debianonly: when failing, it gives a shell error, 
+    317757 cannot be reproduced?
 
- -- Junichi Uekawa <dancer@debian.org>  Sat, 16 Jul 2005 16:47:09 +0900
+ -- Junichi Uekawa <dancer@debian.org>  Sat, 16 Jul 2005 18:37:53 +0900
 
 dpatch (2.0.13) unstable; urgency=low
 


--- orig/dpep/dpatch-edit-patch
+++ mod/dpep/dpatch-edit-patch
@@ -36,6 +36,7 @@
 DPEP_TMPDIR="${DPEP_TMPDIR:-${conf_tmpdir:-${TMPDIR:-/tmp}}}"
 DPEP_SHELL="${DPEP_SHELL:-${conf_shell:-${SHELL:-$(getent passwd $(id -un) | cut -f7- -d:)}}}"
 DPEP_EXCLUDE="${DPEP_EXCLUDE:-${conf_exclude:-CVS .svn}}"
+DPEP_ORIGTARGZPATH="${DPEP_ORIGTARGZPATH:-${conf_origtargzpath:-}}"
 
 # We special-case $DPEP_ROOTCMD later, after dpep_parse_options()
 
@@ -172,6 +173,7 @@
             PACKAGENAME="$(dpkg-parsechangelog | sed -n '/^Source:/{s/^Source:[[:space:]]\+\(.*\)/\1/;p;q}')"
             UPSTREAMVERSION="$(dpkg-parsechangelog | sed -n '/^Version:/{s/^Version:[[:space:]]\+\([^-]\+\).*/\1/;p;q}')"
             ORIGTARGZ="${PACKAGENAME}_${UPSTREAMVERSION}.orig.tar.gz"
+	    export DPGO_ORIGTARGZPATH="$DPEP_ORIGTARGZPATH"
 	    if ! eval "$DPEP_GETORIGTARGZ $REFPDIR"; then
 	        dpep_message error "unable to obtain upstream tarball, $DPEP_GET_ORIGTARGZ failed"
 		exit 1


--- orig/dpep/dpatch-edit-patch.1
+++ mod/dpep/dpatch-edit-patch.1
@@ -133,6 +133,15 @@
 and \fBconf_origtargz\fR (\fI~/.dpatch.conf\fR), Environment Variables
 \fBDPEP_DEBIANONLY\fR and \fBDPEP_ORIGTARGZ\fR.
 .TP
+.IB "\-P, \-\-origtargzpath="path
+When
+.IB \-b
+is in use, specify the path where upstream tarballs should be looked for.
+.B path
+is a colon-separated list of directories.
+Configuration variables: \fBconf_origtargzpath\fR (\fI~/.dpatch.conf\fR),
+Environment Variables \fBDPEP_ORIGTARGZPATH\fR.
+.TP
 .IB "\-r, \-\-rootcmd="value
 Command used to gain root privileges used to clean DPEP_SOURCEDIR.
 Configuration variable \fBconf_rootcmd\fR, environment variable \fBDPEP_ROOTCMD\fR.
@@ -321,7 +330,7 @@
 
 .SH AUTHOR
 This manual page was written by David B Harris <david@eelf.ddts.net>
-and modified in the course of development by Gergely Nagy <algernon@debian.org>
-and Marc Haber <mh+debian\-packages@zugschlus.de>.
+and modified in the course of development by Gergely Nagy <algernon@debian.org>,
+Marc Haber <mh+debian\-packages@zugschlus.de>, and Stefano Zacchiroli <zack@debian.org>.
 
 .\" arch-tag: 7c0644f7-93aa-4308-bf43-b50d415e282e


--- orig/dpep/dpatch-edit-patch.functions
+++ mod/dpep/dpatch-edit-patch.functions
@@ -37,6 +37,10 @@
     -k|--keeptemp	   Keep working source tree after exit.
     -c|--clean		   Clean the current directory.
     -l|--shell=shell	   Which shell should be invoked.
+    -P|--origtargzpath=path  
+                           Path where to look for upstream tarballs
+			   (colon-separated list of directories,
+			   meaninfgul only with -b).
     -h|--help		   Print this message.
 
 Examples:
@@ -96,8 +100,8 @@
 }
 
 dpep_parse_options() {
-    TEMP=$(getopt -o d:o:s:t:e:b::l:kch \
-                  --long description:,outdir:,sourcedir:,tmpdir:,exclude:,debianonly::,shell:,keeptemp,clean,help \
+    TEMP=$(getopt -o d:o:s:t:e:b::l:kchP: \
+                  --long description:,outdir:,sourcedir:,tmpdir:,exclude:,debianonly::,shell:,keeptemp,clean,help,origtargzpath: \
 		  -n 'dpatch-edit-patch' -- "$@")
 
 
@@ -116,6 +120,7 @@
 	    -p|--stampdir)    DPEP_STAMPDIR="$2"; shift 2;;
 	    -e|--exclude)     DPEP_EXCLUDE="$2"; shift 2;;
 	    -b|--debianonly)  DPEP_DEBIANONLY=1; DPEP_ORIGTARGZ="$2"; shift 2;;
+	    -P|--origtargzpath) DPEP_ORIGTARGZPATH="$2"; shift 2;;
 	    -k|--keeptemp)    DPEP_KEEPTEMP=1; shift;;
 	    -c|--clean)       DPEP_CLEAN=1; shift;;
 	    -r|--rootcmd)     DPEP_ROOTCMD="$2"; shift 2;;


--- orig/scripts/dpatch-get-origtargz
+++ mod/scripts/dpatch-get-origtargz
@@ -2,7 +2,7 @@
 
 set -e
 
-DPFO_BASENAME="$(basename $0)"
+DPGO_BASENAME="$(basename $0)"
 
 # makes sure that there is a .orig.tar.gz in a given directory.
 # This script is to be invoked from a package build directory as it uses
@@ -13,7 +13,7 @@
 ORIGTARDIR="$1"
 shift
 if [ -z "$ORIGTARDIR" ] || [ -n "$1" ]; then
-  echo >&2 "${DPFO_BASENAME}: Usage: dpatch-find-origtargz <origtardir>"
+  echo >&2 "${DPGO_BASENAME}: Usage: dpatch-get-origtargz <origtardir>"
   exit 1
 fi
 
@@ -24,26 +24,40 @@
   true
 elif [ -f "${DPGO_ORIGTARDIR}/$ORIGTARGZ" ]; then
   cp $(readlink -f "${DPGO_ORIGTARDIR}/$ORIGTARGZ") $ORIGTARDIR
-elif [ -f "../$ORIGTARGZ" ]; then
-  cp $(readlink -f "../$ORIGTARGZ") $ORIGTARDIR
-elif [ -x $(which apt-get) ]; then
-  if (cd $ORIGTARDIR && apt-get --tar-only source "$PACKAGENAME"); then
-    if ! [ -f "${ORIGTARDIR}/$ORIGTARGZ" ]; then
-      echo >&2 "${DPFO_BASENAME}: Error: apt-get source $PACKAGENAME delivered wrong version of $ORIGTARGZ"
+elif [ ! -z "${DPGO_ORIGTARGZPATH}" ]; then
+    for dir in $(echo ${DPGO_ORIGTARGZPATH} | cut -d: -f 1- --output-delimiter=' '); do
+	echo DEBUG: try $dir 
+	if [ -f "$dir/$ORIGTARGZ" ]; then
+	    cp $(readlink -f "$dir/$ORIGTARGZ") $ORIGTARDIR
+	    break
+	fi
+    done
+fi
+ 
+# path and other methods failed, try heuristics and apt
+
+if [ ! -f  "${ORIGTARDIR}/$ORIGTARGZ" ]; then
+    if [ -f "../$ORIGTARGZ" ]; then
+	cp $(readlink -f "../$ORIGTARGZ") $ORIGTARDIR
+    elif [ -x $(which apt-get) ]; then
+	if (cd $ORIGTARDIR && apt-get --tar-only source "$PACKAGENAME"); then
+	    if ! [ -f "${ORIGTARDIR}/$ORIGTARGZ" ]; then
+		echo >&2 "${DPGO_BASENAME}: Error: apt-get source $PACKAGENAME failed to provide the correct version of $ORIGTARGZ"
+	    fi
+	else
+	    echo >&2 "${DPGO_BASENAME}: Error: apt-get source $PACKAGENAME failed"
+	fi
     fi
-  else
-    echo >&2 "${DPFO_BASENAME}: Error: apt-get source $PACKAGENAME failed"
-  fi
 fi
 
 # as a last resort, use debian/watch
 
 if [ ! -f "${ORIGTARDIR}/$ORIGTARGZ" -a -f "debian/watch" -a -x $(which curl) ] && ! curl --fail "$(< debian/watch sed -n "/^\\(http\\|ftp\\)/{s/^\\([^(]\\+\\)([^)]*)\\([^ ]*\\).*/\\1${UPSTREAMVERSION}\\2/;s/\\\\//g;p;q;}")" > ${ORIGTARDIR}/$ORIGTARGZ; then
-  echo >&2 "${DPFO_BASENAME}: Error: cannot curl $ORIGTARGZ from debian/watch location"
+  echo >&2 "${DPGO_BASENAME}: Error: cannot curl $ORIGTARGZ from debian/watch location"
 fi
 
 if [ ! -f "${ORIGTARDIR}/$ORIGTARGZ" ]; then
-  echo >&2 "${DPFO_BASENAME}: Error: unable to obtain $ORIGTARGZ from anywhere"
+  echo >&2 "${DPGO_BASENAME}: Error: unable to obtain $ORIGTARGZ from anywhere"
   exit 1
 fi
 


--- orig/scripts/dpatch-get-origtargz.1
+++ mod/scripts/dpatch-get-origtargz.1
@@ -15,13 +15,16 @@
 will try to find the upstream tarball using one of the following
 methods:
 .br
-1) in the directory pointed to by \fBDPGO_ORIGTARDIR\fR,
+1) in the directory pointed to by the \fBDPGO_ORIGTARDIR\fR environment variable,
 .br
-2) in the parent directory of the current work directory,
+2) in all directories listed in the \fBDPGO_ORIGTARPATH\fR environment
+variable (colon-separated list of directories),
 .br
-3) on the Debian mirror configured into apt, and
+3) in the parent directory of the current work directory,
 .br
-4) on the Internet, using the first URL found in debian/watch.
+4) on the Debian mirror configured into apt, and
+.br
+5) on the Internet, using the first URL found in debian/watch.
 .br
 
 If not, it tries to obtain the upstream tarball from a
@@ -29,8 +32,12 @@
 repository configured, and finally, the internet server
 pointed to by debian/watch.
 
+.SH SEE ALSO
+\fIdpatch\fR(1)
+
 .SH AUTHOR
 dpatch\-get\-origtargz and this manual page was written by Marc Haber
-<mh+debian\-packages@zugschlus.de>.
+<mh+debian\-packages@zugschlus.de> and modified by Stefano Zacchiroli
+<zack@debian.org>.
 
 .\" arch-tag: a8bdf178-9016-4721-a6b0-e5d492df89b7


--- orig/tests/08_dpatch_list_patch.sh
+++ mod/tests/08_dpatch_list_patch.sh
@@ -38,5 +38,4 @@
     :
 fi
 
-dpatch-list-patch | grep  "Description of this patch"
-
+dpatch-list-patch | grep "Description of this patch"


--- orig/tests/10_dpep_debianonly.sh
+++ mod/tests/10_dpep_debianonly.sh
@@ -15,21 +15,21 @@
 
 # create the orig.tar.gz and a debian directory
 cp -r $PKGPATH/debian debianonly/dpatch-test
-tar cfz debianonly/upstream/dpatch-test.orig.tar.gz dpatch-test
+tar cfz debianonly/upstream/dpatch-test_0.1.orig.tar.gz dpatch-test
 
 cd debianonly/dpatch-test
 
 # try running dpatch-edit-patch with full path to the orig.tar.gz
-echo 'echo another-patch > 10 ' | dpatch-edit-patch --debianonly=../upstream/dpatch-test.orig.tar.gz -d test 10_test_patch
+echo 'echo another-patch > 10 ' | dpatch-edit-patch --debianonly=../upstream/dpatch-test_0.1.orig.tar.gz -d test 10_test_patch
 
 ##: Also try checking that given a wrong full path, it will error out.; 
 ##: message fixed in 317758
-if echo 'echo even more > 10 ' | dpatch-edit-patch --debianonly=../upstream/dpatch-test.orig.tar.gz- -d test 10_test_patch; then
+if echo 'echo even more > 10 ' | dpatch-edit-patch --debianonly=../upstream/dpatch-test_0.1.orig.tar.gz- -d test 10_test_patch; then
     echo Wrong-path test failed!
     exit 1
 else
     echo success
 fi
 
-cat debian/patches/10_test_patch.dpatch
+#cat debian/patches/10_test_patch.dpatch
 grep "another-patch" debian/patches/10_test_patch.dpatch


--- orig/tests/11_dpep_debianonly_origtargz_in_upstream.sh
+++ mod/tests/11_dpep_debianonly_origtargz_in_upstream.sh
@@ -15,18 +15,22 @@
 cd $PKGPATH/../debianonly/dpatch-test
 
 mv ../upstream ../hidden-upstream
-# try running dpatch-edit-patch without full path to the orig.tar.gz; this should error out
-echo 'echo yet-more-patch > 11 ' | dpatch-edit-patch --debianonly -d test 11_test_patch
-
-mv ../hidden-upstream ../upstream
-# try running dpatch-edit-patch without full path to the orig.tar.gz; this should error out
-if echo 'echo yet-more-patch > 11 ' | dpatch-edit-patch --debianonly -d test 11_test_patch; then
+# Error out if given wrong upstream orig.tar.gz path.
+if echo 'echo yet-more-patch > 11 ' | dpatch-edit-patch -P$(pwd)/../upstream --debianonly -d test 11_test_patch; then
     echo "exit with error expected, upstream not found for this package"
     exit 1
 else
     :
 fi
 
+
+mv ../hidden-upstream ../upstream
+# Give proper upstream orig.tar.gz path, should succeed
+echo 'echo yet-more-patch > 11 ' | dpatch-edit-patch -P$(pwd)/../upstream --debianonly -d test 11_test_patch
+
+# Give proper upstream orig.tar.gz path, should succeed
+echo 'echo yet-more-patch > 11 ' | dpatch-edit-patch --origtargzpath=$(pwd)/../upstream --debianonly -d test 11_test_patch
+
 # check the resulting dpatch file.
-cat debian/patches/11_test_patch.dpatch
+#cat debian/patches/11_test_patch.dpatch
 grep yet-more-patch debian/patches/11_test_patch.dpatch




















--- orig/tests/run-test.sh
+++ mod/tests/run-test.sh
@@ -21,7 +21,12 @@
     else
 	echo [FAIL] $1 >> test.log.summary
     fi
-    ) | tee log/$1
+    ) | tee log/$1.tmp
+
+    # process /tmp/XXX/ dir pathnames so that we have consistent log output
+    # every time; helps to have a consistent output.
+    sed -e's,/tmp/[^/]*/,/tmp/XXXX/,g' < log/$1.tmp > log/$1
+    rm log/$1.tmp
 }
 : > test.log.summary
 


--- orig/tests/test.log.summary
+++ mod/tests/test.log.summary
@@ -7,4 +7,4 @@
 [OK] 07_dpatch_edit_patch_description_preserve.sh
 [OK] 08_dpatch_list_patch.sh
 [OK] 10_dpep_debianonly.sh
-[FAIL] 11_dpep_debianonly_origtargz_in_upstream.sh
+[OK] 11_dpep_debianonly_origtargz_in_upstream.sh



