-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcreate-debdiff
More file actions
executable file
·96 lines (82 loc) · 2.11 KB
/
create-debdiff
File metadata and controls
executable file
·96 lines (82 loc) · 2.11 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/bash -eu
#
# Create a debdiff file
#
function usage()
{
cat <<EOF
Usage: $(basename "${0}") [-h] [-p] [PREVIOUS_VERSION|OFFSET]
Create a debdiff file.
Positional argument:
PREVIOUS_VERSION Previous source package version.
OFFSET debian/changelog package entry offset.
-1 is the previous entry.
Optional arguments:
-h, --help Show this help text and exit.
-p, --plain Generate a plain debdiff without a custom header.
EOF
}
prev_version_offset=
plain=0
while [ ${#} -gt 0 ] ; do
case "${1}" in
-h|--help)
usage
exit
;;
-p|--plain)
plain=1
;;
*)
if [ -n "${prev_version_offset}" ] ; then
echo "Invalid argument: ${1}" >&2
exit 2
fi
prev_version_offset=${1}
;;
esac
shift
done
curr_name=$(dpkg-parsechangelog -S Source)
curr_version=$(dpkg-parsechangelog -S Version)
curr_version=${curr_version#*:}
curr_base=../${curr_name}_${curr_version}
case "${prev_version_offset}" in
"")
prev_name=$(dpkg-parsechangelog -S Source -o 1 -c 1)
prev_version=$(dpkg-parsechangelog -S Version -o 1 -c 1)
;;
-*)
offset=${prev_version_offset#-}
prev_name=$(dpkg-parsechangelog -S Source -o "${offset}" -c 1)
prev_version=$(dpkg-parsechangelog -S Version -o "${offset}" -c 1)
;;
*)
prev_name=${curr_name}
prev_version=${prev_version_offset}
;;
esac
prev_version=${prev_version#*:}
prev_base=../${prev_name}_${prev_version}
echo "Current base: ${curr_base}"
echo "Previous base: ${prev_base}"
if [ -e "${prev_base}".dsc ] && [ -e "${curr_base}".dsc ] ; then
prev=${prev_base}.dsc
curr=${curr_base}.dsc
elif [ -e "${prev_base}"_source.changes ] && [ -e "${curr_base}"_source.changes ] ; then
prev=${prev_base}_source.changes
curr=${curr_base}_source.changes
else
echo "Current and/or previous .dsc or .changes files not found" >&2
exit 1
fi
{
if [ ${plain} -eq 0 ] ; then
# Add a 'header' that identifies the previous and current dsc
echo "# HEADER Current: ${curr##*/}"
echo "# HEADER Previous: ${prev##*/}"
fi
# Generate the debdiff
debdiff "${prev}" "${curr}"
} > "${curr_base}".debdiff || true
echo "Created ${curr_base}".debdiff