forked from nathanchance/env
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupstream
More file actions
executable file
·133 lines (95 loc) · 3.54 KB
/
upstream
File metadata and controls
executable file
·133 lines (95 loc) · 3.54 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/usr/bin/env bash
#
# Pull in linux-stable updates to a kernel tree
#
# Copyright (C) 2017 Nathan Chancellor
#
# 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.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
# SOURCE OUR UNIVERSAL FUNCTIONS SCRIPT AND MAC CHECK
source common
# GATHER PARAMETERS
while [[ $# -ge 1 ]]; do
case "${1}" in
# MERGE VERSION INSTEAD OF CHERRY-PICK
"-m"|"--merge")
MERGE=true ;;
# PICK FROM THE RC TREE
"-rc"|"--release-candidate")
RC=true ;;
# ONLY UPDATE THE REMOTES
"-u"|"--update-only")
UPDATE_ONLY=true ;;
# SPECIFY THE VERSION TO MERGE/CHERRY-PICK TO
"-v"|"--version")
shift && enforce_value $@
NEW_VERSION=${1} ;;
*)
report_error "Invalid parameter!" ;;
esac
shift
done
# VERIFY REMOTE FUNCTION
function verify_remote() {
add_remote ${1} ${KERNEL_FOLDER}/mirrors/${1}
git fetch ${1}
[[ $? -ne 0 ]] && report_error "Remote ${1} update failed!" \
|| echo "Remote ${1} updated successfully!"
}
# GENERATE VERSIONS
function gen_versions() {
[[ -n ${UPDATE_ONLY} ]] && exit
CUR_VERSION=$(make kernelversion)
MAJOR_VERSION=$(echo ${CUR_VERSION} | cut -f 1,2 -d .)
if [[ -z ${NEW_VERSION} ]]; then
SUBLEVEL=$(($(echo ${CUR_VERSION} | cut -d . -f 3) + 1))
NEW_VERSION=${MAJOR_VERSION}.${SUBLEVEL}
fi
# SET RANGE BASED ON IF WE ARE PICKING A RELEASE OR RC BUILD
[[ -z ${RC} ]] && RANGE=v${CUR_VERSION}..v${NEW_VERSION} \
|| RANGE=v${CUR_VERSION}..stable-rc/linux-${MAJOR_VERSION}.y
# NUMBER OF COMMITS DIFFERENT
ND=$(git rev-list --count ${RANGE} 2> /dev/null)
[[ -z ${ND} || ${ND} -eq 0 ]] && report_error "There are no commits to pick/merge!"
export NEW_VERSION RANGE ND
}
# MERGE FUNCTION
function merge() {
header "MERGING ${NEW_VERSION}"
git merge v${NEW_VERSION} -m "Merge ${NEW_VERSION} into $(git rev-parse --abbrev-ref HEAD)
Changes in ${NEW_VERSION}: (${ND} commits)
$(git log --reverse --format=" %s" ${RANGE})
Signed-off-by: $(git config --get user.name) <$(git config --get user.email)>"
[[ $? -ne 0 ]] && report_error "Merge needs manual intervention!
Resolve conflicts then run git merge --continue!" || header "${NEW_VERSION} MERGED CLEANLY!" ${GRN}
}
# CHERRY-PICK FUNCTION
function cherry_pick() {
header "CHERRY-PICKING ${NEW_VERSION}"
git cherry-pick ${RANGE}
[[ $? -ne 0 ]] && report_error "Cherry-pick needs manual intervention! Resolve conflicts then run:
git add . && git cherry-pick --continue" || header "${NEW_VERSION} PICKED CLEANLY!" ${GRN}
}
# THIS MUST BE RUN IN A KERNEL TREE
[[ ! -f Makefile ]] && report_error "Run this in a kernel tree!"
# MAKE SURE STABLE REMOTES EXISTS
header "UPDATING REMOTES"
verify_remote stable
verify_remote stable-rc
# GENERATE VERSIONS
gen_versions
# PICK OR MERGE!
[[ -n ${MERGE} ]] && merge \
|| cherry_pick
# ALERT OF SCRIPT END
echo "\a"