#!/usr/bin/bash
#
# $Id: fmd-pkg-pkgadd,v 1.2 2025/04/07 03:43:53 snw Exp $
# Solaris package builder
#
#
# 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-pkgadd,v $
# Revision 1.2 2025/04/07 03:43:53 snw
# Attempt to correct bash incompatibility on Solaris 8
#
# Revision 1.1 2025/04/07 03:23:44 snw
# Port Solaris packaging script to fmd infrastructure
#
#
# 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
PKG=CLDfreem
ARCH=${_fmd_subarch}
OS=${_fmd_distribution}
VERS=${_fmd_freem_version}
SOLVER=${_fmd_osversion}
PKGFILE=${PKG}-${VERS}-${OS}${SOLVER}-${ARCH}.pkg
echo "${PGM}: producing pkgadd package \"${PKGFILE}\""
TMPDIR="/tmp/fmd-pkg-pkgadd"
rm -rf "${TMPDIR}"
mkdir -p "${TMPDIR}"
LOGFILE="${TMPDIR}/pkgbuild.log"
echo "${PGM}: logging to ${LOGFILE}"
cat <<EOF > pkginfo
PKG=${PKG}
NAME=Coherent Logic Development FreeM programming language and database
ARCH=${ARCH}
VERSION=${VERS}
CATEGORY=application
BASEDIR=/usr/local
EOF
echo -n "${PGM}: running pkgmk... "
pkgmk -o -d /tmp -a ${ARCH} >> "${LOGFILE}" 2>&1
if [[ $? == 0 ]]
then
echo "[OK]"
else
echo "[FAIL]"
exit 1
fi
touch ${PKGFILE}
echo -n "${PGM}: running pkgtrans... "
pkgtrans -s /tmp ${PKGFILE} ${PKG} >> "${LOGFILE}" 2>&1
if [[ $? == 0 ]]
then
echo "[OK]"
else
echo "[FAIL]"
exit 1
fi
echo -n "${PGM}: cleaning up... "
rm -r /tmp/${PKG}
if [[ $? == 0 ]]
then
echo "[OK]"
else
echo "[FAIL]"
exit 1
fi
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>