| #!/bin/bash |
| # |
| # Copyright 2023 Google LLC |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); |
| # you may not use this file except in compliance with the License. |
| # You may obtain a copy of the License at |
| # |
| # https://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| # |
| # This script is given one argument: the base of the source directory of |
| # the package, and it prints a string on stdout with the numerical version |
| # number for said repo. |
| # |
| # shellcheck disable=SC2001 |
| set -ex |
| |
| |
| function get_ebuild() { |
| ls -- *-r*.ebuild |
| } |
| |
| function get_revision() { |
| local ebuild; ebuild="$(ls -- *-r*.ebuild)" |
| local ebuild="${ebuild%.ebuild}" |
| local revision="${ebuild#*-r}" |
| echo "${revision}" |
| } |
| |
| DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")")" |
| COS_KERNEL="${DIR}/../../../project-lakitu/sys-kernel/lakitu-kernel-6_1/" |
| COS_EBUILD="$(ls -- "${COS_KERNEL}"/lakitu-kernel-6_1*r*.ebuild)" |
| COS_EBUILD_VERSION="$(echo "${COS_EBUILD}" | sed 's/.*lakitu-kernel-6_1-\([0-9\.]*\)-.*/\1/')" |
| VERSIONS="$(grep CROS_WORKON_ "${COS_EBUILD}")" |
| EBUILD="$(get_ebuild)" |
| BASE_EBUILD="$(realpath "${EBUILD}")" |
| REV="$(get_revision)" |
| NEXT_REV=$((REV+1)) |
| for line in ${VERSIONS}; do |
| sed -i "s,${line%=*}=.*,${line}," "${BASE_EBUILD}" |
| done |
| NEW_BASE_NAME="lakitu-kernel-6_1-${COS_EBUILD_VERSION}" |
| mv "${BASE_EBUILD}" "${NEW_BASE_NAME}.ebuild" |
| rm "${EBUILD}" |
| ln -s "${NEW_BASE_NAME}.ebuild" "${NEW_BASE_NAME}-r${NEXT_REV}.ebuild" |