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

1.1       snw         1: #!/usr/bin/env bash
                      2: 
                      3: #
1.3     ! snw         4: #   $Id: fmd-setversion,v 1.2 2025/04/04 19:43:18 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.3     ! snw        28: #   Revision 1.2  2025/04/04 19:43:18  snw
        !            29: #   Switch to using environment catalog to determine user and group for environment, and remove -u and -g flags from freem
        !            30: #
1.2       snw        31: #   Revision 1.1  2025/04/04 18:00:01  snw
                     32: #   *** empty log message ***
                     33: #
1.1       snw        34: #
                     35: # SPDX-FileCopyrightText:  (C) 2025 Coherent Logic Development LLC
                     36: # SPDX-License-Identifier: AGPL-3.0-or-later
                     37: #
                     38: 
1.3     ! snw        39: function usage()
        !            40: {
        !            41:     echo
        !            42:     echo "Sets the FreeM version in this repository"
        !            43:     echo
        !            44:     echo "usage:"
        !            45:     echo
        !            46:     echo "  fmd setversion <version>"
        !            47:     echo "   - Sets the FreeM version in this repository to <version>"
        !            48:     echo
        !            49:     echo "  fmd setversion --revert"
        !            50:     echo "   - Reverts to the previous FreeM version"
        !            51:     echo
        !            52:     exit 0
        !            53: }
        !            54: 
        !            55: if [[ $1 == "help" ]]
1.1       snw        56: then
1.3     ! snw        57:     usage
1.1       snw        58: fi
                     59: 
1.3     ! snw        60: if [[ $# == 0 ]]
1.1       snw        61: then
1.3     ! snw        62:     echo "setversion:  must be run from 'fmd setversion'"
1.1       snw        63:     exit 1
                     64: fi
                     65: 
                     66: CURVER=$(cat sem.ver)
                     67: OLDVER=$(cat ver.old)
                     68: FMD=$1
                     69: NEWVER=$2
                     70: 
                     71: if [[ $# == 1 ]]
                     72: then
                     73:     echo "setversion:  assuming new version is \"cvs-current\""
                     74:     NEWVER="cvs-current"
                     75: fi
                     76: 
                     77: if [[ "${NEWVER}" == "--revert" ]]
                     78: then
                     79:     NEWVER="${OLDVER}"
                     80:     echo "setversion:  reverting to previous version ${NEWVER}"
                     81: fi
                     82: 
                     83: if [[ "${CURVER}" == "${NEWVER}" ]]
                     84: then
                     85:     echo "setversion:  no change"
                     86:     exit 1
                     87: fi
                     88: 
                     89: echo "setversion:  version change ${CURVER} => ${NEWVER}"
                     90: echo "setversion:  backing up old version"
                     91: cp sem.ver ver.old
                     92: 
                     93: echo "${NEWVER}" > sem.ver
                     94: 
                     95: sed -i.orig "s/${CURVER}/${NEWVER}/g" doc/freem.texi
                     96: sed -i.orig "s/${CURVER}/${NEWVER}/g" configure.ac
                     97: 
                     98: VERSTR="VERSION ${NEWVER}"
                     99: 
                    100: echo "" >> ChangeLog
                    101: echo '********************************************************************************' >> ChangeLog
                    102: echo "${VERSTR}" >> ChangeLog
                    103: echo "" >> ChangeLog
                    104: 
1.2       snw       105: ${FMD} log "Change version from ${CURVER} to ${NEWVER}"
1.1       snw       106: 
                    107: ${FMD} changelog ${NEWVER}
                    108: 
                    109: 

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