Home | History | Annotate | Download | only in dragon-kernel
      1 #!/bin/bash
      2 
      3 # script to push new prebuilt kernel from cros builder
      4 
      5 show_usage()
      6 {
      7 	echo usage: $0 [artifact_path] [rootdir] [kernel_path]
      8 	echo For: echo Artifacts[smaug]: smaug-release/R45-7199.0.0
      9 	echo artifact_path=smaug-release/R45-7199.0.0
     10 	echo If kernel comes from nvidia-kernel:
     11 	echo kernel_path=src/partner_private/nvidia-kernel
     12 	exit 1
     13 }
     14 
     15 artifact_path=$1
     16 TOP="$2"
     17 if [ -z "$TOP" ]; then
     18 	TOP="$(pwd)"
     19 fi
     20 kernel_path="$3"
     21 if [ -z "$kernel_path" ]; then
     22 	kernel_path="src/third_party/kernel/v3.18"
     23 fi
     24 
     25 gsbase=gs://chromeos-image-archive
     26 # smaug-release - works well
     27 # smaug-canary - works well - old, no longer works
     28 # smaug-paladin - potentially has kernel changes that are not upstream
     29 # trybot-smaug-paladin - works well with: cbuildbot --remote smaug-paladin
     30 build=smaug-release
     31 built_kernel="$TOP/device/google/dragon-kernel"
     32 kernel="$TOP/kernel/private/dragon"
     33 preamble="dragon: Update prebuilt kernel to"
     34 
     35 if [ ! -d "$built_kernel" ]; then
     36 	echo ERROR: missing prebuilt directory $built_kernel
     37 	show_usage
     38 fi
     39 
     40 if [ ! -d "$kernel" ]; then
     41 	echo ERROR: missing kernel directory $kernel
     42 	show_usage
     43 fi
     44 
     45 if [ -z "$artifact_path" ]; then
     46 	latest=$(gsutil.py cat ${gsbase}/${build}/LATEST-master)
     47 	if [ $? -ne 0 ]; then
     48 		echo ERROR: could not determine artifact_path
     49 		exit 1
     50 	fi
     51 	artifact_path=${build}/${latest}
     52 fi
     53 gspath=${gsbase}/${artifact_path}
     54 
     55 echo promoting kernel from $gspath
     56 
     57 cd "$built_kernel"
     58 gsutil.py cat ${gspath}/stripped-packages.tar | bsdtar -s '/.*kernel.*tbz2/kernel.tbz2/' -x -f - '*kernel*'
     59 if [ $? -ne 0 ]; then
     60 	echo ERROR: could not retrieve stripped-packages
     61 	exit 1
     62 fi
     63 bsdtar -s '/.*vmlinuz-3.18.*/Image.fit/' -jxf kernel.tbz2 '*vmlinuz-3.18*'
     64 rm kernel.tbz2
     65 newrev=$(gsutil.py cat ${gspath}/manifest.xml | grep "path=\"${kernel_path}\"" | sed -e 's/.*revision="\([0123456789abcdef]\+\).*/\1/')
     66 oldrev=$(git log --oneline | head -1 | sed -e "s/.*${preamble} \(.*\)/\1/")
     67 
     68 cd "$kernel"
     69 git remote update
     70 commitmsg=$(mktemp /tmp/msg.XXXXXX)
     71 cat >>$commitmsg <<EOD
     72 $preamble $newrev
     73 
     74 Build: $artifact_path
     75 
     76 Changes include:
     77 EOD
     78 git log --graph --oneline $oldrev..$newrev >> $commitmsg
     79 
     80 cd "$built_kernel"
     81 git add Image.fit
     82 git commit -t $commitmsg
     83 rm $commitmsg
     84