bromite-buildtools/create-from-patch.sh

60 lines
1.1 KiB
Bash
Raw Permalink Normal View History

2021-04-28 16:32:53 +05:30
#!/bin/bash
PATCH=$1
PLEASEWAIT=0
if [[ $PATCH =~ ^+.* ]]; then
2022-01-14 19:09:12 +05:30
PLEASEWAIT=1
PATCH=${PATCH:1}
2021-04-28 16:32:53 +05:30
fi
if [ -z "$2" ]
then
2022-02-23 19:58:48 +05:30
PATCH_NEW_PATH=~/bromite/build/patches-new
2021-04-28 16:32:53 +05:30
else
2022-01-14 19:09:12 +05:30
PATCH_NEW_PATH=$2
2021-04-28 16:32:53 +05:30
fi
echo " Creating new patch"
git add .
HEAD=$(sed -n '1,/---/ p' $PATCH | sed '/^---/d')
CONTENT=$(git -C ~/chromium/src/ diff --cached --binary)
PATCH_FILE=$PATCH_NEW_PATH/$(basename $PATCH)
2022-01-14 19:09:12 +05:30
test -f $PATCH_FILE && rm $PATCH_FILE
2021-04-28 16:32:53 +05:30
echo "$HEAD" >$PATCH_FILE
NEWLINE=$(tail -n 1 "$PATCH_FILE")
2022-01-14 19:09:12 +05:30
#echo $NEWLINE
2021-04-28 16:32:53 +05:30
if [[ "$NEWLINE" == Subject:* ]]; then
2022-01-14 19:09:12 +05:30
echo "" >>$PATCH_FILE
2021-04-28 16:32:53 +05:30
else
2022-01-14 19:09:12 +05:30
NEWLINE=$(tail -n 2 "$PATCH_FILE" | head -n 1)
if [[ "$NEWLINE" == Subject:* ]]; then
echo "" >>$PATCH_FILE
fi
2021-07-31 17:45:32 +05:30
fi
2021-04-28 16:32:53 +05:30
echo "FILE:$(basename $PATCH)" >>$PATCH_FILE
echo "---" >>$PATCH_FILE
echo "$CONTENT" >>$PATCH_FILE
2021-09-23 14:30:57 +05:30
#echo press return
#read -n 1
2021-04-28 16:32:53 +05:30
git reset --hard
git clean -f -d
echo " Applying new patch"
2021-07-31 17:45:32 +05:30
OK=1
git am $PATCH_FILE || OK=0
if [[ OK -eq 0 ]]; then
2022-01-14 19:09:12 +05:30
if [ -n "$SILENT" ]; then
exit 1
fi
2021-07-31 17:45:32 +05:30
echo "---> Failed to apply. Press return"
read -n 1
fi