Differences From
Artifact [0eb1bfa1cb]:
1 1 #! /usr/bin/env bash
2 2
3 +PATH="${PATH}:$(dirname "$(which "$0")")"
4 +
3 5 if [ "$1" == '--cpio' ]; then
4 6 shift
5 7
6 8 mode='file'
7 9
8 10 pkgfile="$1"
9 11 else
10 12 mode='dir'
11 13
12 14 pkgsdir="$1"
13 15 fi
14 16 appfsdir="$2"
17 +
18 +shift; shift
15 19
16 20 if [ -z "${pkgsdir}" -a -z "${pkgfile}" ] || [ -z "${appfsdir}" ]; then
17 - echo 'Usage: appfs-mk {--cpio <pkgfile>|<pkgsdir>} <appfsdir>' >&2
21 + echo 'Usage: appfs-mk {--cpio <pkgfile>|<pkgsdir>} <appfsdir> [<site-key> [<site-certificate>]]' >&2
18 22
19 23 exit 1
20 24 fi
21 25
22 26 appfsdir="$(cd "${appfsdir}" && pwd)"
23 27 if [ -z "${appfsdir}" ]; then
24 28 echo "Unable to find appfs directory." >&2
................................................................................
210 214 ' | sort -u > "${packagelistfile}.new"
211 215 cat "${packagelistfile}.new" > "${packagelistfile}"
212 216 rm -f "${packagelistfile}.new"
213 217
214 218 packagelistfile_hash="$(sha1 "${packagelistfile}")"
215 219 mv "${packagelistfile}" "${appfsdir}/sha1/${packagelistfile_hash}"
216 220
217 -echo "${packagelistfile_hash},sha1" > "${appfsdir}/index"
221 +if [ -n "$APPFS_SIGN_IN_PLACE" ]; then
222 + indexfile="${appfsdir}/index"
223 +else
224 + indexfile="${appfsdir}/index.new"
225 +fi
226 +
227 +echo "${packagelistfile_hash},sha1" > "${indexfile}"
228 +
229 +if [ -x "$(which 'appfs-cert' 2>/dev/null)"]; then
230 + appfs-cert sign-site "${indexfile}" "$@"
231 +fi
232 +
233 +if [ -z "$APPFS_SIGN_IN_PLACE" ]; then
234 + mv "${indexfile}" "${appfsdir}/index"
235 +fi
218 236
219 237 case "${mode}" in
220 238 file)
221 239 cd /
222 240 rm -rf "${workdir}"
223 241 ;;
224 242 esac