summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/build-compare/files/functions.sh-improve-deb-and-ipk-checking.patch
blob: 05420f89f7f04761dd3438643a166665b1d364a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
From b4eb7fde10318162bd2d02b9017ef51746752a91 Mon Sep 17 00:00:00 2001
From: Robert Yang <liezhi.yang@windriver.com>
Date: Thu, 14 Jul 2016 23:14:21 -0700
Subject: [PATCH 4/4] functions.sh: improve deb and ipk checking

* The deb and ipk's depends version string is like:
  Depends: libc6 (>= 2.24)
  Update trim_release_old and trim_release_new to match the bracket in
  the end ")".

* The deb's data tarball now is .tar.xz, and ipk's is .tar.gz.

* Update adjust_controlfile() to make ituse trim_release_old and
  trim_release_new.

Upstream-Status: Submitted [https://github.com/openSUSE/build-compare/pull/10]

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
 functions.sh | 45 ++++++++++++++++++++++++++++-----------------
 1 file changed, 28 insertions(+), 17 deletions(-)

diff --git a/functions.sh b/functions.sh
index aa572f9..fe493ba 100755
--- a/functions.sh
+++ b/functions.sh
@@ -78,7 +78,7 @@ check_header()
 function trim_release_old()
 {
   sed -e "
-  /\(\/boot\|\/lib\/modules\|\/lib\/firmware\|\/usr\/src\|$version_release_old_regex_l\$\)/{s,$version_release_old_regex_l,@VERSION@-@RELEASE_LONG@,g;s,$version_release_old_regex_s,@VERSION@-@RELEASE_SHORT@,g}
+  /\(\/boot\|\/lib\/modules\|\/lib\/firmware\|\/usr\/src\|$version_release_old_regex_l\$\|$version_release_old_regex_l)\)/{s,$version_release_old_regex_l,@VERSION@-@RELEASE_LONG@,g;s,$version_release_old_regex_s,@VERSION@-@RELEASE_SHORT@,g}
   s/\(\/var\/adm\/update-scripts\/\)${name_ver_rel_old_regex_l}\([^[:blank:]]\+\)/\1@NAME_VER_REL@\2/g
   s/^ *//g
   "
@@ -86,7 +86,7 @@ function trim_release_old()
 function trim_release_new()
 {
   sed -e "
-  /\(\/boot\|\/lib\/modules\|\/lib\/firmware\|\/usr\/src\|$version_release_new_regex_l\$\)/{s,$version_release_new_regex_l,@VERSION@-@RELEASE_LONG@,g;s,$version_release_new_regex_s,@VERSION@-@RELEASE_SHORT@,g}
+  /\(\/boot\|\/lib\/modules\|\/lib\/firmware\|\/usr\/src\|$version_release_new_regex_l\$\|$version_release_new_regex_l)\)/{s,$version_release_new_regex_l,@VERSION@-@RELEASE_LONG@,g;s,$version_release_new_regex_s,@VERSION@-@RELEASE_SHORT@,g}
   s/\(\/var\/adm\/update-scripts\/\)${name_ver_rel_new_regex_l}\([^[:blank:]]\+\)/\1@NAME_VER_REL@\2/g
   s/^ *//g
   "
@@ -133,8 +133,8 @@ function unpackage()
             ar x $file
             tar xf control.tar.gz
             rm control.tar.gz
-            tar xf data.tar.gz
-            rm data.tar.gz
+            tar xf data.tar.[xg]z
+            rm data.tar.[xg]z
             ;;
     esac
     popd 1>/dev/null
@@ -164,6 +164,22 @@ function get_value()
     sed -n -e "/^___${1}___/,/^___${1}___/p" $2 | sed -e "/^___${1}___/d"
 }
 
+# Set version_release_old_regex_s, version_release_old_regex_l and
+# name_ver_rel_old_regex_l, also the new ones.
+function set_regex() {
+    # Remember to quote the . which is in release
+    # Short version without B_CN
+    version_release_old_regex_s=${version_release_old%.*}
+    version_release_old_regex_s=${version_release_old_regex_s//./\\.}
+    version_release_new_regex_s=${version_release_new%.*}
+    version_release_new_regex_s=${version_release_new_regex_s//./\\.}
+    # Long version with B_CNT
+    version_release_old_regex_l=${version_release_old//./\\.}
+    version_release_new_regex_l=${version_release_new//./\\.}
+    name_ver_rel_old_regex_l=${name_ver_rel_old//./\\.}
+    name_ver_rel_new_regex_l=${name_ver_rel_new//./\\.}
+}
+
 # Compare just the rpm meta data of two rpms
 # Returns:
 # 0 in case of same content
@@ -194,17 +210,7 @@ function cmp_spec ()
     version_release_old="$(get_value QF_VER_REL $spec_old)"
     name_ver_rel_old="$(get_value QF_NAME_VER_REL $spec_old)"
 
-    # Remember to quote the . which is in release
-    # Short version without B_CN
-    version_release_old_regex_s=${version_release_old%.*}
-    version_release_old_regex_s=${version_release_old_regex_s//./\\.}
-    version_release_new_regex_s=${version_release_new%.*}
-    version_release_new_regex_s=${version_release_new_regex_s//./\\.}
-    # Long version with B_CNT
-    version_release_old_regex_l=${version_release_old//./\\.}
-    version_release_new_regex_l=${version_release_new//./\\.}
-    name_ver_rel_old_regex_l=${name_ver_rel_old//./\\.}
-    name_ver_rel_new_regex_l=${name_ver_rel_new//./\\.}
+    set_regex
 
     # Check the whole spec file at first, return 0 immediately if the
     # are the same.
@@ -285,9 +291,14 @@ function cmp_spec ()
 }
 
 function adjust_controlfile() {
-    cat $1/control | sed '/^Version: /d' > $1/control.fixed
+    version_release_old="`sed -ne 's/^Version: \(.*\)/\1/p' $1/control`"
+    name_ver_rel_old="`sed -n -e 's/^Package: \(.*\)/\1/p' $1/control`-`sed -n -e 's/^Version: \(.*\)/\1/p' $1/control`"
+    version_release_new="`sed -ne 's/^Version: \(.*\)/\1/p' $2/control`"
+    name_ver_rel_new="`sed -n -e 's/^Package: \(.*\)/\1/p' $2/control`-`sed -n -e 's/^Version: \(.*\)/\1/p' $2/control`"
+    set_regex
+    cat $1/control | trim_release_old > $1/control.fixed
     mv $1/control.fixed $1/control
-    cat $2/control | sed '/^Version: /d' > $2/control.fixed
+    cat $2/control | trim_release_new > $2/control.fixed
     mv $2/control.fixed $2/control
 }
 
-- 
2.9.0