#!/bin/bash # where to store the packages TARGET=${PWD}/ZIP [ ! -d ${TARGET} ] && mkdir ${TARGET} # get list of directories with .package files DIRS="" cd .. for i in $(find . -name ".package"); do DIRS="${DIRS} $(dirname $i)" done for pkg in ${DIRS}; do echo "----- ${pkg}" TMPDIR=$(mktemp -d) NAME="" while read LINE; do IFS=';' read -ra DATA <<< ${LINE} # the name of the target .zip archive: [ "${DATA[0]}" = "N" ] && NAME=${DATA[1]} # standard/source files: if [ "${DATA[0]}" = "F" -o "${DATA[0]}" = "S" ]; then if [ "${DATA[2]}" = "" ]; then cp ${pkg}/${DATA[1]} ${TMPDIR}/${DATA[1]^^} else cp ${pkg}/${DATA[1]} ${TMPDIR}/${DATA[2]} fi fi # README file: if [ "${DATA[0]}" = "R" ]; then if [ "${DATA[2]}" = "" ]; then pandoc -f markdown -t plain -s ${pkg}/${DATA[1]} -o ${TMPDIR}/${NAME}.DOC else pandoc -f markdown -t plain -s ${pkg}/${DATA[1]} -o ${TMPDIR}/${DATA[2]} fi fi # FILE_ID.DIZ contents: [ "${DATA[0]}" = "D" ] && echo "${DATA[1]}" >> ${TMPDIR}/FILE_ID.DIZ done < ${pkg}/.package zip -k -j ${TARGET}/${NAME}.ZIP ${TMPDIR}/* rm -R ${TMPDIR} done