Repository navigation
Expand file tree
/
Copy pathgit-update
More file actions
executable file
·162 lines (137 loc) · 5.2 KB
/
Copy pathgit-update
File metadata and controls
executable file
·162 lines (137 loc) · 5.2 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#!/bin/bash
# Update the kernel trees, firmware, portage config and the system.
# The same file runs on quark and axion; what differs is set under the case.
export PATH=/usr/lib/llvm/23/bin:$PATH
[[ $EUID == 0 ]] || { echo "git-update: run as root" >&2; exit 1; }
STAMP=$(date +%F-%T)
JOBS=$(nproc)
failed=()
fail() { failed+=("$1"); echo "!!! $1" >&2; }
# name:image:branch of each tree under /usr/src, in build order
KERNELS=(linux:tip:linus/master drm:drm:airlied/drm-next agd5f:agd5f:agd5f/drm-next)
PUSH_REMOTES=()
EMERGE_EXCLUDE=(--exclude yuzu)
WORLD_OPTS=(--keep-going --complete-graph y)
PUSH_PORTAGE=0
MESA=
case ${HOSTNAME%%.*} in
axion)
KERNELS=(agd5f:agd5f:agd5f/drm-next linux:tip:linus/master)
PUSH_REMOTES=(github gitlab freedesktop)
EMERGE_EXCLUDE=(--exclude yuzu --exclude citron --exclude wine-proton)
WORLD_OPTS=()
PUSH_PORTAGE=1
MESA=/home/fireburn/Mesa
;;
esac
MESA_OLD_TAGS=(
R300_DRIVER_0 before_upgrade_03_01_05 blended_fountain
embedded-1-20030120 embedded-1-20030224 embedded-1-20030305
embedded-1-20030324 embedded-1-20030417 embedded-1-20030502
gliding_penguin jump_and_click kw-mesa-1 mesa-6_5-20060712
mesa_20050504 mesa_20050526 mesa_20050610 mesa_20050715 mesa_20060201
mesa_20060325 mesa_3_1 mesa_3_1_beta_3 mesa_3_2 mesa_3_2_1
mesa_3_2_beta_1 mesa_3_3 mesa_3_4 mesa_3_4_1 mesa_3_4_2 mesa_3_5
mesa_4_0 mesa_4_0_1 mesa_4_0_2 mesa_4_0_3 mesa_4_0_4 mesa_4_1
mesa_5_0 mesa_5_0_1 mesa_6_3 mesa_6_3_1 mesa_6_3_1_1 mesa_6_3_2
mesa_6_4 mesa_6_4_1 mesa_6_4_2 mesa_6_5 mesa_6_5_1 mesa_6_5_2
mesa_texman_20060210 noisy_cube red_tinted_cube rotating_gears
shimmering_gears start texman_0_1_20060325 texman_0_1_20060330
texman_0_1_20060621 texman_0_1_20060705 texman_0_1_pre_ttm
texmem_0_2_20060912 texmem_0_3_20060923 texmem_0_3_20060929
the_perfect_frag trunk_20040329 unichrome-last-xinerama
vtx-0-2-21112003-freeze vtx-0-2-24112003
)
# Commit whatever changed in a repo that is updated by hand, then push it.
syncRepo() {
local dir=$1
git -C "$dir" rev-parse --git-dir >/dev/null 2>&1 || { fail "$dir is not a git repo"; return; }
cd "$dir" || return
git pull --rebase --autostash || fail "$dir: pull"
git add .
git diff --cached --quiet || git commit -q -m "Git Update $STAMP"
git push || fail "$dir: push"
}
updateKernel() {
local dir=${1%%:*} img rest=${1#*:} branch rel d
img=${rest%%:*}; branch=${rest#*:}
cd /usr/src/$dir || { fail "$dir: no tree"; return; }
# --empty=drop so local fixes that have landed upstream are dropped
# rather than stopping the rebase on an empty commit
if ! git rebase --empty=drop "$branch"; then
git rebase --abort 2>/dev/null
git cherry-pick --abort 2>/dev/null
git am --abort 2>/dev/null
# the reset discards local commits, so keep them reachable
git branch -f "backup/git-update-$img" HEAD
git reset --hard "$branch"
echo "$dir: rebase failed, old head kept as backup/git-update-$img" >&2
fi
make LLVM=1 -j"$JOBS" || { fail "$dir: build failed, /boot not touched"; return; }
make LLVM=1 -j"$JOBS" modules_install || { fail "$dir: modules_install"; return; }
rel=$(make -s LLVM=1 kernelrelease)
install -m 755 arch/x86/boot/bzImage /boot/bzImage-$img.efi.new &&
mv -f /boot/bzImage-$img.efi.new /boot/bzImage-$img.efi ||
{ fail "$dir: install to /boot"; return; }
# only now that a new kernel is in place, drop the old module sets
for d in /lib/modules/*-"$img"+; do
[[ -d $d ]] || continue
[[ ${d##*/} == "$rel" || ${d##*/} == $(uname -r) ]] && continue
rm -rf "$d"
done
}
pushAll() {
local r
for r in "$@"; do
git remote | grep -qx "$r" || continue
git push "$r" --all --force || fail "$PWD: push $r"
git push "$r" --tags || fail "$PWD: push tags $r"
done
}
rm -f /etc/portage/make.conf~
cp /usr/bin/git-update /usr/src/
cd /usr/src && git pull --rebase --autostash || fail "/usr/src: pull"
if git -C /lib/firmware rev-parse --git-dir >/dev/null 2>&1; then
git -C /lib/firmware pull --rebase || fail "/lib/firmware: pull"
else
fail "/lib/firmware is not a git repo"
fi
cd /usr/src/linux && git fetch --all --prune || fail "fetch"
((${#PUSH_REMOTES[@]})) && pushAll "${PUSH_REMOTES[@]}"
for k in "${KERNELS[@]}"; do
updateKernel "$k"
done
for d in linux drm agd5f stable; do
n=$d
[[ $d == linux ]] && n=tip
[[ -f /usr/src/$d/.config ]] && cp /usr/src/$d/.config /usr/src/dot_config_$n
done
syncRepo /usr/src
syncRepo /etc/portage
if [[ -d $MESA ]]; then
cd "$MESA" || exit 1
sudo -u fireburn git fetch --all --prune
sudo -u fireburn git pull
sudo -u fireburn git tag -d "${MESA_OLD_TAGS[@]}" >/dev/null 2>&1
sudo -u fireburn git push github --all --force
sudo -u fireburn git push github --tags
sudo -u fireburn git push gitlab --all --force
sudo -u fireburn git push gitlab --tags
fi
cd /usr/portage
git pull --rebase --autostash || fail "/usr/portage: pull"
emerge --sync --quiet || fail "emerge --sync"
if ((PUSH_PORTAGE)); then
git push gitlab --all --force
git push github --all --force
fi
emerge -vDuNt "${WORLD_OPTS[@]}" @world || fail "world update"
emerge -vDt "${WORLD_OPTS[@]}" @live-rebuild @preserved-rebuild "${EMERGE_EXCLUDE[@]}" ||
fail "live-rebuild"
emerge --depclean -a
eclean-dist --destructive -q
if ((${#failed[@]})); then
printf '\n%s\n' "git-update finished with problems:"
printf ' %s\n' "${failed[@]}"
exit 1
fi