Page Menu
Home
Search
Configure Global Search
Log In
Paste
P1137
winsigner.py
Active
Public
Actions
Authored by
Nathan Letwory (jesterking)
on Oct 10 2019, 12:28 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Tags
None
Subscribers
None
import
subprocess
import
zipfile
import
pathlib
import
os
import
time
PFX
=
"D:\Dev
\\
bf-blender
\\
signbuildbot
\\
blendersigner
\\
buildbot
\\
BlenderSPC.pfx"
TIMESTAMP_URL
=
"http://timestamp.digicert.com"
WINSIGNER_UNSIGNED_DIR
=
"N:
\\
uploaded_builds
\\
unsigned"
WINSIGNER_SIGNED_DIR
=
"N:
\\
uploaded_builds
\\
signed"
cwd_with_sep
=
WINSIGNER_UNSIGNED_DIR
+
os
.
sep
to_sign_zip
=
os
.
path
.
join
(
WINSIGNER_UNSIGNED_DIR
,
"tosign.zip"
)
to_sign_file
=
os
.
path
.
join
(
WINSIGNER_UNSIGNED_DIR
,
'to_sign'
)
signed_zip
=
os
.
path
.
join
(
WINSIGNER_SIGNED_DIR
,
"signed.zip"
)
signed_file
=
os
.
path
.
join
(
WINSIGNER_SIGNED_DIR
,
'signed'
)
incantation
=
"signtool sign /v /f {} /t {}"
.
format
(
PFX
,
TIMESTAMP_URL
)
# forever
while
True
:
os
.
chdir
(
WINSIGNER_UNSIGNED_DIR
)
print
(
"Waiting for sign request..."
)
while
not
os
.
path
.
exists
(
to_sign_file
):
time
.
sleep
(
1
)
print
(
"Received request to sign"
)
with
zipfile
.
ZipFile
(
to_sign_zip
,
'r'
)
as
zf
:
zf
.
extractall
()
# signing
blenextractdirpath
=
pathlib
.
Path
(
WINSIGNER_UNSIGNED_DIR
)
allfiles
=
[
list
(
blenextractdirpath
.
rglob
(
"*.exe"
)),
list
(
blenextractdirpath
.
rglob
(
"*.dll"
)),
list
(
blenextractdirpath
.
rglob
(
"*.msi"
))
]
allfiles
=
[
y
for
x
in
allfiles
for
y
in
x
]
command
=
incantation
.
split
()
for
allfn
in
allfiles
:
allfn
=
str
(
allfn
)
if
allfn
.
find
(
"ms-win"
)
>-
1
:
continue
if
allfn
.
endswith
(
"140.all"
):
continue
allfn
=
allfn
.
replace
(
cwd_with_sep
,
""
)
command
.
append
(
allfn
)
print
(
command
)
subprocess
.
run
(
command
)
# rezip to signed dir
with
zipfile
.
ZipFile
(
signed_zip
,
'w'
)
as
zf
:
for
allfn
in
allfiles
:
allfn
=
str
(
allfn
)
shortallfn
=
allfn
.
replace
(
cwd_with_sep
,
""
)
zf
.
write
(
allfn
,
arcname
=
shortallfn
)
# cleanup
for
allfn
in
allfiles
:
os
.
remove
(
allfn
)
os
.
remove
(
to_sign_file
)
with
open
(
signed_file
,
'w'
)
as
f
:
f
.
write
(
" "
)
print
(
"Done signing"
)
Event Timeline
Nathan Letwory (jesterking)
created this paste.
Oct 10 2019, 12:28 PM
Nathan Letwory (jesterking)
mentioned this in
D6036: Sign executable and thumbnail DLL.
.
Oct 10 2019, 12:32 PM
Nathan Letwory (jesterking)
mentioned this in
T67054: Code sign Windows build on buildbot
.
Oct 10 2019, 12:36 PM
Log In to Comment