Merge #10777: [tests] Avoid redundant assignments. Remove unused variables
[bitcoinplatinum.git] / contrib / macdeploy / detached-sig-create.sh
blob7f017bb4f1c961714837b27424aa3f31ecf19964
1 #!/bin/sh
2 # Copyright (c) 2014-2015 The Bitcoin Core developers
3 # Distributed under the MIT software license, see the accompanying
4 # file COPYING or http://www.opensource.org/licenses/mit-license.php.
6 set -e
8 ROOTDIR=dist
9 BUNDLE="${ROOTDIR}/Bitcoin-Qt.app"
10 CODESIGN=codesign
11 TEMPDIR=sign.temp
12 TEMPLIST=${TEMPDIR}/signatures.txt
13 OUT=signature-osx.tar.gz
14 OUTROOT=osx
16 if [ ! -n "$1" ]; then
17 echo "usage: $0 <codesign args>"
18 echo "example: $0 -s MyIdentity"
19 exit 1
22 rm -rf ${TEMPDIR} ${TEMPLIST}
23 mkdir -p ${TEMPDIR}
25 ${CODESIGN} -f --file-list ${TEMPLIST} "$@" "${BUNDLE}"
27 grep -v CodeResources < "${TEMPLIST}" | while read i; do
28 TARGETFILE="${BUNDLE}/`echo "${i}" | sed "s|.*${BUNDLE}/||"`"
29 SIZE=`pagestuff "$i" -p | tail -2 | grep size | sed 's/[^0-9]*//g'`
30 OFFSET=`pagestuff "$i" -p | tail -2 | grep offset | sed 's/[^0-9]*//g'`
31 SIGNFILE="${TEMPDIR}/${OUTROOT}/${TARGETFILE}.sign"
32 DIRNAME="`dirname "${SIGNFILE}"`"
33 mkdir -p "${DIRNAME}"
34 echo "Adding detached signature for: ${TARGETFILE}. Size: ${SIZE}. Offset: ${OFFSET}"
35 dd if="$i" of="${SIGNFILE}" bs=1 skip=${OFFSET} count=${SIZE} 2>/dev/null
36 done
38 grep CodeResources < "${TEMPLIST}" | while read i; do
39 TARGETFILE="${BUNDLE}/`echo "${i}" | sed "s|.*${BUNDLE}/||"`"
40 RESOURCE="${TEMPDIR}/${OUTROOT}/${TARGETFILE}"
41 DIRNAME="`dirname "${RESOURCE}"`"
42 mkdir -p "${DIRNAME}"
43 echo "Adding resource for: "${TARGETFILE}""
44 cp "${i}" "${RESOURCE}"
45 done
47 rm ${TEMPLIST}
49 tar -C "${TEMPDIR}" -czf "${OUT}" .
50 rm -rf "${TEMPDIR}"
51 echo "Created ${OUT}"