From b34479fe9a150a63dd852eb1ba2f5d9d33bd887d Mon Sep 17 00:00:00 2001 From: Carmelo Messina Date: Thu, 26 Nov 2020 08:53:00 +0100 Subject: [PATCH] first initial commit --- .gitignore | 5 +++ apply-all-patch.sh | 40 ++++++++++++++++++++++ apply-single-patch.sh | 75 ++++++++++++++++++++++++++++++++++++++++++ export-all-patch.sh | 26 +++++++++++++++ export-single-patch.sh | 35 ++++++++++++++++++++ 5 files changed, 181 insertions(+) create mode 100644 .gitignore create mode 100644 apply-all-patch.sh create mode 100644 apply-single-patch.sh create mode 100644 export-all-patch.sh create mode 100644 export-single-patch.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d6c4114 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +################################################################################ +# This .gitignore file was automatically created by Microsoft(R) Visual Studio. +################################################################################ + +/.vs diff --git a/apply-all-patch.sh b/apply-all-patch.sh new file mode 100644 index 0000000..fed822f --- /dev/null +++ b/apply-all-patch.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +git am --abort + +PATCH_OLD_PATH=../../bromite/build/patches +PATCH_NEW_PATH=../../bromite/build/patches-new +DESTINATION=~/bromite/build/bromite_patches_list_ok.txt +DESTINATION_FAILED=~/bromite/build/bromite_patches_list_failed.txt + +rm $DESTINATION +rm $DESTINATION_FAILED +mkdir $PATCH_NEW_PATH + +IFS=$'\n' + +#cp ~/bromite/build/bromite_patches_list.txt ~/bromite/build/bromite_patches_list_new.txt + +echo "Phase 1: check clean" +for current_file in $(cat ~/bromite/build/bromite_patches_list_new.txt); do + + if [[ $current_file =~ ^#.* ]]; then + + echo "Executing $current_file" + eval "${current_file:1}" + echo $current_file >>$DESTINATION + + else + + bash /home/cab/apply-single-patch.sh $PATCH_OLD_PATH/$current_file $PATCH_NEW_PATH + + echo $PATCH_FILE + + echo "" + LAST_COMMIT=$(git rev-parse HEAD) + echo "Last Commit " $LAST_COMMIT + bash /home/cab/export-single-patch.sh $LAST_COMMIT + + fi + +done diff --git a/apply-single-patch.sh b/apply-single-patch.sh new file mode 100644 index 0000000..527a7c4 --- /dev/null +++ b/apply-single-patch.sh @@ -0,0 +1,75 @@ +#!/bin/bash + +PATCH=$1 + +if [ -z "$2" ] +then + PATCH_NEW_PATH="/home/cab/bromite/build/patches-new" +else + PATCH_NEW_PATH=$2 +fi + +dos2unix $PATCH + +echo "" +echo "Applying patch $PATCH" +git apply --reject --whitespace=fix $PATCH + +for file in $(find . -name *.rej); do + echo " -> Check $file"; + wiggle --replace ${file::-4} $file && rm $file && rm ${file::-4}.porig && echo " OK"; +done + +OK=1 +for file in $(find . -name *.rej); do + echo "---Found: $file"; + OK=0 +done + +if [[ OK -eq 0 ]]; then + echo "Patch not apply cleanly. Please fix..." + echo "Press return" + read -n 1 + +else + echo "Patch apply cleanly." + +fi + +echo " Deleting rej" +find . -type f -name '*.rej' -delete +find . -type f -name '*.porig' -delete + +#echo "Read to add. Press return" +#read -n 1 + +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 +fi + +echo "FILE:$(basename $PATCH)" >>$PATCH_FILE +echo "---" >>$PATCH_FILE +echo "$CONTENT" >>$PATCH_FILE + +git reset --hard +git clean -f -d + +echo " Applying new patch" +git am $PATCH_FILE diff --git a/export-all-patch.sh b/export-all-patch.sh new file mode 100644 index 0000000..419033f --- /dev/null +++ b/export-all-patch.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +VERSION=$(cat ~/bromite/build/RELEASE) +CURRENT_RELEASE=$(git -C ~/chromium/src/ rev-parse --verify refs/tags/$VERSION) + +ALLPATCHS=$(git -C ~/chromium/src/ rev-list HEAD...$CURRENT_RELEASE) + +mkdir ~/bromite/build/patches-new + +NO_NAME=1 + +for patch in $ALLPATCHS; do + + PATCH_FILE=$(git -C ~/chromium/src/ show -s $patch | grep FILE: | sed 's/FILE://g' | sed 's/^[ \t]*//;s/[ \t]*$//') + if [ -z "$PATCH_FILE" ] + then + PATCH_FILE=$NO_NAME.patch + NO_NAME=$NO_NAME.1 + + echo No Name ${NO_NAME}, press return + read -n 1 + fi + + bash ~/export-single-patch.sh $patch $PATCH_FILE + +done diff --git a/export-single-patch.sh b/export-single-patch.sh new file mode 100644 index 0000000..93d995d --- /dev/null +++ b/export-single-patch.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +patch=$1 +output=$2 + +PATCH_FILE=$(git -C ~/chromium/src/ show -s $patch | grep FILE: | sed 's/FILE://g' | sed 's/^[ \t]*//;s/[ \t]*$//') +if [ -z "$output" ] +then + echo Exporting $patch ~/bromite/build/patches-new/$PATCH_FILE +else + PATCH_FILE=$output + echo Exporting new $patch ~/bromite/build/patches-new/$PATCH_FILE +fi + +git -C ~/chromium/src/ format-patch -1 --keep-subject --stdout --full-index --zero-commit --no-signature $patch >~/bromite/build/patches-new/$PATCH_FILE + +while read line; do + #echo $line + if [[ "$line" == index* ]]; then + next_line=$(grep -A1 "${line}" ~/bromite/build/patches-new/$PATCH_FILE | tail -n 1 ) + if [[ "$next_line" != "GIT binary patch" ]]; then + sed -i "/^$line/d" ~/bromite/build/patches-new/$PATCH_FILE + fi + fi +done <~/bromite/build/patches-new/$PATCH_FILE + +sed -i '/^From 0000000000000000000000000000000000000000/d' ~/bromite/build/patches-new/$PATCH_FILE +sed -i '/^FILE:/d' ~/bromite/build/patches-new/$PATCH_FILE +sed -i '/^ mode change/d' ~/bromite/build/patches-new/$PATCH_FILE +sed -i '/^old mode /d' ~/bromite/build/patches-new/$PATCH_FILE +sed -i '/^new mode /d' ~/bromite/build/patches-new/$PATCH_FILE + +echo "-- " >> ~/bromite/build/patches-new/$PATCH_FILE +echo "2.17.1" >> ~/bromite/build/patches-new/$PATCH_FILE +echo "" >> ~/bromite/build/patches-new/$PATCH_FILE