blob: e43e3c639d28966606dacc4769e06b1840c4487a (
plain)
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
97
98
99
100
101
102
|
#!/bin/bash
# -*- coding: utf-8 -*-
# Copyright (C) 2022 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
set -e
usage()
{
printf "Usage:\n"
printf "%s build-from <base-commit-ref> " "$0"
printf "# Build all commits since <base-commit-ref>\n" "%0"
printf "%s continue " "$0"
printf "# Continue rebasing and building commits\n" "%0"
exit 64; # EX_USAGE from sysexits.h
}
print_header()
{
set +e
message="$1"
len=$(expr $(echo -n ${message} | wc -c) + 2)
nr_chars=$(expr $(expr 80 - ${len}) / 2)
i="${nr_chars}"
while [ ${i} -gt 0 ] ; do
echo -n "#"
i="$(expr ${i} - 1)"
done
echo -n " ${message} "
i="${nr_chars}"
while [ ${i} -gt 0 ] ; do
echo -n "#"
i="$(expr ${i} - 1)"
done
echo
set -e
}
build_and_git_rebase_continue()
{
total_commits="$1"
total_targets="$(./vendor/replicant/build.sh targets | wc -l)"
parallel_tasks=$(echo "$(grep 'processor' /proc/cpuinfo | wc -l ) + 1" | bc)
local_modules="$(grep \
"^LOCAL_MODULE := " \
hardware/replicant/libsamsung-ipc/Android.mk | \
awk '{print $3}' | sort -u)"
source build/envsetup.sh
# Currently all the Replicant versions supported by libsamsung-ipc
# have an aosp_arm-eng target. Using aosp_arm-eng also ensures
# that TARGET_DEVICE isn't set by the device repository. This also
# leaves us more freedom in libsamsung-ipc as we could for
# instance decide to not build unused code based on TARGET_DEVICE.
lunch aosp_arm-eng
commit_nr=1
while true ; do
print_header "[ commit ${commit_nr} of ${total_commits} ]"
make "-j${parallel_tasks}" ${local_modules}
git -C hardware/replicant/libsamsung-ipc rebase --continue || break
commit_nr="$(expr ${commit_nr} + 1)"
done
}
if [ $# -eq 2 ] && [ "$1" == "build-from" ] ; then
base_commit="$2"
nr_commits="$(git -C hardware/replicant/libsamsung-ipc log --oneline \
${base_commit}~1..HEAD --oneline | wc -l)"
GIT_EDITOR="sed 's#^pick #edit #g' -i " \
git -C hardware/replicant/libsamsung-ipc \
rebase -i "${base_commit}"
build_and_git_rebase_continue "${nr_commits}"
elif [ $# -eq 1 ] && [ "$1" == "continue" ] ; then
nr_commits="$(git -C hardware/replicant/libsamsung-ipc \
log --oneline REBASE_HEAD~1..ORIG_HEAD --oneline | wc -l)"
build_and_git_rebase_continue "${nr_commits}"
else
usage
fi
|