Skip to content

Commit c23e8d0

Browse files
MarcoFalkeComputerCraftr
authored andcommitted
Merge #22191: [0.21] gitian: Use custom MacOS code signing tool
0fe60a8 Use latest signapple commit (Andrew Chow) 5313d6a gitian: Remove codesign_allocate and pagestuff from MacOS build (Andrew Chow) 27d691b gitian: use signapple to create the MacOS code signature (Andrew Chow) 2f33e33 gitian: use signapple to apply the MacOS code signature (Andrew Chow) 65ce833 gitian: install signapple in gitian-osx-signer.yml (Andrew Chow) Pull request description: Backport of #20880 and #22190 ACKs for top commit: MarcoFalke: cherry-pick-only ACK 0fe60a8 🍀 Tree-SHA512: e864048fab02a1857161602dd53abba552ca3f859c133a47a5e62c28d3e4de9cd099bce86123a1b5892042b09f51cc1ddd2ed1b0c71bfba162710eaee3f5bf91
1 parent aa4c979 commit c23e8d0

File tree

4 files changed

+24
-67
lines changed

4 files changed

+24
-67
lines changed

contrib/gitian-descriptors/gitian-osx-signer.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@ architectures:
77
- "amd64"
88
packages:
99
- "faketime"
10+
- "python3-pip"
1011
remotes:
1112
- "url": "https://github.com/xep-core/xep-detached-sigs.git"
1213
"dir": "signature"
14+
- "url": "https://github.com/achow101/signapple.git"
15+
"dir": "signapple"
16+
"commit": "b084cbbf44d5330448ffce0c7d118f75781b64bd"
1317
files:
1418
- "xep-osx-unsigned.tar.gz"
1519
script: |
@@ -30,11 +34,19 @@ script: |
3034
chmod +x ${WRAP_DIR}/${prog}
3135
done
3236
33-
UNSIGNED=xep-osx-unsigned.tar.gz
37+
# Install signapple
38+
cd signapple
39+
python3 -m pip install -U pip setuptools
40+
python3 -m pip install .
41+
export PATH="$HOME/.local/bin":$PATH
42+
cd ..
43+
44+
UNSIGNED_TARBALL=xep-osx-unsigned.tar.gz
45+
UNSIGNED_APP=dist/XEP-Qt.app
3446
SIGNED=xep-osx-signed.dmg
3547
36-
tar -xf ${UNSIGNED}
48+
tar -xf ${UNSIGNED_TARBALL}
3749
OSX_VOLNAME="$(cat osx_volname)"
38-
./detached-sig-apply.sh ${UNSIGNED} signature/osx
50+
./detached-sig-apply.sh ${UNSIGNED_APP} signature/osx/dist
3951
${WRAP_DIR}/genisoimage -no-cache-inodes -D -l -probe -V "${OSX_VOLNAME}" -no-pad -r -dir-mode 0755 -apple -o uncompressed.dmg signed-app
4052
${WRAP_DIR}/dmg dmg uncompressed.dmg ${OUTDIR}/${SIGNED}

contrib/gitian-descriptors/gitian-osx.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,6 @@ script: |
138138
cp contrib/macdeploy/detached-sig-apply.sh unsigned-app-${i}
139139
cp contrib/macdeploy/detached-sig-create.sh unsigned-app-${i}
140140
cp ${BASEPREFIX}/${i}/native/bin/dmg ${BASEPREFIX}/${i}/native/bin/genisoimage unsigned-app-${i}
141-
cp ${BASEPREFIX}/${i}/native/bin/${i}-codesign_allocate unsigned-app-${i}/codesign_allocate
142-
cp ${BASEPREFIX}/${i}/native/bin/${i}-pagestuff unsigned-app-${i}/pagestuff
143141
mv dist unsigned-app-${i}
144142
pushd unsigned-app-${i}
145143
find . | sort | tar --mtime="$REFERENCE_DATETIME" --no-recursion --mode='u+rw,go+r-w,a+X' --owner=0 --group=0 -c -T - | gzip -9n > ${OUTDIR}/${DISTNAME}-osx-unsigned.tar.gz

contrib/macdeploy/detached-sig-apply.sh

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ set -e
88

99
UNSIGNED="$1"
1010
SIGNATURE="$2"
11-
ARCH=x86_64
1211
ROOTDIR=dist
13-
TEMPDIR=signed.temp
1412
OUTDIR=signed-app
13+
SIGNAPPLE=signapple
1514

1615
if [ -z "$UNSIGNED" ]; then
1716
echo "usage: $0 <unsigned app> <signature>"
@@ -23,35 +22,6 @@ if [ -z "$SIGNATURE" ]; then
2322
exit 1
2423
fi
2524

26-
rm -rf ${TEMPDIR} && mkdir -p ${TEMPDIR}
27-
tar -C ${TEMPDIR} -xf ${UNSIGNED}
28-
cp -rf "${SIGNATURE}"/* ${TEMPDIR}
29-
30-
if [ -z "${PAGESTUFF}" ]; then
31-
PAGESTUFF=${TEMPDIR}/pagestuff
32-
fi
33-
34-
if [ -z "${CODESIGN_ALLOCATE}" ]; then
35-
CODESIGN_ALLOCATE=${TEMPDIR}/codesign_allocate
36-
fi
37-
38-
find ${TEMPDIR} -name "*.sign" | while read i; do
39-
SIZE=$(stat -c %s "${i}")
40-
TARGET_FILE="$(echo "${i}" | sed 's/\.sign$//')"
41-
42-
echo "Allocating space for the signature of size ${SIZE} in ${TARGET_FILE}"
43-
${CODESIGN_ALLOCATE} -i "${TARGET_FILE}" -a ${ARCH} ${SIZE} -o "${i}.tmp"
44-
45-
OFFSET=$(${PAGESTUFF} "${i}.tmp" -p | tail -2 | grep offset | sed 's/[^0-9]*//g')
46-
if [ -z ${QUIET} ]; then
47-
echo "Attaching signature at offset ${OFFSET}"
48-
fi
49-
50-
dd if="$i" of="${i}.tmp" bs=1 seek=${OFFSET} count=${SIZE} 2>/dev/null
51-
mv "${i}.tmp" "${TARGET_FILE}"
52-
rm "${i}"
53-
echo "Success."
54-
done
55-
mv ${TEMPDIR}/${ROOTDIR} ${OUTDIR}
56-
rm -rf ${TEMPDIR}
25+
${SIGNAPPLE} apply ${UNSIGNED} ${SIGNATURE}
26+
mv ${ROOTDIR} ${OUTDIR}
5727
echo "Signed: ${OUTDIR}"

contrib/macdeploy/detached-sig-create.sh

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,44 +8,21 @@ set -e
88

99
ROOTDIR=dist
1010
BUNDLE="${ROOTDIR}/XEP-Qt.app"
11-
CODESIGN=codesign
11+
SIGNAPPLE=signapple
1212
TEMPDIR=sign.temp
13-
TEMPLIST=${TEMPDIR}/signatures.txt
1413
OUT=signature-osx.tar.gz
15-
OUTROOT=osx
14+
OUTROOT=osx/dist
1615

1716
if [ -z "$1" ]; then
18-
echo "usage: $0 <codesign args>"
19-
echo "example: $0 -s MyIdentity"
17+
echo "usage: $0 <signapple args>"
18+
echo "example: $0 <path to key>"
2019
exit 1
2120
fi
2221

23-
rm -rf ${TEMPDIR} ${TEMPLIST}
22+
rm -rf ${TEMPDIR}
2423
mkdir -p ${TEMPDIR}
2524

26-
${CODESIGN} -f --file-list ${TEMPLIST} "$@" "${BUNDLE}"
27-
28-
grep -v CodeResources < "${TEMPLIST}" | while read i; do
29-
TARGETFILE="${BUNDLE}/$(echo "${i}" | sed "s|.*${BUNDLE}/||")"
30-
SIZE=$(pagestuff "$i" -p | tail -2 | grep size | sed 's/[^0-9]*//g')
31-
OFFSET=$(pagestuff "$i" -p | tail -2 | grep offset | sed 's/[^0-9]*//g')
32-
SIGNFILE="${TEMPDIR}/${OUTROOT}/${TARGETFILE}.sign"
33-
DIRNAME="$(dirname "${SIGNFILE}")"
34-
mkdir -p "${DIRNAME}"
35-
echo "Adding detached signature for: ${TARGETFILE}. Size: ${SIZE}. Offset: ${OFFSET}"
36-
dd if="$i" of="${SIGNFILE}" bs=1 skip=${OFFSET} count=${SIZE} 2>/dev/null
37-
done
38-
39-
grep CodeResources < "${TEMPLIST}" | while read i; do
40-
TARGETFILE="${BUNDLE}/$(echo "${i}" | sed "s|.*${BUNDLE}/||")"
41-
RESOURCE="${TEMPDIR}/${OUTROOT}/${TARGETFILE}"
42-
DIRNAME="$(dirname "${RESOURCE}")"
43-
mkdir -p "${DIRNAME}"
44-
echo "Adding resource for: \"${TARGETFILE}\""
45-
cp "${i}" "${RESOURCE}"
46-
done
47-
48-
rm ${TEMPLIST}
25+
${SIGNAPPLE} sign -f --detach "${TEMPDIR}/${OUTROOT}" "$@" "${BUNDLE}"
4926

5027
tar -C "${TEMPDIR}" -czf "${OUT}" .
5128
rm -rf "${TEMPDIR}"

0 commit comments

Comments
 (0)