1: #!/usr/bin/env bash
2:
3: #
4: # $Id: fmd-pkg-os2rpm,v 1.1 2025/04/14 13:06:46 snw Exp $
5: # Creates an rpm package on OS/2
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-pkg-os2rpm,v $
28: # Revision 1.1 2025/04/14 13:06:46 snw
29: # Add OS/2 RPM build script to fmd
30: #
31: #
32: #
33: # SPDX-FileCopyrightText: (C) 2025 Coherent Logic Development LLC
34: # SPDX-License-Identifier: AGPL-3.0-or-later
35: #
36:
37: PGM=$(basename $0)
38: SCRIPT_DIR=$(dirname "$0")
39:
40: source "${SCRIPT_DIR}/_fmd_common.bash"
41:
42: if [[ $# != 1 ]]
43: then
44: echo "${PGM}: must run from fmd package"
45: exit 1
46: fi
47:
48: TMPDIR="/tmp/fmd-pkg-os2rpm"
49: rm -rf "${TMPDIR}"
50: mkdir -p "${TMPDIR}"
51:
52: LOGFILE="${TMPDIR}/pkgbuild.log"
53: echo "${PGM}: logging to ${LOGFILE}"
54:
55: RPM_RELEASE=$(echo "${_fmd_freem_version}" | sed "s/-/~/g")
56:
57: if [[ ! -f Makefile ]]
58: then
59: echo -n "${PGM}: running autogen.sh..."
60: ./autogen.sh &>> "${LOGFILE}"
61: if [[ $? != 0 ]]
62: then
63: echo "[FAIL]"
64: exit 1
65: else
66: echo "[OK]"
67: fi
68: echo -n "${PGM}: running configure..."
69: ./configure &>> "${LOGFILE}"
70: if [[ $? != 0 ]]
71: then
72: echo "[FAIL]"
73: exit 1
74: else
75: echo "[OK]"
76: fi
77:
78: fi
79:
80: ORIG_TARBALL="freem-${_fmd_freem_version}.tar.gz"
81: ORIG_DIR="freem-${_fmd_freem_version}/"
82: NEW_DIR="freem-${RPM_RELEASE}/"
83: NEW_TARBALL="freem-${RPM_RELEASE}.tar.gz"
84:
85: echo -n "${PGM}: running 'make dist' to prepare source tarball..."
86: make dist &>> "${LOGFILE}"
87: if [[ $? != 0 ]]
88: then
89: echo "[FAIL]"
90: exit 1
91: else
92: echo "[OK]"
93: fi
94:
95: if [[ "${ORIG_TARBALL}" != "${NEW_TARBALL}" ]]
96: then
97: RENAME=1
98: else
99: RENAME=0
100: fi
101:
102: if [[ $RENAME == 1 ]]
103: then
104: echo -n "${PGM}: cleaning up..."
105: rm -rf "${OLD_DIR}" "${NEW_DIR}" "${NEW_TARBALL}" &>> /dev/null
106: if [[ $? != 0 ]]
107: then
108: echo "[FAIL]"
109: exit 1
110: else
111: echo "[OK]"
112: fi
113: fi
114:
115: echo -n "${PGM}: decompressing source tarball..."
116: tar xzf "${ORIG_TARBALL}"
117: if [[ $? != 0 ]]
118: then
119: echo "[FAIL]"
120: exit 1
121: else
122: echo "[OK]"
123: fi
124:
125: if [[ $RENAME == 1 ]]
126: then
127: echo -n "${PGM}: renaming ${ORIG_DIR} -> ${NEW_DIR}..."
128: mv "${ORIG_DIR}" "${NEW_DIR}" &>> /dev/null
129: if [[ $? != 0 ]]
130: then
131: echo "[FAIL]"
132: exit 1
133: else
134: echo "[OK]"
135: fi
136:
137:
138: echo -n "${PGM}: generating ${NEW_TARBALL}..."
139: tar cf "${NEW_TARBALL}" "${NEW_DIR}" &>> /dev/null
140: if [[ $? != 0 ]]
141: then
142: echo "[FAIL]"
143: exit 1
144: else
145: echo "[OK]"
146: fi
147: fi
148:
149: echo -n "${PGM}: uploading source tarball..."
150: scp "${NEW_TARBALL}" jpw@freem.coherent-logic.com://var/www/freem.coherent-logic.com/downloads/ &>> "${LOGFILE}"
151: if [[ $? != 0 ]]
152: then
153: echo "[FAIL]"
154: exit 1
155: else
156: echo "[OK]"
157: fi
158:
159: echo "${PGM}: performing substitutions on specfile..."
160: cat scripts/rpm/freem.spec.os2 | sed "s/FREEM_VERSION/${RPM_RELEASE}/g" > scripts/rpm/freem.spec
161:
162: RPMROOT="${HOME}/rpmbuild"
163: echo -n "${PGM}: removing ${RPMROOT}..."
164: rm -rf "${RPMROOT}" &>> "${LOGFILE}"
165: if [[ $? != 0 ]]
166: then
167: echo "[FAIL]"
168: exit 1
169: else
170: echo "[OK]"
171: fi
172:
173: echo -n "${PGM}: preparing directory structure..."
174: mkdir -p ~/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS} &>> "${LOGFILE}"
175: if [[ $? != 0 ]]
176: then
177: echo "[FAIL]"
178: exit 1
179: else
180: echo "[OK]"
181: fi
182:
183: echo -n "${PGM}: running spectool..."
184: spectool -g -R scripts/rpm/freem.spec &>> "${LOGFILE}"
185: if [[ $? != 0 ]]
186: then
187: echo "[FAIL]"
188: exit 1
189: else
190: echo "[OK]"
191: fi
192:
193: echo -n "${PGM}: building package..."
194: rpmbuild -ba scripts/rpm/freem.spec &>> "${LOGFILE}"
195: if [[ $? != 0 ]]
196: then
197: echo "[FAIL]"
198: exit 1
199: else
200: echo "[OK]"
201: fi
202:
203: echo -n "${PGM}: cleaning up..."
204: rm -rf "${OLD_DIR}" "${NEW_DIR}" "${NEW_TARBALL}" &>> /dev/null
205: if [[ $? != 0 ]]
206: then
207: echo "[FAIL]"
208: exit 1
209: else
210: echo "[OK]"
211: fi
212:
213: echo -n "${PGM}: copying rpm packages..."
214: cp ${RPMROOT}/RPMS/${_fmd_arch}/*.rpm . &>> "${LOGFILE}"
215: if [[ $? != 0 ]]
216: then
217: echo "[FAIL]"
218: exit 1
219: else
220: echo "[OK]"
221: fi
222:
223: echo -n "${PGM}: copying source rpm packages..."
224: cp ${RPMROOT}/SRPMS/*.rpm . &>> "${LOGFILE}"
225: if [[ $? != 0 ]]
226: then
227: echo "[FAIL]"
228: exit 1
229: else
230: echo "[OK]"
231: fi
232:
233: RPM_BUILT=$(ls -1 *.rpm)
234:
235: BLDLST=""
236: for PKGFILE in ${RPM_BUILT}
237: do
238: if [[ "${BLDLST}" == "" ]]
239: then
240: BLDLST="${PKGFILE}"
241: else
242: BLDLST="${BLDLST} ${PKGFILE}"
243: fi
244: done
245:
246: echo "${PGM}: built ${BLDLST}"
247:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>