diff options
author | Hugues Hiegel <hugues@hiegel.fr> | 2009-02-06 11:44:09 +0100 |
---|---|---|
committer | Hugues Hiegel <hugues@hiegel.fr> | 2009-02-06 11:44:09 +0100 |
commit | f0dd1e566d56e03b7fa4db6f0e33a6df844b0ae4 (patch) | |
tree | 1cb8bc02c8a8aff01b7096b0233c7a29577520dd | |
parent | 582dfd16fbf04ecb487914fddef5e8ccdf4be26c (diff) |
[STLinux] import_patches factorization
-rwxr-xr-x | STLinux/stlinux_import_patches.sh | 45 |
1 files changed, 19 insertions, 26 deletions
diff --git a/STLinux/stlinux_import_patches.sh b/STLinux/stlinux_import_patches.sh index 1f12198..7865e45 100755 --- a/STLinux/stlinux_import_patches.sh +++ b/STLinux/stlinux_import_patches.sh @@ -30,6 +30,22 @@ grep -if =(grep "^%patch" $STLINUX_FOLDER/*.spec | sed 's/%\(patch.*\) .*/^\1:/' #cat $PATCHES_LIST +function read_patch_file() +{ + case $1:e in + "patch") + < $1 + ;; + "bz2") + bunzip -c $1 + ;; + "*") + echo >&2 "Error ! $1:e is not a recognized patch extension !" + exit; + ;; + esac +} + export RELEASE="" for file in $(cat $PATCHES_LIST ) do @@ -44,10 +60,6 @@ do file=$file:r fi - ext=$file:e - - #( preprint $file $color[white] ; echo ; ) >&2 - ( # # On extrait le numéro de release ST dans le nom du fichier .patch @@ -73,23 +85,15 @@ do RELEASE="" fi - # Voici la première ligne du message de commit + # Voici la première ligne du message de commit. C'est la plus jolie. echo "[Patch #$i] ${RELEASE}Applied $file" # # On récupère le commentaire dans le patch en guise de message de commit # avec gestion des .patch ou des .patch.bz2 # - case $ext in - "patch") - awk '{ RS="--- "; } { if ( NR <= 2 ) { print $0 } }' < $STLINUX_FOLDER/$file | \ - grep -v -e "^diff \-" -e "^Index: " -e "^=*$" -e "^Signed-off-by: " -e "^index "; - ;; - "bz2") - bunzip2 -c $STLINUX_FOLDER/$file | awk '{ RS="--- "; } { if ( NR <= 2 ) { print $0 } }' | \ + read_patch_file $STLINUX_FOLDER/$file | awk '{ RS="--- "; } { if ( NR <= 2 ) { print $0 } }' | \ grep -v -e "^diff \-" -e "^Index: " -e "^=*$" -e "^Signed-off-by: " -e "^index "; - ;; - esac ) | sed 's/
//' > .git/message ; @@ -99,18 +103,7 @@ do # On affiche le résultat de l'application du patch dans le message de commit # echo "---" >> .git/message - case $ext in - "bz2") - bunzip2 $STLINUX_FOLDER/$file | patch -Np1 >> .git/message - ;; - "patch") - patch -Np1 < $STLINUX_FOLDER/$file >> .git/message - ;; - *) - echo "$ext NOT SUPPORTED !!" - exit - ;; - esac + read_patch_file $STLINUX_FOLDER/$file | patch -Np1 >> .git/message # Suppression des fichiers supprimés par le patch git-rm $(git-ls-files --deleted) 2>/dev/null # Ajout de tout le reste :-) |