#!/bin/bash
|
# Description: This shell script used to generate patch file
|
# Author: guowenxue <guowenxue@gmail.com>
|
# Version: 1.0.0
|
|
# this project absolute path
|
#PRJ_PATH=$(cd $(dirname "${BASH_SOURCE[0]}")/.. && pwd)
|
PRJ_PATH=$(pwd)
|
|
# shell script will exit once get command error
|
#set -e
|
|
#+-------------------------+
|
#| Shell script functions |
|
#+-------------------------+
|
|
function pr_error() {
|
echo -e "\033[40;31m $1 \033[0m"
|
}
|
|
function pr_warn() {
|
echo -e "\033[40;33m $1 \033[0m"
|
}
|
|
function pr_info() {
|
echo -e "\033[40;32m $1 \033[0m"
|
}
|
|
# parser configure file and export environment variable
|
function do_export()
|
{
|
export SDKVER=$(basename $1)
|
export BOARD=$(basename $2)
|
}
|
|
function gen_patch()
|
{
|
SRC_PATH=$1
|
PATCH_NAME=${SDKVER}-${BOARD}.patch
|
|
if [ ! -d $SRC_FPATH ] ; then
|
pr_error "\nERROR: source code $SRC_FPATH not exist, exit now\n\n"
|
exit;
|
fi
|
|
pr_info "generate patch file for $SRC_PATH"
|
cd $SRC_PATH
|
|
pwd
|
|
if [ ! -f patched.tag ] ; then
|
touch patched.tag
|
fi
|
|
git add * 2> /dev/null
|
git add .igkboard-*.defconfig 2> /dev/null
|
git add -f files 2> /dev/null
|
|
git diff --cached > $PRJ_PATH/$PATCH_NAME
|
}
|
|
function do_patch()
|
{
|
gen_patch buildroot
|
}
|
|
if [ $# != 2 ] ; then
|
pr_info "$0 usage example:"
|
pr_info "$0 openwrt-25.12 igkboard-rk3576"
|
exit
|
fi
|
|
do_export $1 $2
|
|
gen_patch $1
|