Fixed required space computing.
This commit is contained in:
parent
368e7bd5bd
commit
1e1d4ca9b8
@ -63,7 +63,6 @@ NSIS_SCRIPT_TEMPLATE = r"""
|
|||||||
Page instFiles
|
Page instFiles
|
||||||
|
|
||||||
UninstPage custom un.installConfirm un.installConfirmLeave
|
UninstPage custom un.installConfirm un.installConfirmLeave
|
||||||
UninstPage uninstConfirm
|
|
||||||
UninstPage instFiles
|
UninstPage instFiles
|
||||||
|
|
||||||
Var Dialog
|
Var Dialog
|
||||||
@ -131,8 +130,7 @@ NSIS_SCRIPT_TEMPLATE = r"""
|
|||||||
StrCpy $$CheckBox_Associate_State $${BST_CHECKED}
|
StrCpy $$CheckBox_Associate_State $${BST_CHECKED}
|
||||||
StrCpy $$CheckBox_StartMenuShortcut_State $${BST_CHECKED}
|
StrCpy $$CheckBox_StartMenuShortcut_State $${BST_CHECKED}
|
||||||
|
|
||||||
SectionGetSize 1 $$Size
|
Call GetSize
|
||||||
;Call GetSize
|
|
||||||
Call DriveSpace
|
Call DriveSpace
|
||||||
Call Language
|
Call Language
|
||||||
FunctionEnd
|
FunctionEnd
|
||||||
@ -252,9 +250,9 @@ NSIS_SCRIPT_TEMPLATE = r"""
|
|||||||
Abort
|
Abort
|
||||||
FunctionEnd
|
FunctionEnd
|
||||||
|
|
||||||
;Calculates size of installation files
|
|
||||||
Function GetSize
|
Function GetSize
|
||||||
$${GetSize} "$$PROGRAMFILES\Syncplay" "/S=0K" $$Size $$1 $$2
|
StrCpy $$Size "$totalSize"
|
||||||
|
IntOp $$Size $$Size / 1024
|
||||||
IntFmt $$SizeHex "0x%08X" $$Size
|
IntFmt $$SizeHex "0x%08X" $$Size
|
||||||
IntOp $$Size $$Size / 1024
|
IntOp $$Size $$Size / 1024
|
||||||
FunctionEnd
|
FunctionEnd
|
||||||
@ -387,7 +385,7 @@ NSIS_SCRIPT_TEMPLATE = r"""
|
|||||||
Delete $$VLC_Directory\lua\intf\syncplay.lua
|
Delete $$VLC_Directory\lua\intf\syncplay.lua
|
||||||
FunctionEnd
|
FunctionEnd
|
||||||
|
|
||||||
Section "Install" 1
|
Section "Install"
|
||||||
SetOverwrite on
|
SetOverwrite on
|
||||||
SetOutPath $$INSTDIR
|
SetOutPath $$INSTDIR
|
||||||
WriteUninstaller uninstall.exe
|
WriteUninstaller uninstall.exe
|
||||||
@ -417,7 +415,8 @@ NSIS_SCRIPT_TEMPLATE = r"""
|
|||||||
|
|
||||||
class NSISScript(object):
|
class NSISScript(object):
|
||||||
def create(self):
|
def create(self):
|
||||||
fileList = self.getBuildDirContents(OUT_DIR)
|
fileList, totalSize = self.getBuildDirContents(OUT_DIR)
|
||||||
|
print "Total size eq: {}".format(totalSize)
|
||||||
installFiles = self.prepareInstallListTemplate(fileList)
|
installFiles = self.prepareInstallListTemplate(fileList)
|
||||||
uninstallFiles = self.prepareDeleteListTemplate(fileList)
|
uninstallFiles = self.prepareDeleteListTemplate(fileList)
|
||||||
|
|
||||||
@ -427,11 +426,14 @@ class NSISScript(object):
|
|||||||
version = syncplay.version,
|
version = syncplay.version,
|
||||||
uninstallFiles = uninstallFiles,
|
uninstallFiles = uninstallFiles,
|
||||||
installFiles = installFiles,
|
installFiles = installFiles,
|
||||||
|
totalSize = totalSize,
|
||||||
)
|
)
|
||||||
with open(SETUP_SCRIPT_PATH, "w") as outfile:
|
with open(SETUP_SCRIPT_PATH, "w") as outfile:
|
||||||
outfile.write(contents)
|
outfile.write(contents)
|
||||||
|
|
||||||
def compile(self):
|
def compile(self):
|
||||||
|
if(not os.path.isfile(NSIS_COMPILE)):
|
||||||
|
return "makensis.exe not found, won't create the installer"
|
||||||
subproc = subprocess.Popen([NSIS_COMPILE, SETUP_SCRIPT_PATH], env=os.environ)
|
subproc = subprocess.Popen([NSIS_COMPILE, SETUP_SCRIPT_PATH], env=os.environ)
|
||||||
subproc.communicate()
|
subproc.communicate()
|
||||||
retcode = subproc.returncode
|
retcode = subproc.returncode
|
||||||
@ -441,14 +443,15 @@ class NSISScript(object):
|
|||||||
|
|
||||||
def getBuildDirContents(self, path):
|
def getBuildDirContents(self, path):
|
||||||
fileList = {}
|
fileList = {}
|
||||||
|
totalSize = 0
|
||||||
for root, _, files in os.walk(path):
|
for root, _, files in os.walk(path):
|
||||||
|
totalSize += sum(os.path.getsize(os.path.join(root, file_)) for file_ in files)
|
||||||
for file_ in files:
|
for file_ in files:
|
||||||
new_root = root.replace(OUT_DIR, "").strip("\\")
|
new_root = root.replace(OUT_DIR, "").strip("\\")
|
||||||
if(not fileList.has_key(new_root)):
|
if(not fileList.has_key(new_root)):
|
||||||
fileList[new_root] = []
|
fileList[new_root] = []
|
||||||
fileList[new_root].append(file_)
|
fileList[new_root].append(file_)
|
||||||
return fileList
|
return fileList, totalSize
|
||||||
|
|
||||||
|
|
||||||
def prepareInstallListTemplate(self, fileList):
|
def prepareInstallListTemplate(self, fileList):
|
||||||
create = []
|
create = []
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user