Projects
Eulaceura:Factory
rubik
_service:obs_scm:gen-version.sh
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:obs_scm:gen-version.sh of Package rubik
#!/bin/bash ################################################################################################### # Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. # rubik 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 # 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. # See the Mulan PSL v2 for more details. # Author: Xiang Li # Create: 2021-12-27 # Description: This script used for update rubik version and release. Enjoy and cherrs ################################################################################################### # Basic info top_dir=$(git rev-parse --show-toplevel) version_file="${top_dir}/VERSION-vendor" spec_file="${top_dir}/rubik.spec" color=$(tput setaf 2) # red color_reset=$(tput sgr0) # Commit ID changeID=$(git log -1 | grep Change-Id | awk '{print $2}' | head -c 40) if [ "${changeID}" = "" ]; then changeID=$(date | sha256sum | head -c 40) fi echo "${changeID}" > "${top_dir}"/git-commit old_all=$(cat "${version_file}") old_version=$(awk -F"-" '{print $1}' < "${version_file}") old_release=$(awk -F"-" '{print $2}' < "${version_file}") major_old_version=$(echo "${old_version}" | awk -F "." '{print $1}') minor_old_version=$(echo "${old_version}" | awk -F "." '{print $2}') revision_old_version=$(echo "${old_version}" | awk -F "." '{print $3}') # Read user input read -rp "update version: Major(1), Minor(2), Revision(3), Release(4) [1/2/3/4]: " input case ${input} in 1) major_old_version=$((major_old_version + 1)) minor_old_version="0" revision_old_version="0" new_release_num="1" ;; 2) minor_old_version=$((minor_old_version + 1)) revision_old_version="0" new_release_num="1" ;; 3) revision_old_version=$((revision_old_version + 1)) new_release_num="1" ;; 4) new_release_num=$((old_release + 1)) ;; *) echo "Wrong input, Version Not modified: ${old_version}" exit 0 ;; esac author=$(git config user.name) email=$(git config user.email) # VERSION format: # Major.Minor.Revision new_version=${major_old_version}.${minor_old_version}.${revision_old_version} new_release="${new_release_num}" new_all=${new_version}-${new_release} new_changelog=$( cat << EOF * $(LC_ALL="C" date '+%a %b %d %Y') $author <$email> - $new_all\n- Type:\n- CVE:\n- SUG:\n- DESC:\n EOF ) # Replace version and release for spec and VERSION files sed -i -e "s/^Version: .*$/Version: ${new_version}/g" "${spec_file}" sed -i -e "s/^Release: .*$/Release: ${new_release}/g" "${spec_file}" sed -i -e "/\%changelog/a$new_changelog" "${spec_file}" echo "${new_all}" > "${version_file}" if [[ "${old_all}" != "${new_all}" ]]; then printf 'Version: %s -> %s\n' "${old_all}" "${color}${new_all}${color_reset}" fi
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2