File:  [Coherent Logic Development] / freem / scripts / fmd-pkg-rpm
Revision 1.2: download - view: text, annotated - select for diffs
Mon Apr 7 05:39:23 2025 UTC (3 days, 22 hours ago) by snw
Branches: MAIN
CVS tags: HEAD
Further work on fmd rpm porting

#!/usr/bin/env bash

#
#   $Id: fmd-pkg-rpm,v 1.2 2025/04/07 05:39:23 snw Exp $
#    Creates an rpm package
#
#  
#   Author: Serena Willis <snw@coherent-logic.com>
#    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 <https://www.gnu.org/licenses/>.
#
#   $Log: fmd-pkg-rpm,v $
#   Revision 1.2  2025/04/07 05:39:23  snw
#   Further work on fmd rpm porting
#
#   Revision 1.1  2025/04/07 05:19:36  snw
#   Initial work on moving rpm packaging 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-rpm"
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
    

echo -n "${PGM}:  running 'make dist' to prepare source tarball..."
make dist &>> "${LOGFILE}"
if [[ $? != 0 ]]
then
    echo "[FAIL]"
    exit 1
else
    echo "[OK]"
fi

ORIG_TARBALL="freem-${_fmd_freem_version.tar.gz}"

echo -n "${PGM}:  decompressing source tarball..."
tar xzf "${TARBALL}"
if [[ $? != 0 ]]
then
    echo "[FAIL]"
    exit 1
else
    echo "[OK]"
fi


echo -n "${PGM}:  uploading source tarball..."
scp freem*.tar.gz 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.in | sed "s/FREEM_VERSION/${RPM_RELEASE}/g" > scripts/rpm/freem.spec

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

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