[v7,03/10] buildtools: add ABI update shell script

Message ID d1af51f1795ee2e8f3a0180a7655ae707760916b.1573230233.git.anatoly.burakov@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series Implement the new ABI policy and add helper scripts |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Burakov, Anatoly Nov. 8, 2019, 4:25 p.m. UTC
  In order to facilitate mass updating of version files, add a shell
script that recurses into lib/ and drivers/ directories and calls
the ABI version update script.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---

Notes:
    v3:
    - Switch to sh rather than bash, and remove bash-isms
    - Address review comments
    
    v2:
    - Add this patch to split the shell script from previous commit
    - Fixup miscellaneous bugs

 buildtools/update-abi.sh | 42 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100755 buildtools/update-abi.sh
  

Comments

Thomas Monjalon Nov. 19, 2019, 5:38 p.m. UTC | #1
08/11/2019 17:25, Anatoly Burakov:
> In order to facilitate mass updating of version files, add a shell
> script that recurses into lib/ and drivers/ directories and calls
> the ABI version update script.
> 
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> --- /dev/null
> +++ b/buildtools/update-abi.sh
> @@ -0,0 +1,42 @@
> +#!/bin/sh

For such script, I think -e is mandatory, so we do not miss any error.
It would just require merge following check in the "if":

> +# check version string format
> +echo $abi_version | grep -q -e "^[[:digit:]]\{1,2\}\.[[:digit:]]\{1,2\}$"
> +if [ "$?" -ne 0 ]; then
> +      # output to stderr
> +      >&2 echo "ABI version must be formatted as MAJOR.MINOR version"
> +      exit 1
> +fi
  
Burakov, Anatoly Nov. 20, 2019, 11:50 a.m. UTC | #2
On 19-Nov-19 5:38 PM, Thomas Monjalon wrote:
> 08/11/2019 17:25, Anatoly Burakov:
>> In order to facilitate mass updating of version files, add a shell
>> script that recurses into lib/ and drivers/ directories and calls
>> the ABI version update script.
>>
>> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
>> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
>> --- /dev/null
>> +++ b/buildtools/update-abi.sh
>> @@ -0,0 +1,42 @@
>> +#!/bin/sh
> 
> For such script, I think -e is mandatory, so we do not miss any error.
> It would just require merge following check in the "if":
> 

As was discussed on IRC, i'm fine with -e added to shebang, but i don't 
like if statements that take half of my monitor :) I would rather put it 
into a function. I just tested it:

```
#!/bin/sh -e

func() {
         false
}

if [ !func ]; then
         echo "Error"
fi
func
echo "This is never reached"
```

This outputs "Error". So i think i'll go ahead and make it into a 
function. This would still leave the code readable, *and* satisfy the 
"#!/bin/sh -e" shebang requirement :)
  

Patch

diff --git a/buildtools/update-abi.sh b/buildtools/update-abi.sh
new file mode 100755
index 0000000000..89ba5804a6
--- /dev/null
+++ b/buildtools/update-abi.sh
@@ -0,0 +1,42 @@ 
+#!/bin/sh
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2019 Intel Corporation
+
+abi_version=$1
+abi_version_file="./config/ABI_VERSION"
+update_path="lib drivers"
+
+if [ -z "$1" ]; then
+      # output to stderr
+      >&2 echo "Please provide ABI version"
+      exit 1
+fi
+
+# check version string format
+echo $abi_version | grep -q -e "^[[:digit:]]\{1,2\}\.[[:digit:]]\{1,2\}$"
+if [ "$?" -ne 0 ]; then
+      # output to stderr
+      >&2 echo "ABI version must be formatted as MAJOR.MINOR version"
+      exit 1
+fi
+
+if [ -n "$2" ]; then
+      abi_version_file=$2
+fi
+
+if [ -n "$3" ]; then
+      # drop $1 and $2
+      shift 2
+      # assign all other arguments as update paths
+      update_path=$@
+fi
+
+echo "New ABI version:" $abi_version
+echo "ABI_VERSION path:" $abi_version_file
+echo "Path to update:" $update_path
+
+echo $abi_version > $abi_version_file
+
+find $update_path -name  \*version.map -exec \
+      ./buildtools/update_version_map_abi.py {} \
+      $abi_version \; -print