Commit 6b1e75e6 authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Handle signing of the installer for the Windows desktop version of Linphone.

parent 2a03c7dd
......@@ -117,5 +117,30 @@ if(WIN32)
set(CPACK_NSIS_PACKAGE_NAME "Linphone ${LINPHONE_MAJOR_VERSION}.${LINPHONE_MINOR_VERSION}.${LINPHONE_MICRO_VERSION}")
set(CPACK_NSIS_URL_INFO_ABOUT "http://www.linphone.org/")
set(CPACK_NSIS_MUI_FINISHPAGE_RUN "linphone")
# Sign the installer
set(TIMESTAMP_URL "http://timestamp.verisign.com/scripts/timestamp.dll")
set(PFX_FILE "${CMAKE_CURRENT_SOURCE_DIR}/sign/linphone.pfx")
set(PASSPHRASE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/sign/passphrase.txt")
get_filename_component(WINSDK_DIR "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows;CurrentInstallFolder]" REALPATH CACHE)
find_package(PythonInterp)
find_program(SIGNTOOL signtool PATHS ${WINSDK_DIR}/bin)
set(SIGNTOOL_COMMAND "${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/signtool.py")
set(PERFORM_SIGNING 0)
if(EXISTS ${PFX_FILE})
if(SIGNTOOL)
set(SIGNTOOL_COMMAND "${SIGNTOOL_COMMAND} signtool sign /f ${PFX_FILE}")
set(SIGNTOOL_COMMAND "${SIGNTOOL_COMMAND} /p ${PASSPHRASE_FILE}")
set(SIGNTOOL_COMMAND "${SIGNTOOL_COMMAND} /t ${TIMESTAMP_URL}")
message("Found signtool and certificate ${PFX_FILE}")
set(PERFORM_SIGNING 1)
else()
message(STATUS "Could not find signtool! Code signing disabled (${SIGNTOOL})")
endif()
else()
message(STATUS "No signtool certificate found; assuming development machine (${PFX_FILE})")
endif()
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/WindowsPackaging.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/WindowsPackaging.cmake" @ONLY)
install(SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/WindowsPackaging.cmake")
endif()
include(CPack)
############################################################################
# WindowsPackaging.cmake
# Copyright (C) 2014 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
############################################################################
if(NOT "${CMAKE_INSTALL_PREFIX}" MATCHES .*/_CPack_Packages/.*)
execute_process(
COMMAND ${CMAKE_CPACK_COMMAND} -G NSIS
RESULT_VARIABLE CPACK_COMMAND_SUCCESS
)
if(@PERFORM_SIGNING@)
execute_process(
COMMAND @SIGNTOOL_COMMAND@ @CMAKE_CURRENT_BINARY_DIR@/@CPACK_PACKAGE_FILE_NAME@.exe
)
endif()
endif()
#!/usr/bin/env python
import os, sys
import subprocess
class PassFile:
def __init__(self, file):
self.file = file
def password(self, v):
file = open(self.file, "r");
line = file.readline().strip()
file.close()
return line
if __name__ == '__main__':
if len(sys.argv) <= 2:
sys.exit(0)
for i,arg in enumerate(sys.argv):
if arg == "/p":
if (i + 1) == len(sys.argv):
print "Missing password argument"
sys.exit(3)
try:
sys.argv[i+1] = PassFile(sys.argv[i+1]).password(None)
except IOError:
print "Password file not found"
sys.exit(3)
actual_args = sys.argv[1:]
ret = subprocess.call(actual_args)
sys.exit(ret)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment