|
Miguel Flores Silverio |
14ee8bf |
#! /bin/sh
|
|
Miguel Flores Silverio |
14ee8bf |
# This script was created in a effort to make patch management a bit easier.
|
|
Miguel Flores Silverio |
14ee8bf |
# It list all the patches in the current tree and identifies if they are
|
|
Miguel Flores Silverio |
14ee8bf |
# present in the kernel.spec, PatchList.txt, both files or neither.
|
|
Miguel Flores Silverio |
14ee8bf |
#
|
|
Miguel Flores Silverio |
14ee8bf |
# eg. ./check-patchlist.sh [optional flag]
|
|
Miguel Flores Silverio |
14ee8bf |
|
|
Miguel Flores Silverio |
14ee8bf |
function usage(){
|
|
Miguel Flores Silverio |
14ee8bf |
echo "List all the patches currently in the tree. It also helps identify"
|
|
Miguel Flores Silverio |
14ee8bf |
echo "if the patch is present in kernel.spec or PatchList.txt. "
|
|
Miguel Flores Silverio |
14ee8bf |
echo "-h, --help "
|
|
Miguel Flores Silverio |
14ee8bf |
echo "-t, --tracked patches in both kernel.spec and PatchList.txt "
|
|
Miguel Flores Silverio |
14ee8bf |
echo "-p, --patchlist patches added to PatchList.txt. "
|
|
Miguel Flores Silverio |
14ee8bf |
echo "-s, --specfile patches added to kernel.spec. "
|
|
Miguel Flores Silverio |
14ee8bf |
echo "-n, --not-tracked patches in the tree but not in PatchList.txt "
|
|
Miguel Flores Silverio |
14ee8bf |
echo " or kernel.spec "
|
|
Miguel Flores Silverio |
14ee8bf |
}
|
|
Miguel Flores Silverio |
14ee8bf |
|
|
Miguel Flores Silverio |
14ee8bf |
BASEDIR=$(dirname "$( cd $(dirname $BASH_SOURCE[0]) && pwd)")
|
|
Miguel Flores Silverio |
14ee8bf |
pushd $BASEDIR > /dev/null
|
|
Miguel Flores Silverio |
14ee8bf |
|
|
Miguel Flores Silverio |
14ee8bf |
function list_all(){
|
|
Miguel Flores Silverio |
14ee8bf |
echo "===========Legend==========================="
|
|
Miguel Flores Silverio |
14ee8bf |
echo ". In kernel.spec "
|
|
Miguel Flores Silverio |
14ee8bf |
echo "* In PatchList.txt "
|
|
Miguel Flores Silverio |
14ee8bf |
echo "+ In PatchList.txt & Kernel.spec "
|
|
Miguel Flores Silverio |
14ee8bf |
echo "- Neither in PatchList.txt nor kernel.spec"
|
|
Miguel Flores Silverio |
14ee8bf |
echo "============================================"
|
|
Miguel Flores Silverio |
14ee8bf |
for patch in $(ls *.patch); do
|
|
Miguel Flores Silverio |
14ee8bf |
if [ ! -z "$(grep $patch PatchList.txt)" ] && [ ! -z "$(grep $patch kernel.spec)" ]
|
|
Miguel Flores Silverio |
14ee8bf |
then
|
|
Miguel Flores Silverio |
14ee8bf |
echo "+ ${patch}" # Patches in kernel.spec and PatchList.txt
|
|
Miguel Flores Silverio |
14ee8bf |
|
|
Miguel Flores Silverio |
14ee8bf |
elif [ ! -z "$(grep $patch PatchList.txt)" ] && [ -z "$(grep $patch kernel.spec)" ]
|
|
Miguel Flores Silverio |
14ee8bf |
then
|
|
Miguel Flores Silverio |
14ee8bf |
echo "* ${patch}" # Patches in PatchList.txt but not in kernel.spec
|
|
Miguel Flores Silverio |
14ee8bf |
|
|
Miguel Flores Silverio |
14ee8bf |
elif [ -z "$(grep $patch PatchList.txt)" ] && [ ! -z "$(grep $patch kernel.spec)" ]
|
|
Miguel Flores Silverio |
14ee8bf |
then
|
|
Miguel Flores Silverio |
14ee8bf |
echo ". ${patch}" # Patches in kernel.spec but not in PatchList.txt
|
|
Miguel Flores Silverio |
14ee8bf |
|
|
Miguel Flores Silverio |
14ee8bf |
else
|
|
Miguel Flores Silverio |
14ee8bf |
echo "- ${patch}" # Neither in PatchList.txt nor kernel.spec
|
|
Miguel Flores Silverio |
14ee8bf |
|
|
Miguel Flores Silverio |
14ee8bf |
fi
|
|
Miguel Flores Silverio |
14ee8bf |
done
|
|
Miguel Flores Silverio |
14ee8bf |
}
|
|
Miguel Flores Silverio |
14ee8bf |
|
|
Miguel Flores Silverio |
14ee8bf |
function list_present_not_added(){
|
|
Miguel Flores Silverio |
14ee8bf |
for patch in $(ls *.patch); do
|
|
Miguel Flores Silverio |
14ee8bf |
if [ -z "$(grep $patch PatchList.txt)" ] && [ -z "$(grep $patch kernel.spec)" ]
|
|
Miguel Flores Silverio |
14ee8bf |
then
|
|
Miguel Flores Silverio |
14ee8bf |
echo $patch
|
|
Miguel Flores Silverio |
14ee8bf |
fi
|
|
Miguel Flores Silverio |
14ee8bf |
done
|
|
Miguel Flores Silverio |
14ee8bf |
}
|
|
Miguel Flores Silverio |
14ee8bf |
|
|
Miguel Flores Silverio |
14ee8bf |
function list_present_added(){
|
|
Miguel Flores Silverio |
14ee8bf |
for patch in $(ls *.patch); do
|
|
Miguel Flores Silverio |
14ee8bf |
if [ ! -z "$(grep $patch PatchList.txt)" ] && [ ! -z "$(grep $patch kernel.spec)" ]
|
|
Miguel Flores Silverio |
14ee8bf |
then
|
|
Miguel Flores Silverio |
14ee8bf |
echo $patch
|
|
Miguel Flores Silverio |
14ee8bf |
fi
|
|
Miguel Flores Silverio |
14ee8bf |
done
|
|
Miguel Flores Silverio |
14ee8bf |
}
|
|
Miguel Flores Silverio |
14ee8bf |
|
|
Miguel Flores Silverio |
14ee8bf |
function list_patchList(){
|
|
Miguel Flores Silverio |
14ee8bf |
for patch in $(ls *.patch); do
|
|
Miguel Flores Silverio |
14ee8bf |
if [ ! -z "$(grep $patch PatchList.txt)" ] && [ -z "$(grep $patch kernel.spec)" ]
|
|
Miguel Flores Silverio |
14ee8bf |
then
|
|
Miguel Flores Silverio |
14ee8bf |
echo $patch
|
|
Miguel Flores Silverio |
14ee8bf |
fi
|
|
Miguel Flores Silverio |
14ee8bf |
done
|
|
Miguel Flores Silverio |
14ee8bf |
|
|
Miguel Flores Silverio |
14ee8bf |
}
|
|
Miguel Flores Silverio |
14ee8bf |
function list_specfile(){
|
|
Miguel Flores Silverio |
14ee8bf |
for patch in $(ls *.patch); do
|
|
Miguel Flores Silverio |
14ee8bf |
if [ -z "$(grep $patch PatchList.txt)" ] && [ ! -z "$(grep $patch kernel.spec)" ]
|
|
Miguel Flores Silverio |
14ee8bf |
then
|
|
Miguel Flores Silverio |
14ee8bf |
echo $patch
|
|
Miguel Flores Silverio |
14ee8bf |
fi
|
|
Miguel Flores Silverio |
14ee8bf |
done
|
|
Miguel Flores Silverio |
14ee8bf |
}
|
|
Miguel Flores Silverio |
14ee8bf |
|
|
Miguel Flores Silverio |
14ee8bf |
if [ -z "$@" ]; then
|
|
Miguel Flores Silverio |
14ee8bf |
list_all
|
|
Miguel Flores Silverio |
14ee8bf |
else
|
|
Miguel Flores Silverio |
14ee8bf |
|
|
Miguel Flores Silverio |
14ee8bf |
for opt in "$@"; do
|
|
Miguel Flores Silverio |
14ee8bf |
case $opt in
|
|
Miguel Flores Silverio |
14ee8bf |
-t|--tracked)
|
|
Miguel Flores Silverio |
14ee8bf |
list_present_added
|
|
Miguel Flores Silverio |
14ee8bf |
;;
|
|
Miguel Flores Silverio |
14ee8bf |
-s|--specfile)
|
|
Miguel Flores Silverio |
14ee8bf |
list_specfile
|
|
Miguel Flores Silverio |
14ee8bf |
;;
|
|
Miguel Flores Silverio |
14ee8bf |
-h|--help)
|
|
Miguel Flores Silverio |
14ee8bf |
usage
|
|
Miguel Flores Silverio |
14ee8bf |
;;
|
|
Miguel Flores Silverio |
14ee8bf |
-n|--not-added)
|
|
Miguel Flores Silverio |
14ee8bf |
list_present_not_added
|
|
Miguel Flores Silverio |
14ee8bf |
;;
|
|
Miguel Flores Silverio |
14ee8bf |
-p|--patchlist)
|
|
Miguel Flores Silverio |
14ee8bf |
list_patchList
|
|
Miguel Flores Silverio |
14ee8bf |
;;
|
|
Miguel Flores Silverio |
14ee8bf |
*)
|
|
Miguel Flores Silverio |
14ee8bf |
usage
|
|
Miguel Flores Silverio |
14ee8bf |
;;
|
|
Miguel Flores Silverio |
14ee8bf |
esac
|
|
Miguel Flores Silverio |
14ee8bf |
done
|
|
Miguel Flores Silverio |
14ee8bf |
fi
|
|
Miguel Flores Silverio |
14ee8bf |
|
|
Miguel Flores Silverio |
14ee8bf |
popd > /dev/null
|