File: dpatch-convert-diffgz

package info (click to toggle)
dpatch 2.0.38+nmu1~bpo9+1
  • links: PTS, VCS
  • area: main
  • in suites: stretch-backports
  • size: 676 kB
  • sloc: sh: 1,013; makefile: 225; awk: 57; perl: 17
file content (79 lines) | stat: -rwxr-xr-x 1,963 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#! /bin/sh
## try and get a dpatch file from Debian diff.gz file.
## Copyright 2003 Junichi Uekawa.
## licensed under GPL version 2.

# before running this code, you need to have prepared your debian/rules
# as described in dpatch manual, and you need to have an empty
# debian/patches/00list
# 
# You can also use this script to add new patches.
#
# enjoy,   
#   15 Jan 2003, Junichi Uekawa

set -e

if [ ! -e /usr/bin/filterdiff ]; then
	echo "dpatch-convert-diffgz: filterdiff not found, aborting!" >&2
	echo " (consider installing patchutils)" >&2
	exit 1
fi

while ! test -d ./debian -o "$(pwd)" = "/" ; do
	cd ..;
done

if [ $# -eq 2 ]; then
	DPCD_PATCHNO="$1"
	DPCD_PATCHNAME="$(basename $2 .dpatch)"
elif [ $# -eq 1 ]; then
	DPCD_PATCHNO=$(echo "$1" | cut -d "_" -f1)
	DPCD_PATCHNAME=$(basename $(echo "$1" | cut -d "_" -f2-) .dpatch)
fi
DPCD_PATCHDIR=debian/patches

if [ -z "$DPCD_PATCHNAME" ] || [ "$DPCD_PATCHNAME" = ".dpatch"; then
	cat <<EOF
Usage:

dpatch-convert-diffgz patchno patchname

OR

dpatch-convert-diffgz patchno_patchname

like: 
dpatch-convert-diffgz 01 debian-patch

OR

dpatch-convert-diffgz 01_debian-patch
EOF
    exit 1
fi

if [ ! -d "$DPCD_PATCHDIR" ]; then
	mkdir -p "$DPCD_PATCHDIR"
fi

fakeroot debian/rules unpatch
dpkg-buildpackage -S -us -uc -rfakeroot

DPCD_SOURCE=$(dpkg-parsechangelog | sed -n 's/^Source: //p')
DPCD_VERSION=$(dpkg-parsechangelog | sed -n 's/^Version: \(.*:\)\?//p')

echo
echo "Building ${DPCD_PATCHDIR}/${DPCD_PATCHNO}_${DPCD_PATCHNAME}..."
echo

zcat ../"${DPCD_SOURCE}_${DPCD_VERSION}.diff.gz" | filterdiff -x '*/debian/*' \
  | dpatch patch-template --prepend ${DPCD_PATCHNO}_${DPCD_PATCHNAME} \
	"New patch generated from ${DPCD_SOURCE} ${DPCD_VERSION} diff.gz" \
	| tee "${DPCD_PATCHDIR}/${DPCD_PATCHNO}_${DPCD_PATCHNAME}.dpatch" \
	| patch -p1 -R

echo "${DPCD_PATCHNO}_${DPCD_PATCHNAME}" >> ${DPCD_PATCHDIR}/00list
fakeroot debian/rules patch

# arch-tag: 5d7cf9b9-459c-4a5e-8a62-6bc1efa16e21