업데이트 설치에 대한 코드 추가
This commit is contained in:
parent
9b6b85d05f
commit
6ae894cfd2
|
|
@ -0,0 +1,6 @@
|
|||
import cpuinfo
|
||||
|
||||
info = cpuinfo.get_cpu_info()
|
||||
print(f"CPU: {info['brand_raw']}")
|
||||
print(f"AVX 지원: {'avx' in info['flags']}")
|
||||
print(f"AVX2 지원: {'avx2' in info['flags']}")
|
||||
|
|
@ -44,7 +44,7 @@ def generate_iss_file():
|
|||
|
||||
# 템플릿 작성
|
||||
iss_template = f"""; AutoPercenty3 Inno Setup Script
|
||||
; 이 스크립트는 cx_Freeze로 빌드된 결과물이 있는 "build\exe.win-amd64-3.11" 폴더를 기반으로 인스톨러를 제작합니다.
|
||||
; 이 스크립트는 cx_Freeze로 빌드된 결과물이 있는 "build\\exe.win-amd64-3.11" 폴더를 기반으로 인스톨러를 제작합니다.
|
||||
; {date_str}에 생성됨
|
||||
|
||||
#define MyAppName "{version_module.__title__}"
|
||||
|
|
@ -59,11 +59,11 @@ def generate_iss_file():
|
|||
#define MySetupOutputDir "{version_module.__setup_output_dir__}"
|
||||
|
||||
[Setup]
|
||||
; 기본 설정
|
||||
AppId={{{{YOUR-APP-ID}}}}
|
||||
AppName={{#MyAppProgramName}}
|
||||
AppVersion={{#MyAppVersion}}
|
||||
AppPublisher={{#MyAppPublisher}}
|
||||
AppPublisherURL=
|
||||
; 기본 설치 경로: AppData\Local\AutoPercenty3
|
||||
DefaultDirName={{localappdata}}\\{{#MyAppName}}
|
||||
DefaultGroupName={{#MyAppProgramName}}
|
||||
OutputDir={{#MySetupOutputDir}}
|
||||
|
|
@ -71,6 +71,15 @@ OutputBaseFilename={{#MySetupName}}
|
|||
SetupIconFile={{#MySetupIcon}}
|
||||
Compression=lzma
|
||||
SolidCompression=yes
|
||||
|
||||
; 업데이트 관련 설정
|
||||
PrivilegesRequired=lowest
|
||||
UpdateUninstallLogAppName=yes
|
||||
AppMutex={{#MyAppName}}
|
||||
CloseApplications=yes
|
||||
RestartApplications=no
|
||||
|
||||
; 버전 정보
|
||||
VersionInfoVersion={{#MyAppVersion}}
|
||||
VersionInfoCompany={{#MyAppPublisher}}
|
||||
VersionInfoDescription={{#MyAppDescription}}
|
||||
|
|
@ -90,7 +99,7 @@ Name: "desktopicon"; Description: "{{cm:CreateDesktopIcon}}"; GroupDescription:
|
|||
Name: "{{app}}\\logs"; Permissions: users-modify
|
||||
|
||||
[Files]
|
||||
; cx_Freeze로 빌드된 결과물 모두를 설치 폴더로 복사
|
||||
; 프로그램 파일만 설치 (항상 덮어쓰기)
|
||||
Source: "build\\exe.win-amd64-3.11\\*"; DestDir: "{{app}}"; Flags: ignoreversion recursesubdirs createallsubdirs
|
||||
; VC++ 재배포 패키지 파일을 임시 폴더({{tmp}})에 복사
|
||||
Source: "VC_redist.x64.exe"; DestDir: "{{tmp}}"; Flags: deleteafterinstall
|
||||
|
|
@ -104,19 +113,94 @@ Name: "{{autodesktop}}\\{{#MyAppProgramName}}"; Filename: "{{app}}\\{{#MyAppExeN
|
|||
[Run]
|
||||
; VC++ 재배포 패키지 설치 (필요할 경우)
|
||||
Filename: "{{tmp}}\\VC_redist.x64.exe"; Parameters: "/install /passive /norestart"; StatusMsg: "VC++ 재배포 패키지 설치 중..."; Check: NeedsVCredist
|
||||
; 설치 후 프로그램 실행 (원할 경우 주석 해제)
|
||||
; 설치 후 프로그램 실행 (원할 경우)
|
||||
Filename: "{{app}}\\{{#MyAppExeName}}.exe"; Description: "{{cm:LaunchProgram,{{#MyAppProgramName}}}}"; Flags: nowait postinstall skipifsilent
|
||||
|
||||
[Code]
|
||||
function InitializeSetup(): Boolean;
|
||||
var
|
||||
OldVersion: String;
|
||||
NewVersion: String;
|
||||
begin
|
||||
Result := True;
|
||||
NewVersion := '{{#MyAppVersion}}';
|
||||
|
||||
// 이전 버전 확인
|
||||
if RegQueryStringValue(HKLM, 'Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{{#MyAppName}}_is1',
|
||||
'DisplayVersion', OldVersion) then
|
||||
begin
|
||||
// 같은 버전이거나 더 높은 버전이 설치되어 있는 경우
|
||||
if CompareVersion(OldVersion, NewVersion) >= 0 then
|
||||
begin
|
||||
MsgBox('현재 설치된 버전(' + OldVersion + ')이 이 설치 프로그램의 버전(' +
|
||||
NewVersion + ')과 같거나 더 높습니다.' + #13#10 +
|
||||
'설치를 계속할 수 없습니다.', mbInformation, MB_OK);
|
||||
Result := False;
|
||||
exit;
|
||||
end;
|
||||
|
||||
// 이전 버전이 설치되어 있는 경우 업데이트 모드로 진행
|
||||
if CompareVersion(OldVersion, NewVersion) < 0 then
|
||||
begin
|
||||
Log('업데이트 설치 진행: ' + OldVersion + ' -> ' + NewVersion);
|
||||
|
||||
// 프로그램이 실행 중인지 확인하고 종료 요청
|
||||
if IsAppRunning('{{#MyAppExeName}}.exe') then
|
||||
begin
|
||||
if MsgBox('프로그램을 업데이트하기 위해 실행 중인 프로그램을 종료해야 합니다.' + #13#10 +
|
||||
'계속하시겠습니까?', mbConfirmation, MB_YESNO) = IDNO then
|
||||
begin
|
||||
Result := False;
|
||||
exit;
|
||||
end;
|
||||
CloseApplication('{{#MyAppExeName}}.exe');
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
// 프로그램 실행 여부 확인
|
||||
function IsAppRunning(const FileName: string): Boolean;
|
||||
var
|
||||
Handle: THandle;
|
||||
begin
|
||||
Handle := FindWindowByWindowName('{{#MyAppProgramName}}'); // 프로그램의 윈도우 타이틀로 찾기
|
||||
Result := (Handle <> 0);
|
||||
end;
|
||||
|
||||
// 프로그램 종료
|
||||
procedure CloseApplication(const FileName: string);
|
||||
var
|
||||
Handle: THandle;
|
||||
begin
|
||||
Handle := FindWindowByWindowName('{{#MyAppProgramName}}');
|
||||
if Handle <> 0 then
|
||||
begin
|
||||
PostMessage(Handle, 18, 0, 0); // WM_QUIT
|
||||
Sleep(1000); // 종료 대기
|
||||
end;
|
||||
end;
|
||||
|
||||
// VC++ 재배포 패키지 필요 여부 확인
|
||||
function NeedsVCredist: Boolean;
|
||||
begin
|
||||
// 예: 레지스트리 키 확인으로 VC++ 2015~2022 x64 런타임이 깔려있는지 판단
|
||||
// (VC++ 버전에 따라 키/값이 달라질 수 있으므로, 실제 환경에 맞게 수정 필요)
|
||||
if RegKeyExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\\Microsoft\\VisualStudio\\14.0\\VC\\Runtimes\\x64') then
|
||||
Result := False // 이미 설치됨
|
||||
else
|
||||
Result := True; // 미설치 -> 설치 필요
|
||||
end;
|
||||
|
||||
// 설치 완료 후 실행 여부 확인
|
||||
function InitializeFinish(): Boolean;
|
||||
begin
|
||||
Result := True;
|
||||
if MsgBox('설치가 완료되었습니다. 프로그램을 실행하시겠습니까?' + #13#10 +
|
||||
'(실행 시 서버와 동기화하여 설정이 업데이트됩니다)',
|
||||
mbConfirmation, MB_YESNO) = IDYES then
|
||||
begin
|
||||
Exec(ExpandConstant('{{app}}\\{{#MyAppExeName}}.exe'), '', '', SW_SHOW, ewNoWait, ResultCode);
|
||||
end;
|
||||
end;
|
||||
"""
|
||||
|
||||
# .iss 파일 저장
|
||||
|
|
|
|||
|
|
@ -0,0 +1,134 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
updateManager/__version__.py 파일에서 정보를 읽어 Inno Setup 스크립트 파일을 생성합니다.
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import datetime
|
||||
import importlib.util
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def load_version_module(version_file_path):
|
||||
"""버전 정보 모듈을 동적으로 로드합니다."""
|
||||
spec = importlib.util.spec_from_file_location("version_module", version_file_path)
|
||||
version_module = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(version_module)
|
||||
return version_module
|
||||
|
||||
def generate_iss_file():
|
||||
"""버전 정보를 읽어 .iss 파일을 생성합니다."""
|
||||
# 현재 디렉토리 확인
|
||||
current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
# 버전 파일 경로
|
||||
version_file = os.path.join(current_dir, 'updateManager', '__version__.py')
|
||||
|
||||
if not os.path.exists(version_file):
|
||||
print(f"오류: 버전 파일을 찾을 수 없습니다: {version_file}")
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
# 버전 모듈 로드
|
||||
version_module = load_version_module(version_file)
|
||||
|
||||
# 현재 날짜와 시간
|
||||
now = datetime.datetime.now()
|
||||
date_str = now.strftime("%Y%m%d_%H%M%S")
|
||||
|
||||
# 생성할 .iss 파일 이름
|
||||
iss_filename = f"AutoPercenty_{date_str}.iss"
|
||||
|
||||
# 템플릿 작성
|
||||
iss_template = f"""; AutoPercenty3 Inno Setup Script
|
||||
; 이 스크립트는 cx_Freeze로 빌드된 결과물이 있는 "build\exe.win-amd64-3.11" 폴더를 기반으로 인스톨러를 제작합니다.
|
||||
; {date_str}에 생성됨
|
||||
|
||||
#define MyAppName "{version_module.__title__}"
|
||||
#define MyAppVersion "{version_module.__version__}"
|
||||
#define MyAppPublisher "{version_module.__company_name__}"
|
||||
#define MyAppProgramName "{version_module.__program_name__}"
|
||||
#define MyAppDescription "{version_module.__description__}"
|
||||
#define MyAppCopyright "{version_module.__copyright__}"
|
||||
#define MyAppExeName "{version_module.__exe_name__}"
|
||||
#define MySetupName "{version_module.__setup_name__}"
|
||||
#define MySetupIcon "{version_module.__icon_file__}"
|
||||
#define MySetupOutputDir "{version_module.__setup_output_dir__}"
|
||||
|
||||
[Setup]
|
||||
AppName={{#MyAppProgramName}}
|
||||
AppVersion={{#MyAppVersion}}
|
||||
AppPublisher={{#MyAppPublisher}}
|
||||
AppPublisherURL=
|
||||
; 기본 설치 경로: AppData\Local\AutoPercenty3
|
||||
DefaultDirName={{localappdata}}\\{{#MyAppName}}
|
||||
DefaultGroupName={{#MyAppProgramName}}
|
||||
OutputDir={{#MySetupOutputDir}}
|
||||
OutputBaseFilename={{#MySetupName}}
|
||||
SetupIconFile={{#MySetupIcon}}
|
||||
Compression=lzma
|
||||
SolidCompression=yes
|
||||
VersionInfoVersion={{#MyAppVersion}}
|
||||
VersionInfoCompany={{#MyAppPublisher}}
|
||||
VersionInfoDescription={{#MyAppDescription}}
|
||||
VersionInfoCopyright={{#MyAppCopyright}}
|
||||
VersionInfoProductName={{#MyAppProgramName}}
|
||||
VersionInfoProductVersion={{#MyAppVersion}}
|
||||
|
||||
[Languages]
|
||||
Name: "korean"; MessagesFile: "compiler:Languages\\Korean.isl"
|
||||
|
||||
[Tasks]
|
||||
Name: "desktopicon"; Description: "{{cm:CreateDesktopIcon}}"; GroupDescription: "{{cm:AdditionalIcons}}"
|
||||
|
||||
[Dirs]
|
||||
; 설치 시 {{app}}\\logs 폴더를 생성하고,
|
||||
; Users 그룹에 'modify' 권한(=쓰기 가능)을 부여
|
||||
Name: "{{app}}\\logs"; Permissions: users-modify
|
||||
|
||||
[Files]
|
||||
; cx_Freeze로 빌드된 결과물 모두를 설치 폴더로 복사
|
||||
Source: "build\\exe.win-amd64-3.11\\*"; DestDir: "{{app}}"; Flags: ignoreversion recursesubdirs createallsubdirs
|
||||
; VC++ 재배포 패키지 파일을 임시 폴더({{tmp}})에 복사
|
||||
Source: "VC_redist.x64.exe"; DestDir: "{{tmp}}"; Flags: deleteafterinstall
|
||||
|
||||
[Icons]
|
||||
; 시작 메뉴 바로가기
|
||||
Name: "{{group}}\\{{#MyAppProgramName}}"; Filename: "{{app}}\\{{#MyAppExeName}}.exe"
|
||||
; 바탕화면 바로가기
|
||||
Name: "{{autodesktop}}\\{{#MyAppProgramName}}"; Filename: "{{app}}\\{{#MyAppExeName}}.exe"; Tasks: desktopicon
|
||||
|
||||
[Run]
|
||||
; VC++ 재배포 패키지 설치 (필요할 경우)
|
||||
Filename: "{{tmp}}\\VC_redist.x64.exe"; Parameters: "/install /passive /norestart"; StatusMsg: "VC++ 재배포 패키지 설치 중..."; Check: NeedsVCredist
|
||||
; 설치 후 프로그램 실행 (원할 경우 주석 해제)
|
||||
Filename: "{{app}}\\{{#MyAppExeName}}.exe"; Description: "{{cm:LaunchProgram,{{#MyAppProgramName}}}}"; Flags: nowait postinstall skipifsilent
|
||||
|
||||
[Code]
|
||||
function NeedsVCredist: Boolean;
|
||||
begin
|
||||
// 예: 레지스트리 키 확인으로 VC++ 2015~2022 x64 런타임이 깔려있는지 판단
|
||||
// (VC++ 버전에 따라 키/값이 달라질 수 있으므로, 실제 환경에 맞게 수정 필요)
|
||||
if RegKeyExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\\Microsoft\\VisualStudio\\14.0\\VC\\Runtimes\\x64') then
|
||||
Result := False // 이미 설치됨
|
||||
else
|
||||
Result := True; // 미설치 -> 설치 필요
|
||||
end;
|
||||
"""
|
||||
|
||||
# .iss 파일 저장
|
||||
with open(iss_filename, 'w', encoding='utf-8') as f:
|
||||
f.write(iss_template)
|
||||
|
||||
print(f".iss 파일이 성공적으로 생성되었습니다: {iss_filename}")
|
||||
return iss_filename
|
||||
|
||||
except Exception as e:
|
||||
print(f"오류 발생: {e}")
|
||||
sys.exit(1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
generate_iss_file()
|
||||
Loading…
Reference in New Issue