[v7,03/10] buildtools: add ABI update shell script
Checks
Commit Message
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
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
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 :)
new file mode 100755
@@ -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