Skip to content

Commit

Permalink
fixed installer for windows
Browse files Browse the repository at this point in the history
Better (more graceful) error reporting for the windows installer.
  • Loading branch information
thesave committed Feb 26, 2016
1 parent 2fdfa70 commit 1294ab5
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 26 deletions.
6 changes: 4 additions & 2 deletions scripts/inst_interface.iol
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ constants
JOLIE_FOLDER = "jolie"
}

type ErrorType: void { .message: string }

interface InstInterface {
RequestResponse:
getDJH( void )( string ),
getDLP( void )( string ),
copyBins( string )( void ),
copyLaunchers( string )( void ),
copyBins( string )( void ) throws CannotCopyBins( ErrorType ),
copyLaunchers( string )( void ) throws CannotCopyInstallers( ErrorType ),
mkdir( string )( void ),
deleteDir( string )( void ),
normalisePath( string )( string ),
Expand Down
28 changes: 20 additions & 8 deletions scripts/installer.ol
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ include "runtime.iol"
include "exec.iol"
include "file.iol"
include "string_utils.iol"
include "time.iol"

include "inst_interface.iol"

outputPort OSInst{
outputPort OSInst{
Interfaces: InstInterface
}

Expand All @@ -53,7 +54,7 @@ define setLPProc
{
getDLP@OSInst()( dlp );
print@Console(
"\nInsert the installation path for the Jolie launcher executables\n" +
"\nInsert the installation path for the Jolie launcher executables\n" +
"[press Enter to use the default value: " + dlp + "]\nPlease note that using spaces in paths may cause problems.\n\n > "
)();
in( lp );
Expand All @@ -65,7 +66,7 @@ define setLPProc
}

main
{
{
// sets the installer for this OS
eInfo.type = "Jolie";
if( args[0] == "macos" || args[0] == "linux" ) {
Expand Down Expand Up @@ -95,12 +96,18 @@ main
println@Console( "\nDirectory " + jh + " does not exist. It has now been created." )();
mkdir@OSInst( jh )()
}
} else {
} else {
println@Console( "\nDirectory " + jh + " does not exist. It has now been created." )();
mkdir@OSInst( jh )()
mkdir@OSInst( jh )()
} ;

install ( CannotCopyBins =>
sleep@Time( 1000 )();
println@Console( main.CannotCopyBins.message )();
throw( FaultInstallation )
);
copyBins@OSInst( jh )();

println@Console( "\nJolie libraries installed in path " + jh + "\n" )();

setLPProc;
Expand All @@ -109,12 +116,17 @@ main
println@Console( "\nDirectory " + lp + " does not exist. It has now been created." )();
mkdir@OSInst( lp )()
};
copyLaunchers@OSInst( lp )();

install ( CannotCopyInstallers =>
sleep@Time( 1000 )();
println@Console( main.CannotCopyInstallers.message )();
throw( FaultInstallation )
);
copyLaunchers@OSInst( lp )();

println@Console( "\nJolie launcher executables installed in path " + lp + "\n" )();

installationFinished@OSInst( jh )();

println@Console( "\nJolie is installed. Try running 'jolie' under a new shell [press Enter to exit]" )()
}

39 changes: 23 additions & 16 deletions scripts/windows_installer.ol
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ constants
{
DEFAULT_JOLIE_HOME = "C:\\Jolie",
DEFAULT_LAUNCHERS_PATH = "C:\\Windows\\system32",
LAUNCHERS_PATH = "launchers/windows"
LAUNCHERS_PATH = "launchers/windows",
ADMIN_ERROR = "Error: the installer could not find the launchers files. To complete the installation, try to run the installer with administrator privileges."
}

inputPort In {
Expand Down Expand Up @@ -73,39 +74,45 @@ main
e.args[#e.args] = jh;
e.args[#e.args] = "/m";
e.waitFor = 1;
exec@Exec( e )( e_res );
exec@Exec( e )( e_res );
if( e_res.exitCode == 0 ) {
// command succeeded
println@Console("Environment variable JOLIE_HOME created.")()
} else {
println@Console("Creation of variable JOLIE_HOME failed. Please manually add variable JOLIE_HOME=" + jh + " to your system environment")()
};
println@Console("IMPORTANT: if you chose a custom installation directory for the launchers, remember to add this directory to your system environment PATH variable")()

} ] { nullProcess }

[ deleteDir( dir )() {
deleteDir@File( dir )( delete_resp );
if ( !delete_resp ) { throw( CannotDeleteBinFolder ) }
} ] { nullProcess }

[ mkdir( dir )() {
mkdir@File( dir )( delete_resp );
if ( !delete_resp ) { throw( CannotCreateBinFolder ) }
if ( !delete_resp ) { throw( CannotCreateBinFolder ) }
} ] { nullProcess }

[ copyBins( bin_folder )(){
// copy the content of dist/jolie
copy.from = cd + "/" + DIST_FOLDER + "/" + JOLIE_FOLDER + "/";
copy.to = bin_folder;
copyDir@File( copy )( copy_resp );
if ( !copy_resp ) { throw( CannotCopyBins ) }
scope ( s ){
install ( FileNotFound => throw( CannotCopyBins, { .message = ADMIN_ERROR } ) );
// copy the content of dist/jolie
copy.from = cd + "/" + DIST_FOLDER + "/" + JOLIE_FOLDER + "/";
copy.to = bin_folder;
copyDir@File( copy )( copy_resp );
if ( !copy_resp ) { throw( FileNotFound ) }
}
}]{ nullProcess }

[ copyLaunchers( l_folder )() {
copy.from = cd + "/" + DIST_FOLDER + "/" + LAUNCHERS_PATH + "/";
copy.to = l_folder;
copyDir@File( copy )( copy_resp );
if ( !copy_resp ) { throw( CannotCopyLaunchers ) }
scope ( s ){
install ( FileNotFound => throw( CannotCopyInstallers, { .message = ADMIN_ERROR } ) );
copy.from = cd + "/" + DIST_FOLDER + "/" + LAUNCHERS_PATH + "/";
copy.to = l_folder;
copyDir@File( copy )( copy_resp );
if ( !copy_resp ) { throw( FileNotFound ) }
}
}]{ nullProcess }
}

0 comments on commit 1294ab5

Please sign in to comment.