#!/usr/bin/env bash # # $Id: fmd-pkg-dpkg,v 1.3 2025/04/07 00:45:52 snw Exp $ # Creates a Debian package for a specific FreeM version # # # 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-dpkg,v $ # Revision 1.3 2025/04/07 00:45:52 snw # Enhance fmd-pkg-dpkg to auto-generate the debian/changelog file from the FreeM ChangeLog # # Revision 1.2 2025/04/06 05:01:21 snw # Initial working implementation of fmd package for dpkg # # 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") source "${SCRIPT_DIR}/_fmd_common.bash" if [[ $# != 1 ]] then echo "${PGM}: must run from fmd package" exit 1 fi FMD=$1 FREEM_VERSION="${_fmd_freem_version}" FREEM_VERSION_MOD=$(echo "${FREEM_VERSION}" | sed 's/-/./g') export DEBEMAIL="${_fmd_email}" export DEBFULLNAME="${_fmd_fullname}" echo -n "${PGM}: getting debian package release for ${_fmd_freem_version}... " FDPKG_VERSION=$(_fmd_next_dpkg) echo "[${FDPKG_VERSION}]" echo "${PGM}: package version is ${FREEM_VERSION}-${FDPKG_VERSION}" TMPDIR="/tmp/fmd-pkg-dpkg" rm -rf "${TMPDIR}" mkdir -p "${TMPDIR}" LOGFILE="${TMPDIR}/pkgbuild.log" echo "${PGM}: logging to ${LOGFILE}" INFILE="freem-${FREEM_VERSION}.tar.gz" OUTFILE="${TMPDIR}/freem_${FREEM_VERSION_MOD}.orig.tar.gz" TARDIR="${TMPDIR}/freem-${FREEM_VERSION_MOD}" if [[ -f "${INFILE}" ]] then echo "${PGM}: removing ${INFILE}" rm -f "${INFILE}" 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 echo "${PGM}: moving ${INFILE} to ${OUTFILE}..." mv "${INFILE}" "${OUTFILE}" echo "${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 echo "${PGM}: generating Debian changelog..." TMP_CHLOG=$(mktemp) ${FMD} changelog --minimal > "${TMP_CHLOG}" pushd scripts &> /dev/null rm debian/changelog dch --create -v "${FREEM_VERSION_MOD}-${FDPKG_VERSION}" -u low --package freem --empty &>> "${LOGFILE}" while read LINE do dch --append "${LINE}" &>> "${LOGFILE}" done < "${TMP_CHLOG}" rm -f "${TMP_CHLOG}" dch --release "Release the package" &>> "${LOGFILE}" popd &> /dev/null echo -n "${PGM}: copying Debian packaging control info to ${TARDIR}... " cp -r scripts/debian "${TARDIR}/" if [[ $? == 0 ]] then echo "[OK]" else echo "[FAIL]" exit 1 fi sed -i "s/FREEM_VERSION/${FREEM_VERSION}-${FDPKG_VERSION}/g" "${TARDIR}/debian/control" echo -n "${PGM}: building the packages (this may take awhile)..." cd "${TARDIR}" export DEB_BUILD_MAINT_OPTIONS=hardening=-fortify,-format,-stackprotector,-stackprotectorstrong debuild -us -uc &>> "${LOGFILE}" if [[ $? == 0 ]] then echo "[OK]" else echo "[FAIL]" exit 1 fi cd - &> /dev/null mv ${TMPDIR}/*.deb . DPKG_BUILT=$(ls -1 *.deb) BLDLST="" for PKGFILE in ${DPKG_BUILT} do if [[ "${BLDLST}" == "" ]] then BLDLST="${PKGFILE}" else BLDLST="${BLDLST} ${PKGFILE}" fi done echo "${PGM}: built ${BLDLST}"