Created
October 8, 2020 10:53
-
-
Save vianpl/ec18a70949a5387503de54702996f0b4 to your computer and use it in GitHub Desktop.
Crappy backporting scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
check_series() { | |
[[ -z $1 ]] && { echo Commit range not provided; return 1; } | |
current_branch=$(git branch --show-current) | |
git log --pretty=format:'%h' --reverse $1 | while read patch; do | |
git checkout --quiet $patch | |
git log --pretty=oneline --abbrev-commit -1 | |
./scripts/sequence-patch.sh --rapid 1>/dev/null || { echo NOK; break; } | |
cd tmp/linux-5.3 | |
./run_oldconfig.sh --check 1>/dev/null || { echo NOK; break; } | |
cd - 1>/dev/null | |
echo OK | |
done | |
git checkout --quiet $current_branch | |
} | |
get_patches_usage() { | |
echo "Usage: [options] [ -r REFERENCE] <rev-list>" 1>&2 | |
echo " -r Bugzilla/Jira reference" 1>&2 | |
echo " -f File to look parse" 1>&2 | |
echo " -h This help" 1>&2 | |
} | |
__apply_patch() { | |
# Check patch isn't already applied | |
grep -r "Git-commit: $2" ../kernel-source/patches.suse 1>/dev/null && \ | |
echo "Bypass $patch, already exists" && return 0 | |
# Export the patch | |
patch_name=$(exportpatch --reference=$1 --dir=../kernel-source/patches.suse --write --suffix $patch) | |
[[ "$?" != 0 || -z "$patch_name" ]] && { echo "Failed to export $patch"; return; } | |
# add into series files | |
cd ../kernel-source/ | |
./scripts/git_sort/series_insert.py patches.suse/$patch_name | |
cd - 1>/dev/null | |
echo "Applied $1 -- $patch_name" | |
} | |
get_patches() { | |
local OPTIND | |
local file | |
local opt | |
local ref | |
while getopts ':hr:f:' opt; do | |
case ${opt} in | |
f) | |
file=${OPTARG} | |
;; | |
r) | |
ref=${OPTARG} | |
;; | |
h) | |
get_patches_usage | |
return 0 | |
;; | |
?) | |
echo "Unexpected option -${opt}" 1>&2 | |
get_patches_usage | |
return 1 | |
;; | |
esac | |
done | |
shift $((OPTIND-1)) | |
[[ -z $ref ]] && { echo "No reference provided"; get_patches_usage; return 1; } || \ | |
echo "Bugizlla/Jira reference $ref" | |
current_branch=$(git branch --show-current) | |
if [[ ! -z $file ]]; then | |
for patch in $(cat $file); do | |
__apply_patch $ref $patch | |
done | |
elif [[ ! -z $* ]]; then | |
for patch in $*;do | |
__apply_patch $ref $patch | |
done | |
else | |
while read -d " " patch; do | |
__apply_patch $ref $patch | |
done | |
fi | |
git checkout --quiet $current_branch | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment