137 lines
2.6 KiB
Bash
Executable file
137 lines
2.6 KiB
Bash
Executable file
#!/bin/bash
|
|
#
|
|
# pack/pack
|
|
# (c) Copyright 2013
|
|
# Allwinner Technology Co., Ltd. <www.allwinnertech.com>
|
|
# flord wang <wangflord@allwinnertech.com>
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
# (at your option) any later version.
|
|
|
|
ROOT_DIR=$PWD
|
|
TOOLS_DIR=${ROOT_DIR}/pctools/linux
|
|
SELECT_CHIP=
|
|
|
|
export PATH=${TOOLS_DIR}/openssl:$PATH
|
|
|
|
function pack_error()
|
|
{
|
|
echo -e "\033[47;31mERROR: $*\033[0m"
|
|
}
|
|
|
|
function pack_warn()
|
|
{
|
|
echo -e "\033[47;34mWARN: $*\033[0m"
|
|
}
|
|
|
|
function pack_info()
|
|
{
|
|
echo -e "\033[0;31;1mINFO: $*\033[0m"
|
|
}
|
|
|
|
show_help()
|
|
{
|
|
echo "build.sh - this script is used to create all keys defined in the dragon_toc.cfg"
|
|
echo "OPTIONS"
|
|
echo "-h Display help message"
|
|
echo "-c [chip_type] Chip type, e.g. sun50iw6p1,sun50iw3p1..."
|
|
}
|
|
|
|
build_select_chip()
|
|
{
|
|
local count=0
|
|
printf "All valid Sunxi chip:\n"
|
|
for chip in $( find chips/ -mindepth 1 -maxdepth 1 -type d |sort); do
|
|
chips[$count]=`basename $chip`
|
|
printf "$count. ${chips[$count]}\n"
|
|
let count=$count+1
|
|
done
|
|
|
|
while true; do
|
|
read -p "Please select a chip:"
|
|
RES=`expr match $REPLY "[0-9][0-9]*$"`
|
|
if [ "$RES" -le 0 ]; then
|
|
echo "please use index number"
|
|
continue
|
|
fi
|
|
if [ "$REPLY" -ge $count ]; then
|
|
echo "too big"
|
|
continue
|
|
fi
|
|
if [ "$REPLY" -lt "0" ]; then
|
|
echo "too small"
|
|
continue
|
|
fi
|
|
break
|
|
done
|
|
|
|
SELECT_CHIP=${chips[$REPLY]}
|
|
}
|
|
|
|
createkeys()
|
|
{
|
|
printf "ready to create keys\n"
|
|
|
|
find chips/ -mindepth 1 -maxdepth 1 -type d | grep -w "$SELECT_CHIP"
|
|
if [ $? -ne 0 ]
|
|
then
|
|
pack_error "plat: $SELECT_CHIP is not exist"
|
|
exit 1
|
|
fi
|
|
|
|
pack_info "SELECT_CHIP is $SELECT_CHIP\n"
|
|
|
|
if [ -f chips/$SELECT_CHIP/configs/default/dragon_toc.cfg ]
|
|
then
|
|
cp -v chips/$SELECT_CHIP/configs/default/dragon_toc.cfg dragon_toc.cfg
|
|
else
|
|
cp -v common/sign_config/dragon_toc.cfg dragon_toc.cfg
|
|
fi
|
|
|
|
if [ $? -ne 0 ]
|
|
then
|
|
pack_error "dragon toc config file is not exist"
|
|
exit 1
|
|
fi
|
|
|
|
dragonsecboot -key dragon_toc.cfg common/keys
|
|
if [ $? -ne 0 ]
|
|
then
|
|
pack_error "dragon toc run error"
|
|
rm -rf dragon_toc.cfg
|
|
|
|
exit 1
|
|
fi
|
|
|
|
printf "\n"
|
|
if [ -f chips/$SELECT_CHIP/configs/default/dragon_toc.cfg ]
|
|
then
|
|
pack_info "use platform[$SELECT_CHIP] toc config to creat keys"
|
|
else
|
|
pack_info "use default toc config to creat keys"
|
|
fi
|
|
printf "\n"
|
|
|
|
rm -rf dragon_toc.cfg
|
|
}
|
|
|
|
while getopts hc: OPTION
|
|
do
|
|
case $OPTION in
|
|
h) show_help
|
|
exit 0
|
|
;;
|
|
c) SELECT_CHIP=$OPTARG
|
|
createkeys
|
|
exit 0
|
|
;;
|
|
*) show_help
|
|
exit 0
|
|
;;
|
|
esac
|
|
done
|
|
|
|
build_select_chip
|
|
createkeys
|