Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1 | From b4eb7fde10318162bd2d02b9017ef51746752a91 Mon Sep 17 00:00:00 2001 |
| 2 | From: Robert Yang <liezhi.yang@windriver.com> |
| 3 | Date: Thu, 14 Jul 2016 23:14:21 -0700 |
| 4 | Subject: [PATCH 4/4] functions.sh: improve deb and ipk checking |
| 5 | |
| 6 | * The deb and ipk's depends version string is like: |
| 7 | Depends: libc6 (>= 2.24) |
| 8 | Update trim_release_old and trim_release_new to match the bracket in |
| 9 | the end ")". |
| 10 | |
| 11 | * The deb's data tarball now is .tar.xz, and ipk's is .tar.gz. |
| 12 | |
| 13 | * Update adjust_controlfile() to make ituse trim_release_old and |
| 14 | trim_release_new. |
| 15 | |
| 16 | Upstream-Status: Submitted [https://github.com/openSUSE/build-compare/pull/10] |
| 17 | |
| 18 | Signed-off-by: Robert Yang <liezhi.yang@windriver.com> |
| 19 | --- |
| 20 | functions.sh | 45 ++++++++++++++++++++++++++++----------------- |
| 21 | 1 file changed, 28 insertions(+), 17 deletions(-) |
| 22 | |
| 23 | diff --git a/functions.sh b/functions.sh |
| 24 | index aa572f9..fe493ba 100755 |
| 25 | --- a/functions.sh |
| 26 | +++ b/functions.sh |
| 27 | @@ -78,7 +78,7 @@ check_header() |
| 28 | function trim_release_old() |
| 29 | { |
| 30 | sed -e " |
| 31 | - /\(\/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} |
| 32 | + /\(\/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} |
| 33 | s/\(\/var\/adm\/update-scripts\/\)${name_ver_rel_old_regex_l}\([^[:blank:]]\+\)/\1@NAME_VER_REL@\2/g |
| 34 | s/^ *//g |
| 35 | " |
| 36 | @@ -86,7 +86,7 @@ function trim_release_old() |
| 37 | function trim_release_new() |
| 38 | { |
| 39 | sed -e " |
| 40 | - /\(\/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} |
| 41 | + /\(\/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} |
| 42 | s/\(\/var\/adm\/update-scripts\/\)${name_ver_rel_new_regex_l}\([^[:blank:]]\+\)/\1@NAME_VER_REL@\2/g |
| 43 | s/^ *//g |
| 44 | " |
| 45 | @@ -133,8 +133,8 @@ function unpackage() |
| 46 | ar x $file |
| 47 | tar xf control.tar.gz |
| 48 | rm control.tar.gz |
| 49 | - tar xf data.tar.gz |
| 50 | - rm data.tar.gz |
| 51 | + tar xf data.tar.[xg]z |
| 52 | + rm data.tar.[xg]z |
| 53 | ;; |
| 54 | esac |
| 55 | popd 1>/dev/null |
| 56 | @@ -164,6 +164,22 @@ function get_value() |
| 57 | sed -n -e "/^___${1}___/,/^___${1}___/p" $2 | sed -e "/^___${1}___/d" |
| 58 | } |
| 59 | |
| 60 | +# Set version_release_old_regex_s, version_release_old_regex_l and |
| 61 | +# name_ver_rel_old_regex_l, also the new ones. |
| 62 | +function set_regex() { |
| 63 | + # Remember to quote the . which is in release |
| 64 | + # Short version without B_CN |
| 65 | + version_release_old_regex_s=${version_release_old%.*} |
| 66 | + version_release_old_regex_s=${version_release_old_regex_s//./\\.} |
| 67 | + version_release_new_regex_s=${version_release_new%.*} |
| 68 | + version_release_new_regex_s=${version_release_new_regex_s//./\\.} |
| 69 | + # Long version with B_CNT |
| 70 | + version_release_old_regex_l=${version_release_old//./\\.} |
| 71 | + version_release_new_regex_l=${version_release_new//./\\.} |
| 72 | + name_ver_rel_old_regex_l=${name_ver_rel_old//./\\.} |
| 73 | + name_ver_rel_new_regex_l=${name_ver_rel_new//./\\.} |
| 74 | +} |
| 75 | + |
| 76 | # Compare just the rpm meta data of two rpms |
| 77 | # Returns: |
| 78 | # 0 in case of same content |
| 79 | @@ -194,17 +210,7 @@ function cmp_spec () |
| 80 | version_release_old="$(get_value QF_VER_REL $spec_old)" |
| 81 | name_ver_rel_old="$(get_value QF_NAME_VER_REL $spec_old)" |
| 82 | |
| 83 | - # Remember to quote the . which is in release |
| 84 | - # Short version without B_CN |
| 85 | - version_release_old_regex_s=${version_release_old%.*} |
| 86 | - version_release_old_regex_s=${version_release_old_regex_s//./\\.} |
| 87 | - version_release_new_regex_s=${version_release_new%.*} |
| 88 | - version_release_new_regex_s=${version_release_new_regex_s//./\\.} |
| 89 | - # Long version with B_CNT |
| 90 | - version_release_old_regex_l=${version_release_old//./\\.} |
| 91 | - version_release_new_regex_l=${version_release_new//./\\.} |
| 92 | - name_ver_rel_old_regex_l=${name_ver_rel_old//./\\.} |
| 93 | - name_ver_rel_new_regex_l=${name_ver_rel_new//./\\.} |
| 94 | + set_regex |
| 95 | |
| 96 | # Check the whole spec file at first, return 0 immediately if the |
| 97 | # are the same. |
| 98 | @@ -285,9 +291,14 @@ function cmp_spec () |
| 99 | } |
| 100 | |
| 101 | function adjust_controlfile() { |
| 102 | - cat $1/control | sed '/^Version: /d' > $1/control.fixed |
| 103 | + version_release_old="`sed -ne 's/^Version: \(.*\)/\1/p' $1/control`" |
| 104 | + name_ver_rel_old="`sed -n -e 's/^Package: \(.*\)/\1/p' $1/control`-`sed -n -e 's/^Version: \(.*\)/\1/p' $1/control`" |
| 105 | + version_release_new="`sed -ne 's/^Version: \(.*\)/\1/p' $2/control`" |
| 106 | + name_ver_rel_new="`sed -n -e 's/^Package: \(.*\)/\1/p' $2/control`-`sed -n -e 's/^Version: \(.*\)/\1/p' $2/control`" |
| 107 | + set_regex |
| 108 | + cat $1/control | trim_release_old > $1/control.fixed |
| 109 | mv $1/control.fixed $1/control |
| 110 | - cat $2/control | sed '/^Version: /d' > $2/control.fixed |
| 111 | + cat $2/control | trim_release_new > $2/control.fixed |
| 112 | mv $2/control.fixed $2/control |
| 113 | } |
| 114 | |
| 115 | -- |
| 116 | 2.9.0 |
| 117 | |