summaryrefslogtreecommitdiff
path: root/push-kernel.sh
blob: 500ab54823bc52d4f3ac73fc7a003f7d9fc17900 (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
#!/bin/bash

# script to push new prebuilt kernel from cros builder

show_usage()
{
	echo usage: $0 [artifact_path] [rootdir] [kernel_path]
	echo For: echo Artifacts[smaug]: smaug-release/R45-7199.0.0
	echo artifact_path=smaug-release/R45-7199.0.0
	echo If kernel comes from nvidia-kernel:
	echo kernel_path=src/partner_private/nvidia-kernel
	exit 1
}

artifact_path=$1
TOP="$2"
if [ -z "$TOP" ]; then
	TOP="$(pwd)"
fi
kernel_path="$3"
if [ -z "$kernel_path" ]; then
	kernel_path="src/third_party/kernel/v3.18"
fi

gsbase=gs://chromeos-image-archive
# smaug-release - works well
# smaug-canary - works well - old, no longer works
# smaug-paladin - potentially has kernel changes that are not upstream
# trybot-smaug-paladin - works well with: cbuildbot --remote smaug-paladin
build=smaug-release
built_kernel="$TOP/device/google/dragon-kernel"
kernel="$TOP/kernel/private/dragon"
preamble="dragon: Update prebuilt kernel to"

if [ ! -d "$built_kernel" ]; then
	echo ERROR: missing prebuilt directory $built_kernel
	show_usage
fi

if [ ! -d "$kernel" ]; then
	echo ERROR: missing kernel directory $kernel
	show_usage
fi

if [ -z "$artifact_path" ]; then
	latest=$(gsutil.py cat ${gsbase}/${build}/LATEST-master)
	if [ $? -ne 0 ]; then
		echo ERROR: could not determine artifact_path
		exit 1
	fi
	artifact_path=${build}/${latest}
fi
gspath=${gsbase}/${artifact_path}

echo promoting kernel from $gspath

cd "$built_kernel"
gsutil.py cat ${gspath}/stripped-packages.tar | bsdtar -s '/.*kernel.*tbz2/kernel.tbz2/' -x -f - '*kernel*'
if [ $? -ne 0 ]; then
	echo ERROR: could not retrieve stripped-packages
	exit 1
fi
bsdtar -s '/.*vmlinuz-3.18.*/Image.fit/' -jxf kernel.tbz2 '*vmlinuz-3.18*'
rm kernel.tbz2
newrev=$(gsutil.py cat ${gspath}/manifest.xml | grep "path=\"${kernel_path}\"" | sed -e 's/.*revision="\([0123456789abcdef]\+\).*/\1/')
oldrev=$(git log --oneline | head -1 | sed -e "s/.*${preamble} \(.*\)/\1/")

cd "$kernel"
git remote update
commitmsg=$(mktemp /tmp/msg.XXXXXX)
cat >>$commitmsg <<EOD
$preamble $newrev

Build: $artifact_path

Changes include:
EOD
git log --graph --oneline $oldrev..$newrev >> $commitmsg

cd "$built_kernel"
git add Image.fit
git commit -t $commitmsg
rm $commitmsg