Installer.doc Documentation for 1.24 Installer Last Revised: January 12th, 1993 (C) Copyright 1991-93 Commodore-Amiga,Inc. All Rights Resrved Contents: 1 Background 2 Overview 2.1 Standard Invocation 2.2 Initial Actions 2.3 Startup Screens 2.4 Installation Actions 3 Scripting Language Tutorial 3.1 Basic Elements 3.2 Escape Characters 3.3 Symbols (Variables) 3.4 Types of Symbols 3.5 Statements 3.6 Data Types 3.7 Special Features 3.8 Miscellaneous 4 Installer Language Reference 4.1 Notes 4.2 Statements 4.3 Control Statements 4.4 Debugging Statements 4.5 User-Defined Procedures 4.6 Functions 4.7 Summary of Parameters 4.8 Pre-Defined Variables 5 Installer Language Quick Reference 5.1 Overview 5.2 Quick Language Overview 5.3 Pre-Defined Variables 5.4 Default Help String Variables 5.5 Statements 5.6 Functions Section 1: Background Installation of applications from floppy disks onto a hard disk has proven to be a very inconsistent and often frustrating endeavor for most end-users. This has been caused by many factors, some of which are: a. Many products do not come with any utility or script to install an application on a hard disk. b. Many products assume a great deal of familiarity with the startup process of the Amiga and applications, including assigns, device names (as opposed to volume names), etc. c. The installation scripts or utilities included with some products vary widely in their ability to deal with different environments and systems. About a year ago, Commodore set out to remedy this situation, by developing a standard tool that developers can include with their products, which provides the user with a standard way to install applications. The Installer's features were based on a number of assumptions: a. Installation requirements vary widely---some need assigns, some need new drawers created, some install pieces in system drawers such as a fonts drawer, a `product' might be just an upgrade and the installation must check to see which version (if any) they currently have installed, etc. b. Different users have different levels of comfort and expertise when attempting to install software, and the Installer should be able to accommodate a range of users. Many installation scripts assume a great deal of knowledge, which is very intimidating for a novice. c. The installer tool must be very flexible internally, but present a consistent pleasant graphical user interface to the user that only shows the user information or prompts that they need to see. The Installer should be resolution, color and font sensitive. d. Writing scripts to install an application will require some effort, but certainly no more than writing an AmigaDOS shell script equivalent, and the resulting installation procedure will be more friendly, flexible, and much better looking than the latter. e. Not everyone will be running 2.0 by the time the tool becomes available, so it must run under 1.3 and 2.0. Section 2: Overview The Installer is a script driven program, that presents a consistent installation environment to the end user. The user never sees the script. Instead they are presented with simple yes/no choices, and may be asked to specify locations to put things on their system. To accommodate different user levels, they can choose to run the tool in novice, average or expert modes. Scripts can include help text to explain any choices that the user must make. At each step the user is given the option of aborting the installation. 2.1 Standard Invocation The Installer program requires a 10000 byte stack. Project icons for Installer script should indicate a stack size of 10000. If starting Installer from a CLI, first do a "Stack 10000". The Installer is normally started up from a Workbench Project icon which has the same name as the script to interpret and has a default tool of Installer. A number of tooltypes are available to modify the operation of the Installer: SCRIPT - Path to a script file to be used with Installer. APPNAME - Name of the application being installed (appears in the startup screen). This MUST be given. MINUSER - The minimum possible operation mode of the installation for a script. This will be either NOVICE (all decisions made by Installer), AVERAGE (only important decisions made by user) or EXPERT (user confirms almost all actions). The Default is NOVICE. DEFUSER - Indicates which operation mode button should be initially selected. Same values as MINUSER, with the value of the MINUSER tooltype being the default (which will be NOVICE if MINUSER not defined). NOPRINT - If set to FALSE, then the printer option in the log file settings will be ghosted. PRETEND - If set to FALSE, indicates that PRETEND mode not available for this script. LANGUAGE - Used to set the variable @language (default for @language is "english". The use of this variable is left up to the install script. LOGFILE - The name of the log file that the Installer should use. This must be a full path. The default is "install_log_file". LOG - In NOVICE mode the default is to create a log file (to disk). If this tooltype is set to FALSE, the creation of a log file in NOVICE mode is disabled. Although the installer can be started up from the CLI, that is not the recommended mode. CLI invocation is provided mainly for script debugging purposes. The command template is: SCRIPT/k,APPNAME,MINUSER,DEFUSER,LOGFILE,NOLOG/s,NOPRETEND/s, NOPRINT/s,LANGUAGE/k 2.2 Initial Actions The first thing the installer does is compile the installation script into an internal format that can be easily interpreted. If there are syntax errors in the script, they will be caught during this phase. 2.3 Startup Screens Next, the Installer asks the user what Installation Mode to run in, either NOVICE, AVERAGE or EXPERT. If the user chooses NOVICE, they will not be asked any more questions (although they may be requested to do things). In the other user levels, a second display appears asking the user if he wants to install "for real" or "do a dry run", and if he wants a transcription of the installation process written to either a file or printer. 2.4 Installation Actions Now the Installer interprets its internal version of the script. Any commands that call for a user interface will cause the Installer to algorithmically generate a display, always including buttons to allow for context sensitive help and aborting the installation. Section 3: Scripting Language Tutorial The script language of the Installer is based on LISP. It is not difficult to learn, but requires a lot of parentheses. An Installer script can easily be made to look very readable. 3.1 Basic Elements The basic elements of the installer language are: Type Example ---- ------- decimal integers 5 hexadecimal integers $a000 binary integers %0010010 strings "Hello" or 'Hello' symbols x comments ; this is a comment ( ) for statement definition space delimits symbols (or any white space) 3.2 Escape Characters Escape characters are supported as in the C language: Escape sequence Produces -------- -------- '\n' newline character '\r' return character '\t' tab character '\0' a NUL character '\"' a double-quote '\\' a backslash 3.3 Symbols (Variables) A symbol is any sequence of characters surrounded by spaces that is not a quoted string, an integer or a control character. This means that symbols can have punctuation marks and other special characters in them. The following are all valid symbols: x total this-is-a-symbol **name** @#__#@ 3.4 Types of Symbols There are three types of symbols: a. user-defined symbols. These are created using the "set" function. b. built-in function names. These include things like '+' and '*' as well as textual names such as "delete" or "rename". c. special symbols. These are variables which are created by the installer before the script actually starts to run, and are used to tell the script certain things about the environment. These symbols always begin with an '@' sign. An example is '@default-dest' which tells you the default directory that was selected by the installer. 3.5 Statements The format of a statement is: (operator ...) A statement to assign the value '5' to the variable 'x' would be: (set x 5) You can read this as "set x to 5". Note that the variable 'x' does not have to be declared -- it is created by this statement. Note that there is no difference between operators and functions -- the function 'set' and the arithmetic operator '+' are both used exactly the same way. Combining statements: A statement can be used as the operand to another statement as follows: (set var (+ 3 5)) In this case, the statement '(+ 3 5)' is evaluated first, and the result is 8. You can think of this as having the '(+ 3 5)' part being replaced by an 8. So now we are left with: (set var 8) which is the same form as the first example. Note that the '(+ 3 5)' part actually produced a value: 8. This is called the "result" of the statement. Many statements return results, even some that might surprise you (such as "set" and "if"). 3.6 Data Types All data types in the installer are dynamic, that is to say the type of a variable is determined by the data that is in it. So if you assign the string "Hello, World" to the variable 'x', then 'x' will be of type STRING. Later you can assign an integer to 'x' and x will be of type INTEGER. When using variables in expressions, the interpreter will attempt to convert to the proper type if possible. Special forms: There are two exceptions to the form of a statement. The first type is used for string substitution: If the first item in parentheses is a text string rather than a function name, the result of that clause is another string that is created by taking the original string and performing a "printf"-like formatting operation on it, using the other arguments of the statement as parameters to the formatting operation. Thus the statement: ("My name is %s and I am %ld years old" "Mary" 5) Becomes: "My name is Mary and I am 5 years old" Note since the formatting operation uses the ROM "RawDoFmt" routine, decimal values must always be specified with "%ld" rather than "%d" (The interpreter always passes numeric quantities as longwords). Note that a variable containing the string may be used rather than the string itself. The second type of exception occurs if the elements in parentheses are themselves statements in parentheses. In this case, the interpreter assumes that all the elements are statements to be executed sequentially. For example, this statement sets the value of three different variables: "var1", "var2" and "var3". ((set var1 5) (set var2 6) (set var3 7)) What this feature does is allow the language to have a block structure, where an "if" statement can have multiple statements in its "then" or "else" clause. Note that the result of this statement will be the result of the last statement in the sequence. Complex statements: Here is an example of how statements in the script language can be combined into complex expressions. We will start with an "if" statement. The basic format of an "if" statement is: (if []) The condition should be a statement which returns a value. The "then" and optional "else" parts should be statements. Note that if the "then" or "else" statements produce a result, then the "if" statement will also have this result. Our first example is a rather strange one: Using an "if" statement to simulate a boolean "not" operator. (Note that there are easier ways in the script language to do this). (set flag 0) ; set a flag to FALSE (set flag (if flag 0 1)) ; a Boolean NOT Basically, the "if" statement tests the variable "flag". If flag is non-zero, it produces the value "0". Otherwise, the result is "1". In either case, "flag" is set to the result of the "if" statement. Now, let's plug some real statements into our "if" statement. (if flag ; conditional test (message "'flag' was non-zero\n") ; "then" clause. (message "'flag' was zero\n") ; "else" clause. ) ; closing parenthesis Note the style of the indenting. This makes for an easier to read program. Now, we'll add a real condition. "=" tests for equality of the two items. (if (= a 2) ; conditional test (message "a is 2\n") ; "then" clause (message "a is not 2\n") ; "else" clause ) ; closing parenthesis Finally, just to make things interesting, we'll make the "else" clause a compound statement. (if (= a 2) ; conditional test (message "a is 2\n") ; "then" clause ( (message "a is not 2\n") ; "else" compound statement (set a 2) (message "but it is now!\n") ) ; end of compound statement ) ; end of if 3.7 Special Features When the Installer first starts up, it attempts to determine the "best" place to install the application. Any volume named "WORK:" is given preference, as this is the standard way that an Amiga comes configured from Commodore. There are two keyboard shortcuts. Whenever there is a "Help" button active, pressing the HELP key will also bring up the help display. Whenever there is an "Abort" button active, pressing ESC brings up the abort requester. Also, whenever the installer is "busy", pressing ESC brings up the abort requester -- there is text is the title bar to that effect. If an application must have assigns or other actions performed during system boot, the Installer will add these to a file named "S:user-startup". The installer will then add the lines if exists S:user-startup execute S:user-startup endif to the user's "startup-sequence". The Installer will attempt to determine the boot volume of the system when looking for the "startup-sequence" and can handle any AmigaDOS scripts executed from "startup-sequence" (up to 10 levels of nesting). The Installer can create an assign to just a device, volume or logical assignment. This comes in handy when you want to update an application which comes on a volume named "MyApp:", but the installed version is in a directory with the logical assign "MyApp:"! The Installer always copies files in CLONE mode, meaning all the protection bits, filenotes and file dates are preserved. When copying files the Installer gives a "fuelgauge" readout of the progress of the copy. The Installer can find the version number of any executable file that has either a RomTag with an ID string (such as libraries and devices) or has a version string conforming to that given in the 1990 DevCon notes. The Installer can also checksum files. A separate utility named "instsum" is provided to determine a file's checksum for use with this feature. 3.8 Miscellaneous To perform a set of actions on all the contents of a directory matching a pattern you can use the "foreach" operator. To perform a set of actions on an explicit set of files, the following installer statements can be used as a template: (set n 0) (while (set thisfile (select n "file1" "file2" "file3" "")) ( (set n (+ n 1)) (... your stuff involving this file ...) ) ) Note that an empty string is considered a FALSE value to any condition operator. To run an external CLI command which normally requires user input, redirect the input from a file with the needed responses. For example, to format a disk one could combine the statement shown below with a file which contains only a newline character. (run "format [ ...]) Set the variable to the indicated value. If does not exist it will be created. Set returns the value of the last assignment. Note: All variables are typeless, and any variable may be used wherever a string could be used. All variables are global. The "set" statement can be used to convert a string to an integer value: (set (+ )) Use the "cat" statement to do the reverse. (makedir ) Creates a new directory. Parameters: prompt - tell the user what's going to happen. help - text of help message infos - create an icon for directory confirm - if this option is present, user will be prompted, else the directory will be created silently. safe - make directory even if in PRETEND mode (copyfiles ) Copies one or more files from the install disk to a target directory. Each file will be displayed with a checkmark next to the name indicating if the file should be copied or not. Note that a write protected file is considered "delete protected" as well. Parameters: prompt, help - as above source - name of source directory or file dest - name of destination directory, which is created if it doesn't exist Note that both source and dest may be relative pathnames. newname - if copying one file only, and file is to be renamed, this is the new name choices - a list of files/directories to be copied (optional) all - all files/directories in the source directory should be copied pattern - indicates that files/directories from the source dir matching a pattern should be copied. The pattern should be no more than 64 characters long. Note that only one of "choices", "all" or "pattern" should be used at any one time. files - only copy files. By default the installer will match and copy subdirectories. infos - switch to copy icons along with other files/directories fonts - switch to not display ".font" files, yet still copy any that match a directory that is being copied. (optional