Remove packpanda and eggcacher, don't require libpython on Linux

This commit is contained in:
rdb 2017-01-05 17:22:11 +01:00
parent 127cbc3b38
commit 53752bd376
8 changed files with 20 additions and 1386 deletions

View File

@ -1,106 +0,0 @@
// This is a little wrapper to make it easy to run a python program from the
// command line. Basically, it just interfaces to the Python API and imports
// the module that was specified by the IMPORT_MODULE preprocessor definition
// when it was compiled.
#include "dtoolbase.h"
#undef _POSIX_C_SOURCE
#undef _XOPEN_SOURCE
#include <Python.h>
#if PY_MAJOR_VERSION >= 3
#include <wchar.h>
#endif
#ifndef IMPORT_MODULE
#error IMPORT_MODULE must be defined when compiling ppython.cxx !
#endif
#define _STRINGIFY(s) #s
#define STRINGIFY(s) _STRINGIFY(s)
#define IMPORT_MODULE_STR STRINGIFY(IMPORT_MODULE)
#if defined(_WIN32) && PY_MAJOR_VERSION >= 3
// As Py_SetProgramName expects a wchar_t*, it's easiest to just use the wmain
// entry point.
int wmain(int argc, wchar_t *argv[]) {
Py_SetProgramName(argv[0]);
#elif PY_MAJOR_VERSION >= 3
// Convert from UTF-8 to wchar_t*.
int main(int argc, char *mb_argv[]) {
wchar_t **argv = new wchar_t*[argc + 1];
for (int i = 0; i < argc; ++i) {
size_t len = mbstowcs(NULL, mb_argv[i], 0);
argv[i] = new wchar_t[len + 1];
mbstowcs(argv[i], mb_argv[i], len);
argv[i][len] = 0;
}
// Just for good measure
argv[argc] = NULL;
Py_SetProgramName(argv[0]);
#else
// Python 2.
int main(int argc, char *argv[]) {
Py_SetProgramName(argv[0]);
#endif
// On Windows, we need to set pythonhome correctly. We'll try to find
// ppython.exe on the path and set pythonhome to its location.
#ifdef _WIN32
#if PY_MAJOR_VERSION >= 3
// Py_SetPythonHome expects a wchar_t in Python 3.
wchar_t *path = _wgetenv(L"PATH");
wchar_t *result = wcstok(path, L";");
while (result != NULL) {
struct _stat st;
wchar_t *ppython = (wchar_t*) malloc(wcslen(result) * 2 + 26);
wcscpy(ppython, result);
wcscat(ppython, L"\\python.exe");
if (_wstat(ppython, &st) == 0) {
Py_SetPythonHome(result);
free(ppython);
break;
}
result = wcstok(NULL, L";");
free(ppython);
}
#else
char *path = getenv("PATH");
char *result = strtok(path, ";");
while (result != NULL) {
struct stat st;
char *ppython = (char*) malloc(strlen(result) + 13);
strcpy(ppython, result);
strcat(ppython, "\\ppython.exe");
if (stat(ppython, &st) == 0) {
Py_SetPythonHome(result);
free(ppython);
break;
}
result = strtok(NULL, ";");
free(ppython);
}
#endif
#endif
Py_Initialize();
if (Py_VerboseFlag) {
fprintf(stderr, "Python %s\\n%s\\n", Py_GetVersion(), Py_GetCopyright());
}
PySys_SetArgv(argc, argv);
int sts = 0;
PyObject* m = PyImport_ImportModule(IMPORT_MODULE_STR);
if (m <= 0) {
PyErr_Print();
sts = 1;
}
Py_Finalize();
return sts;
}

View File

@ -87,8 +87,13 @@ class EggCacher:
TexturePool.releaseAllTextures()
progress += size
cacher = EggCacher(sys.argv[1:])
# Dummy main function so this can be added to console_scripts.
def main():
def main(args=None):
if args is None:
args = sys.argv[1:]
cacher = EggCacher(args)
return 0
if __name__ == '__main__':
sys.exit(main())

View File

@ -1,831 +0,0 @@
; Panda3D installation script for the Nullsoft Installation System (NSIS).
; Jon Parise <jparise@cmu.edu>
; with Ben Johnson <bkj@andrew.cmu.edu>
; with Jason Pratt <pratt@andrew.cmu.edu>
; mangled by Josh Yelon <jyelon@andrew.cmu.edu>
; Caller needs to define these variables:
;
; COMPRESSOR - either zlib or lzma
; NAME - name of what we're building (ie, "Panda3D" or "Airblade")
; SMDIRECTORY - where to put this in the start menu (ie, "Panda3D 1.1.0" or "Airblade 1.1.0")
; INSTALLDIR - where to install the program (ie, "C:\Program Files\Panda3D-1.1.0")
; OUTFILE - where to put the output file (ie, "..\nsis-output.exe")
; LICENSE - location of the license file (ie, "C:\Airblade\LICENSE.TXT")
; LANGUAGE - name of the Language file to use (ie, "English" or "Panda3DEnglish")
; RUNTEXT - text for run-box at end of installation (ie, "Run the Panda Greeting Card")
; IBITMAP - name of installer bitmap (ie, "C:\Airblade\Airblade.bmp")
; UBITMAP - name of uninstaller bitmap (ie, "C:\Airblade\Airblade.bmp")
;
; PANDA - location of panda install tree.
; PYVER - version of Python that Panda was built with (ie, "2.7")
; PANDACONF - name of panda config directory - usually $PANDA\etc
; PSOURCE - location of the panda source-tree if available, OR location of panda install tree.
; PYEXTRAS - directory containing python extras, if any.
; REGVIEW - either 32 or 64, depending on the build architecture.
;
; PPGAME - directory containing prepagaged game, if any (ie, "C:\My Games\Airblade")
; PPMAIN - python program containing prepackaged game, if any (ie, "Airblade.py")
; PPICON - file containing icon of prepackaged game.
;
!include "MUI.nsh"
!include "WinMessages.nsh"
Name "${NAME}"
InstallDir "${INSTALLDIR}"
OutFile "${OUTFILE}"
SetCompress auto
SetCompressor ${COMPRESSOR}
!define MUI_WELCOMEFINISHPAGE_BITMAP "${IBITMAP}"
!define MUI_UNWELCOMEFINISHPAGE_BITMAP "${UBITMAP}"
!define MUI_ABORTWARNING
!define MUI_FINISHPAGE_NOREBOOTSUPPORT
!define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_FUNCTION runFunction
!define MUI_FINISHPAGE_RUN_TEXT "${RUNTEXT}"
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "${LICENSE}"
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
!insertmacro MUI_LANGUAGE "${LANGUAGE}"
ShowInstDetails nevershow
ShowUninstDetails nevershow
LicenseData "${LICENSE}"
InstType "Typical"
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
var READABLE
var MANPAGE
var TUTNAME
Function runFunction
!ifdef PPGAME
ExecShell "open" "$SMPROGRAMS\${SMDIRECTORY}\Play ${NAME}.lnk"
!else
ExecShell "open" "$SMPROGRAMS\${SMDIRECTORY}\Panda Manual.lnk"
!endif
FunctionEnd
Section "${SMDIRECTORY}" SecCore
SectionIn 1 2 3 RO
SetDetailsPrint none
SetOutPath $INSTDIR
SetOverwrite try
SetOutPath $INSTDIR
File "${PANDA}\LICENSE"
SetOutPath $INSTDIR\bin
File /r "${PANDA}\bin\*.dll"
File /nonfatal /r "${PANDA}\bin\*.pyd"
File /nonfatal /r "${PANDA}\bin\Microsoft.*.manifest"
SetOutPath $INSTDIR\etc
File /r "${PANDACONF}\*"
SetOutPath $INSTDIR\direct\directscripts
File /r /x CVS /x Opt?-Win32 "${PANDA}\direct\directscripts\*"
SetOutPath $INSTDIR\direct\filter
File /r /x CVS /x Opt?-Win32 "${PANDA}\direct\filter\*.sha"
SetOutPath $INSTDIR\direct
File /r /x CVS /x Opt?-Win32 "${PANDA}\direct\*.py"
Delete "$INSTDIR\panda3d.py"
Delete "$INSTDIR\panda3d.pyc"
Delete "$INSTDIR\panda3d.pyo"
SetOutPath $INSTDIR\pandac
File /r "${PANDA}\pandac\*.py"
SetOutPath $INSTDIR\panda3d
File /r "${PANDA}\panda3d\*.py"
File /r "${PANDA}\panda3d\*.pyd"
SetOutPath $INSTDIR\python
File /r "${PANDA}\python\*"
RMDir /r "$SMPROGRAMS\${SMDIRECTORY}"
CreateDirectory "$SMPROGRAMS\${SMDIRECTORY}"
!ifdef PPGAME
SetOutPath $INSTDIR\models
File /r /x CVS "${PANDA}\models\*"
SetOutPath $INSTDIR\bin
File /r "${PANDA}\bin\eggcacher.exe"
SetOutpath $INSTDIR\game
File /r "${PPGAME}\*"
CreateShortCut "$SMPROGRAMS\${SMDIRECTORY}\Play ${NAME}.lnk" "$INSTDIR\python\ppython.exe" "-E ${PPMAIN}" "$INSTDIR\${PPICON}" 0 SW_SHOWMINIMIZED "" "Play ${NAME}"
# Preload all EGG files into the model-cache
SetOutPath $INSTDIR
SetDetailsPrint textonly
SetDetailsView show
nsExec::ExecToLog '"$INSTDIR\bin\eggcacher.exe" --concise game'
SetDetailsPrint none
SetDetailsView hide
!else
SetOutPath $INSTDIR\plugins
File /nonfatal /r "${PANDA}\plugins\*.dle"
File /nonfatal /r "${PANDA}\plugins\*.dlo"
File /nonfatal /r "${PANDA}\plugins\*.mll"
File /nonfatal /r "${PANDA}\plugins\*.mel"
File /nonfatal /r "${PANDA}\plugins\*.ms"
File "${PSOURCE}\doc\INSTALLING-PLUGINS.TXT"
SetOutPath $INSTDIR\pandac\input
File /r "${PANDA}\pandac\input\*"
SetOutPath $INSTDIR\bin
File /r "${PANDA}\bin\*.exe"
File /nonfatal /r "${PANDA}\bin\*.p3d"
SetOutPath $INSTDIR\lib
File /r /x *.exp "${PANDA}\lib\*"
SetOutPath $INSTDIR\include
File /r /x *.exp "${PANDA}\include\*"
SetOutPath $INSTDIR\Pmw
File /r /x CVS "${PANDA}\Pmw\*"
SetOutPath $INSTDIR\NSIS
File /r /x CVS "${NSISDIR}\*"
SetOutPath $INSTDIR
File /r /x CVS "${PANDA}\ReleaseNotes"
!ifdef PYEXTRAS
SetOutPath $INSTDIR\python\lib
File /nonfatal /r "${PYEXTRAS}\*"
!endif
SetOutPath $INSTDIR\models
File /r /x CVS "${PANDA}\models\*"
SetOutPath $INSTDIR\samples
File /nonfatal /r /x CVS "${PSOURCE}\samples\*"
MessageBox MB_YESNO|MB_ICONQUESTION \
"EGG caching is about to begin.$\nThis process may take a couple minute and approximately 270 MB of RAM.$\nWARNING : It might stuck if your computer resources are low.$\n$\nDo you really want to do this optional step ?" \
IDNO SkipCaching
# Preload all EGG files into the model-cache
SetOutPath $INSTDIR
SetDetailsPrint both
SetDetailsView show
nsExec::ExecToLog '"$INSTDIR\bin\eggcacher.exe" --concise models samples'
SetDetailsPrint none
SetDetailsView hide
SkipCaching:
SetOutPath $INSTDIR
WriteINIStr $INSTDIR\Website.url "InternetShortcut" "URL" "http://panda3d.org/"
WriteINIStr $INSTDIR\Manual.url "InternetShortcut" "URL" "http://panda3d.org/wiki/index.php"
WriteINIStr $INSTDIR\Samples.url "InternetShortcut" "URL" "http://panda3d.org/wiki/index.php/Sample_Programs_in_the_Distribution"
SetOutPath $INSTDIR
CreateShortCut "$SMPROGRAMS\${SMDIRECTORY}\Panda Manual.lnk" "$INSTDIR\Manual.url" "" "$INSTDIR\bin\eggcacher.exe" 0 "" "" "Panda Manual"
CreateShortCut "$SMPROGRAMS\${SMDIRECTORY}\Panda Website.lnk" "$INSTDIR\Website.url" "" "$INSTDIR\bin\eggcacher.exe" 0 "" "" "Panda Website"
CreateShortCut "$SMPROGRAMS\${SMDIRECTORY}\Sample Program Manual.lnk" "$INSTDIR\Samples.url" "" "$INSTDIR\bin\eggcacher.exe" 0 "" "" "Sample Program Manual"
FindFirst $0 $1 $INSTDIR\samples\*
loop:
StrCmp $1 "" done
StrCmp $1 "." next
StrCmp $1 ".." next
Push $1
Push "-"
Push " "
Call StrRep
Pop $R0
StrCpy $READABLE $R0
Push $1
Push "-"
Push "_"
Call StrRep
Pop $R0
StrCpy $MANPAGE $R0
CreateDirectory "$SMPROGRAMS\${SMDIRECTORY}\Sample Programs\$READABLE"
SetOutPath $INSTDIR\samples\$1
WriteINIStr $INSTDIR\samples\$1\ManualPage.url "InternetShortcut" "URL" "http://panda3d.org/wiki/index.php/Sample_Programs:_$MANPAGE"
CreateShortCut "$SMPROGRAMS\${SMDIRECTORY}\Sample Programs\$READABLE\Manual Page.lnk" "$INSTDIR\samples\$1\ManualPage.url" "" "$INSTDIR\bin\eggcacher.exe" 0 "" "" "Manual Entry on this Sample Program"
CreateShortCut "$SMPROGRAMS\${SMDIRECTORY}\Sample Programs\$READABLE\View Source Code.lnk" "$INSTDIR\samples\$1"
FindFirst $2 $3 $INSTDIR\samples\$1\Tut-*.py
iloop:
StrCmp $3 "" idone
StrCpy $TUTNAME $3 -3 4
Push $TUTNAME
Push "-"
Push " "
Call StrRep
Pop $R0
StrCpy $TUTNAME $R0
CreateShortCut "$SMPROGRAMS\${SMDIRECTORY}\Sample Programs\$READABLE\Run $TUTNAME.lnk" "$INSTDIR\python\python.exe" "-E $3" "$INSTDIR\bin\eggcacher.exe" 0 SW_SHOWMINIMIZED "" "Run $TUTNAME"
CreateShortCut "$INSTDIR\samples\$1\Run $TUTNAME.lnk" "$INSTDIR\python\python.exe" "-E $3" "$INSTDIR\bin\eggcacher.exe" 0 SW_SHOWMINIMIZED "" "Run $TUTNAME"
FindNext $2 $3
goto iloop
idone:
next:
FindNext $0 $1
Goto loop
done:
!endif
SectionEnd
Section -post
!ifdef REGVIEW
SetRegView ${REGVIEW}
!endif
!ifndef PPGAME
# Add the "bin" directory to the PATH.
Push "$INSTDIR\python"
Call RemoveFromPath
Push "$INSTDIR\python\Scripts"
Call RemoveFromPath
Push "$INSTDIR\bin"
Call RemoveFromPath
Push "$INSTDIR\python"
Call AddToPath
Push "$INSTDIR\python\Scripts"
Call AddToPath
Push "$INSTDIR\bin"
Call AddToPath
ReadRegStr $0 HKLM "Software\Python\PythonCore\${PYVER}\InstallPath" ""
StrCmp $0 "$INSTDIR\python" RegPath 0
StrCmp $0 "" RegPath 0
MessageBox MB_YESNO|MB_ICONQUESTION \
"Your system already has a copy of Python installed. Panda3D installs its own copy of Python ${PYVER}, which will install alongside your existing copy. Would you like to make Panda's copy the default Python? If you choose 'No', you will have to configure your existing copy of Python to use the Panda3D libraries, keeping in mind that this version of Panda3D can only run with Python ${PYVER}." \
IDNO SkipRegPath
RegPath:
DetailPrint "Adding registry keys for python..."
WriteRegStr HKLM "Software\Python\PythonCore\${PYVER}\InstallPath" "" "$INSTDIR\python"
SkipRegPath:
!endif
DetailPrint "Adding the uninstaller ..."
Delete "$INSTDIR\uninst.exe"
WriteUninstaller "$INSTDIR\uninst.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${SMDIRECTORY}" "DisplayName" "${SMDIRECTORY}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${SMDIRECTORY}" "UninstallString" '"$INSTDIR\uninst.exe"'
SetOutPath $INSTDIR
CreateShortcut "$SMPROGRAMS\${SMDIRECTORY}\Uninstall ${NAME}.lnk" "$INSTDIR\uninst.exe" ""
SectionEnd
Section Uninstall
!ifdef REGVIEW
SetRegView ${REGVIEW}
!endif
!ifndef PPGAME
Push "$INSTDIR\python"
Call un.RemoveFromPath
Push "$INSTDIR\python\Scripts"
Call un.RemoveFromPath
Push "$INSTDIR\bin"
Call un.RemoveFromPath
ReadRegStr $0 HKLM "Software\Python\PythonCore\${PYVER}\InstallPath" ""
StrCmp $0 "$INSTDIR\python" 0 SkipUnReg
DeleteRegKey HKLM "Software\Python\PythonCore\${PYVER}"
SkipUnReg:
!endif
Delete "$INSTDIR\uninst.exe"
RMDir /r "$SMPROGRAMS\${SMDIRECTORY}"
RMDir /r "$INSTDIR"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${SMDIRECTORY}"
SectionEnd
# --[ Utility Functions ]------------------------------------------------------
; From: http://nsis.sourceforge.net/archive/viewpage.php?pageid=91
Function IsNT
Push $0
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
StrCmp $0 "" 0 IsNT_yes
; we are not NT.
Pop $0
Push 0
Return
IsNT_yes:
; NT!!!
Pop $0
Push 1
FunctionEnd
; From: http://nsis.sourceforge.net/archive/viewpage.php?pageid=91
Function un.IsNT
Push $0
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
StrCmp $0 "" 0 unIsNT_yes
; we are not NT.
Pop $0
Push 0
Return
unIsNT_yes:
; NT!!!
Pop $0
Push 1
FunctionEnd
; From: http://nsis.sourceforge.net/archive/viewpage.php?pageid=91
Function StrStr
Push $0
Exch
Pop $0 ; $0 now have the string to find
Push $1
Exch 2
Pop $1 ; $1 now have the string to find in
Exch
Push $2
Push $3
Push $4
Push $5
StrCpy $2 -1
StrLen $3 $0
StrLen $4 $1
IntOp $4 $4 - $3
unStrStr_loop:
IntOp $2 $2 + 1
IntCmp $2 $4 0 0 unStrStrReturn_notFound
StrCpy $5 $1 $3 $2
StrCmp $5 $0 unStrStr_done unStrStr_loop
unStrStrReturn_notFound:
StrCpy $2 -1
unStrStr_done:
Pop $5
Pop $4
Pop $3
Exch $2
Exch 2
Pop $0
Pop $1
FunctionEnd
; From: http://nsis.sourceforge.net/archive/viewpage.php?pageid=91
Function un.StrStr
Push $0
Exch
Pop $0 ; $0 now have the string to find
Push $1
Exch 2
Pop $1 ; $1 now have the string to find in
Exch
Push $2
Push $3
Push $4
Push $5
StrCpy $2 -1
StrLen $3 $0
StrLen $4 $1
IntOp $4 $4 - $3
unStrStr_loop:
IntOp $2 $2 + 1
IntCmp $2 $4 0 0 unStrStrReturn_notFound
StrCpy $5 $1 $3 $2
StrCmp $5 $0 unStrStr_done unStrStr_loop
unStrStrReturn_notFound:
StrCpy $2 -1
unStrStr_done:
Pop $5
Pop $4
Pop $3
Exch $2
Exch 2
Pop $0
Pop $1
FunctionEnd
; From: http://nsis.sourceforge.net/archive/viewpage.php?pageid=91
; Commentary and smarter ';' checking by Jon Parise <jparise@cmu.edu>
Function AddToPath
Exch $0
Push $1
Push $2
Push $3
Call IsNT
Pop $1
StrCmp $1 1 AddToPath_NT
; We're not on NT, so modify the AUTOEXEC.BAT file.
StrCpy $1 $WINDIR 2
FileOpen $1 "$1\autoexec.bat" a
FileSeek $1 0 END
GetFullPathName /SHORT $0 $0
FileWrite $1 "$\r$\nSET PATH=%PATH%;$0$\r$\n"
FileClose $1
Goto AddToPath_done
AddToPath_NT:
ReadRegStr $1 HKCU "Environment" "PATH"
Call IsUserAdmin
Pop $3
; If this is an Admin user, use the System env. variable instead of the user's env. variable
StrCmp $3 1 0 +2
ReadRegStr $1 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH"
; If the PATH string is empty, jump over the mangling routines.
StrCmp $1 "" AddToPath_NTdoIt
; Pull off the last character of the PATH string. If it's a semicolon,
; we don't need to add another one, so jump to the section where we
; append the new PATH component(s).
StrCpy $2 $1 1 -1
StrCmp $2 ";" AddToPath_NTAddPath AddToPath_NTAddSemi
AddToPath_NTAddSemi:
StrCpy $1 "$1;"
Goto AddToPath_NTAddPath
AddToPath_NTAddPath:
StrCpy $0 "$1$0"
Goto AddToPath_NTdoIt
AddToPath_NTdoIt:
Call IsUserAdmin
Pop $3
StrCmp $3 1 0 NotAdmin
WriteRegExpandStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH" $0
Goto AddToPath_done
NotAdmin:
WriteRegExpandStr HKCU "Environment" "PATH" $0
AddToPath_done:
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
Pop $3
Pop $2
Pop $1
Pop $0
FunctionEnd
; From: http://nsis.sourceforge.net/archive/viewpage.php?pageid=91
Function RemoveFromPath
Exch $0
Push $1
Push $2
Push $3
Push $4
Push $5
Call IsNT
Pop $1
StrCmp $1 1 unRemoveFromPath_NT
; Not on NT
StrCpy $1 $WINDIR 2
FileOpen $1 "$1\autoexec.bat" r
GetTempFileName $4
FileOpen $2 $4 w
GetFullPathName /SHORT $0 $0
StrCpy $0 "SET PATH=%PATH%;$0"
SetRebootFlag true
Goto unRemoveFromPath_dosLoop
unRemoveFromPath_dosLoop:
FileRead $1 $3
StrCmp $3 "$0$\r$\n" unRemoveFromPath_dosLoop
StrCmp $3 "$0$\n" unRemoveFromPath_dosLoop
StrCmp $3 "$0" unRemoveFromPath_dosLoop
StrCmp $3 "" unRemoveFromPath_dosLoopEnd
FileWrite $2 $3
Goto unRemoveFromPath_dosLoop
unRemoveFromPath_dosLoopEnd:
FileClose $2
FileClose $1
StrCpy $1 $WINDIR 2
Delete "$1\autoexec.bat"
CopyFiles /SILENT $4 "$1\autoexec.bat"
Delete $4
Goto unRemoveFromPath_done
unRemoveFromPath_NT:
StrLen $2 $0
Call IsUserAdmin
Pop $5
StrCmp $5 1 0 NotAdmin
ReadRegStr $1 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH"
Push $1
Push $0
Call StrStr ; Find $0 in $1
Pop $0 ; pos of our dir
IntCmp $0 -1 unRemoveFromPath_done
; else, it is in path
StrCpy $3 $1 $0 ; $3 now has the part of the path before our dir
IntOp $2 $2 + $0 ; $2 now contains the pos after our dir in the path (';')
IntOp $2 $2 + 1 ; $2 now containts the pos after our dir and the semicolon.
StrLen $0 $1
StrCpy $1 $1 $0 $2
StrCpy $3 "$3$1"
WriteRegExpandStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH" $3
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
Goto unRemoveFromPath_done
NotAdmin:
ReadRegStr $1 HKCU "Environment" "PATH"
Push $1
Push $0
Call StrStr ; Find $0 in $1
Pop $0 ; pos of our dir
IntCmp $0 -1 unRemoveFromPath_done
; else, it is in path
StrCpy $3 $1 $0 ; $3 now has the part of the path before our dir
IntOp $2 $2 + $0 ; $2 now contains the pos after our dir in the path (';')
IntOp $2 $2 + 1 ; $2 now containts the pos after our dir and the semicolon.
StrLen $0 $1
StrCpy $1 $1 $0 $2
StrCpy $3 "$3$1"
WriteRegExpandStr HKCU "Environment" "PATH" $3
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
unRemoveFromPath_done:
Pop $5
Pop $4
Pop $3
Pop $2
Pop $1
Pop $0
FunctionEnd
; From: http://nsis.sourceforge.net/archive/viewpage.php?pageid=91
Function un.RemoveFromPath
Exch $0
Push $1
Push $2
Push $3
Push $4
Push $5
Call un.IsNT
Pop $1
StrCmp $1 1 unRemoveFromPath_NT
; Not on NT
StrCpy $1 $WINDIR 2
FileOpen $1 "$1\autoexec.bat" r
GetTempFileName $4
FileOpen $2 $4 w
GetFullPathName /SHORT $0 $0
StrCpy $0 "SET PATH=%PATH%;$0"
SetRebootFlag true
Goto unRemoveFromPath_dosLoop
unRemoveFromPath_dosLoop:
FileRead $1 $3
StrCmp $3 "$0$\r$\n" unRemoveFromPath_dosLoop
StrCmp $3 "$0$\n" unRemoveFromPath_dosLoop
StrCmp $3 "$0" unRemoveFromPath_dosLoop
StrCmp $3 "" unRemoveFromPath_dosLoopEnd
FileWrite $2 $3
Goto unRemoveFromPath_dosLoop
unRemoveFromPath_dosLoopEnd:
FileClose $2
FileClose $1
StrCpy $1 $WINDIR 2
Delete "$1\autoexec.bat"
CopyFiles /SILENT $4 "$1\autoexec.bat"
Delete $4
Goto unRemoveFromPath_done
unRemoveFromPath_NT:
StrLen $2 $0
Call un.IsUserAdmin
Pop $5
StrCmp $5 1 0 NotAdmin
ReadRegStr $1 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH"
Push $1
Push $0
Call un.StrStr ; Find $0 in $1
Pop $0 ; pos of our dir
IntCmp $0 -1 unRemoveFromPath_done
; else, it is in path
StrCpy $3 $1 $0 ; $3 now has the part of the path before our dir
IntOp $2 $2 + $0 ; $2 now contains the pos after our dir in the path (';')
IntOp $2 $2 + 1 ; $2 now containts the pos after our dir and the semicolon.
StrLen $0 $1
StrCpy $1 $1 $0 $2
StrCpy $3 "$3$1"
WriteRegExpandStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH" $3
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
Goto unRemoveFromPath_done
NotAdmin:
ReadRegStr $1 HKCU "Environment" "PATH"
Push $1
Push $0
Call un.StrStr ; Find $0 in $1
Pop $0 ; pos of our dir
IntCmp $0 -1 unRemoveFromPath_done
; else, it is in path
StrCpy $3 $1 $0 ; $3 now has the part of the path before our dir
IntOp $2 $2 + $0 ; $2 now contains the pos after our dir in the path (';')
IntOp $2 $2 + 1 ; $2 now containts the pos after our dir and the semicolon.
StrLen $0 $1
StrCpy $1 $1 $0 $2
StrCpy $3 "$3$1"
WriteRegExpandStr HKCU "Environment" "PATH" $3
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
unRemoveFromPath_done:
Pop $5
Pop $4
Pop $3
Pop $2
Pop $1
Pop $0
FunctionEnd
; From: http://nsis.sourceforge.net/archive/nsisweb.php?page=329&instances=0,11
; Localized by Ben Johnson (bkj@andrew.cmu.edu)
Function IsUserAdmin
Push $0
Push $1
Push $2
Push $3
Call IsNT
Pop $1
ClearErrors
UserInfo::GetName
;IfErrors Win9x
Pop $2
UserInfo::GetAccountType
Pop $3
; Compare results of IsNT with "1"
StrCmp $1 1 0 NotNT
;This is NT
StrCmp $3 "Admin" 0 NotAdmin
; Observation: I get here when running Win98SE. (Lilla)
; The functions UserInfo.dll looks for are there on Win98 too,
; but just don't work. So UserInfo.dll, knowing that admin isn't required
; on Win98, returns admin anyway. (per kichik)
; MessageBox MB_OK 'User "$R1" is in the Administrators group'
Pop $3
Pop $2
Pop $1
Pop $0
Push 1
Return
NotAdmin:
; You should still check for an empty string because the functions
; UserInfo.dll looks for may not be present on Windows 95. (per kichik)
#StrCmp $2 "" Win9x
#StrCpy $0 0
;MessageBox MB_OK 'User "$2" is in the "$3" group'
Pop $3
Pop $2
Pop $1
Pop $0
Push 0
Return
;Because we use IsNT, this is redundant.
#Win9x:
# ; comment/message below is by UserInfo.nsi author:
# ; This one means you don't need to care about admin or
# ; not admin because Windows 9x doesn't either
# ;MessageBox MB_OK "Error! This DLL can't run under Windows 9x!"
# StrCpy $0 0
NotNT:
;We are not NT
;Win9x doesn't have "admin" users.
;Let the user do whatever.
Pop $3
Pop $2
Pop $1
Pop $0
Push 1
FunctionEnd
Function un.IsUserAdmin
Push $0
Push $1
Push $2
Push $3
Call un.IsNT
Pop $1
ClearErrors
UserInfo::GetName
;IfErrors Win9x
Pop $2
UserInfo::GetAccountType
Pop $3
; Compare results of IsNT with "1"
StrCmp $1 1 0 NotNT
;This is NT
StrCmp $3 "Admin" 0 NotAdmin
; Observation: I get here when running Win98SE. (Lilla)
; The functions UserInfo.dll looks for are there on Win98 too,
; but just don't work. So UserInfo.dll, knowing that admin isn't required
; on Win98, returns admin anyway. (per kichik)
; MessageBox MB_OK 'User "$R1" is in the Administrators group'
Pop $3
Pop $2
Pop $1
Pop $0
Push 1
Return
NotAdmin:
; You should still check for an empty string because the functions
; UserInfo.dll looks for may not be present on Windows 95. (per kichik)
#StrCmp $2 "" Win9x
#StrCpy $0 0
;MessageBox MB_OK 'User "$2" is in the "$3" group'
Pop $3
Pop $2
Pop $1
Pop $0
Push 0
Return
;Because we use IsNT, this is redundant.
#Win9x:
# ; comment/message below is by UserInfo.nsi author:
# ; This one means you don't need to care about admin or
# ; not admin because Windows 9x doesn't either
# ;MessageBox MB_OK "Error! This DLL can't run under Windows 9x!"
# StrCpy $0 0
NotNT:
;We are not NT
;Win9x doesn't have "admin" users.
;Let the user do whatever.
Pop $3
Pop $2
Pop $1
Pop $0
Push 1
FunctionEnd
Function StrRep
;Written by dirtydingus 2003-02-20 04:30:09
; USAGE
;Push String to do replacement in (haystack)
;Push String to replace (needle)
;Push Replacement
;Call StrRep
;Pop $R0 result
;StrCpy $Result STR $R0
Exch $R4 ; $R4 = Replacement String
Exch
Exch $R3 ; $R3 = String to replace (needle)
Exch 2
Exch $R1 ; $R1 = String to do replacement in (haystack)
Push $R2 ; Replaced haystack
Push $R5 ; Len (needle)
Push $R6 ; len (haystack)
Push $R7 ; Scratch reg
StrCpy $R2 ""
StrLen $R5 $R3
StrLen $R6 $R1
loop:
StrCpy $R7 $R1 $R5
StrCmp $R7 $R3 found
StrCpy $R7 $R1 1 ; - optimization can be removed if U know len needle=1
StrCpy $R2 "$R2$R7"
StrCpy $R1 $R1 $R6 1
StrCmp $R1 "" done loop
found:
StrCpy $R2 "$R2$R4"
StrCpy $R1 $R1 $R6 $R5
StrCmp $R1 "" done loop
done:
StrCpy $R3 $R2
Pop $R7
Pop $R6
Pop $R5
Pop $R2
Pop $R1
Pop $R4
Exch $R3
FunctionEnd

View File

@ -1,424 +0,0 @@
#############################################################################
#
# packpanda - this is a tool that packages up a panda game into a
# convenient, easily-downloaded windows executable. Packpanda runs on linux
# and windows - on linux, it builds .debs and .rpms, on windows it relies on
# NSIS, the nullsoft scriptable install system, to do the hard work.
#
# This is intentionally a very simplistic game-packer with very
# limited options. The goal is simplicity, not feature richness.
# There are dozens of complex, powerful packaging tools already out
# there. This one is for people who just want to do it quick and
# easy.
#
##############################################################################
import sys, os, getopt, shutil, py_compile, subprocess
OPTIONLIST = [
("dir", 1, "Name of directory containing game"),
("name", 1, "Human-readable name of the game"),
("version", 1, "Version number to add to game name"),
("rmdir", 2, "Delete all directories with given name"),
("rmext", 2, "Delete all files with given extension"),
("fast", 0, "Use fast compression instead of good compression"),
("bam", 0, "Generate BAM files, change default-model-extension to BAM"),
("pyc", 0, "Generate PYC files"),
]
def ParseFailure():
print("")
print("packpanda usage:")
print("")
for (opt, hasval, explanation) in OPTIONLIST:
if (hasval):
print(" --%-10s %s"%(opt+" x", explanation))
else:
print(" --%-10s %s"%(opt+" ", explanation))
sys.exit(1)
def ParseOptions(args):
try:
options = {}
longopts = []
for (opt, hasval, explanation) in OPTIONLIST:
if (hasval==2):
longopts.append(opt+"=")
options[opt] = []
elif (hasval==1):
longopts.append(opt+"=")
options[opt] = ""
else:
longopts.append(opt)
options[opt] = 0
opts, extras = getopt.getopt(args, "", longopts)
for option, value in opts:
for (opt, hasval, explanation) in OPTIONLIST:
if (option == "--"+opt):
if (hasval==2): options[opt].append(value)
elif (hasval==1): options[opt] = value
else: options[opt] = 1
return options
except: ParseFailure();
OPTIONS = ParseOptions(sys.argv[1:])
##############################################################################
#
# Locate the relevant trees.
#
##############################################################################
PANDA=None
for dir in sys.path:
if (dir != "") and os.path.exists(os.path.join(dir,"direct")) and os.path.exists(os.path.join(dir,"pandac")):
PANDA=os.path.abspath(dir)
if (PANDA is None):
sys.exit("Cannot locate the panda root directory in the python path (cannot locate directory containing direct and pandac).")
print("PANDA located at "+PANDA)
if (os.path.exists(os.path.join(PANDA,"..","makepanda","makepanda.py"))) and (sys.platform != "win32" or os.path.exists(os.path.join(PANDA,"..","thirdparty","win-nsis","makensis.exe"))):
PSOURCE=os.path.abspath(os.path.join(PANDA,".."))
if (sys.platform == "win32"):
NSIS=os.path.abspath(os.path.join(PANDA,"..","thirdparty","win-nsis"))
else:
PSOURCE=PANDA
if (sys.platform == "win32"):
NSIS=os.path.join(PANDA,"nsis")
##############################################################################
#
# Identify the main parts of the game: DIR, NAME, MAIN, ICON, BITMAP, etc
#
##############################################################################
VER=OPTIONS["version"]
DIR=OPTIONS["dir"]
if (DIR==""):
print("You must specify the --dir option.")
ParseFailure()
DIR=os.path.abspath(DIR)
MYDIR=os.path.abspath(os.getcwd())
BASENAME=os.path.basename(DIR)
if (OPTIONS["name"] != ""):
NAME=OPTIONS["name"]
else:
NAME=BASENAME
SMDIRECTORY=NAME
if (VER!=""): SMDIRECTORY=SMDIRECTORY+" "+VER
PYTHONV="python"+sys.version[:3]
LICENSE=os.path.join(DIR, "license.txt")
OUTFILE=os.path.basename(DIR)
if (VER!=""): OUTFILE=OUTFILE+"-"+VER
if (sys.platform == "win32"):
ICON=os.path.join(DIR, "icon.ico")
BITMAP=os.path.join(DIR, "installer.bmp")
OUTFILE=os.path.abspath(OUTFILE+".exe")
INSTALLDIR='C:\\'+os.path.basename(DIR)
if (VER!=""): INSTALLDIR=INSTALLDIR+"-"+VER
COMPRESS="lzma"
if (OPTIONS["fast"]): COMPRESS="zlib"
if (OPTIONS["pyc"]): MAIN="main.pyc"
else: MAIN="main.py"
def PrintFileStatus(label, file):
if (os.path.exists(file)):
print("%-15s: %s"%(label, file))
else:
print("%-15s: %s (MISSING)"%(label, file))
PrintFileStatus("Dir", DIR)
print("%-15s: %s"%("Name", NAME))
print("%-15s: %s"%("Start Menu", SMDIRECTORY))
PrintFileStatus("Main", os.path.join(DIR, MAIN))
if (sys.platform == "win32"):
PrintFileStatus("Icon", ICON)
PrintFileStatus("Bitmap", BITMAP)
PrintFileStatus("License", LICENSE)
print("%-15s: %s"%("Output", OUTFILE))
if (sys.platform == "win32"):
print("%-15s: %s"%("Install Dir", INSTALLDIR))
if (os.path.isdir(DIR)==0):
sys.exit("Difficulty reading "+DIR+". Cannot continue.")
if (os.path.isfile(os.path.join(DIR, "main.py"))==0):
sys.exit("Difficulty reading main.py. Cannot continue.")
if (os.path.isfile(LICENSE)==0):
LICENSE=os.path.join(PANDA,"LICENSE")
if (sys.platform == "win32") and (os.path.isfile(BITMAP)==0):
BITMAP=os.path.join(NSIS,"Contrib","Graphics","Wizard","nsis.bmp")
if (sys.platform == "win32"):
if (os.path.isfile(ICON)==0):
PPICON="bin\\ppython.exe"
else:
PPICON="game\\icon.ico"
##############################################################################
#
# Copy the game to a temporary directory, so we can modify it safely.
#
##############################################################################
def limitedCopyTree(src, dst, rmdir):
if (os.path.isdir(src)):
if (os.path.basename(src) in rmdir):
return
if (not os.path.isdir(dst)): os.mkdir(dst)
for x in os.listdir(src):
limitedCopyTree(os.path.join(src,x), os.path.join(dst,x), rmdir)
else:
shutil.copyfile(src, dst)
TMPDIR=os.path.abspath("packpanda-TMP")
if (sys.platform == "win32"):
TMPGAME=os.path.join(TMPDIR,"game")
TMPETC=os.path.join(TMPDIR,"etc")
else:
TMPGAME=os.path.join(TMPDIR,"usr","share","games",BASENAME,"game")
TMPETC=os.path.join(TMPDIR,"usr","share","games",BASENAME,"etc")
print("")
print("Copying the game to "+TMPDIR+"...")
if (os.path.exists(TMPDIR)):
try: shutil.rmtree(TMPDIR)
except: sys.exit("Cannot delete "+TMPDIR)
try:
os.mkdir(TMPDIR)
rmdir = {}
for x in OPTIONS["rmdir"]:
rmdir[x] = 1
if not os.path.isdir( TMPGAME ):
os.makedirs(TMPGAME)
limitedCopyTree(DIR, TMPGAME, rmdir)
if not os.path.isdir( TMPETC ):
os.makedirs(TMPETC)
if sys.platform == "win32":
limitedCopyTree(os.path.join(PANDA, "etc"), TMPETC, {})
else:
shutil.copyfile("/etc/Config.prc", os.path.join(TMPETC, "Config.prc"))
shutil.copyfile("/etc/Confauto.prc", os.path.join(TMPETC, "Confauto.prc"))
except: sys.exit("Cannot copy game to "+TMPDIR)
##############################################################################
#
# If --bam requested, change default-model-extension .egg to bam.
#
##############################################################################
def ReadFile(wfile):
try:
srchandle = open(wfile, "rb")
data = srchandle.read()
srchandle.close()
return data
except: exit("Cannot read "+wfile)
def WriteFile(wfile,data):
try:
dsthandle = open(wfile, "wb")
dsthandle.write(data)
dsthandle.close()
except: exit("Cannot write "+wfile)
if OPTIONS["bam"]:
CONF=ReadFile(os.path.join(TMPETC,"Confauto.prc"))
CONF=CONF.replace("default-model-extension .egg","default-model-extension .bam")
WriteFile(os.path.join(TMPETC,"Confauto.prc"), CONF)
##############################################################################
#
# Compile all py files, convert all egg files.
#
# We do this as a sanity check, even if the user
# hasn't requested that his files be compiled.
#
##############################################################################
if (sys.platform == "win32"):
EGG2BAM=os.path.join(PANDA,"bin","egg2bam.exe")
else:
EGG2BAM=os.path.join(PANDA,"bin","egg2bam")
def egg2bam(file,bam):
present = os.path.exists(bam)
if (present): bam = "packpanda-TMP.bam";
cmd = 'egg2bam -noabs -ps rel -pd . "'+file+'" -o "'+bam+'"'
print("Executing: "+cmd)
if (sys.platform == "win32"):
res = os.spawnl(os.P_WAIT, EGG2BAM, cmd)
else:
res = os.system(cmd)
if (res != 0): sys.exit("Problem in egg file: "+file)
if (present) or (OPTIONS["bam"]==0):
os.unlink(bam)
def py2pyc(file):
print("Compiling python "+file)
pyc = file[:-3]+'.pyc'
pyo = file[:-3]+'.pyo'
if (os.path.exists(pyc)): os.unlink(pyc)
if (os.path.exists(pyo)): os.unlink(pyo)
try: py_compile.compile(file)
except: sys.exit("Cannot compile "+file)
if (OPTIONS["pyc"]==0):
if (os.path.exists(pyc)):
os.unlink(pyc)
if (os.path.exists(pyo)):
os.unlink(pyo)
def CompileFiles(file):
if (os.path.isfile(file)):
if (file.endswith(".egg")):
egg2bam(file, file[:-4]+'.bam')
elif (file.endswith(".egg.pz") or file.endswith(".egg.gz")):
egg2bam(file, file[:-7]+'.bam')
elif (file.endswith(".py")):
py2pyc(file)
else: pass
elif (os.path.isdir(file)):
for x in os.listdir(file):
CompileFiles(os.path.join(file, x))
def DeleteFiles(file):
base = os.path.basename(file).lower()
if (os.path.isdir(file)):
for pattern in OPTIONS["rmdir"]:
if pattern.lower() == base:
print("Deleting "+file)
shutil.rmtree(file)
return
for x in os.listdir(file):
DeleteFiles(os.path.join(file, x))
else:
for ext in OPTIONS["rmext"]:
if base[-(len(ext) + 1):] == ("." + ext).lower():
print("Deleting "+file)
os.unlink(file)
return
print("")
print("Compiling BAM and PYC files...")
os.chdir(TMPGAME)
CompileFiles(".")
DeleteFiles(".")
##############################################################################
#
# Now make the installer. Yay!
#
##############################################################################
INSTALLER_DEB_FILE="""
Package: BASENAME
Version: VERSION
Section: games
Priority: optional
Architecture: ARCH
Essential: no
Depends: PYTHONV
Provides: BASENAME
Description: NAME
Maintainer: Unknown
"""
INSTALLER_SPEC_FILE="""
Summary: NAME
Name: BASENAME
Version: VERSION
Release: 1
Group: Amusement/Games
License: See license file
BuildRoot: TMPDIR
BuildRequires: PYTHONV
%description
NAME
%files
%defattr(-,root,root)
/usr/bin/BASENAME
/usr/lib/games/BASENAME
/usr/share/games/BASENAME
"""
RUN_SCRIPT="""
#!/bin/sh
cd /usr/share/games/BASENAME/game
PYTHONPATH=/usr/lib/games/BASENAME:/usr/share/games/BASENAME
LD_LIBRARY_PATH=/usr/lib/games/BASENAME
PYTHONV MAIN
"""
if (sys.platform == "win32"):
CMD="\""+NSIS+"\\makensis.exe\" /V2 "
CMD=CMD+'/DCOMPRESSOR="'+COMPRESS+'" '
CMD=CMD+'/DNAME="'+NAME+'" '
CMD=CMD+'/DSMDIRECTORY="'+SMDIRECTORY+'" '
CMD=CMD+'/DINSTALLDIR="'+INSTALLDIR+'" '
CMD=CMD+'/DOUTFILE="'+OUTFILE+'" '
CMD=CMD+'/DLICENSE="'+LICENSE+'" '
CMD=CMD+'/DLANGUAGE="English" '
CMD=CMD+'/DRUNTEXT="Play '+NAME+'" '
CMD=CMD+'/DIBITMAP="'+BITMAP+'" '
CMD=CMD+'/DUBITMAP="'+BITMAP+'" '
CMD=CMD+'/DPANDA="'+PANDA+'" '
CMD=CMD+'/DPANDACONF="'+TMPETC+'" '
CMD=CMD+'/DPSOURCE="'+PSOURCE+'" '
CMD=CMD+'/DPPGAME="'+TMPGAME+'" '
CMD=CMD+'/DPPMAIN="'+MAIN+'" '
CMD=CMD+'/DPPICON="'+PPICON+'" '
CMD=CMD+'"'+PSOURCE+'\\direct\\directscripts\\packpanda.nsi"'
print("")
print(CMD)
print("packing...")
subprocess.call(CMD)
else:
os.chdir(MYDIR)
os.system("mkdir -p %s/usr/bin" % TMPDIR)
os.system("mkdir -p %s/usr/share/games/%s" % (TMPDIR, BASENAME))
os.system("mkdir -p %s/usr/lib/games/%s" % (TMPDIR, BASENAME))
os.system("cp --recursive %s/direct %s/usr/share/games/%s/direct" % (PANDA, TMPDIR, BASENAME))
os.system("cp --recursive %s/pandac %s/usr/share/games/%s/pandac" % (PANDA, TMPDIR, BASENAME))
os.system("cp --recursive %s/models %s/usr/share/games/%s/models" % (PANDA, TMPDIR, BASENAME))
os.system("cp --recursive %s/Pmw %s/usr/share/games/%s/Pmw" % (PANDA, TMPDIR, BASENAME))
os.system("cp %s %s/usr/share/games/%s/LICENSE" % (LICENSE, TMPDIR, BASENAME))
os.system("cp --recursive /usr/lib/panda3d/* %s/usr/lib/games/%s/" % (TMPDIR, BASENAME))
# Make the script to run the game
txt = RUN_SCRIPT[1:].replace("BASENAME",BASENAME).replace("PYTHONV",PYTHONV).replace("MAIN",MAIN)
WriteFile(TMPDIR+"/usr/bin/"+BASENAME, txt)
os.system("chmod +x "+TMPDIR+"/usr/bin/"+BASENAME)
if (os.path.exists("/usr/bin/rpmbuild")):
os.system("rm -rf %s/DEBIAN" % TMPDIR)
os.system("rpm -E '%_target_cpu' > packpanda-TMP.txt")
ARCH=ReadFile("packpanda-TMP.txt").strip()
os.remove("packpanda-TMP.txt")
txt = INSTALLER_SPEC_FILE[1:].replace("VERSION",VER).replace("TMPDIR",TMPDIR)
txt = txt.replace("BASENAME",BASENAME).replace("NAME",NAME).replace("PYTHONV",PYTHONV)
WriteFile("packpanda-TMP.spec", txt)
os.system("rpmbuild --define '_rpmdir "+TMPDIR+"' -bb packpanda-TMP.spec")
os.system("mv "+ARCH+"/"+BASENAME+"-"+VER+"-1."+ARCH+".rpm .")
os.rmdir(ARCH)
os.remove("packpanda-TMP.spec")
if (os.path.exists("/usr/bin/dpkg-deb")):
os.system("dpkg --print-architecture > packpanda-TMP.txt")
ARCH=ReadFile("packpanda-TMP.txt").strip()
os.remove("packpanda-TMP.txt")
txt = INSTALLER_DEB_FILE[1:].replace("VERSION",str(VER)).replace("PYTHONV",PYTHONV)
txt = txt.replace("BASENAME",BASENAME).replace("NAME",NAME).replace("ARCH",ARCH)
os.system("mkdir -p %s/DEBIAN" % TMPDIR)
os.system("cd %s ; (find usr -type f -exec md5sum {} \;) > DEBIAN/md5sums" % TMPDIR)
WriteFile(TMPDIR+"/DEBIAN/control",txt)
os.system("dpkg-deb -b "+TMPDIR+" "+BASENAME+"_"+VER+"_"+ARCH+".deb")
if not(os.path.exists("/usr/bin/rpmbuild") or os.path.exists("/usr/bin/dpkg-deb")):
exit("To build an installer, either rpmbuild or dpkg-deb must be present on your system!")
# Dummy main function so this can be added to console_scripts.
def main():
return 0

View File

@ -619,13 +619,10 @@ Section -post
DetailPrint "Preloading .egg files into the model cache..."
SetDetailsPrint listonly
; We need to set the $PATH for eggcacher.
SetOutPath $INSTDIR
ReadEnvStr $R0 "PATH"
StrCpy $R0 "$INSTDIR\python;$INSTDIR\bin;$R0"
System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("PATH", R0).r2'
nsExec::ExecToLog '"$INSTDIR\bin\eggcacher.exe" --concise models samples'
nsExec::ExecToLog '"$INSTDIR\python\python.exe" -m direct.directscripts.eggcacher --concise models samples'
Pop $0
DetailPrint "Command returned exit status $0"
SetDetailsPrint both
DetailPrint "Writing the uninstaller ..."

View File

@ -90,7 +90,7 @@ PkgListSet(["PYTHON", "DIRECT", # Python support
"ROCKET", "AWESOMIUM", # GUI libraries
"CARBON", "COCOA", # Mac OS X toolkits
"X11", # Unix platform support
"PANDATOOL", "PVIEW", "DEPLOYTOOLS", "DIRECTSCRIPTS",# Toolchain
"PANDATOOL", "PVIEW", "DEPLOYTOOLS", # Toolchain
"SKEL", # Example SKEL project
"PANDAFX", # Some distortion special lenses
"PANDAPARTICLESYSTEM", # Built in particle system
@ -172,7 +172,7 @@ def parseopts(args):
"version=","lzma","no-python","threads=","outputdir=","override=",
"static","host=","debversion=","rpmrelease=","p3dsuffix=","rtdist-version=",
"directx-sdk=", "windows-sdk=", "msvc-version=", "clean", "use-icl",
"universal", "target=", "arch=", "git-commit=",
"universal", "target=", "arch=", "git-commit=", "no-directscripts",
"use-touchinput", "no-touchinput"]
anything = 0
optimize = ""
@ -224,6 +224,7 @@ def parseopts(args):
# Backward compatibility, OPENGL was renamed to GL
elif (option=="--use-opengl"): PkgEnable("GL")
elif (option=="--no-opengl"): PkgDisable("GL")
elif (option=="--no-directscripts"): pass
elif (option=="--directx-sdk"):
STRDXSDKVERSION = value.strip().lower()
if STRDXSDKVERSION == '':
@ -832,7 +833,11 @@ if (COMPILER=="GCC"):
SmartPkgEnable("ROCKET", "", rocket_libs, "Rocket/Core.h")
if not PkgSkip("PYTHON"):
SmartPkgEnable("PYTHON", "", SDK["PYTHONVERSION"], (SDK["PYTHONVERSION"], SDK["PYTHONVERSION"] + "/Python.h"), tool = SDK["PYTHONVERSION"] + "-config")
python_lib = SDK["PYTHONVERSION"]
if not RTDIST:
# We don't link anything in the SDK with libpython.
python_lib = ""
SmartPkgEnable("PYTHON", "", python_lib, (SDK["PYTHONVERSION"], SDK["PYTHONVERSION"] + "/Python.h"), tool = SDK["PYTHONVERSION"] + "-config")
SmartPkgEnable("OPENSSL", "openssl", ("ssl", "crypto"), ("openssl/ssl.h", "openssl/crypto.h"))
SmartPkgEnable("ZLIB", "zlib", ("z"), "zlib.h")
@ -4996,17 +5001,6 @@ if (PkgSkip("DIRECT")==0):
OPTS=['DIR:direct/src/directbase', 'PYTHON']
TargetAdd('p3directbase_directbase.obj', opts=OPTS+['BUILDING:DIRECT'], input='directbase.cxx')
if not PkgSkip("PYTHON") and not RTDIST and not RUNTIME and not PkgSkip("DIRECTSCRIPTS"):
DefSymbol("BUILDING:PACKPANDA", "IMPORT_MODULE", "direct.directscripts.packpanda")
TargetAdd('packpanda.obj', opts=OPTS+['BUILDING:PACKPANDA'], input='ppython.cxx')
TargetAdd('packpanda.exe', input='packpanda.obj')
TargetAdd('packpanda.exe', opts=['PYTHON'])
DefSymbol("BUILDING:EGGCACHER", "IMPORT_MODULE", "direct.directscripts.eggcacher")
TargetAdd('eggcacher.obj', opts=OPTS+['BUILDING:EGGCACHER'], input='ppython.cxx')
TargetAdd('eggcacher.exe', input='eggcacher.obj')
TargetAdd('eggcacher.exe', opts=['PYTHON'])
#
# DIRECTORY: direct/src/dcparser/
#

View File

@ -1574,7 +1574,7 @@ def SmartPkgEnable(pkg, pkgconfig = None, libs = None, incs = None, defs = None,
location = os.path.join(GetOutputDir(), "lib", os.path.basename(location))
LibName(target_pkg, location)
else:
print(GetColor("cyan") + "Couldn't find library lib" + libname + " in thirdparty directory " + pkg.lower() + GetColor())
print(GetColor("cyan") + "Couldn't find library lib" + libname + " in thirdparty directory " + thirdparty_dir + GetColor())
for d, v in defs.values():
DefSymbol(target_pkg, d, v)

View File

@ -551,7 +551,6 @@ def makewheel(version, output_dir, platform=default_platform):
# Add a panda3d-tools directory containing the executables.
entry_points = '[console_scripts]\n'
entry_points += 'eggcacher = direct.directscripts.eggcacher:main\n'
entry_points += 'packpanda = direct.directscripts.packpanda:main\n'
tools_init = ''
for file in os.listdir(bin_dir):
basename = os.path.splitext(file)[0]