File:  [Coherent Logic Development] / freem / scripts / fmd-pkg-dpkg
Revision 1.1: download - view: text, annotated - select for diffs
Sun Apr 6 03:38:05 2025 UTC (3 months, 1 week ago) by snw
Branches: MAIN
CVS tags: HEAD
Prepare for adding packaging functionality to fmd

#!/usr/bin/env bash

#
#   $Id: fmd-pkg-dpkg,v 1.1 2025/04/06 03:38:05 snw Exp $
#    Creates a Debian package for a specific FreeM version
#
#  
#   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-dpkg,v $
#   Revision 1.1  2025/04/06 03:38:05  snw
#   Prepare for adding packaging functionality 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")

if [[ $# != 2 ]]
then
    echo "fmd-pkg-dpkg:  must run from fmd package"
    exit 1
fi

FMD=$1

FREEM_VERSION="${_fmd_freem_version}"
FREEM_VERSION_MOD=$(echo "${FREEM_VERSION}" | sed 's/-/./g')
FDPKG_VERSION=$2

TMPDIR="/tmp/fmd-pkg-dpkg"
rm -rf "${TMPDIR}"

INFILE="freem-${FREEM_VERSION}.tar.gz"
OUTFILE="${TMPDIR}/freem_${FREEM_VERSION_MOD}.orig.tar.gz"
TARDIR="${TMPDIR}/freem-${FREEM_VERSION_MOD}"


echo -n "${PGM}:  extracting ${OUTFILE} to ${TARDIR}..."
tar zxf "${OUTFILE}" -C "${TMPDIR}"
if [[ "${FREEM_VERSION}" != "${FREEM_VERSION_MOD}" ]]
then
    mv "${TMPDIR}/freem-${FREEM_VERSION}" "${TMPDIR}/freem-${FREEM_VERSION_MOD}"
fi
if [[ $? == 0 ]]
then
    echo "[OK]"
else
    echo "[FAIL]"
    exit 1
fi

echo -n "${PGM}:  copying Debian packaging control info to ${TARDIR}..."
cp -r debian "${TARDIR}/"
if [[ $? == 0 ]]
then
    echo "[OK]"
else
    echo "[FAIL]"
    exit 1
fi

sed -i "s/FREEM_VERSION/${FREEM_VERSION_MOD}-${FDPKG_VERSION}/g" "${TARDIR}/debian/changelog"
sed -i "s/FREEM_VERSION/${FREEM_VERSION}-${FDPKG_VERSION}/g" "${TARDIR}/debian/control"

echo "${PGM}:  building the package..."
cd "${TARDIR}"
export DEB_BUILD_MAINT_OPTIONS=hardening=-fortify,-format,-stackprotector,-stackprotectorstrong
debuild -us -uc

echo "${PGM}:  the package is in ${TMPDIR}"

rm -f ${TMPDIR}/*dbgsym*
scp ${TMPDIR}/*.deb "${FDSSH}://var/www/freem.coherent-logic.com/downloads/binaries/debian/" 

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