Annotation of freem/scripts/fmd-setversion, revision 1.4

1.1       snw         1: #!/usr/bin/env bash
                      2: 
                      3: #
1.4     ! snw         4: #   $Id: fmd-setversion,v 1.3 2025/04/06 03:38:05 snw Exp $
1.1       snw         5: #    Set version in FreeM repository
                      6: #
                      7: #  
                      8: #   Author: Serena Willis <snw@coherent-logic.com>
                      9: #    Copyright (C) 2025 Coherent Logic Development LLC
                     10: #
                     11: #
                     12: #   This file is part of FreeM.
                     13: #
                     14: #   FreeM is free software: you can redistribute it and/or modify
                     15: #   it under the terms of the GNU Affero Public License as published by
                     16: #   the Free Software Foundation, either version 3 of the License, or
                     17: #   (at your option) any later version.
                     18: #
                     19: #   FreeM is distributed in the hope that it will be useful,
                     20: #   but WITHOUT ANY WARRANTY; without even the implied warranty of
                     21: #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     22: #   GNU Affero Public License for more details.
                     23: #
                     24: #   You should have received a copy of the GNU Affero Public License
                     25: #   along with FreeM.  If not, see <https://www.gnu.org/licenses/>.
                     26: #
1.2       snw        27: #   $Log: fmd-setversion,v $
1.4     ! snw        28: #   Revision 1.3  2025/04/06 03:38:05  snw
        !            29: #   Prepare for adding packaging functionality to fmd
        !            30: #
1.3       snw        31: #   Revision 1.2  2025/04/04 19:43:18  snw
                     32: #   Switch to using environment catalog to determine user and group for environment, and remove -u and -g flags from freem
                     33: #
1.2       snw        34: #   Revision 1.1  2025/04/04 18:00:01  snw
                     35: #   *** empty log message ***
                     36: #
1.1       snw        37: #
                     38: # SPDX-FileCopyrightText:  (C) 2025 Coherent Logic Development LLC
                     39: # SPDX-License-Identifier: AGPL-3.0-or-later
                     40: #
                     41: 
1.3       snw        42: function usage()
                     43: {
                     44:     echo
                     45:     echo "Sets the FreeM version in this repository"
                     46:     echo
                     47:     echo "usage:"
                     48:     echo
                     49:     echo "  fmd setversion <version>"
                     50:     echo "   - Sets the FreeM version in this repository to <version>"
                     51:     echo
                     52:     echo "  fmd setversion --revert"
                     53:     echo "   - Reverts to the previous FreeM version"
                     54:     echo
                     55:     exit 0
                     56: }
                     57: 
                     58: if [[ $1 == "help" ]]
1.1       snw        59: then
1.3       snw        60:     usage
1.1       snw        61: fi
                     62: 
1.3       snw        63: if [[ $# == 0 ]]
1.1       snw        64: then
1.3       snw        65:     echo "setversion:  must be run from 'fmd setversion'"
1.1       snw        66:     exit 1
                     67: fi
                     68: 
                     69: CURVER=$(cat sem.ver)
                     70: OLDVER=$(cat ver.old)
                     71: FMD=$1
                     72: NEWVER=$2
                     73: 
                     74: if [[ $# == 1 ]]
                     75: then
                     76:     echo "setversion:  assuming new version is \"cvs-current\""
                     77:     NEWVER="cvs-current"
                     78: fi
                     79: 
                     80: if [[ "${NEWVER}" == "--revert" ]]
                     81: then
                     82:     NEWVER="${OLDVER}"
                     83:     echo "setversion:  reverting to previous version ${NEWVER}"
                     84: fi
                     85: 
                     86: if [[ "${CURVER}" == "${NEWVER}" ]]
                     87: then
                     88:     echo "setversion:  no change"
                     89:     exit 1
                     90: fi
                     91: 
                     92: echo "setversion:  version change ${CURVER} => ${NEWVER}"
                     93: echo "setversion:  backing up old version"
                     94: cp sem.ver ver.old
                     95: 
                     96: echo "${NEWVER}" > sem.ver
                     97: 
                     98: sed -i.orig "s/${CURVER}/${NEWVER}/g" doc/freem.texi
                     99: sed -i.orig "s/${CURVER}/${NEWVER}/g" configure.ac
1.4     ! snw       100: sed -i.orig "s/${CURVER}/${NEWVER}/g" doc/freem_conformance.1
1.1       snw       101: 
                    102: VERSTR="VERSION ${NEWVER}"
                    103: 
                    104: echo "" >> ChangeLog
                    105: echo '********************************************************************************' >> ChangeLog
                    106: echo "${VERSTR}" >> ChangeLog
                    107: echo "" >> ChangeLog
                    108: 
1.2       snw       109: ${FMD} log "Change version from ${CURVER} to ${NEWVER}"
1.1       snw       110: 
                    111: ${FMD} changelog ${NEWVER}
                    112: 
                    113: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>