Skip to content

Commit

Permalink
Windows package/script updates. Cygwin doesn't have sudo, but one can
Browse files Browse the repository at this point in the history
get around this with
$@
as "sudo" and executable in search path.  With this, wr_install and
wr_unstall now work fine in Cygwin.
  • Loading branch information
wrcad committed Sep 25, 2017
1 parent 57673a0 commit 8ab23dd
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 30 deletions.
5 changes: 0 additions & 5 deletions wrspice/bin/wrspice.cc
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,6 @@ namespace {
"\t[-r rawfile] [-t term] [file ...]\n";
}

#ifdef WIN32
// Tell the msw interface that we're Generation 4.
const char *msw::MSWpkgSuffix = "-4";
#endif

#ifdef HAVE_LOCAL_ALLOCATOR

// This handles errors from the memory allocator if it is linked.
Expand Down
2 changes: 0 additions & 2 deletions wrspice/bin/wrspiced.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,6 @@ extern char *sys_errlist[];
#endif

#ifdef WIN32
// Tell the msw interface that we're Generation 4.
const char *msw::MSWpkgSuffix = "-4";

#define CLOSESOCKET(x) shutdown(x, SD_SEND), closesocket(x)
#else
Expand Down
2 changes: 1 addition & 1 deletion wrspice/packages/Win32/files/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ if [ -d $devkit ]; then
$utod $devkit/Makefile
$utod $devkit/admst/*
$utod $devkit/include/*
foo=`cat ../../util/adms_examples`
foo=`cat ../util/adms_examples`
for a in $foo; do
$utod $devkit/$a
done
Expand Down
9 changes: 8 additions & 1 deletion xt_base/packages/test/run
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ echo Install some old packages.
echo
rm -f $HOME/.wrclean
shopt -s nullglob
sudo ./wr_install *.rpm *.pkg *.exe
exes=*.exe
if [ -n "$exes" ]; then
for a in $exes; do
./$a
done
else
sudo ./wr_install *.rpm *.pkg *.exe
fi

# Install the 4.3 packages. The clear-old operation should be triggered
# and will uninstall the old packages before installing the new ones.
Expand Down
10 changes: 9 additions & 1 deletion xt_base/packages/util/cleanold.bat
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ goto :eof

:final
@rem The installer may not entirely remove xic and wrspice directories.
@rem This finishes the job.
@rem There also might be prog.current directories still around for some
@rem reason. This removes these if found.
set prog=%1
set ucmd=%2
set dryrun=%3
Expand All @@ -205,5 +206,12 @@ if exist %loc%\%prog% (
rd /s /q %loc%\%prog%
)
)
if exist %loc%\%prog%.current (
if %dryrun%==yes (
echo rd /s /q %loc%\%prog%.current
) else (
rd /s /q %loc%\%prog%.current
)
)
goto :eof

13 changes: 7 additions & 6 deletions xt_base/packages/util/uninstall.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
@rem Uninstall script for Microsoft Windows.

if -%1-==-- (
echo
echo.
echo Usage: uninstall [-t] prog ...
echo
echo.
echo Arguments are program names from the following:
echo adms fastcap fasthenry mozy mrouter vl wrspice xic xtlserv
echo
echo.
echo Programs listed after -t won't be uninstalled, but the command
echo that would otherwise run is printed.
exit
Expand All @@ -19,6 +19,7 @@ if -%1-==-- (
set dryrun=no

:start

if -%1-==-- exit

set appname=
Expand All @@ -36,8 +37,8 @@ if %1==vl set appname=vl_is1
if %1==wrspice set appname=wrspice_is1
if %1==xic set appname=xic_is1

if -%appname-==-- (
echo Unown program %1, ignoring.
if -%appname%-==-- (
echo Unknown program %1, ignoring.
goto :advance
)

Expand All @@ -52,7 +53,7 @@ if ERRORLEVEL 1 (
)
reg query %key%\%appname% /v UninstallString > NUL 2>&1
if ERRORLEVEL 1 (
echo %1 installation location not found in registry.
echo Uninstall info not found: %1
goto :advance
)

Expand Down
34 changes: 31 additions & 3 deletions xt_base/packages/util/wr_install
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,24 @@

#=======================================================================

command -v sudo 2>&1 > /dev/null
if [ $? != 0 ]; then
echo
echo \
"ERROR:
The sudo command is not found. You can fake it by creating a file
named \"sudo\" somewhere in your search path, with content
#!/bin/bash
\$@
Make the file executable with "chmod 755 sudo". This creates a
phony sudo command that simply executes the arguments. You may need
to run the calling script as an administrator or root user."
exit 1
fi

script_path=$(dirname $0)
PATH=$PATH:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin

usage()
Expand Down Expand Up @@ -364,6 +382,8 @@ clean_old()
check_clean()
{
dryrun=$1
windows=$2
script_path=$3
if [ -f $HOME/.wrclean ]; then
read resp < $HOME/.wrclean
fi
Expand All @@ -384,7 +404,15 @@ print commands it would otherwise execute."
echo -n "Run now? [n]: "
read resp
if [ x$resp = xy -o x$resp = xyes ]; then
clean_old $dryrun
if [ x$windows = xyes ]; then
if [ $dryrun = yes ]; then
$script_path/cleanold.bat /t
else
$script_path/cleanold.bat
fi
else
clean_old $dryrun
fi
else
if [ $dryrun != yes ]; then
echo Aborting.
Expand Down Expand Up @@ -693,7 +721,7 @@ if [ $windows = yes ]; then
continue
fi
if [ $cleanchk = no ]; then
check_clean $dryrun
check_clean $dryrun $windows $script_path
cleanchk=yes
fi
do_update $fname /usr/local $dryrun
Expand Down Expand Up @@ -747,7 +775,7 @@ for fname in $pkgs; do
continue
fi
if [ $cleanchk = no ]; then
check_clean $dryrun
check_clean $dryrun $windows $script_path
cleanchk=yes
fi
do_update $fname $prefix $dryrun
Expand Down
31 changes: 20 additions & 11 deletions xt_base/packages/util/wr_uninstall
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,27 @@
# Whiteley Research Inc., open source, Apache 2.0 license
# Stephen R. Whiteley 9/23/2017

# This is the directory that contains the uninstall.bat and osx_uninstall
# scripts, which are called under Windows and OS X respectively. By
# default, we assume that they are in the current directory, but you can
# change this.
#
script_path=.
# For Windows, you can run uninstall.bat instead of this script, the
# argument lists and effects are the same. In fact, unless you are
# running Cygwin bash or equivalent, this script won't work in
# Windows, you should instead run the batch script from a CMD prompt.

# For Windows and OS X, you can run the scripts mentioned above
# instead of this one, the argument lists and effects are the same.
# In fact, unless you are running Cygwin bash or equivalent, this
# script won't work in Windows, you should instead run the batch
# script from a CMD window.
command -v sudo 2>&1 > /dev/null
if [ $? != 0 ]; then
echo
echo \
"ERROR:
The sudo command is not found. You can fake it by creating a file
named \"sudo\" somewhere in your search path, with content
#!/bin/bash
\$@
Make the file executable with "chmod 755 sudo". This creates a
phony sudo command that simply executes the arguments. You may need
to run the calling script as an administrator or root user."
exit 1
fi

windows=no
if [ -n "$COMSPEC" ]; then
Expand Down Expand Up @@ -119,6 +127,7 @@ done
if [ -n "$names" ]; then

if [ $windows = yes ]; then
script_path=$(dirname $0)
if [ $dryrun = no ]; then
sudo $script_path/uninstall.bat $names
else
Expand Down

0 comments on commit 8ab23dd

Please sign in to comment.