#!/bin/bash

usage () {
    echo "$0 usage:"
    echo ""
    echo "    cd /usr/src/linux ; $0 [-h|--help| [-v|--verbose] <TAG>]"
    echo ""
    echo "  Copies the following files from the current directory to /boot,"
    echo "  appending -<TAG> to the names."
    echo "      vmlinux"
    echo "      System.map"
    echo "      .config"
    echo "      include/linux/autoconf.h"
    echo "      include/linux/version.h"
}

verbose=0

for arg ; do
    case "$arg" in
    -h|--help)
        usage
        exit 0
        ;;
    -v|--verbose)
        verbose=1
        ;;
    -*)
        echo "$0: Invalid option '$arg'."
        usage
        exit 1
        ;;
    *)
        if [ -n "$tag" ] ; then
            echo "$0: Tag '$tag' already given. '$arg' is supperfluous."
            usage
            exit 1
        fi
        tag="$arg"
        ;;
    esac
done

if [ -z "$tag" ] ; then
    echo "$0: Missing a tag argument"
    usage
    exit 1
fi

if [ $verbose -eq 0 ] ; then
    cpv=
    tarv=
    lnv=
else
    cpv=-v
    tarv=-v
    lnv=-v
fi

cp $cpv arch/$(arch)/boot/bzImage             /boot/vmlinuz-${tag}
cp $cpv System.map                            /boot/vmlinuz-${tag}.System.map
ln $lnv -sf /boot/vmlinuz-${tag}.System.map   /boot/System.map
tar $tarv -zcf                                /boot/vmlinuz-${tag}.config.tar.gz \
    .config \
    $( [ -r include/linux/autoconf.h ] && echo include/linux/autoconf.h ) \
    $( [ -d include/generated ] && echo include/generated ) \
    include/linux/version.h
if [ $verbose -ne 0 ] ; then
    echo "  to /boot/vmlinuz-${tag}.config.tar.gz"
fi

#END#
ViewGit