2013-11-14 08:43:05 -08:00
|
|
|
#!/bin/bash
|
2013-09-18 12:41:12 -07:00
|
|
|
#
|
|
|
|
# NAME:
|
|
|
|
# gen-patch.sh - extract linuxized patches from the ACPICA git
|
|
|
|
# repository
|
|
|
|
#
|
|
|
|
# SYNOPSIS:
|
2016-12-27 15:46:27 +08:00
|
|
|
# gen-patch.sh [-f from] [-i index] [-l link] [-m maintainer] [-n hash] [-u] [commit]
|
2013-09-18 12:41:12 -07:00
|
|
|
#
|
|
|
|
# DESCRIPTION:
|
|
|
|
# Extract linuxized patches from the git repository.
|
|
|
|
# Options:
|
2016-12-27 15:46:27 +08:00
|
|
|
# -i: Specify patch index.
|
2014-07-24 10:33:42 +08:00
|
|
|
# -l: Specify a URL prefix that can be used to link the commit.
|
|
|
|
# -m: Specify maintainer name <email> for Signed-off-by field.
|
2016-12-27 15:46:27 +08:00
|
|
|
# -n: Specify number of digits from commit hash to form a name.
|
2014-07-24 10:33:42 +08:00
|
|
|
# -u: Specify whether the commit is in an upstream repository.
|
|
|
|
# commit: GIT commit (default to HEAD).
|
2013-09-18 12:41:12 -07:00
|
|
|
#
|
|
|
|
|
|
|
|
usage() {
|
2016-12-27 15:46:27 +08:00
|
|
|
echo "Usage: `basename $0` [-f from] [-i index] [-l link] [-m maintainer] [-n hash] [-u] <commit>"
|
2013-09-18 12:41:12 -07:00
|
|
|
echo "Where:"
|
|
|
|
echo " -i: Specify patch index (default to 0)."
|
2014-07-24 10:33:42 +08:00
|
|
|
echo " -l: Specify a URL prefix that can be used to link the commit."
|
|
|
|
echo " -m: Specify maintainer name <email> for Signed-off-by field."
|
2016-12-27 15:46:27 +08:00
|
|
|
echo " -n: Specify number of digits from commit hash to form a name"
|
|
|
|
echo " (default to 8)."
|
2014-07-24 10:33:42 +08:00
|
|
|
echo " -u: Specify whether the commit is in an upstream repository."
|
2013-09-18 12:41:12 -07:00
|
|
|
echo " commit: GIT commit (default to HEAD)."
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2014-07-24 10:33:42 +08:00
|
|
|
COMMITTER="`git config user.name` <`git config user.email`>"
|
2013-09-18 12:41:12 -07:00
|
|
|
INDEX=0
|
2014-07-24 10:33:42 +08:00
|
|
|
UPSTREAM=no
|
2016-12-27 15:46:27 +08:00
|
|
|
HASH=8
|
2013-09-18 12:41:12 -07:00
|
|
|
|
2016-12-27 15:46:27 +08:00
|
|
|
while getopts "i:l:m:n:u" opt
|
2013-09-18 12:41:12 -07:00
|
|
|
do
|
|
|
|
case $opt in
|
|
|
|
i) INDEX=$OPTARG;;
|
2014-07-24 10:33:42 +08:00
|
|
|
l) LINK=$OPTARG;;
|
2016-12-27 15:46:27 +08:00
|
|
|
n) HASH=$OPTARG;;
|
2014-07-24 10:33:42 +08:00
|
|
|
m) MAINTAINER=$OPTARG;;
|
|
|
|
u) UPSTREAM=yes
|
|
|
|
if [ "x${LINK}" = "x" ]; then
|
|
|
|
LINK=https://github.com/acpica/acpica/commit/
|
|
|
|
fi;;
|
2013-09-18 12:41:12 -07:00
|
|
|
?) echo "Invalid argument $opt"
|
|
|
|
usage;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
shift $(($OPTIND - 1))
|
|
|
|
|
2014-07-24 10:33:42 +08:00
|
|
|
COMMIT=$1
|
|
|
|
if [ "x${COMMIT}" = "x" ]; then
|
|
|
|
COMMIT=HEAD
|
|
|
|
fi
|
|
|
|
|
2016-12-09 16:02:37 +08:00
|
|
|
after=`git log -1 ${COMMIT} --format=%H`
|
2016-12-27 15:46:27 +08:00
|
|
|
after_name=`git log -1 ${COMMIT} --format=%H | cut -c 1-${HASH}`
|
2016-12-09 16:02:37 +08:00
|
|
|
before=`git log -1 ${COMMIT}^1 --format=%H`
|
2016-12-27 15:46:27 +08:00
|
|
|
before_name=`git log -1 ${COMMIT}^1 --format=%H | cut -c 1-${HASH}`
|
2013-09-18 12:41:12 -07:00
|
|
|
|
|
|
|
SCRIPT=`(cd \`dirname $0\`; pwd)`
|
2013-11-08 08:11:48 -08:00
|
|
|
. $SCRIPT/libacpica.sh
|
2013-09-18 12:41:12 -07:00
|
|
|
|
|
|
|
GP_acpica_repo=$CURDIR/acpica.repo
|
2016-12-27 15:46:27 +08:00
|
|
|
GP_linux_before=$CURDIR/linux.before_name
|
|
|
|
GP_linux_after=$CURDIR/linux.after_name
|
|
|
|
GP_acpica_patch=$CURDIR/acpica-$after_name.patch
|
|
|
|
GP_linux_patch=$CURDIR/linux-$after_name.patch
|
2013-09-18 12:41:12 -07:00
|
|
|
|
|
|
|
echo "[gen-patch.sh] Extracting GIT ($SRCDIR)..."
|
|
|
|
# Cleanup
|
|
|
|
rm -rf $GP_linux_before
|
|
|
|
rm -rf $GP_linux_after
|
|
|
|
rm -rf $GP_acpica_repo
|
|
|
|
git clone $SRCDIR $GP_acpica_repo > /dev/null || exit 2
|
|
|
|
|
2014-07-24 10:33:42 +08:00
|
|
|
# Preset environments: LINK
|
|
|
|
# Arg 1: commit ID
|
|
|
|
generate_refs()
|
|
|
|
{
|
|
|
|
if [ "x${LINK}" != "x" ]; then
|
|
|
|
echo "Link: ${LINK}$1"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Preset environments: AUTHOR, MAINTAINER, COMMITTER
|
|
|
|
# Arg 1: commit ID
|
|
|
|
generate_sobs()
|
|
|
|
{
|
|
|
|
split_desc $1 1
|
|
|
|
echo "Signed-off-by: ${AUTHOR}"
|
|
|
|
if [ "x${MAINTAINER}" != "x" ]; then
|
|
|
|
echo "Signed-off-by: ${MAINTAINER}"
|
|
|
|
fi
|
|
|
|
echo "Signed-off-by: ${COMMITTER}"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Preset environments: UPSTREAM, INDEX, COMMITTER
|
|
|
|
# Arg 1: commit ID
|
|
|
|
generate_acpica_desc()
|
|
|
|
{
|
2016-10-14 21:25:42 +08:00
|
|
|
AUTHOR_NAME=`git log -1 $1 --format="%aN"`
|
|
|
|
AUTHOR_EMAIL=`git log -1 $1 --format="%aE"`
|
2014-07-24 10:33:42 +08:00
|
|
|
if [ "x${AUTHOR_NAME}" = "xRobert Moore" ]; then
|
|
|
|
AUTHOR_NAME="Bob Moore"
|
|
|
|
fi
|
|
|
|
if [ "x${AUTHOR_EMAIL}" = "xRobert.Moore@intel.com" ]; then
|
|
|
|
AUTHOR_EMAIL="robert.moore@intel.com"
|
|
|
|
fi
|
|
|
|
AUTHOR="${AUTHOR_NAME} <${AUTHOR_EMAIL}>"
|
2015-01-27 09:48:05 +08:00
|
|
|
FORMAT="From %H Mon Sep 17 00:00:00 2001%nFrom: $COMMITTER%nDate: %aD%nFrom: $AUTHOR%nSubject: [PATCH $INDEX] ACPICA: %s%n%n%b"
|
2014-07-24 10:33:42 +08:00
|
|
|
if [ "x$UPSTREAM" = "xyes" ]; then
|
2015-01-27 09:48:05 +08:00
|
|
|
FORMAT="From %H Mon Sep 17 00:00:00 2001%nFrom: $COMMITTER%nDate: %aD%nFrom: $AUTHOR%nSubject: [PATCH $INDEX] ACPICA: %s%n%nACPICA commit %H%n%n%b"
|
2014-07-24 10:33:42 +08:00
|
|
|
fi
|
|
|
|
GIT_LOG_FORMAT=`echo $FORMAT`
|
2016-10-14 21:25:42 +08:00
|
|
|
eval "git log -1 $1 --format=\"$GIT_LOG_FORMAT\""
|
2014-07-24 10:33:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
# Arg 1: patch description file
|
|
|
|
# Arg 2: 1=dump SOB block, 0=dump other text
|
|
|
|
split_desc()
|
|
|
|
{
|
|
|
|
tac $1 | DOSOB=$2 awk '
|
|
|
|
BEGIN { SOB=1 }
|
|
|
|
{
|
|
|
|
if (SOB==1) {
|
|
|
|
if (match($0, /^Signed-off-by:.*/)) {
|
|
|
|
if (ENVIRON["DOSOB"]==1)
|
|
|
|
print $0
|
2015-01-27 09:48:05 +08:00
|
|
|
} else if (match($0, /^Fixed-by:.*/)) {
|
|
|
|
if (ENVIRON["DOSOB"]==1)
|
|
|
|
print $0
|
|
|
|
} else if (match($0, /^Original-by:.*/)) {
|
|
|
|
if (ENVIRON["DOSOB"]==1)
|
|
|
|
print $0
|
2014-07-24 10:33:42 +08:00
|
|
|
} else if (match($0, /^Acked-by:.*/)) {
|
|
|
|
if (ENVIRON["DOSOB"]==1)
|
|
|
|
print $0
|
|
|
|
} else if (match($0, /^Reviewed-by:.*/)) {
|
|
|
|
if (ENVIRON["DOSOB"]==1)
|
|
|
|
print $0
|
|
|
|
} else if (match($0, /^Reported-by:.*/)) {
|
|
|
|
if (ENVIRON["DOSOB"]==1)
|
|
|
|
print $0
|
|
|
|
} else if (match($0, /^Tested-by:.*/)) {
|
|
|
|
if (ENVIRON["DOSOB"]==1)
|
|
|
|
print $0
|
|
|
|
} else if (match($0, /^Reported-and-tested-by:.*/)) {
|
|
|
|
if (ENVIRON["DOSOB"]==1)
|
|
|
|
print $0
|
|
|
|
} else if (match($0, /^Link:.*/)) {
|
|
|
|
if (ENVIRON["DOSOB"]==1)
|
2015-01-27 09:48:05 +08:00
|
|
|
print $0
|
2014-07-24 10:33:42 +08:00
|
|
|
} else if (match($0, /^Reference:.*/)) {
|
|
|
|
if (ENVIRON["DOSOB"]==1)
|
|
|
|
print $0
|
|
|
|
} else if (match($0, /^$/)) {
|
|
|
|
} else {
|
|
|
|
SOB=0
|
|
|
|
if (ENVIRON["DOSOB"]==0)
|
|
|
|
print $0
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (ENVIRON["DOSOB"]==0)
|
|
|
|
print $0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
' | tac
|
|
|
|
}
|
|
|
|
|
|
|
|
# Preset environments: LINK, AUTHOR, MAINTAINER, COMMITTER
|
|
|
|
# Arg 1: commit ID
|
|
|
|
# Arg 2: patch description file
|
|
|
|
generate_linux_desc()
|
|
|
|
{
|
|
|
|
split_desc $2 0
|
|
|
|
echo ""
|
|
|
|
generate_refs $1
|
|
|
|
generate_sobs $2 | awk '
|
|
|
|
{
|
|
|
|
if (printed[$0]==0) {
|
|
|
|
print $0
|
|
|
|
printed[$0]=1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
'
|
|
|
|
}
|
|
|
|
|
2016-12-27 15:46:27 +08:00
|
|
|
echo "[gen-patch.sh] Creating ACPICA repository ($after_name)..."
|
2013-09-18 12:41:12 -07:00
|
|
|
(
|
|
|
|
cd $GP_acpica_repo
|
|
|
|
git reset $after --hard >/dev/null 2>&1
|
|
|
|
)
|
|
|
|
|
2016-12-27 15:46:27 +08:00
|
|
|
echo "[gen-patch.sh] Creating ACPICA patch (acpica-$after_name.patch)..."
|
2013-09-18 12:41:12 -07:00
|
|
|
(
|
|
|
|
cd $GP_acpica_repo
|
|
|
|
git format-patch -1 --stdout >> $GP_acpica_patch
|
|
|
|
)
|
|
|
|
|
2016-12-27 15:46:27 +08:00
|
|
|
echo "[gen-patch.sh] Creating Linux repository ($after_name)..."
|
2013-09-18 12:41:12 -07:00
|
|
|
(
|
|
|
|
cd $GP_acpica_repo/generate/linux
|
|
|
|
if [ ! -f ./gen-repo.sh ]; then
|
|
|
|
cp $SRCDIR/generate/linux/gen-repo.sh ./
|
|
|
|
fi
|
2016-12-27 15:46:27 +08:00
|
|
|
./gen-repo.sh -c -n $HASH $after
|
2013-09-18 12:41:12 -07:00
|
|
|
)
|
2016-12-27 15:46:27 +08:00
|
|
|
mv -f $GP_acpica_repo/generate/linux/linux-$after_name $GP_linux_after
|
2013-09-18 12:41:12 -07:00
|
|
|
|
2016-12-27 15:46:27 +08:00
|
|
|
echo "[gen-patch.sh] Creating ACPICA repository ($before_name)..."
|
2013-09-18 12:41:12 -07:00
|
|
|
(
|
|
|
|
cd $GP_acpica_repo
|
|
|
|
git reset $before --hard >/dev/null 2>&1
|
|
|
|
)
|
|
|
|
|
2016-12-27 15:46:27 +08:00
|
|
|
echo "[gen-patch.sh] Creating Linux repository ($before_name)..."
|
2013-09-18 12:41:12 -07:00
|
|
|
(
|
|
|
|
cd $GP_acpica_repo/generate/linux
|
|
|
|
if [ ! -f ./gen-repo.sh ]; then
|
|
|
|
cp $SRCDIR/generate/linux/gen-repo.sh ./
|
|
|
|
fi
|
2016-12-27 15:46:27 +08:00
|
|
|
./gen-repo.sh -c -n $HASH $before
|
2013-09-18 12:41:12 -07:00
|
|
|
)
|
2016-12-27 15:46:27 +08:00
|
|
|
mv -f $GP_acpica_repo/generate/linux/linux-$before_name $GP_linux_before
|
2013-09-18 12:41:12 -07:00
|
|
|
|
|
|
|
(
|
2016-12-27 15:46:27 +08:00
|
|
|
echo "[gen-patch.sh] Creating Linux patch (linux-$after_name.patch)..."
|
2013-09-18 12:41:12 -07:00
|
|
|
cd $CURDIR
|
2016-10-14 21:25:42 +08:00
|
|
|
tmpdiff=`mktemp -u`
|
|
|
|
tmpdesc=`mktemp -u`
|
2016-12-27 15:46:27 +08:00
|
|
|
diff -Nurp linux.before_name linux.after_name >> $tmpdiff
|
2013-09-18 12:41:12 -07:00
|
|
|
|
|
|
|
if [ $? -ne 0 ]; then
|
2014-07-24 10:33:42 +08:00
|
|
|
generate_acpica_desc $after > $tmpdesc
|
2016-12-27 15:46:27 +08:00
|
|
|
generate_linux_desc $after_name $tmpdesc > $GP_linux_patch
|
2014-01-10 14:06:33 -08:00
|
|
|
$ACPISRC -ldqy $GP_linux_patch $GP_linux_patch > /dev/null
|
2013-09-18 12:41:12 -07:00
|
|
|
echo "---" >> $GP_linux_patch
|
2014-07-24 10:33:42 +08:00
|
|
|
diffstat $tmpdiff >> $GP_linux_patch
|
2013-09-18 12:41:12 -07:00
|
|
|
echo >> $GP_linux_patch
|
2014-07-24 10:33:42 +08:00
|
|
|
cat $tmpdiff >> $GP_linux_patch
|
2013-09-18 12:41:12 -07:00
|
|
|
else
|
2016-12-27 15:46:27 +08:00
|
|
|
echo "Warning: Linux version is empty, skipping $after_name..."
|
2013-09-18 12:41:12 -07:00
|
|
|
fi
|
2014-07-24 10:33:42 +08:00
|
|
|
rm -f $tmpdiff
|
|
|
|
rm -f $tmpdesc
|
2013-09-18 12:41:12 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
# Cleanup temporary directories
|
|
|
|
rm -rf $GP_linux_before
|
|
|
|
rm -rf $GP_linux_after
|
|
|
|
rm -rf $GP_acpica_repo
|