Skip to content

Commit 5a0f0d3

Browse files
committed
Fix bug #28
Add deploy helper(unfinished)
1 parent d60f636 commit 5a0f0d3

File tree

5 files changed

+109
-3
lines changed

5 files changed

+109
-3
lines changed

deploy/.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/V*-*
2+
/V*-*/
3+
/32/
4+
/64/
5+
/client/

deploy/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Deploy helper
2+
Just for generating Github release
3+
Useless for general users

deploy/deploy.py

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import os, sys, shutil
2+
from win32api import GetFileVersionInfo
3+
from json import load
4+
from re import fullmatch, IGNORECASE
5+
6+
7+
def getPEVersion(fname):
8+
try:
9+
fileInfo = GetFileVersionInfo(fname, '\\')
10+
version = "V%d.%d.%d" % (fileInfo['FileVersionMS'] / 65536,
11+
fileInfo['FileVersionMS'] % 65536,
12+
fileInfo['FileVersionLS'] / 65536)
13+
except Exception:
14+
print("Cannot get version number of", fname)
15+
return version
16+
17+
18+
os.chdir(sys.path[0])
19+
print("Current Directory:", os.getcwd())
20+
targetName = os.path.abspath(os.getcwd()).split('\\')[-2]
21+
print("Target Name", targetName)
22+
23+
src32Dir = ""
24+
src64Dir = ""
25+
dirList = os.listdir("../")
26+
27+
for i in dirList:
28+
if not os.path.isdir("../" + i):
29+
continue
30+
if not i.startswith("build"):
31+
continue
32+
33+
if i.endswith("32_bit-Release"):
34+
src32Dir = "../" + i
35+
elif i.endswith("64_bit-Release"):
36+
src64Dir = "../" + i
37+
38+
src32Path = src32Dir + "/release/" + targetName + ".exe"
39+
src64Path = src64Dir + "/release/" + targetName + ".exe"
40+
print("Target Files:")
41+
print(src32Path)
42+
print(src64Path)
43+
44+
ver32 = getPEVersion(src32Path)
45+
ver64 = getPEVersion(src64Path)
46+
print("Versions:")
47+
print("win32:", ver32)
48+
print("win64:", ver64)
49+
if ver32 != ver64:
50+
print("WARNING!")
51+
print("Version names are not the same!")
52+
dst32Dir = "./" + ver32 + "-win32"
53+
dst64Dir = "./" + ver64 + "-win64"
54+
dst32Path = dst32Dir + "/" + targetName + ".exe"
55+
dst64Path = dst64Dir + "/" + targetName + ".exe"
56+
57+
if os.path.exists(dst32Dir) and os.path.exists(dst32Path):
58+
print(dst32Path, "exists, replacing...")
59+
os.remove(dst32Path)
60+
elif not os.path.exists(dst32Dir):
61+
print(dst32Dir, "doesn't exist, creating...")
62+
shutil.copytree("./32", dst32Dir)
63+
shutil.copyfile(src32Path, dst32Path)
64+
configPath = dst32Dir + "/config"
65+
if os.path.exists(configPath):
66+
print(configPath, "exists, replacing...")
67+
shutil.rmtree(configPath)
68+
shutil.copytree("../config", configPath)
69+
70+
if os.path.exists(dst64Dir) and os.path.exists(dst64Path):
71+
print(dst64Path, "exists, replacing...")
72+
os.remove(dst64Path)
73+
elif not os.path.exists(dst64Dir):
74+
print(dst64Dir, "doesn't exist, creating...")
75+
shutil.copytree("./64", dst64Dir)
76+
shutil.copyfile(src64Path, dst64Path)
77+
configPath = dst64Dir + "/config"
78+
if os.path.exists(configPath):
79+
print(configPath, "exists, replacing...")
80+
shutil.rmtree(configPath)
81+
shutil.copytree("../config", configPath)
82+
83+
# TODO: GUI+client
84+
85+
use7z = input("Compress?(y/N)")
86+
if fullmatch("yes|y", use7z, IGNORECASE):
87+
archive32Path = dst32Dir + ".7z"
88+
archive64Path = dst64Dir + ".7z"
89+
90+
if os.path.exists(archive32Path):
91+
print(archive32Path, "exists, replacing...")
92+
os.remove(archive32Path)
93+
os.system("7z a -t7z -mmt8 -mx9 " + archive32Path + " " + dst32Dir)
94+
95+
if os.path.exists(archive64Path):
96+
print(archive64Path, "exists, replacing...")
97+
os.remove(archive64Path)
98+
os.system("7z a -t7z -mmt8 -mx9 " + archive64Path + " " + dst64Dir)

doc/tutorial/Quickstart/quickstart.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727
(4) Go to "Settings" panel. Input the config file path which matching the client you use.
2828
![](configpath.png)
2929

30-
(5) If setup.bat is required, input the script path in the "Preload script path" editbox.
30+
(5) If setup.bat is required, input the script path in the "Preload script path" editbox.
3131
![](preloadpath.png)
3232

33-
(6) If using RRG/Iceman repo, input "-p \<port\> -f" in the "Start arguments" editbox.
33+
(6) If using RRG/Iceman repo, input "-p \<port\> -f" in the "Start arguments" editbox.
3434
![](args.png)
3535

3636
***

src/ui/mainwindow.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ void MainWindow::on_MF_File_clearButton_clicked()
715715
mifare->data_clearKey();
716716
mifare->data_syncWithKeyWidget();
717717
}
718-
else if(ui->MF_File_keyButton->isChecked())
718+
else if(ui->MF_File_dataButton->isChecked())
719719
{
720720
mifare->data_clearData();
721721
mifare->data_syncWithDataWidget();

0 commit comments

Comments
 (0)