Skip to content

Commit

Permalink
Merge branch 'master' of /usr1/git/xt
Browse files Browse the repository at this point in the history
Conflicts:
	wrspice/packages/Win32/files/preinstall.bat
	xt_base/packages/util/wr_install
  • Loading branch information
wrcad committed Sep 21, 2017
2 parents 11b831b + 8e549eb commit fd4df1d
Show file tree
Hide file tree
Showing 9 changed files with 328 additions and 498 deletions.
18 changes: 11 additions & 7 deletions wrspice/packages/Win32/files/preinstall.bat
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@rem This is called by the installer before installation, and after
@rem deinstallation.

@rem Remove links.
@rem Seems that you must use rmdir rather than del to remove a link
@rem created with mklink /j.

Expand All @@ -14,16 +15,19 @@ rmdir bin\proc2mod.exe
rmdir bin\printtoraw.exe
rmdir bin\wrspiced.exe

@rem Save backup for Safe Install.
@rem Copy to backup for Safe Install.

for /f "Tokens=1-3 delim= " %%A in (
'wrspice.current/bin/wrspice.exe --v'
set prog=xic
for /f "Tokens=1-3" %%a in (
'%prog%.current\bin\%prog%.exe --v'
) do (
set version=%%A
set version=%%a
)

if (x%version%!=x) then (
rd /s /q wrspice-%version%
xcopy /s /i /q wrspice.current wrspice-%version%
if not x%version%==x (
if exist %prog%-%version% (
rd /s /q %prog%-%version%
)
xcopy /s /i /q %prog%.current %prog%-%version%
)

17 changes: 17 additions & 0 deletions xic/packages/Win32/files/preinstall.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@rem This is called by the installer before installation, and after
@rem deinstallation.

@rem Remove links.
@rem Seems that you must use rmdir rather than del to remove a link
@rem created with mklink /j.

Expand All @@ -13,3 +14,19 @@ rmdir bin\wrdecode.exe
rmdir bin\wrencode.exe
rmdir bin\wrsetpass.exe

@rem Copy to backup for Safe Install.

set prog=xic
for /f "Tokens=1-3" %%a in (
'%prog%.current\bin\%prog%.exe --v'
) do (
set version=%%a
)

if not x%version%==x (
if exist %prog%-%version% (
rd /s /q %prog%-%version%
)
xcopy /s /i /q %prog%.current %prog%-%version%
)

5 changes: 0 additions & 5 deletions xt_base/include/miscutil/msw.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@ namespace msw {
void UnBillize(char*);
int ListPrinters(int*, char***);
const char *RawFileToPrinter(const char*, const char*);

// This must be defined in the application, and provides a suffix
// used when creating application names as known in the registry.
//
extern const char *MSWpkgSuffix;
}

#endif
Expand Down
238 changes: 72 additions & 166 deletions xt_base/miscutil/msw.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,182 +68,88 @@ msw::IsWinNT()
}


namespace {
// The inno installer places an item in the registry which gives the
// location of the uninstall directory. Return the full path to the
// directory containing this directory. The returned path uses '/' as
// the separator character.
//
// This assumes admin install only.
//
// Locations:
// Xic, XicII, WRspice:
// .../xictools/program/uninstall/uninst000.exe
// XicTools accessories:
// .../xictools/accs-uninstall/uninst000.exe
//
static char *
get_inno_uninst(const char *program)
{
unsigned int key_read = KEY_READ;

// Note that "program" is the name used by the installer.
char buf[1024];
sprintf(buf,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%s_is1",
program);

HKEY key;
long ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, buf, 0, key_read, &key);
if (ret != ERROR_SUCCESS) {
// Try again with WOW64. This seemed to be required in
// early versions of Win-7_64 (could be wrong about this),
// but presently this flag causes failure.
//
OSVERSIONINFO osv;
osv.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&osv);
if (osv.dwMajorVersion > 5 ||
(osv.dwMajorVersion == 5 && osv.dwMinorVersion >= 1)) {
// XP or later
key_read |= KEY_WOW64_64KEY;
ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, buf, 0, key_read, &key);
}
if (ret != ERROR_SUCCESS)
return (0);
}
DWORD len = 1024;
DWORD type;
ret = RegQueryValueEx(key, "UninstallString", 0, &type, (BYTE*)buf,
&len);
RegCloseKey(key);

// The string should contain the full path to the uninstall program,
//
if (ret != ERROR_SUCCESS || type != REG_SZ || len < 20)
return (0);
// ASSUMES INNO INSTALLER!!!
// Return the path to the uninstall data.
//
// The inno installer places an item in the registry which gives the
// location of the uninstall directory. Return the full path to the
// directory containing this directory. The returned path uses '/' as
// the separator character.
//
// This assumes admin install only.
//
// Locations:
// .../xictools/<program>/uninstall/uninst???.exe
//
char *
msw::GetInstallDir(const char *program)
{
unsigned int key_read = KEY_READ;

char *s = buf;
char *p = lstring::getqtok(&s);
s = strrchr(p, '\\');
if (!s) {
delete [] p;
return (0);
}
*s = 0;
s = strrchr(p, '\\');
if (!s) {
delete [] p;
return (0);
}
*s = 0;
// inno-5.5.9 on Windows 10
const char *keyfmt1 =
"Software\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%s_is1";

lstring::unix_path(p);
return (p);
}
// inno-5.5.1 on Windows 7-10
const char *keyfmt2 =
"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%s_is1";

// Note that "program" is the name used by the installer.
char buf[1024];
sprintf(buf, keyfmt1, program);

// The Ghost Installer places an item in the registry which gives the
// location of the uninstall.log file. Return the full path to the
// directory containing this file. The returned path uses '/' as the
// separator character
//
// Locations:
// Xic, XicII, WRspice:
// .../xictools/program/setup/install.log
// XicTools accessories:
// .../xictools/accs-install.log
//
static char *
get_gins_uninst(const char *program)
{
unsigned int key_read = KEY_READ;

// Note that "program" is the name used by the installer.
char buf[1024];
sprintf(buf,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%s",
program);

HKEY key;
long ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, buf, 0, key_read, &key);
if (ret != ERROR_SUCCESS) {
// Try again with WOW64. This seemed to be required in
// early versions of Win-7_64 (could be wrong about this),
// but presently this flag flag causes failure.
//
OSVERSIONINFO osv;
osv.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&osv);
if (osv.dwMajorVersion > 5 ||
(osv.dwMajorVersion == 5 && osv.dwMinorVersion >= 1)) {
// XP or later
key_read |= KEY_WOW64_64KEY;
ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, buf, 0, key_read, &key);
}
if (ret != ERROR_SUCCESS)
return (0);
}
DWORD len = 1024;
DWORD type;
ret = RegQueryValueEx(key, "UninstallString", 0, &type, (BYTE*)buf,
&len);
RegCloseKey(key);

// The string should contain the full path to the uninstall program,
// followed by the path to the uninstall log file, possibly quoted.
// If the string length is too short to make sense, abort
//
if (ret != ERROR_SUCCESS || type != REG_SZ || len < 20)
return (0);

char *s = lstring::copy(buf);
// Remove any quotes, and peel off the argument of the uninstall
// command, which is the full path to install.log
HKEY key;
long ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, buf, 0, key_read, &key);
if (ret != ERROR_SUCCESS) {
sprintf(buf, keyfmt2, program);
ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, buf, 0, key_read, &key);
}
if (ret != ERROR_SUCCESS) {
// Try again with WOW64. This seemed to be required in
// early versions of Win-7_64 (could be wrong about this),
// but presently this flag causes failure.
//
char *t = s + strlen(s) - 1;
while (t >= s && *t == '"')
*t-- = '\0';
while (t > s && *t != '"' && (!isalpha(*t) || *(t+1) != ':' ||
(*(t+2) != '/' && *(t+2) != '\\')))
t--;
char *dir = 0;
bool ok = false;
if (t > s && *t != '"') {
// found the start of the path
dir = lstring::copy(t);
t = lstring::strrdirsep(dir);
if (t) {
*t = 0; // stripped "/uninstall.log";
ok = true;
}
}
delete [] s;
if (!ok) {
delete [] dir;
dir = 0;
sprintf(buf, keyfmt1, program);
OSVERSIONINFO osv;
osv.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&osv);
if (osv.dwMajorVersion > 5 ||
(osv.dwMajorVersion == 5 && osv.dwMinorVersion >= 1)) {
// XP or later
key_read |= KEY_WOW64_64KEY;
ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, buf, 0, key_read, &key);
}
lstring::unix_path(dir);
return (dir);
if (ret != ERROR_SUCCESS)
return (0);
}
}

DWORD len = 1024;
DWORD type;
ret = RegQueryValueEx(key, "UninstallString", 0, &type, (BYTE*)buf,
&len);
RegCloseKey(key);

// Return the path to the uninstall data.
//
char *
msw::GetInstallDir(const char *program)
{
// Use the application name used in the setup file. This
// differentiates from previous releases.
// The string should contain the full path to the uninstall program,
//
char buf[256];
sprintf(buf, "%s%s", program, MSWpkgSuffix);
if (ret != ERROR_SUCCESS || type != REG_SZ || len < 20)
return (0);

char *s = buf;
char *p = lstring::getqtok(&s);
s = strrchr(p, '\\');
if (!s) {
delete [] p;
return (0);
}
*s = 0;
s = strrchr(p, '\\');
if (!s) {
delete [] p;
return (0);
}
*s = 0;

char *dir = get_inno_uninst(buf);
if (!dir)
dir = get_gins_uninst(buf);
return (dir);
lstring::unix_path(p);
return (p);
}


Expand Down
Loading

0 comments on commit fd4df1d

Please sign in to comment.