#!/bin/bash # Description: This shell script used to generate patch file # Author: guowenxue # Version: 1.0.0 PROJ_PATH=`pwd` PACK_PATH=${PROJ_PATH}/tarballs PATCH_PATH=${PROJ_PATH}/patches BOARD=ok335x PATCH_SUFFIX=${BOARD}.patch function do_clean() { if [ -f .config ] ; then cp .config .cfg-${BOARD} fi echo "WARNNING: Maybe need input sudo passwd here: " sudo bash build.sh clean } if [ $# != 1 ] ; then echo "Usage: $0 [src_path]" printf "\nExample: \n" echo "$0 linux-3.2.0" exit ; fi SRC=`basename $1` if [ ! -d ${SRC} ] ; then printf "\nERROR: ${SRC} source code not exist, exit now\n\n" exit fi if [ ! -f ${PACK_PATH}/${SRC}.tar.xz ] ; then printf "\nERROR: ${SRC}.tar.xz packet not exist, exit now\n\n" exit fi cd ${PROJ_PATH} cd ${SRC} do_clean cd - # rename new source code mv ${SRC} ${SRC}-${BOARD} # decompress orignal soruce code packet tar -xJf ${PACK_PATH}/${SRC}.tar.xz # generate patch file diff -Nuar ${SRC} ${SRC}-${BOARD} > ${SRC}-${PATCH_SUFFIX} # remove orignal soruce code rm -rf ${SRC} # recover new source code mv ${SRC}-${BOARD} ${SRC}