2021-11-16 15:37:54 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
#
|
|
|
|
|
# usage:
|
|
|
|
|
# ./update-version.bash
|
2019-09-30 10:53:41 -04:00
|
|
|
#######################################################################
|
2019-12-25 15:50:34 +08:00
|
|
|
##- @Copyright (C) Huawei Technologies., Ltd. 2019. All rights reserved.
|
2020-04-27 09:43:55 +08:00
|
|
|
# - iSulad licensed under the Mulan PSL v2.
|
|
|
|
|
# - You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
|
|
|
# - You may obtain a copy of Mulan PSL v2 at:
|
|
|
|
|
# - http://license.coscl.org.cn/MulanPSL2
|
2019-09-30 10:53:41 -04:00
|
|
|
# - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
|
|
|
|
# - IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
|
|
|
|
# - PURPOSE.
|
2020-04-27 09:43:55 +08:00
|
|
|
# - See the Mulan PSL v2 for more details.
|
2019-09-30 10:53:41 -04:00
|
|
|
##- @Description: generate cetification
|
|
|
|
|
##- @Author: wujing
|
|
|
|
|
##- @Create: 2019-04-25
|
|
|
|
|
#######################################################################
|
|
|
|
|
topDir=$(git rev-parse --show-toplevel)
|
|
|
|
|
specfile="${topDir}/iSulad.spec"
|
|
|
|
|
old_version=$(cat ${specfile} | grep "%global" | grep "_version" | awk {'print $3'})
|
|
|
|
|
first_old_version=$(cat ${specfile} | grep "%global" | grep "_version" | awk {'print $3'} | awk -F "." {'print $1'})
|
|
|
|
|
second_old_version=$(cat ${specfile} | grep "%global" | grep "_version" | awk {'print $3'} | awk -F "." {'print $2'})
|
|
|
|
|
third_old_version=$(cat ${specfile} | grep "%global" | grep "_version" | awk {'print $3'} | awk -F "." {'print $3'})
|
2021-11-16 15:37:54 +08:00
|
|
|
read -p "Which level version do you want to upgrade?[1/2/3/r/N](default:N) select:" choice
|
2020-09-23 09:51:25 +08:00
|
|
|
if [[ ! -n "${choice}" ]] || [[ ${choice} == "N" ]]; then
|
2019-09-30 10:53:41 -04:00
|
|
|
echo "The version number has not been modified, it is still ${old_version}"
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [[ ${choice} -eq "1" ]]; then
|
|
|
|
|
first_old_version=$(($first_old_version+1))
|
|
|
|
|
second_old_version="0"
|
|
|
|
|
third_old_version="0"
|
|
|
|
|
elif [[ ${choice} -eq "2" ]]; then
|
|
|
|
|
second_old_version=$(($second_old_version+1))
|
|
|
|
|
third_old_version="0"
|
|
|
|
|
elif [[ ${choice} -eq "3" ]]; then
|
|
|
|
|
third_old_version=$(($third_old_version+1))
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
new_version=${first_old_version}.${second_old_version}.${third_old_version}
|
|
|
|
|
|
|
|
|
|
old_release=$(cat ${specfile} | grep "%global" | grep "_release" | awk {'print $3'})
|
2021-11-16 15:37:54 +08:00
|
|
|
new_release=$(($old_release+1))
|
2019-09-30 10:53:41 -04:00
|
|
|
sed -i "s/^\%global _version ${old_version}$/\%global _version ${new_version}/g" ${specfile}
|
|
|
|
|
sed -i "s/^\%global _release ${old_release}$/\%global _release ${new_release}/g" ${specfile}
|
|
|
|
|
|
2021-11-16 15:37:54 +08:00
|
|
|
echo "The release version has been modified: ${old_version}-${old_release} => ${new_version}-${new_release}"
|