#!/usr/bin/env bash # # $Id: fmd-pkg-os2rpm,v 1.1 2025/04/14 13:06:46 snw Exp $ # Creates an rpm package on OS/2 # # # Author: Serena Willis # Copyright (C) 2025 Coherent Logic Development LLC # # # This file is part of FreeM. # # FreeM is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # FreeM is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero Public License for more details. # # You should have received a copy of the GNU Affero Public License # along with FreeM. If not, see . # # $Log: fmd-pkg-os2rpm,v $ # Revision 1.1 2025/04/14 13:06:46 snw # Add OS/2 RPM build script to fmd # # # # SPDX-FileCopyrightText: (C) 2025 Coherent Logic Development LLC # SPDX-License-Identifier: AGPL-3.0-or-later # PGM=$(basename $0) SCRIPT_DIR=$(dirname "$0") source "${SCRIPT_DIR}/_fmd_common.bash" if [[ $# != 1 ]] then echo "${PGM}: must run from fmd package" exit 1 fi TMPDIR="/tmp/fmd-pkg-os2rpm" rm -rf "${TMPDIR}" mkdir -p "${TMPDIR}" LOGFILE="${TMPDIR}/pkgbuild.log" echo "${PGM}: logging to ${LOGFILE}" RPM_RELEASE=$(echo "${_fmd_freem_version}" | sed "s/-/~/g") if [[ ! -f Makefile ]] then echo -n "${PGM}: running autogen.sh..." ./autogen.sh &>> "${LOGFILE}" if [[ $? != 0 ]] then echo "[FAIL]" exit 1 else echo "[OK]" fi echo -n "${PGM}: running configure..." ./configure &>> "${LOGFILE}" if [[ $? != 0 ]] then echo "[FAIL]" exit 1 else echo "[OK]" fi fi ORIG_TARBALL="freem-${_fmd_freem_version}.tar.gz" ORIG_DIR="freem-${_fmd_freem_version}/" NEW_DIR="freem-${RPM_RELEASE}/" NEW_TARBALL="freem-${RPM_RELEASE}.tar.gz" echo -n "${PGM}: running 'make dist' to prepare source tarball..." make dist &>> "${LOGFILE}" if [[ $? != 0 ]] then echo "[FAIL]" exit 1 else echo "[OK]" fi if [[ "${ORIG_TARBALL}" != "${NEW_TARBALL}" ]] then RENAME=1 else RENAME=0 fi if [[ $RENAME == 1 ]] then echo -n "${PGM}: cleaning up..." rm -rf "${OLD_DIR}" "${NEW_DIR}" "${NEW_TARBALL}" &>> /dev/null if [[ $? != 0 ]] then echo "[FAIL]" exit 1 else echo "[OK]" fi fi echo -n "${PGM}: decompressing source tarball..." tar xzf "${ORIG_TARBALL}" if [[ $? != 0 ]] then echo "[FAIL]" exit 1 else echo "[OK]" fi if [[ $RENAME == 1 ]] then echo -n "${PGM}: renaming ${ORIG_DIR} -> ${NEW_DIR}..." mv "${ORIG_DIR}" "${NEW_DIR}" &>> /dev/null if [[ $? != 0 ]] then echo "[FAIL]" exit 1 else echo "[OK]" fi echo -n "${PGM}: generating ${NEW_TARBALL}..." tar cf "${NEW_TARBALL}" "${NEW_DIR}" &>> /dev/null if [[ $? != 0 ]] then echo "[FAIL]" exit 1 else echo "[OK]" fi fi echo -n "${PGM}: uploading source tarball..." scp "${NEW_TARBALL}" jpw@freem.coherent-logic.com://var/www/freem.coherent-logic.com/downloads/ &>> "${LOGFILE}" if [[ $? != 0 ]] then echo "[FAIL]" exit 1 else echo "[OK]" fi echo "${PGM}: performing substitutions on specfile..." cat scripts/rpm/freem.spec.os2 | sed "s/FREEM_VERSION/${RPM_RELEASE}/g" > scripts/rpm/freem.spec RPMROOT="${HOME}/rpmbuild" echo -n "${PGM}: removing ${RPMROOT}..." rm -rf "${RPMROOT}" &>> "${LOGFILE}" if [[ $? != 0 ]] then echo "[FAIL]" exit 1 else echo "[OK]" fi echo -n "${PGM}: preparing directory structure..." mkdir -p ~/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS} &>> "${LOGFILE}" if [[ $? != 0 ]] then echo "[FAIL]" exit 1 else echo "[OK]" fi echo -n "${PGM}: running spectool..." spectool -g -R scripts/rpm/freem.spec &>> "${LOGFILE}" if [[ $? != 0 ]] then echo "[FAIL]" exit 1 else echo "[OK]" fi echo -n "${PGM}: building package..." rpmbuild -ba scripts/rpm/freem.spec &>> "${LOGFILE}" if [[ $? != 0 ]] then echo "[FAIL]" exit 1 else echo "[OK]" fi echo -n "${PGM}: cleaning up..." rm -rf "${OLD_DIR}" "${NEW_DIR}" "${NEW_TARBALL}" &>> /dev/null if [[ $? != 0 ]] then echo "[FAIL]" exit 1 else echo "[OK]" fi echo -n "${PGM}: copying rpm packages..." cp ${RPMROOT}/RPMS/${_fmd_arch}/*.rpm . &>> "${LOGFILE}" if [[ $? != 0 ]] then echo "[FAIL]" exit 1 else echo "[OK]" fi echo -n "${PGM}: copying source rpm packages..." cp ${RPMROOT}/SRPMS/*.rpm . &>> "${LOGFILE}" if [[ $? != 0 ]] then echo "[FAIL]" exit 1 else echo "[OK]" fi RPM_BUILT=$(ls -1 *.rpm) BLDLST="" for PKGFILE in ${RPM_BUILT} do if [[ "${BLDLST}" == "" ]] then BLDLST="${PKGFILE}" else BLDLST="${BLDLST} ${PKGFILE}" fi done echo "${PGM}: built ${BLDLST}"