Move add-patch, edit-patch, and what-patch from ubuntu-dev-tools into

devscripts (Closes: #568481).
This commit is contained in:
Benjamin Drung 2011-05-21 17:53:16 +02:00
parent 58334ba46d
commit 7a104714c4
11 changed files with 8 additions and 521 deletions

View File

@ -1 +0,0 @@
edit-patch

7
debian/changelog vendored
View File

@ -1,3 +1,10 @@
ubuntu-dev-tools (0.124) UNRELEASED; urgency=low
* Move add-patch, edit-patch, and what-patch from ubuntu-dev-tools into
devscripts (Closes: #568481).
-- Benjamin Drung <bdrung@debian.org> Sat, 21 May 2011 17:50:52 +0200
ubuntu-dev-tools (0.123) unstable; urgency=low
[ Stefano Rivera ]

4
debian/control vendored
View File

@ -30,7 +30,7 @@ Package: ubuntu-dev-tools
Architecture: all
Depends: binutils,
dctrl-tools,
devscripts,
devscripts (>= 2.10.74~),
diffstat,
dpkg-dev,
lsb-release,
@ -119,6 +119,4 @@ Description: useful tools for Ubuntu developers
- ubuntu-distro-info - provides information about Ubuntu's distributions.
- ubuntu-iso - output information of an Ubuntu ISO image.
- update-maintainer - script to update maintainer field in ubuntu packages.
- what-patch - determines what patch system, if any, a source package is
using.
- wrap-and-sort - wrap long lines and sort items in packaging files.

5
debian/copyright vendored
View File

@ -87,7 +87,6 @@ License: GPL-2+
Files: ack-sync
doc/bitesize.1
doc/edit-patch.1
doc/get-branches.1
doc/grab-attachments.1
doc/grab-merge.1
@ -98,7 +97,6 @@ Files: ack-sync
doc/setup-packaging-environment.1
doc/syncpackage.1
bitesize
edit-patch
get-branches
grab-attachments
grab-merge
@ -137,7 +135,6 @@ Files: dch-repeat
doc/pull-lp-source.1
doc/pull-revu-source.1
doc/ubuntu-build.1
doc/what-patch.1
get-build-deps
grep-merges
lp-list-bugs
@ -148,12 +145,10 @@ Files: dch-repeat
ubuntutools/lp/libsupport.py
ubuntutools/lp/lpapicache.py
ubuntutools/misc.py
what-patch
Copyright: 2007-2010, Canonical Ltd.
2008-2009, Iain Lane <iain@orangesquash.org.uk>
2006, John Dong <jdong@ubuntu.com>
2009, Jonathan Davies <jpds@ubuntu.com>
2007-2008, Kees Cook <kees@ubuntu.com>
2009, Markus Korn <thekorn@gmx.de>
2009-2010, Michael Bienia <geser@ubuntu.com>
2009, Nathan Handler <nhandler@ubuntu.com>

2
debian/links vendored
View File

@ -1,4 +1,2 @@
/usr/bin/edit-patch /usr/bin/add-patch
/usr/bin/pbuilder-dist /usr/bin/cowbuilder-dist
/usr/share/man/man1/edit-patch.1.gz /usr/share/man/man1/add-patch.1.gz
/usr/share/man/man1/pbuilder-dist.1.gz /usr/share/man/man1/cowbuilder-dist.1.gz

View File

@ -1,43 +0,0 @@
.TH EDIT-PATCH "1" "June 2010" "ubuntu-dev-tools"
.SH NAME
\fBedit-patch\fR, \fBadd-patch\fR \- tool for preparing patches for Debian
source packages
.SH SYNOPSIS
\fBedit-patch\fR <path to patch>
\fBadd-patch\fR <path to patch>
.SH DESCRIPTION
\fBedit-patch\fR is a wrapper script around the quilt, cdbs, and dpatch patch
systems. It simplifies the process of preparing and editing patches to Debian
source packages and allows the user to not have to be concerned with which patch
system is in use.
Run from inside the root directory of the source package, \fBedit-patch\fR can
be used to edit existing patches located in /debian/patches.
It can also be used to incorporate new patches.
If pointed at a patch not already present, it will copy the patch to
/debian/patches in the correct format for the patch system in use.
Next, the patch is applied and a subshell is opened in order to edit the patch.
Typing "exit" or pressing Ctrl-d will close the subshell and launch an editor
to record the debian/changelog entry.
\fBedit-patch\fR is integrated with the bzr and git version control systems.
The patch will be automatically added to the tree, and the debian/changelog
entry will be used as the commit message.
If no patch system is present, the patch is applied inline,
and a copy is stored in debian/patches-applied.
\fBadd-patch\fR is the non-interactive version of \fBedit-patch\fR.
The patch will be incorporated but no editor or subshell will be
spawned.
.SH AUTHORS
\fBedit-patch\fR was written by Daniel Holbach <daniel.holbach@canonical.com>,
Michael Vogt <michael.vogt@canonical.com>, and David Futcher <bobbo@ubuntu.com>.
This manual page was written by Andrew Starr-Bochicchio <a.starr.b@gmail.com>.
.PP
Both are released under the terms of the GNU General Public License, version 3.

View File

@ -1,40 +0,0 @@
.TH WHAT\-PATCH "1" "10 August 2008" "ubuntu-dev-tools"
.SH NAME
what\-patch \- detects which patch system a Debian package uses
.SH SYNOPSIS
.B what\-patch [options]
.SH DESCRIPTION
\fBwhat\-patch\fR examines the debian/rules file to determine which patch
system the Debian package is using.
.PP
\fBwhat\-patch\fR should be run from the root directory of the Debian source
package.
.SH OPTIONS
Listed below are the command line options for what\-patch:
.TP
.B \-h or \-\-help
Display a help message and exit.
.TP
.B \-v
Enable verbose mode.
This will include the listing of any files modified outside or the debian/
directory and report any additional details about the patch system if
available.
.SH AUTHORS
\fBwhat\-patch\fR was written by Kees Cook <kees@ubuntu.com>,
Siegfried-A. Gevatter <rainct@ubuntu.com>, and Daniel Hahler
<ubuntu@thequod.de>, among others.
This manual page was written by Jonathan Patrick Davies <jpds@ubuntu.com>.
.PP
Both are released under the GNU General Public License, version 2.
.SH SEE ALSO
The Ubuntu MOTU team has some documentation about patch systems at the Ubuntu
wiki: \fBhttps://wiki.ubuntu.com/PackagingGuide/PatchSystems\fR
.PP
.B cdbs\-edit\-patch(1), dbs\-edit\-patch(1), dpatch\-edit\-patch(1)

View File

@ -1,303 +0,0 @@
#!/bin/sh
#
# Copyright (C) 2009 Canonical
#
# Authors:
# Michael Vogt
# Daniel Holbach
# David Futcher
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; version 3.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
set -e
PATCHSYSTEM="unknown"
PATCHNAME="no-patch-name"
PREFIX="debian/patches"
PATCH_DESC=$(cat<<EOF
## Description: add some description\
\n## Origin/Author: add some origin or author\
\n## Bug: bug URL
EOF
)
fatal_error() {
echo "$@" >&2
exit 1
}
# check if the given binary is installed and give a error if not
# arg1: binary
# arg2: error message
require_installed() {
if ! which "$1" >/dev/null; then
fatal_error "$2"
fi
}
ensure_debian_dir() {
if [ ! -e debian/control ] || [ ! -e debian/rules ]; then
fatal_error "Can not find debian/rules or debian/control. Not in a debian dir?"
fi
}
detect_patchsystem() {
CDBS_PATCHSYS="^[^#]*simple-patchsys.mk"
if grep -q "$CDBS_PATCHSYS" debian/rules; then
PATCHSYSTEM="cdbs"
require_installed cdbs-edit-patch "no cdbs-edit-patch found, is 'cdbs' installed?"
elif [ -e debian/patches/00list ]; then
PATCHSYSTEM="dpatch"
require_installed dpatch-edit-patch "no dpatch-edit-patch found, is 'dpatch' installed?"
elif [ -e debian/patches/series -o \
"$(cat debian/source/format 2> /dev/null)" = "3.0 (quilt)" ]; then
PATCHSYSTEM="quilt"
require_installed quilt "no quilt found, is 'quilt' installed?"
else
PATCHSYSTEM="none"
PREFIX="debian/applied-patches"
fi
}
# remove full path if given
normalize_patch_path() {
PATCHNAME=${PATCHNAME##*/}
echo "Normalizing patch path to $PATCHNAME"
}
# ensure (for new patches) that:
# - dpatch ends with .dpatch
# - cdbs/quilt with .patch
normalize_patch_extension() {
# check if we have a patch already
if [ -e $PREFIX/$PATCHNAME ]; then
echo "Patch $PATCHNAME exists, not normalizing"
return
fi
# normalize name for new patches
PATCHNAME=${PATCHNAME%.*}
if [ "$PATCHSYSTEM" = "quilt" ]; then
PATCHNAME="${PATCHNAME}.patch"
elif [ "$PATCHSYSTEM" = "cdbs" ]; then
PATCHNAME="${PATCHNAME}.patch"
elif [ "$PATCHSYSTEM" = "dpatch" ]; then
PATCHNAME="${PATCHNAME}.dpatch"
elif [ "$PATCHSYSTEM" = "none" ]; then
PATCHNAME="${PATCHNAME}.patch"
fi
echo "Normalizing patch name to $PATCHNAME"
}
edit_patch_cdbs() {
cdbs-edit-patch $PATCHNAME
vcs_add debian/patches/$1
}
edit_patch_dpatch() {
dpatch-edit-patch $PATCHNAME
# add if needed
if ! grep -q $1 $PREFIX/00list; then
echo "$1" >> $PREFIX/00list
fi
vcs_add $PREFIX/00list $PREFIX/$1
}
edit_patch_quilt() {
export QUILT_PATCHES=debian/patches
if [ -e $PREFIX/$1 ]; then
# if its a existing patch and we are at the end of the stack,
# go back at the beginning
if ! quilt unapplied; then
quilt pop -a
fi
quilt push $1
else
# if its a new patch make sure we are at the end of the stack
if quilt unapplied >/dev/null; then
quilt push -a
fi
quilt new $1
fi
# use a sub-shell
quilt shell
quilt refresh
quilt pop -a
vcs_add $PREFIX/$1 $PREFIX/series
}
edit_patch_none() {
# Dummy edit-patch function, just display a warning message
echo "No patchsystem could be found so the patch was applied inline and a copy \
stored in debian/patches-applied. Please remember to mention this in your changelog."
}
add_patch_quilt() {
# $1 is the original patchfile, $2 the normalized name
# FIXME: use quilt import instead?
cp $1 $PREFIX/$2
if ! grep -q $2 $PREFIX/series; then
echo "$2" >> $PREFIX/series
fi
vcs_add $PREFIX/$2 $PREFIX/series
}
add_patch_cdbs() {
# $1 is the original patchfile, $2 the normalized name
cp $1 $PREFIX/$2
vcs_add $PREFIX/$2
}
add_patch_dpatch() {
# $1 is the original patchfile, $2 the normalized name
cp $1 $PREFIX
if ! grep -q $2 $PREFIX/00list; then
echo "$2" >> $PREFIX/00list
fi
vcs_add $PREFIX/$2 $PREFIX/00list
}
add_patch_none() {
# $1 is the original patchfile, $2 the normalized name
cp $1 $PREFIX/$2
vcs_add $PREFIX/$2
}
vcs_add() {
if [ -d .bzr ]; then
bzr add $@
elif [ -d .git ];then
git add $@
else
echo "Remember to add $@ to a VCS if you use one"
fi
}
vcs_commit() {
# check if debcommit is happy
if ! debcommit --noact 2>/dev/null; then
return
fi
# commit (if the user confirms)
debcommit --confirm
}
add_changelog() {
S="$PREFIX/$1: [DESCRIBE CHANGES HERE]"
if head -n1 debian/changelog|grep UNRELEASED; then
dch --append "$S"
else
dch --increment "$S"
fi
# let the user edit it
dch --edit
}
add_patch_tagging() {
# check if we have a descripton already
if grep "## Description:" $PREFIX/$1; then
return
fi
# if not, add one
RANGE=1,1
# make sure we keep the first line (for dpatch)
if head -n1 $PREFIX/$1|grep -q '^#'; then
RANGE=2,2
fi
sed -i ${RANGE}i"$PATCH_DESC" $PREFIX/$1
}
detect_patch_location() {
# Checks whether the specified patch exists in debian/patches or on the filesystem
FILENAME=${PATCHNAME##*/}
if [ -f "$PREFIX/$FILENAME" ]; then
PATCHTYPE="debian"
elif [ -f "$PATCHNAME" ]; then
PATCHTYPE="file"
PATCHORIG="$PATCHNAME"
else
if [ "$PATCHSYSTEM" = "none" ]; then
fatal_error "No patchsystem detected, cannot create new patch (no dpatch/quilt/cdbs?)"
else
PATCHTYPE="new"
fi
fi
}
handle_file_patch() {
if [ "$PATCHTYPE" = "file" ]; then
[ -f "$PATCHORIG" ] || fatal_error "No patch detected"
if [ "$PATCHSYSTEM" = "none" ]; then
# If we're supplied a file and there is no patchsys we apply it directly
# and store it in debian/applied patches
[ -d $PREFIX ] || mkdir $PREFIX
patch -p0 < "$PATCHORIG"
cp "$PATCHORIG" "$PREFIX/$PATCHNAME"
else
# Patch type is file but there is a patchsys present, so we add it
# correctly
cp "$PATCHORIG" "$PREFIX/$PATCHNAME"
if [ "$PATCHSYSTEM" = "quilt" ]; then
echo "$PATCHNAME" >> $PREFIX/series
elif [ "$PATCHSYSTEM" = "dpatch" ]; then
echo "$PATCHNAME" >> $PREFIX/00list
# Add the dpatch header to files that don't already have it
if ! grep -q "@DPATCH@" "$PREFIX/$PATCHNAME"; then
sed -i '1i#! /bin/sh /usr/share/dpatch/dpatch-run\n@DPATCH@' $PREFIX/$PATCHNAME
fi
fi
echo "Copying and applying new patch. You can now edit the patch or exit the subshell to save."
fi
fi
}
# TODO:
# - edit-patch --remove implementieren
# - dbs patch system
main() {
# parse args
if [ $# -ne 1 ]; then
fatal_error "Need exactly one patch name"
fi
PATCHNAME="$1"
# do the work
ensure_debian_dir
detect_patchsystem
detect_patch_location
normalize_patch_path
normalize_patch_extension
handle_file_patch
if [ "$(basename $0)" = "edit-patch" ]; then
edit_patch_$PATCHSYSTEM $PATCHNAME
elif [ "$(basename $0)" = "add-patch" ]; then
add_patch_$PATCHSYSTEM $1 $PATCHNAME
fi
add_patch_tagging $PATCHNAME
add_changelog $PATCHNAME
vcs_commit
}
main $@

View File

@ -21,7 +21,6 @@ scripts = ['404main',
'dch-repeat',
'debian-distro-info',
'dgetlp',
'edit-patch',
'get-branches',
'get-build-deps',
'grab-attachments',
@ -54,7 +53,6 @@ scripts = ['404main',
'ubuntu-distro-info',
'ubuntu-iso',
'update-maintainer',
'what-patch',
'wrap-and-sort',
]

View File

@ -27,7 +27,6 @@ from ubuntutools.test import unittest
BLACKLIST = {
'check-mir': 'No Help',
'check-symbols': 'No Help',
'edit-patch': 'No Help',
'get-build-deps': 'No Help, runs sudo',
'grep-merges': 'No Help',
'lp-project-upload': 'Returns non-zero after help. '

View File

@ -1,121 +0,0 @@
#!/bin/bash
#
# Copyright 2006-2008 (C) Kees Cook <kees@ubuntu.com>
# Modified by Siegfried-A. Gevatter <rainct@ubuntu.com>
# Modified by Daniel Hahler <ubuntu@thequod.de>
#
# ##################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# See file /usr/share/common-licenses/GPL for more details.
#
# ##################################################################
#
# By default only the name of the patch system is printed. Verbose mode can be
# enabled with -v.
if [ "$1" = "-h" ] || [ "$1" = "--help" ]
then
cat <<EOM
Usage: $0 [-v]
Run this inside the source directory of a Debian package and it will detect
the patch system that it uses.
-v: Enable verbose mode:
- Print a list of all those files outside the debian/ directory that have
been modified (if any).
- Report additional details about patch systems, if available.
EOM
exit 0
fi
while [ ! -r debian/rules ];
do
if [ "$PWD" = "/" ]; then
echo "Can't find debian/rules."
exit 1
fi
cd ..
done
VERBOSE=0
if [ "$1" = "-v" ]
then
VERBOSE=1
fi
if [ "$VERBOSE" -gt 0 ]; then
files=`lsdiff -z ../$(dpkg-parsechangelog | grep ^Source: | sed -e "s/^Source: //")_$(dpkg-parsechangelog | grep ^Version: | sed -e "s/^Version: //").diff.gz 2>/dev/null | grep -v 'debian/'`
if [ -n "$files" ]
then
echo "Following files were modified outside of the debian/ directory:"
echo "$files"
echo "--------------------"
echo
echo -n "Patch System: "
fi
fi
if fgrep -q quilt debian/source/format 2>/dev/null; then
echo "quilt"
exit 0
fi
# Do not change the output of existing checks by default, as there are build
# tools that rely on the exisitng output. If changes in reporting is needed,
# please check the "VERBOSE" flag (see below for examples). Feel free
# to add new patchsystem detection and reporting.
for filename in $(echo "debian/rules"; grep ^include debian/rules | fgrep -v '$(' | awk '{print $2}')
do
fgrep patchsys.mk "$filename" | grep -q -v "^#" && {
if [ "$VERBOSE" -eq 0 ]; then
echo "cdbs"; exit 0;
else
echo "cdbs (patchsys.mk: see 'cdbs-edit-patch')"; exit 0;
fi
}
fgrep quilt "$filename" | grep -q -v "^#" && { echo "quilt"; exit 0; }
fgrep dbs-build.mk "$filename" | grep -q -v "^#" && {
if [ "$VERBOSE" -eq 0 ]; then
echo "dbs"; exit 0;
else
echo "dbs (see 'dbs-edit-patch')"; exit 0;
fi
}
fgrep dpatch "$filename" | grep -q -v "^#" && {
if [ "$VERBOSE" -eq 0 ]; then
echo "dpatch"; exit 0;
else
echo "dpatch (see 'patch-edit-patch')"; exit 0;
fi
}
fgrep '*.diff' "$filename" | grep -q -v "^#" && {
if [ "$VERBOSE" -eq 0 ]; then
echo "diff splash"; exit 0;
else
echo "diff splash (check debian/rules)"; exit 0;
fi
}
done
[ -d debian/patches ] || {
if [ "$VERBOSE" -eq 0 ]; then
echo "patchless?"; exit 0;
else
echo "patchless? (did not find debian/patches/)"; exit 0;
fi
}
if [ "$VERBOSE" -eq 0 ]; then
echo "unknown patch system"
else
echo "unknown patch system (see debian/patches/ and debian/rules)"
fi