Index: appfs-mkfs ================================================================== --- appfs-mkfs +++ appfs-mkfs @@ -1,7 +1,9 @@ #! /usr/bin/env bash +PATH="${PATH}:$(dirname "$(which "$0")")" + if [ "$1" == '--cpio' ]; then shift mode='file' @@ -10,13 +12,15 @@ mode='dir' pkgsdir="$1" fi appfsdir="$2" + +shift; shift if [ -z "${pkgsdir}" -a -z "${pkgfile}" ] || [ -z "${appfsdir}" ]; then - echo 'Usage: appfs-mk {--cpio |} ' >&2 + echo 'Usage: appfs-mk {--cpio |} [ []]' >&2 exit 1 fi appfsdir="$(cd "${appfsdir}" && pwd)" @@ -212,13 +216,27 @@ rm -f "${packagelistfile}.new" packagelistfile_hash="$(sha1 "${packagelistfile}")" mv "${packagelistfile}" "${appfsdir}/sha1/${packagelistfile_hash}" -echo "${packagelistfile_hash},sha1" > "${appfsdir}/index" +if [ -n "$APPFS_SIGN_IN_PLACE" ]; then + indexfile="${appfsdir}/index" +else + indexfile="${appfsdir}/index.new" +fi + +echo "${packagelistfile_hash},sha1" > "${indexfile}" + +if [ -x "$(which 'appfs-cert' 2>/dev/null)"]; then + appfs-cert sign-site "${indexfile}" "$@" +fi + +if [ -z "$APPFS_SIGN_IN_PLACE" ]; then + mv "${indexfile}" "${appfsdir}/index" +fi case "${mode}" in file) cd / rm -rf "${workdir}" ;; esac