1: #!/usr/bin/env bash
2:
3: #
4: # $Id: fmd-changelog,v 1.3 2025/04/07 00:45:52 snw Exp $
5: # Gets the changelog for a specific version
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: #
27: # $Log: fmd-changelog,v $
28: # Revision 1.3 2025/04/07 00:45:52 snw
29: # Enhance fmd-pkg-dpkg to auto-generate the debian/changelog file from the FreeM ChangeLog
30: #
31: # Revision 1.2 2025/04/06 03:38:05 snw
32: # Prepare for adding packaging functionality to fmd
33: #
34: # Revision 1.1 2025/04/04 18:00:01 snw
35: # *** empty log message ***
36: #
37: #
38: # SPDX-FileCopyrightText: (C) 2025 Coherent Logic Development LLC
39: # SPDX-License-Identifier: AGPL-3.0-or-later
40: #
41:
42: MINIMAL=0
43:
44: function usage() {
45: echo
46: echo "Prints a FreeM ChangeLog entry"
47: echo
48: echo "usage:"
49: echo
50: echo " fmd changelog [--minimal] [<freem-version>]"
51: echo
52: echo " If the '--minimal' flag is specified, will print only the ChangeLog entries"
53: echo " without the version header."
54: echo
55: echo " If <freem-version> is omitted, fmd changelog will assume you want the ChangeLog"
56: echo " for the current version in your copy of the repository."
57: echo
58: exit 1
59: }
60:
61: if [[ $1 == "help" ]]
62: then
63: usage
64: fi
65:
66: if [[ $# == 0 ]]
67: then
68: echo "changelog: must be run from 'fmd changelog'"
69: exit 1
70: fi
71:
72: if [[ ! -f sem.ver ]]
73: then
74: echo "Not in the root of the FreeM repository."
75: exit 1
76: fi
77:
78: if [[ $# < 2 ]]
79: then
80: if [[ $# == 1 ]]
81: then
82: FREEM_VERSION=$(cat sem.ver)
83: else
84: usage
85: fi
86: fi
87:
88: if [[ $# == 2 ]]
89: then
90: if [[ "$2" == "--minimal" ]]
91: then
92: MINIMAL=1
93: FREEM_VERSION=$(cat sem.ver)
94: else
95: FREEM_VERSION=$2
96: fi
97: elif [[ $# == 3 ]]
98: then
99: if [[ "$2" != "--minimal" ]]
100: then
101: usage
102: fi
103: FREEM_VERSION=$3
104: MINIMAL=1
105: fi
106:
107: VERSTR="VERSION ${FREEM_VERSION}"
108:
109: egrep "^${VERSTR}" ChangeLog &> /dev/null
110: RESULT=$?
111:
112: if [[ ${RESULT} != 0 ]]
113: then
114: echo "setversion: version ${FREEM_VERSION} not found in ChangeLog"
115: exit 1
116: fi
117:
118: DIVIDER='********************************************************************************'
119: INVER=0
120:
121:
122: while read -r LINE
123: do
124: if [[ "${LINE}" == "${VERSTR}" ]]
125: then
126: if [[ ${MINIMAL} == 0 ]]
127: then
128: echo "${LINE}"
129: fi
130: INVER=1
131: else
132: if [[ ${INVER} == 1 ]]
133: then
134: if [[ "${LINE:0:2}" == '**' ]]
135: then
136: exit 0
137: fi
138: if [[ ${MINIMAL} == 0 ]]
139: then
140: echo " ${LINE}"
141: else
142: if [[ "${LINE:0:1}" == '*' ]]
143: then
144: OLINE=$(echo "${LINE}" | cut -d\* -f2)
145: echo "${OLINE:1}"
146: fi
147: fi
148: fi
149: fi
150:
151: done < ChangeLog
152:
153:
154:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>