Skip to content

Commit d1a3866

Browse files
theunijonasschnelli
authored andcommitted
build: Cope with spaces in filenames when creating/applying OSX sigs
1 parent 7cef321 commit d1a3866

File tree

2 files changed

+21
-22
lines changed

2 files changed

+21
-22
lines changed

contrib/macdeploy/detached-sig-apply.sh

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
#!/bin/sh
22
set -e
33

4-
UNSIGNED=$1
5-
SIGNATURE=$2
4+
UNSIGNED="$1"
5+
SIGNATURE="$2"
66
ARCH=x86_64
77
ROOTDIR=dist
8-
BUNDLE=${ROOTDIR}/Bitcoin-Core.app
98
TEMPDIR=signed.temp
109
OUTDIR=signed-app
1110

@@ -31,21 +30,21 @@ if [ -z "${CODESIGN_ALLOCATE}" ]; then
3130
CODESIGN_ALLOCATE=${TEMPDIR}/codesign_allocate
3231
fi
3332

34-
for i in `find ${TEMPDIR} -name "*.sign"`; do
35-
SIZE=`stat -c %s ${i}`
36-
TARGET_FILE=`echo ${i} | sed 's/\.sign$//'`
33+
find ${TEMPDIR} -name "*.sign" | while read i; do
34+
SIZE=`stat -c %s "${i}"`
35+
TARGET_FILE="`echo "${i}" | sed 's/\.sign$//'`"
3736

3837
echo "Allocating space for the signature of size ${SIZE} in ${TARGET_FILE}"
39-
${CODESIGN_ALLOCATE} -i ${TARGET_FILE} -a ${ARCH} ${SIZE} -o ${i}.tmp
38+
${CODESIGN_ALLOCATE} -i "${TARGET_FILE}" -a ${ARCH} ${SIZE} -o "${i}.tmp"
4039

41-
OFFSET=`${PAGESTUFF} ${i}.tmp -p | tail -2 | grep offset | sed 's/[^0-9]*//g'`
40+
OFFSET=`${PAGESTUFF} "${i}.tmp" -p | tail -2 | grep offset | sed 's/[^0-9]*//g'`
4241
if [ -z ${QUIET} ]; then
4342
echo "Attaching signature at offset ${OFFSET}"
4443
fi
4544

46-
dd if=$i of=${i}.tmp bs=1 seek=${OFFSET} count=${SIZE} 2>/dev/null
47-
mv ${i}.tmp ${TARGET_FILE}
48-
rm ${i}
45+
dd if="$i" of="${i}.tmp" bs=1 seek=${OFFSET} count=${SIZE} 2>/dev/null
46+
mv "${i}.tmp" "${TARGET_FILE}"
47+
rm "${i}"
4948
echo "Success."
5049
done
5150
mv ${TEMPDIR}/${ROOTDIR} ${OUTDIR}

contrib/macdeploy/detached-sig-create.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set -e
33

44
ROOTDIR=dist
5-
BUNDLE=${ROOTDIR}/Bitcoin-Core.app
5+
BUNDLE="${ROOTDIR}/Bitcoin Core.app"
66
CODESIGN=codesign
77
TEMPDIR=sign.temp
88
TEMPLIST=${TEMPDIR}/signatures.txt
@@ -19,19 +19,19 @@ mkdir -p ${TEMPDIR}
1919

2020
${CODESIGN} -f --file-list ${TEMPLIST} "$@" "${BUNDLE}"
2121

22-
for i in `grep -v CodeResources ${TEMPLIST}`; do
23-
TARGETFILE="${BUNDLE}/`echo ${i} | sed "s|.*${BUNDLE}/||"`"
24-
SIZE=`pagestuff $i -p | tail -2 | grep size | sed 's/[^0-9]*//g'`
25-
OFFSET=`pagestuff $i -p | tail -2 | grep offset | sed 's/[^0-9]*//g'`
22+
grep -v CodeResources < "${TEMPLIST}" | while read i; do
23+
TARGETFILE="${BUNDLE}/`echo "${i}" | sed "s|.*${BUNDLE}/||"`"
24+
SIZE=`pagestuff "$i" -p | tail -2 | grep size | sed 's/[^0-9]*//g'`
25+
OFFSET=`pagestuff "$i" -p | tail -2 | grep offset | sed 's/[^0-9]*//g'`
2626
SIGNFILE="${TEMPDIR}/${TARGETFILE}.sign"
27-
DIRNAME="`dirname ${SIGNFILE}`"
27+
DIRNAME="`dirname "${SIGNFILE}"`"
2828
mkdir -p "${DIRNAME}"
2929
echo "Adding detached signature for: ${TARGETFILE}. Size: ${SIZE}. Offset: ${OFFSET}"
30-
dd if=$i of=${SIGNFILE} bs=1 skip=${OFFSET} count=${SIZE} 2>/dev/null
30+
dd if="$i" of="${SIGNFILE}" bs=1 skip=${OFFSET} count=${SIZE} 2>/dev/null
3131
done
3232

33-
for i in `grep CodeResources ${TEMPLIST}`; do
34-
TARGETFILE="${BUNDLE}/`echo ${i} | sed "s|.*${BUNDLE}/||"`"
33+
grep CodeResources < "${TEMPLIST}" | while read i; do
34+
TARGETFILE="${BUNDLE}/`echo "${i}" | sed "s|.*${BUNDLE}/||"`"
3535
RESOURCE="${TEMPDIR}/${TARGETFILE}"
3636
DIRNAME="`dirname "${RESOURCE}"`"
3737
mkdir -p "${DIRNAME}"
@@ -41,6 +41,6 @@ done
4141

4242
rm ${TEMPLIST}
4343

44-
tar -C ${TEMPDIR} -czf ${OUT} .
45-
rm -rf ${TEMPDIR}
44+
tar -C "${TEMPDIR}" -czf "${OUT}" .
45+
rm -rf "${TEMPDIR}"
4646
echo "Created ${OUT}"

0 commit comments

Comments
 (0)