-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdiff-rpi-source
More file actions
executable file
·88 lines (78 loc) · 2.07 KB
/
diff-rpi-source
File metadata and controls
executable file
·88 lines (78 loc) · 2.07 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
#!/bin/bash -eu
#
# Diff the current branch against the relevant raspberrypi branch
#
function usage()
{
cat <<EOF
Usage: diff-rpi-source [-h] [-v] [TAG]
Diff the current branch against the relevant raspberrypi branch.
Postional arguments:
TAG Diff the current branch against tag TAG. If not provided,
determines the tag automatically.
Optional arguments:
-h, --help Show this help text and exit.
-v, --verbose Verbose output.
EOF
}
verbose=0
rpi_tag=
while [ ${#} -gt 0 ] ; do
case "${1}" in
-h|--help)
usage
exit
;;
-v|--verbose)
verbose=1
;;
*)
if [ -z "${rpi_tag}" ] ; then
rpi_tag=${1}
else
echo "Invalid argument: ${1}" >&2
exit 2
fi
;;
esac
shift
done
# Determine the 'start' of the derivative
master_version=$(dpkg-parsechangelog -l debian.master/changelog -S Version)
master_source=$(dpkg-parsechangelog -l debian.master/changelog -S Source)
master_source=${master_source#linux}
master_tag=Ubuntu${master_source}-${master_version}
tmp=$(git log --oneline -2000 | \
grep -m1 -P "^[0-9a-f]{12} UBUNTU: ${master_tag}$" || true)
master_commit=${tmp%% *}
if [ -z "${master_commit}" ] ; then
echo "Failed to determine Ubuntu master commit: ${master_tag}" >&2
exit 1
fi
# Determine the last raspberrypi update tag
if [ -z "${rpi_tag}" ] ; then
tmp=$(git log --oneline -1000 | \
grep -m1 -P "^[0-9a-f]{12} UBUNTU:.* Update to upstream raspberrypi" || \
true)
rpi_tag=${tmp#* upstream raspberrypi }
rpi_tag=${rpi_tag%\)*}
rpi_tag=${rpi_tag/ \(/-}
if [ -z "${rpi_tag}" ] ; then
echo "Failed to determine raspberrypi update tag" >&2
exit 1
fi
fi
if ! git rev-parse "${rpi_tag}" >/dev/null 2>&1 ; then
echo "No such tag: ${rpi_tag}" >&2
exit 1
fi
# Collect the list of modified files
while IFS= read -r name ; do
git --no-pager diff --color=always "${rpi_tag}" -- "${name}" > .tmp || true
if [ ${verbose} -eq 1 ] || [ -s .tmp ] ; then
echo
echo -e "\e[93m${name}\e[0m"
cat .tmp
fi
done < <(git log --format= --name-only "${master_commit}".. | \
grep -vP '^(debian|ubuntu|\.)' | sort -u)