bromite-buildtools/create-from-patch.sh

57 lines
989 B
Bash
Raw Normal View History

2021-04-28 16:32:53 +05:30
#!/bin/bash
PATCH=$1
PLEASEWAIT=0
if [[ $PATCH =~ ^+.* ]]; then
PLEASEWAIT=1
PATCH=${PATCH:1}
fi
if [ -z "$2" ]
then
PATCH_NEW_PATH="~/bromite/build/patches-new"
else
PATCH_NEW_PATH=$2
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)
rm $PATCH_FILE
echo "$HEAD" >$PATCH_FILE
NEWLINE=$(tail -n 1 "$PATCH_FILE")
echo $NEWLINE
if [[ "$NEWLINE" == Subject:* ]]; then
echo "" >>$PATCH_FILE
else
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-07-31 17:45:32 +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
echo "---> Failed to apply. Press return"
read -n 1
fi