Hi, I know that the original submitter is not interested in dpatch any more. I have, however, done some changes to copy and symlink handling which might affect this bug as well.
So, if anybody monitors this bug and is still interested in using our tool, please try this patch (to be applied against 2.0.11), which will dereference all symlinks on copy. Greetings Marc -- ----------------------------------------------------------------------------- Marc Haber | "I don't trust Computers. They | Mailadresse im Header Mannheim, Germany | lose things." Winona Ryder | Fon: *49 621 72739834 Nordisch by Nature | How to make an American Quilt | Fax: *49 621 72739835
diff -urN /home/mh/dpatch-debian/dpatch-2.0.11/dpep/dpatch-edit-patch dpep/dpatch-edit-patch --- /home/mh/dpatch-debian/dpatch-2.0.11/dpep/dpatch-edit-patch 2005-01-16 13:47:33.000000000 +0000 +++ dpep/dpatch-edit-patch 2005-05-01 17:30:05.958856866 +0000 @@ -2,22 +2,42 @@ set -e -# Read in the user's configuration file, should it exist. -[[ -f ~/.dpatch.conf ]] && . ~/.dpatch.conf - # Populate configuration variables. First check for a pre-existing environment # variable which we support; that should override the configuration variable, -# which in turn overrides the default. CLI option parsing comes later, and +# which in turn overrides the default. Some configuration variables are only +# allowed in ~/.dpatch.conf, some only in debian/patches/00dpatch.conf. + +# CLI option parsing comes later, and # will blindly set it to the option given therein; CLI options trump all. -VERBOSITY=0 + +# Read in the package's configuration file, should it exist. +[[ -f debian/patches/00dpatch.conf ]] && . debian/patches/00dpatch.conf +unset conf_sourcedir +unset conf_outdir +unset conf_clean +DPEP_DEBIANONLY="${DPEP_DEBIANONLY:-${conf_debianonly:-}}" +unset conf_newdesc +unset conf_keeptemp +unset conf_tmpdir +unset conf_shell + +# Read in the user's configuration file, should it exist. +[[ -f ~/.dpatch.conf ]] && . ~/.dpatch.conf + DPEP_SOURCEDIR="${DPEP_SOURCEDIR:-${conf_sourcedir:-$(pwd)}}" DPEP_OUTDIR="${DPEP_OUTDIR:-${conf_outdir:-$DPEP_SOURCEDIR/debian/patches}}" +DPEP_CLEAN="${DPEP_CLEAN:-${conf_clean:-}}" +DPEP_ORIGTARGZ="${DPEP_ORIGTARGZ:-${conf_origtargz:-}}" +DPEP_GETORIGTARGZ="${DPEP_GETORIGTARGZ:-${conf_getorigtargz:-dpatch-get-origtargz}}" +DPEP_DESC="${DPEP_NEWDESC:-${conf_newdesc:-No description.}}" +DPEP_KEEPTEMP="${DPEP_KEEPTEMP:-${conf_keeptemp:-0}}" DPEP_TMPDIR="${DPEP_TMPDIR:-${conf_tmpdir:-${TMPDIR:-/tmp}}}" DPEP_SHELL="${DPEP_SHELL:-${conf_shell:-${SHELL:-$(getent passwd $(id -un) | cut -f7- -d:)}}}" -DPEP_KEEPTEMP="${DPEP_KEEPTEMP:-${conf_keeptemp:-0}}" -DPEP_DESC="${DPEP_NEWDESC:-${conf_newdesc:-No description.}}" + # We special-case $DPEP_ROOTCMD later, after dpep_parse_options() +VERBOSITY=0 + # Import functions dpep_usage(), dpep_template(), dpep_parse_options(), # dpep_message(), dpep_parse_longopt_value() . /usr/share/dpatch/dpatch-edit-patch.functions @@ -128,7 +148,7 @@ WORKDIR="$(TMPDIR=$DPEP_TMPDIR mktemp -d -p /tmp dpep-work.XXXXXX)" dpep_message debug1 "Working directory is $WORKDIR" -if [ -n "$DPEP_CLEANOK" ]; then +if [ -n "$DPEP_CLEAN" ]; then REFDIR="$DPEP_SOURCEDIR" dpep_message debug1 "Using source directory $DPEP_SOURCEDIR as reference directory" else @@ -137,29 +157,34 @@ if [ -n "$DPEP_DEBIANONLY" ]; then dpep_message norm "* debian/-only layout selected" if [ -z "$DPEP_ORIGTARGZ" ]; then - if dpep_find_origtargz; then + 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" + if ! eval "$DPEP_GETORIGTARGZ $REFPDIR"; then + dpep_message error "unable to obtain upstream tarball, $DPEP_GET_ORIGTARGZ failed" exit 1 fi + else + ORIGTARGZ="$(readlink -f "$DPEP_ORIGTARGZ")" fi - ORIGTARGZ="$(readlink -f "$DPEP_ORIGTARGZ")" cd "$REFPDIR" dpep_message norm "* unpacking $ORIGTARGZ" tar --extract --gzip --file $ORIGTARGZ # this heuristic is stolen from dpkg-source - if [ "$(find . -maxdepth 1 -mindepth 1 -print | wc -l)" -eq 1 ]; then - if [ "$(readlink -f "$(find . -maxdepth 1 -mindepth 1 -print)")" != "$(readlink -f "$(basename "$DPEP_SOURCEDIR")")" ]; then - mv "$(find . -maxdepth 1 -mindepth 1 -print)" "$(basename "$DPEP_SOURCEDIR")" + if [ "$(find . -type d -maxdepth 1 -mindepth 1 -print | wc -l)" -eq 1 ]; then + if [ "$(readlink -f "$(find . -type d -maxdepth 1 -mindepth 1 -print)")" != "$(readlink -f "$(basename "$DPEP_SOURCEDIR")")" ]; then + mv "$(find . -type d -maxdepth 1 -mindepth 1 -print)" "$(basename "$DPEP_SOURCEDIR")" fi else mkdir "$(basename "$DPEP_SOURCEDIR")" - find . -maxdepth 1 -mindepth 1 -name "$(basename "$DPEP_SOURCEDIR")" -prune -o -print0 | \ + find . -type d -maxdepth 1 -mindepth 1 -name "$(basename "$DPEP_SOURCEDIR")" -prune -o -print0 | \ xargs --null mv --target-directory="$(basename "$DPEP_SOURCEDIR")" fi fi cd "$REFPDIR" dpep_message norm "* Copying $DPEP_SOURCEDIR to reference directory." mkdir -p "$(basename "$DPEP_SOURCEDIR")" - tar --create --file - --directory "$DPEP_SOURCEDIR" . | \ + tar --create --file - --dereference --directory "$DPEP_SOURCEDIR" . | \ tar --extract --file - --directory "$(basename "$DPEP_SOURCEDIR")" REFDIR="$REFPDIR/$(basename $DPEP_SOURCEDIR)" fi @@ -200,7 +225,7 @@ dpep_message norm "* Copying reference directory $REFDIR to work directory." cd "$WORKDIR" -cp -a "$REFDIR" $(basename "$DPEP_SOURCEDIR") +cp --dereference --archive "$REFDIR" $(basename "$DPEP_SOURCEDIR") # Change to the workdirectory, apply the patch we're editing if we're # editing one, and launch an interactive shell. diff -urN /home/mh/dpatch-debian/dpatch-2.0.11/dpep/dpatch-edit-patch.1 dpep/dpatch-edit-patch.1 --- /home/mh/dpatch-debian/dpatch-2.0.11/dpep/dpatch-edit-patch.1 2005-01-16 13:47:33.000000000 +0000 +++ dpep/dpatch-edit-patch.1 2005-03-28 18:00:05.000000000 +0000 @@ -1,5 +1,5 @@ .\" Hey, EMACS: -*- nroff -*- -.TH DPATCH-EDIT-PATCH 1 "Jan 16 2005" DPATCH "dpatch users manual" +.TH DPATCH-EDIT-PATCH 1 "Jan 25 2005" DPATCH "dpatch users manual" .SH NAME dpatch\-edit\-patch \- maintain dpatch patches for a Debian source package @@ -85,17 +85,20 @@ parameter will be the description of the new patch. .SS OPTIONS For the following options, command\-line arguments take precedence over -environment variables, which take precedence over configuration variables. +environment variables, which take precedence over configuration +variables. Configuration variables are read from +\fIdebian/patches/00dpatch.conf\fR and \fI~/.dpatch.conf\fR. .TP .IB "\-s, \-\-sourcedir=" value Directory containing unpacked Debian source package. -Configuration variable \fBconf_sourcedir\fR, environment variable -\fBDPEP_SOURCEDIR\fR. Defaults to the current working directory. +Configuration variable \fBconf_sourcedir\fR (settable only in +\fI~/.dpatch.conf\fR), environment variable \fBDPEP_SOURCEDIR\fR. +Defaults to the current working directory. .TP .IB "\-o, \-\-outdir="value Directory where the updated or newly-created dpatch will be placed. -Configuration variable conf_outdir, environment variable \fBDPEP_OUTDIR\fR. -Defaults to +Configuration variable \fBconf_outdir\fR (\fI~/.dpatch.conf\fR), environment +variable \fBDPEP_OUTDIR\fR. Defaults to .I ./debian/patches/ .TP .IB "\-c, \-\-clean @@ -108,30 +111,31 @@ \fIdebian/rules\fR clean on the reference directory. If given, the current directory is cleaned and then taken as a reference directory. Use this option if your source package is pretty large and -no significant work is destroyed by cleaning. +no significant work is destroyed by cleaning. Configuration variable +\fBconf_clean\fR (\fI~/.dpatch.conf\fR), Environment variable \fBDPEP_CLEAN\fR. .TP -.IB "\-b, \-\-debianonly="value +.IB "\-b, \-\-debianonly[="path] Indicate to .B dpatch\-edit\-patch that the current work directory only contains a debian subdirectory and that an upstream tarball is to be unpacked in the reference -directory before copying the current work directory there. The value -is the path to the upstream tarball. If no value is given, -.B dpatch\-edit\-patch -will try to find the upstream tarball using one of the following -methods: - (1) in the parent directory of the current work directory, - (2) in the directory pointed to by \fBDPEP_ORIGTARDIR\fR, - (3) on the Internet, using the first URL found in debian/watch and - (4) on the Debian mirror configured into apt. - -If the file was downloaded from the Internet, it is placed in the -parent directory of the current work directory for subsequent -invocations. +directory before copying the current work directory there. The +optional argument is the path to the upstream tarball. If no value +is given, +.B dpatch\-edit\-patch +will use +.B dpatch\-get\-origtargz +or the hook script pointed to by \fBconf_getorigtargz\fR (\fI~/.dpatch.conf\fR) or +\fBDPEP_GETORIGTARGZ\fR to obtain the upstream tarball. The hook script should +be callable identically to +.B dpath\-get\-origtargz. +Configuration variables: \fBconf_debianonly\fR (\fIdebian/patches/00dpatch.conf\fR) +and \fBconf_origtargz\fR (\fI~/.dpatch.conf\fR), Environment Variables +\fBDPEP_DEBIANONLY\fR and \fBDPEP_ORIGTARGZ\fR. .TP .IB "\-r, \-\-rootcmd="value Command used to gain root privileges used to clean DPEP_SOURCEDIR. -Configuration variable conf_rootcmd, environment variable \fBDPEP_ROOTCMD\fR. +Configuration variable \fBconf_rootcmd\fR, environment variable \fBDPEP_ROOTCMD\fR. Defaults to \fBfakeroot\fR, if installed. If none of the above are specified, and fakeroot is not installed, .B dpatch\-edit\-patch @@ -140,14 +144,15 @@ .TP .IB "\-d, \-\-description="value Description used for a newly-created patch. -Configuration variable conf_newdesc, environment variable \fBDPEP_NEWDESC\fR, -defaults to +Configuration variable \fBconf_newdesc\fR (\fI~/.dpatch.conf\fR), environment variable +\fBDPEP_NEWDESC\fR, defaults to .I \(lqNo description.\(rq .TP .IB "\-k, \-\-keeptemp="value Boolean value, either \fI0\fR or \fI1\fR. -Configuration variable conf_keeptemp, environment variable \fBDPEP_KEEPTEMP\fR. -When set to \fI1\fR, temporary working tree is not deleted when +Configuration variable \fBconf_keeptemp\fR (\fI~/.dpatch.conf\fR), environment variable +\fBDPEP_KEEPTEMP\fR. When set to \fI1\fR, temporary working tree is not +deleted when .B dpatch\-edit\-patch is done. .TP @@ -155,12 +160,19 @@ Temporary directory within which .B dpatch\-edit\-patch will create the working source tree. -Configuration variable \fIconf_tmpdir\fR, environment variable +Configuration variable \fBconf_tmpdir\fR (\fI~/.dpatch.conf\fR), environment variable \fBDPEP_TMPDIR\fR. Should none of the above be set, .B dpatch\-edit\-patch will first attempt to use the environment variable \fBTMPDIR\fR, and will fall back to .IR /tmp . +.TP +.IB "\-l, \-\-shell="shell +Tell +.B dpatch\-edit\-patch +which shell to invoke. Configuration variable \fBconf_shell\fR +(\fI~/.dpatch.conf\fR), environment variable \fBDPEP_SHELL\fR, defaulting to +$SHELL and the user's default shell. .SH EXAMPLES .SS Create a new patch to be applied after an existing patch. @@ -270,10 +282,16 @@ .B dpatch\-edit\-patch combined with the output of \fBhostname -f\fR. +.SH FILES +.IR debian/patches/00dpatch.conf , +.IR ~/.dpatch.conf . + .SH SEE ALSO -Files in \fI/usr/share/doc/dpatch/\fP +Files in \fI/usr/share/doc/dpatch/\fR; \fIdpatch\-get\-origtargz\fR(1) .SH AUTHOR This manual page was written by David B Harris <[EMAIL PROTECTED]> +and modified in the course of development by Gergely Nagy <[EMAIL PROTECTED]> +and Marc Haber <[EMAIL PROTECTED]>. .\" arch-tag: 7c0644f7-93aa-4308-bf43-b50d415e282e diff -urN /home/mh/dpatch-debian/dpatch-2.0.11/dpep/dpatch-edit-patch.functions dpep/dpatch-edit-patch.functions --- /home/mh/dpatch-debian/dpatch-2.0.11/dpep/dpatch-edit-patch.functions 2005-01-16 13:47:33.000000000 +0000 +++ dpep/dpatch-edit-patch.functions 2005-03-28 18:00:05.000000000 +0000 @@ -1,7 +1,7 @@ #!/bin/bash # Functions for use by dpatch-edit-patch -# Currently include dpep_parse_longopt_value(), dpep_usage(), +# Currently include dpep_usage(), # dpep_template_apply(), dpep_template_hardcoded(), and dpep_message() DPEP_BASENAME="$(basename $0)" @@ -18,38 +18,32 @@ Commands: patch This is the default if no other command is specified. "patchname" is the patch you wish to create or edit, as - listed in debian/patches/00list. If the patch doesn't + listed in debian/patches/00list. If the patch does not exist, it will be created - and a second argument is allowed in this case, [basepatch]. It will be the last patched applied (according to 00list) to the working directory. Options: - -d|--description Description for the new patch, if applicable. - -o|--outdir Output directory for patches, defaults to - \$(pwd)/debian/patches/ - -s|--sourcedir Source directory, defaults to \$(pwd) - -t|--tmpdir Temporary directory, defaults to \$TMPDIR or /tmp/ - -b|--debianonly Unpack .orig.tar.gz before invoking the shell - -k|--keeptemp Keep working source tree after exit. - -c|--clean Clean the current directory. - -h|--help Print this message. + -d|--description=desc Description for the new patch, if applicable. + -o|--outdir=dir Output directory for patches, defaults to + \$(pwd)/debian/patches/ + -s|--sourcedir=dir Source directory, defaults to \$(pwd) + -t|--tmpdir=dir Temporary directory, defaults to \$TMPDIR or /tmp/ + -b|--debianonly[=path] Unpack .orig.tar.gz before invoking the shell + -k|--keeptemp Keep working source tree after exit. + -c|--clean Clean the current directory. + -l|--shell=shell Which shell should be invoked. + -h|--help Print this message. Examples: dpatch-edit-patch 20_upstream_fix2 19_upstream_fix1 dpatch-edit-patch patch 20_upstream_fix2 - dpatch-edit-patch --sourcedir ~/debian/dpatch-1.15 19 + dpatch-edit-patch --sourcedir=~/debian/dpatch-1.15 19 EOF } -dpep_parse_longopt_value() { -# This function retreives the value from a long option specified in the form -# of --longoption=foo. - dpep_message debug1 "Received long option: $*" - printf "%s" "$@" | cut -f2- -d= -} - dpep_template_apply() { if [ "$DPEP_OPTION_EXEC_TEMPLATE" = "1" ]; then chmod +x debian/patches/00template @@ -100,77 +94,39 @@ } dpep_parse_options() { - if [[ "$#" = "0" ]]; then + TEMP=$(getopt -o d:o:s:t:b::l:kch \ + --long description:,outdir:,sourcedir:,tmpdir:,debianonly::,shell:,keeptemp,clean,help \ + -n 'dpatch-edit-patch' -- "$@") + + + if [[ "$?" != "0" ]]; then dpep_usage - dpep_message error "No arguments given, aborting." + dpep_message error "Bad command line given, aborting." exit 1 fi + eval set -- "$TEMP" + + while true; do + case "$1" in + -s|--sourcedir) DPEP_SOURCEDIR="$2"; shift 2;; + -t|--tmpdir) DPEP_TMPDIR="$2"; shift 2;; + -b|--debianonly) DPEP_DEBIANONLY=1; DPEP_ORIGTARGZ="$2"; shift 2;; + -k|--keeptemp) DPEP_KEEPTEMP=1; shift;; + -c|--clean) DPEP_CLEAN=1; shift;; + -r|--rootcmd) DPEP_ROOTCMD="$2"; shift 2;; + -d|--description) DPEP_DESC="$2"; shift 2;; + -l|--shell)q DPEP_SHELL="$2"; shift 2;; + -o|--outdir) DPEP_OUTDIR="$2"; shift 2;; + -h|--help) dpep_usage; exit 0;; + --) shift; break;; + *) dpep_message error "Internal error parsing arguments"; exit 1;; + esac + done + DPEP_COMMAND="patch" for argument in "$@"; do - if [[ ! -z "$DPEP_DO_GETOPTION" ]]; then - eval "$DPEP_DO_GETOPTION'$argument'" - DPEP_DO_GETOPTION="" - shift - continue - fi - case "$argument" in - -s|--sourcedir) - DPEP_DO_GETOPTION="DPEP_SOURCEDIR=" - ;; - --sourcedir=*) - DPEP_SOURCEDIR="$(dpep_parse_longopt_value "$argument")" - ;; - -t|--tmpdir) - DPEP_DO_GETOPTION="DPEP_TMPDIR=" - ;; - --tmpdir=*) - DPEP_TMPDIR="$(dpep_parse_longopt_value "$argument")" - ;; - -b|--debianonly) - DPEP_DEBIANONLY=1 - DPEP_DO_GETOPTION="DPEP_ORIGTARGZ=" - ;; - --debianonly=*) - DPEP_DEBIANONLY=1 - DPEP_ORIGTARGZ="$(dpep_parse_longopt_value "$argument")" - ;; - -k|--keeptemp) - DPEP_KEEPTEMP=1 - ;; - --keeptemp=*) - DPEP_KEEPTEMP="$(dpep_parse_longopt_value "$argument")" - ;; - -c|--clean) - DPEP_CLEANOK=1 - ;; - -r|--rootcmd) - DPEP_DO_GETOPTION="DPEP_ROOTCMD=" - ;; - --rootcmd=*) - DPEP_ROOTCMD="$(dpep_parse_longopt_value "$argument")" - ;; - -d|--description) - DPEP_DO_GETOPTION="DPEP_DESC=" - ;; - --description=*) - DPEP_DESC="$(dpep_parse_longopt_value "$argument")" - ;; - -o|--outdir) - DPEP_DO_GETOPTION="DPEP_OUTDIR=" - ;; - --outdir=*) - DPEP_OUTDIR="$(dpep_parse_longopt_value "$argument")" - ;; - -h|--help) - dpep_usage - exit 0 - ;; - -*) - dpep_usage - dpep_message error "Unknown option: $argument" - exit 1 - ;; + case "$argument" in patch) DPEP_COMMAND="patch" ;; @@ -225,36 +181,4 @@ fi } -dpep_find_origtargz() { - 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" - if [ -f "../$ORIGTARGZ" ]; then - DPEP_ORIGTARGZ="$(readlink -f "../$ORIGTARGZ")" - elif [ -n "${DPEP_ORIGTARDIR}" ] && [ -f "${DPEP_ORIGTARDIR}/${ORIGTAGZ}" ]; then - DPEP_ORIGTARGZ="$(readlink -f "${DPEP_ORIGTARDIR}/${ORIGTAGZ}")" - elif [ -f "debian/watch" -a -x $(which curl) ]; then - if curl "$(< debian/watch sed -n "/^\\(http\\|ftp\\)/{s/^\\([^(]\\+\\)([^)]*)\\([^ ]*\\).*/\\1${UPSTREAMVERSION}\\2/;s/\\\\//g;p;q;}")" > ../$ORIGTARGZ; then - DPEP_ORIGTARGZ="$(readlink -f "../$ORIGTARGZ")" - return 0 - else - dpep_message error "cannot curl $ORIGTARGZ from debian/watch location" - fi - elif [ -x $(which apt-get) ]; then - if (cd .. && apt-get --tar-only source "$PACKAGENAME"); then - if [ -f "../$ORIGTARGZ" ]; then - DPEP_ORIGTARGZ="$(readlink -f "../$ORIGTARGZ")" - return 0 - else - dpep_message error "apt-get source $PACKAGENAME delivered wrong versin of $ORIGTARGZ" - fi - else - dpep_message error "apt-get source $PACKAGENAME failed" - fi - else - dpep_message error "unable to obtain $ORIGTARGZ from anywhere" - fi - return 1 -} - # arch-tag: 53a12b53-0904-4f02-90e4-507212625e01