fix packaging issue while adding new patch
authorZhang Qiang <qiang.z.zhang@intel.com>
Tue, 6 Dec 2011 04:49:48 +0000 (12:49 +0800)
committerZhang Qiang <qiang.z.zhang@intel.com>
Tue, 6 Dec 2011 04:49:48 +0000 (12:49 +0800)
This scripts can't work if 'Patch' info contains in specfile, so we
should pattern 'Patch' from the beginning of lines.

Also sort patch number first, then select the last one.

data/packaging.sh

index e89e6fd..0d4b6d9 100644 (file)
@@ -142,14 +142,14 @@ update_patches()
     # no new patch 
     if [  -n "$newadd_patch" ]; then
         # Find the insert line num
-        line_num=$(grep Patch[0-9]* -r $spec -n|tail -1|cut -d':' -f1)
+        line_num=$(grep "^Patch[0-9]*" -r $spec -n|tail -1|cut -d':' -f1)
         # No patch. Insert after Source
         if [ -z "$line_num" ]; then
             line_num=$(grep Source[0-9]* -r $spec -n|tail -1|cut -d':' -f1)
             num=0
         else
             # The first patch number
-            num=$(grep Patch[0-9]* $spec |tail -1|sed 's/Patch\([0-9]*\):.*/\1/')
+            num=$(grep "^Patch[0-9]*" $spec |sed 's/Patch\([0-9]*\):.*/\1/' |sort -n |tail -1)
             num=$(expr $num + 1)
         fi