Skip to content

Commit e181bda

Browse files
committed
guix: Apply all codesignatures to Windows binaries
1 parent aafbd23 commit e181bda

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

contrib/guix/libexec/codesign.sh

+25-7
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,34 @@ mkdir -p "$DISTSRC"
7373

7474
case "$HOST" in
7575
*mingw*)
76-
find "$PWD" -name "*-unsigned.exe" | while read -r infile; do
77-
infile_base="$(basename "$infile")"
78-
79-
# Codesigned *-unsigned.exe and output to OUTDIR
76+
# Apply detached codesignatures
77+
WORKDIR=".tmp"
78+
mkdir -p ${WORKDIR}
79+
cp -r --target-directory="${WORKDIR}" "unsigned/${DISTNAME}"
80+
find "${WORKDIR}/${DISTNAME}" -name "*.exe" -type f -exec rm {} \;
81+
find unsigned/ -name "*.exe" -type f | while read -r bin
82+
do
83+
bin_base="$(realpath --relative-to=unsigned/ "${bin}")"
84+
mkdir -p "${WORKDIR}/$(dirname "${bin_base}")"
8085
osslsigncode attach-signature \
81-
-in "$infile" \
82-
-out "${OUTDIR}/${infile_base/-unsigned}" \
86+
-in "${bin}" \
87+
-out "${WORKDIR}/${bin_base/-unsigned}" \
8388
-CAfile "$GUIX_ENVIRONMENT/etc/ssl/certs/ca-certificates.crt" \
84-
-sigin codesignatures/win/"$infile_base".pem
89+
-sigin codesignatures/win/"${bin_base}".pem
8590
done
91+
92+
# Move installer to outdir
93+
cd "${WORKDIR}"
94+
find . -name "*setup.exe" -print0 \
95+
| xargs -0r mv --target-directory="${OUTDIR}"
96+
97+
# Make .zip from binaries
98+
find "${DISTNAME}" -print0 \
99+
| xargs -0r touch --no-dereference --date="@${SOURCE_DATE_EPOCH}"
100+
find "${DISTNAME}" \
101+
| sort \
102+
| zip -X@ "${OUTDIR}/${DISTNAME}-${HOST//x86_64-w64-mingw32/win64}.zip" \
103+
|| ( rm -f "${OUTDIR}/${DISTNAME}-${HOST//x86_64-w64-mingw32/win64}.zip" && exit 1 )
86104
;;
87105
*darwin*)
88106
case "$HOST" in

0 commit comments

Comments
 (0)