File:  [Coherent Logic Development] / freem / scripts / fmd-pkg-rpm
Revision 1.4: download - view: text, annotated - select for diffs
Mon Apr 7 21:50:11 2025 UTC (3 months, 3 weeks ago) by snw
Branches: MAIN
CVS tags: HEAD
Fix bug in fmd-pkg-rpm

    1: #!/usr/bin/env bash
    2: 
    3: #
    4: #   $Id: fmd-pkg-rpm,v 1.4 2025/04/07 21:50:11 snw Exp $
    5: #    Creates an rpm package
    6: #
    7: #  
    8: #   Author: Serena Willis <snw@coherent-logic.com>
    9: #    Copyright (C) 2025 Coherent Logic Development LLC
   10: #
   11: #
   12: #   This file is part of FreeM.
   13: #
   14: #   FreeM is free software: you can redistribute it and/or modify
   15: #   it under the terms of the GNU Affero Public License as published by
   16: #   the Free Software Foundation, either version 3 of the License, or
   17: #   (at your option) any later version.
   18: #
   19: #   FreeM is distributed in the hope that it will be useful,
   20: #   but WITHOUT ANY WARRANTY; without even the implied warranty of
   21: #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   22: #   GNU Affero Public License for more details.
   23: #
   24: #   You should have received a copy of the GNU Affero Public License
   25: #   along with FreeM.  If not, see <https://www.gnu.org/licenses/>.
   26: #
   27: #   $Log: fmd-pkg-rpm,v $
   28: #   Revision 1.4  2025/04/07 21:50:11  snw
   29: #   Fix bug in fmd-pkg-rpm
   30: #
   31: #   Revision 1.3  2025/04/07 13:02:51  snw
   32: #   Initial working version of fmd-pkg-rpm
   33: #
   34: #   Revision 1.2  2025/04/07 05:39:23  snw
   35: #   Further work on fmd rpm porting
   36: #
   37: #   Revision 1.1  2025/04/07 05:19:36  snw
   38: #   Initial work on moving rpm packaging to fmd
   39: #
   40: #
   41: # SPDX-FileCopyrightText:  (C) 2025 Coherent Logic Development LLC
   42: # SPDX-License-Identifier: AGPL-3.0-or-later
   43: #
   44: 
   45: PGM=$(basename $0)
   46: SCRIPT_DIR=$(dirname "$0")
   47: 
   48: source "${SCRIPT_DIR}/_fmd_common.bash"
   49: 
   50: if [[ $# != 1 ]]
   51: then
   52:     echo "${PGM}:  must run from fmd package"
   53:     exit 1
   54: fi
   55: 
   56: TMPDIR="/tmp/fmd-pkg-rpm"
   57: rm -rf "${TMPDIR}"
   58: mkdir -p "${TMPDIR}"
   59: 
   60: LOGFILE="${TMPDIR}/pkgbuild.log"
   61: echo "${PGM}:  logging to ${LOGFILE}"
   62: 
   63: RPM_RELEASE=$(echo "${_fmd_freem_version}" | sed "s/-/~/g")
   64: 
   65: if [[ ! -f Makefile ]]
   66: then
   67:     echo -n "${PGM}:  running autogen.sh..."
   68:     ./autogen.sh &>> "${LOGFILE}"
   69:     if [[ $? != 0 ]]
   70:     then
   71: 	echo "[FAIL]"
   72: 	exit 1
   73:     else
   74: 	echo "[OK]"
   75:     fi
   76:     echo -n "${PGM}:  running configure..."
   77:     ./configure &>> "${LOGFILE}"
   78:     if [[ $? != 0 ]]
   79:     then
   80: 	echo "[FAIL]"
   81: 	exit 1
   82:     else
   83: 	echo "[OK]"
   84:     fi
   85: 
   86: fi
   87: 
   88: ORIG_TARBALL="freem-${_fmd_freem_version}.tar.gz"
   89: ORIG_DIR="freem-${_fmd_freem_version}/"
   90: NEW_DIR="freem-${RPM_RELEASE}/"
   91: NEW_TARBALL="freem-${RPM_RELEASE}.tar.gz"
   92: 
   93: echo -n "${PGM}:  running 'make dist' to prepare source tarball..."
   94: make dist &>> "${LOGFILE}"
   95: if [[ $? != 0 ]]
   96: then
   97:     echo "[FAIL]"
   98:     exit 1
   99: else
  100:     echo "[OK]"
  101: fi
  102: 
  103: if [[ "${ORIG_TARBALL}" != "${NEW_TARBALL}" ]]
  104: then
  105:     RENAME=1
  106: else
  107:     RENAME=0
  108: fi
  109: 
  110: if [[ $RENAME == 1 ]]
  111: then
  112:     echo -n "${PGM}:  cleaning up..."
  113:     rm -rf "${OLD_DIR}" "${NEW_DIR}" "${NEW_TARBALL}" &>> /dev/null
  114:     if [[ $? != 0 ]]
  115:     then
  116: 	echo "[FAIL]"
  117: 	exit 1
  118:     else
  119: 	echo "[OK]"
  120:     fi    
  121: fi
  122: 
  123: echo -n "${PGM}:  decompressing source tarball..."
  124: tar xzf "${ORIG_TARBALL}"
  125: if [[ $? != 0 ]]
  126: then
  127:     echo "[FAIL]"
  128:     exit 1
  129: else
  130:     echo "[OK]"
  131: fi
  132: 
  133: if [[ $RENAME == 1 ]]
  134: then
  135:     echo -n "${PGM}:  renaming ${ORIG_DIR} -> ${NEW_DIR}..."
  136:     mv "${ORIG_DIR}" "${NEW_DIR}" &>> /dev/null
  137:     if [[ $? != 0 ]]
  138:     then
  139: 	echo "[FAIL]"
  140: 	exit 1
  141:     else
  142: 	echo "[OK]"
  143:     fi
  144: 
  145: 
  146:     echo -n "${PGM}:  generating ${NEW_TARBALL}..."
  147:     tar cf "${NEW_TARBALL}" "${NEW_DIR}" &>> /dev/null
  148:     if [[ $? != 0 ]]
  149:     then
  150: 	echo "[FAIL]"
  151: 	exit 1
  152:     else
  153: 	echo "[OK]"
  154:     fi
  155: fi
  156: 
  157: echo -n "${PGM}:  uploading source tarball..."
  158: scp "${NEW_TARBALL}" jpw@freem.coherent-logic.com://var/www/freem.coherent-logic.com/downloads/ &>> "${LOGFILE}"
  159: if [[ $? != 0 ]]
  160: then
  161:     echo "[FAIL]"
  162:     exit 1
  163: else
  164:     echo "[OK]"
  165: fi
  166: 
  167: echo "${PGM}:  performing substitutions on specfile..."
  168: cat scripts/rpm/freem.spec.in | sed "s/FREEM_VERSION/${RPM_RELEASE}/g" > scripts/rpm/freem.spec
  169: 
  170: RPMROOT="${HOME}/rpmbuild"
  171: echo -n "${PGM}:  removing ${RPMROOT}..."
  172: rm -rf "${RPMROOT}" &>> "${LOGFILE}"
  173: if [[ $? != 0 ]]
  174: then
  175:     echo "[FAIL]"
  176:     exit 1
  177: else
  178:     echo "[OK]"
  179: fi
  180: 
  181: echo -n "${PGM}:  preparing directory structure..."
  182: rpmdev-setuptree &>> "${LOGFILE}"
  183: if [[ $? != 0 ]]
  184: then
  185:     echo "[FAIL]"
  186:     exit 1
  187: else
  188:     echo "[OK]"
  189: fi
  190: 
  191: echo -n "${PGM}:  running spectool..."
  192: spectool -g -R scripts/rpm/freem.spec &>> "${LOGFILE}"
  193: if [[ $? != 0 ]]
  194: then
  195:     echo "[FAIL]"
  196:     exit 1
  197: else
  198:     echo "[OK]"
  199: fi
  200: 
  201: echo -n "${PGM}:  building package..."
  202: rpmbuild -ba scripts/rpm/freem.spec &>> "${LOGFILE}"
  203: if [[ $? != 0 ]]
  204: then
  205:     echo "[FAIL]"
  206:     exit 1
  207: else
  208:     echo "[OK]"
  209: fi
  210: 
  211: echo -n "${PGM}:  cleaning up..."
  212: rm -rf "${OLD_DIR}" "${NEW_DIR}" "${NEW_TARBALL}" &>> /dev/null
  213: if [[ $? != 0 ]]
  214: then
  215:     echo "[FAIL]"
  216:     exit 1
  217: else
  218:     echo "[OK]"
  219: fi
  220: 
  221: echo -n "${PGM}:  copying rpm packages..."
  222: cp ${RPMROOT}/RPMS/${_fmd_arch}/*.rpm . &>> "${LOGFILE}"
  223: if [[ $? != 0 ]]
  224: then
  225:     echo "[FAIL]"
  226:     exit 1
  227: else
  228:     echo "[OK]"
  229: fi
  230: 
  231: echo -n "${PGM}:  copying source rpm packages..."
  232: cp ${RPMROOT}/SRPMS/*.rpm . &>> "${LOGFILE}"
  233: if [[ $? != 0 ]]
  234: then
  235:     echo "[FAIL]"
  236:     exit 1
  237: else
  238:     echo "[OK]"
  239: fi
  240: 
  241: RPM_BUILT=$(ls -1 *.rpm)
  242: 
  243: BLDLST=""
  244: for PKGFILE in ${RPM_BUILT}
  245: do
  246:     if [[ "${BLDLST}" == "" ]]
  247:     then
  248: 	BLDLST="${PKGFILE}"
  249:     else
  250: 	BLDLST="${BLDLST} ${PKGFILE}"
  251:     fi
  252: done
  253: 
  254: echo "${PGM}:  built ${BLDLST}"
  255: 

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