npbackup/bin/sign_windows.py

37 lines
981 B
Python
Raw Normal View History

2023-05-04 04:12:15 +08:00
#! /usr/bin/env python
# -*- coding: utf-8 -*-
#
# This file is part of npbackup
__intname__ = "npbackup.sign_windows"
__author__ = "Orsiris de Jong"
2024-01-04 03:01:03 +08:00
__copyright__ = "Copyright (C) 2023-2024 NetInvent"
2023-05-04 04:12:15 +08:00
__license__ = "GPL-3.0-only"
__build__ = "2023050301"
__version__ = "1.0.0"
import os
2023-08-29 15:56:49 +08:00
try:
from windows_tools.signtool import SignTool
except ImportError:
print("This tool needs windows_tools.signtool >= 0.3.1")
2023-05-04 04:12:15 +08:00
basepath = r"C:\GIT\npbackup\BUILDS"
audiences = ["private", "public"]
arches = ["x86", "x64"]
binaries = ["NPBackup.exe", "NPBackupInstaller.exe"]
signer = SignTool()
for audience in audiences:
for arch in arches:
for binary in binaries:
exe_path = os.path.join(basepath, audience, "windows", arch, binary)
result = signer.sign(exe_path, bitness=arch)
if not result:
2023-05-27 21:36:44 +08:00
raise EnvironmentError(
"Could not sign executable ! Is the PKI key connected ?"
)