#!/bin/bash # generate metadata files for packages - called after smage2 has done packaging source /etc/mage.rc.global source /etc/mage.rc source /usr/lib/mage/mage4.functions.sh die() { echo -e "Exited ${BASH_SOURCE} at line no ${BASH_LINENO}." echo -e "$@" exit 1 } SMAGEFILE="$1" METADIR=/var/cache/mage/meta source $1 DEST="${METADIR}/${PNAME}/${PNAME}-${PVER}-${PBUILD}" install -d ${DEST} || die install -d ${DEST}/${ARCH} || die # basic meta data echo "${PNAME}" > ${DEST}/meta echo "${PCATEGORIE}" >> ${DEST}/meta echo "${PVER}" >> ${DEST}/meta echo "${PBUILD/r/}" >> ${DEST}/meta echo "${STATE}" >> ${DEST}/meta echo "${DESCRIPTION}" >> ${DEST}/meta echo "${HOMEPAGE}" >> ${DEST}/meta echo "${PKGTYPE}" >> ${DEST}/meta echo "${MAGE_TARGETS}" >> ${DEST}/meta echo "${INHERITS}" >> ${DEST}/meta # arch specific meta data [[ -f ${PKGDIR}/${PNAME}-${PVER}-${ARCH}-${PBUILD}.${PKGSUFFIX} ]] && MD5=$(md5sum ${PKGDIR}/${PNAME}-${PVER}-${ARCH}-${PBUILD}.${PKGSUFFIX} | cut -d' ' -f1) [[ -e ${BUILDDIR}/builded ]] && SIZE="$(du -hDs ${BUILDDIR}/builded | cut -d $'\t' -f1)" [[ -f ${BUILDDIR}/${PNAME}-${PVER}-${ARCH}-${PBUILD}/.mtime ]] && MTIME="$(< ${BUILDDIR}/${PNAME}-${PVER}-${ARCH}-${PBUILD}/.mtime)" echo "${MD5}" > ${DEST}/${ARCH}/desc echo "${SIZE}" >> ${DEST}/${ARCH}/desc echo "${MTIME}" >> ${DEST}/${ARCH}/desc # depends echo "${DEPEND}" > ${DEST}/${ARCH}/depend # sdepends echo "${SDEPEND}" > ${DEST}/${ARCH}/sdepend # provides echo "${PROVIDES}" > ${DEST}/${ARCH}/provides # content # char # dirs # files # pipes # symlinks for i in char dirs files pipes symlinks do SRC="${BUILDDIR}/${PNAME}-${PVER}-${ARCH}-${PBUILD}/.${i}" [[ -f ${SRC} ]] && cat ${SRC} | bzip2 -9 > ${DEST}/${ARCH}/${i}.bz2 done # preinstall etc # routines.sh do_preinst=0 do_postinst=0 do_prerm=0 do_postrm=0 do_script=0 [[ -n $(typeset -f preinstall) ]] && touch ${DEST}/preinstall && do_preinst=1 && do_script=1 [[ -n $(typeset -f postinstall) ]] && touch ${DEST}/postinstall && do_postinst=1 && do_script=1 [[ -n $(typeset -f preremove) ]] && touch ${DEST}/preremove && do_prerm=1 && do_script=1 [[ -n $(typeset -f postremove) ]] && touch ${DEST}/postremove && do_postrm=1 && do_script=1 # create it only if do_script=1 if [[ ${do_script} = 1 ]] then # create a routines script routines="${DEST}/routines.sh" echo "#!/bin/sh" > ${routines} echo "# routines.sh script for ${PNAME}-${PVER}-${PBUILD}" >> ${routines} echo >> ${routines} # special functions and variables if [[ -n ${SPECIAL_VARS} ]] then for i in ${SPECIAL_VARS} do # being tricky here :) echo "${i}=\"$(eval echo \$${i})\"" >> ${routines} done echo >> ${routines} fi # add special functions if [[ -n ${SPECIAL_FUNCTIONS} ]] then for i in ${SPECIAL_FUNCTIONS} do # add to mage (quotes needed !) typeset -f "${i}" >> ${routines} echo >> ${routines} # unset to be safe (quotes needed !) unset "${i}" done echo >> ${routines} fi # postinstall and co for i in preinstall postinstall preremove postremove do if [[ -n $(typeset -f "${i}") ]] then typeset -f "${i}" >> ${routines} echo >> ${routines} fi done # create start logic echo >> ${routines} echo 'case $1 in' >> ${routines} [[ ${do_preinst} = 1 ]] && echo ' preinstall) preinstall ;;' >> ${routines} [[ ${do_postinst} = 1 ]] && echo ' postinstall) postinstall ;;' >> ${routines} [[ ${do_prerm} = 1 ]] && echo ' preremove) preremove ;;' >> ${routines} [[ ${do_postrm} = 1 ]] && echo ' postremove) postremove ;;' >> ${routines} echo ' *) echo "error unkown option \"$1\" ..." ;;' >> ${routines} echo 'esac' >> ${routines} echo >> ${routines} fi