#!/bin/bash
# Clone the chromeos kernel repository and create a tarball:

KVER="3.4"
SRCDIR="linux-${KVER}"

GITURI="https://git.chromium.org/git/chromiumos/third_party/kernel.git"
GITBRANCH="chromeos-$KVER"

if [ ! -d "$SRCDIR" ]; then
  echo "Cloning ChromeOS kernel repository"
  mkdir $SRCDIR || exit 1
  git clone $GITURI $SRCDIR
  cd $SRCDIR
  git checkout $GITBRANCH
  cd -
else
  echo "Updating ChromeOS kernel repository"
  cd $SRCDIR
  git pull origin
  cd -
fi

echo "Creating kernel tarball"
tar --exclude=".git" --exclude=".gitignore" -Jcvf $SRCDIR.tar.xz $SRCDIR
