# Bail if we're not running a core with kernel functions

if [ ! -e $FUNCTIONS/kernel.lunar ] ; then
  message "${PROBLEM_COLOR}Bailing out, ${DEFAULT_COLOR}Lunar (or theedge) code version too old"
  message "${PROBLEM_COLOR}Update core ${MODULE_COLOR}(lin lunar or lin theedge)${DEFAULT_COLOR} to install this kernel"
  exit 1
fi

mk_source_dir $SOURCE_DIRECTORY
rm -f /usr/src/linux
ln -sf $SOURCE_DIRECTORY /usr/src/linux
cd $SOURCE_DIRECTORY

# Check wether we're running an up-to-date tar
if [ `installed_version tar | cut -d. -f2` -ge 15 ]; then
  tar xf $SOURCE_CACHE/$SOURCE --no-same-owner \
  --no-same-permissions --strip-components=1
else
  message "${PROBLEM_COLOR}Error:${DEFAULT_COLOR} Please update your tar module"
  exit 1
fi

if  [ -f $CONFIG_CACHE/.config.2.6.stable ]; then
    cp $CONFIG_CACHE/.config.2.6.stable $SOURCE_DIRECTORY/.config;
elif [ -f $CONFIG_CACHE/.config.beta ]; then
    cp $CONFIG_CACHE/.config.beta $SOURCE_DIRECTORY/.config;
fi
