Automated Deployment of Perforce

Info & Tags

Article #:
68
Created:
04/25/07
Modified:
10/01/09
Tags:
automate, deployment, installation, p4, p4v, p4win

Related Articles

TASK

How do I automate deployment of Perforce client programs at large Windows sites?


SOLUTION

For releases prior to 2007.3, a scripted installer solution is provided to automate deployment of client applications. Details can be found below.

For releases 2007.3 and later, Perforce installers provide silent and customizable installations to automate large-scale deployment of client applications. Silent installs use command line options passed to the Perforce installer executable. The command line options are used to:

  • Specify the desired user interface level
  • Specify which features are installed or removed
  • Specify property values used during the installation
  • Optionally instruct the installer to generate a log file

Here is an example of a basic command line for a silent install of the Perforce Visual Client (P4V):

p4vinst.exe /v”/qb P4PORT=perforce:1666 P4USER=bruno"

The /v”” passes any options inside the quotes directly to the Windows Installer Engine (msiexec). In the example above, we instruct the installer to use a basic user interface (/qb) and specify values for both P4PORT and P4USER. To produce an installer log file, add "/l+* <filename.log>":

p4vinst.exe /v”/qb /l+* p4vinst.log P4PORT=perforce:1666 P4USER=bruno"

Specifying desired user interface level

The following user interface levels are available:

  • /qn - Silent, no user interface.
  • /qb - Basic user interface
  • /qr  - Reduced user interface
  • /qf  - Full UI (default)

Specifying which features are installed or removed

You can pass additional arguments to specify which features are installed or removed. The syntax for specifying features is as follows:

ADDLOCAL=<feature>,<feature> (or ALL)
REMOVE=<feature>,<feature> (or ALL)

where ADDLOCAL is the entire list of features to install and REMOVE is the entire list of features to not install or uninstall.


Examples:


Install all features except P4SCC:
p4vinst.exe /v"/qb ADDLOCAL=ALL REMOVE=P4SCC" 
Install only P4SCC feature:
p4vinst.exe /v"/qb ADDLOCAL=P4SCC"
Uninstall P4SCC feature:
p4vinst.exe /v"/qb REMOVE=P4SCC"
Uninstall all features:
p4vinst.exe /v"/qb REMOVE=ALL"

The valid feature names for each installer are:

Perforce Visual Client - P4V, P4MERGE, P4EXP, P4SCC, P4
Perforce Windows Client - P4WIN, P4DIFF, P4WINMRG, P4EXP, P4
Perforce Web - P4WEB, P4

Note, when installing the P4EXP component, a reboot is required. You can suppress the reboot by setting the MSI REBOOT property as follows:
p4vinst.exe /v"/qb REBOOT=ReallySuppress ..."
but P4EXP will not be guaranteed to work properly until the system has been rebooted.

Specifying values for properties

The basic syntax for assigning property values is:

PropertyName=PropertyValue

where properties are delimited by spaces. Property values containing spaces must be delimited within backslash/double-quote (\") characters. Placing an underscore (_) between property name and the equal sign (=) will only set the property if not already set (not supported by P4Win performance properties).

P4V custom settings 

P4V 2009.1 and later can read settings from two XML files to configure initial preference settings and feature availability:

INSTALLDIR\P4VResources\p4vdefaults.xml
INSTALLDIR\P4VResources\p4vfeatures.xml

To enable or disable specific P4V features and set initial preferences for automated installs, your installation process creates
custom XML configuration files defining the default preference settings and features you desire and writes them to the appropriate location on each client machine. For reference, example configuration files are provided in the following directory of a P4V 2009.1 installation:

INSTALLDIR\P4VResources\examples

Four example files are provided:
  • p4vfeatures.xml: Configures the feature set for P4V (all features enabled). 
  • basic_p4vfeatures.xml: Enables a minimum set of features. 
  • p4vdefaults.xml: Configures the default settings for performance preferences and initial application appearance. 
  • basic_p4vdefaults.xml: Enables a simplified application layout. 
The p4vdefaults.xml file contains two blocks:
  • Performance: Defines settings that control the impact of P4V on the Perforce server 
  • Layout: Enables you to define the features that are visible when P4V is launched, to determine its initial appearance.
For further details, consult the example configuration files. If these files are present when P4V is launched, P4V reads the settings to determine which features are visible to the user and to enforce any limits set to minimize impact on the performance of the Perforce server. The settings in these files override P4V's application defaults. After P4V is launched, users can modify any of the settings using the P4V Preferences dialogs. Note that changing preference settings does modify the configuration files.  After you edit the configuration files, you must restart P4V for the new settings to take effect.

Batch file example

The commands for invoking the installer and configuring its arguments and property settings can be placed into a batch file, an example of which is given below.

@ECHO OFF

REM Example batch files showing silent install of 
REM the Perforce Visual Client (P4V). Install all 
REM features except P4SCC and create a p4vfeatures.xml 
REM file that turns off the Connection Wizard.

REM Set the installer executable name
SET INSTALLERCMD=p4vinst.exe

REM Set the arguments we'll pass to msiexec
SET MSIARGS=/qb /l+* .\p4vinst.log^
   INSTALLDIR=\"%ProgramFiles%\Perforce\"^
   P4USER=%UserName%^
   P4CLIENT=%UserName%-%ComputerName%^
   P4PORT=perforce:1666^
   ADDLOCAL=ALL^
   REMOVE=P4SCC

REM Invoke the installer
%INSTALLERCMD% /v"%MSIARGS%"

REM Create a feature XML file in the P4VResources directory 
REM to turn off the P4V Connection Wizard.
SET PREFDIR=%ProgramFiles%\Perforce\P4VResources\
SET P4VFEATS=%PrefDir%p4vfeatures.xml
echo ^<?xml version="1.0" encoding="UTF-8"?^> > "%P4VFeats%"
echo ^<!--perforce-xml-version=1.0--^> >> %P4VFeats%
echo ^<FeaturesEnabled varName="FeaturesEnabled"^> >> "%P4VFeats%"
echo ^<Visibilility varName="Functionality"^> >> "%P4VFeats%"
echo ^<ConnectionWizard^>Off^</ConnectionWizard^> >> "%P4VFeats%"
echo ^</Visibilility^> >> "%P4VFeats%"
echo ^</FeaturesEnabled^> >> "%P4VFeats%"

Full list of properties: 

Common to all products

INSTALLDIR
Path to installation directory.

P4PORT
Host name or IP address and/or port number of Perforce server that client applications connect to. Using only a port number attempts to connect to a local server.

P4EDITOR
Path to editor invoked by those Perforce commands that use forms.

P4USER
Perforce user to connect as.

P4CLIENT
Perforce client to connect as.

P4MERGE
Path to application used for merging files.

P4DIFF
Path to application to use for comparing files.

NETUSER
Name of local system user to run services as if using a network location. Must have administrative privileges and rights to log on as a service. Required if INSTALLDIR, SERVROOT, PRXYCACHE, P4LOG, or P4JOUNAL are set to network location.

NETPASS
Password for NETUSER. Required if INSTALLDIR, SERVROOT, PRXYCACHE, P4LOG, or P4JOUNAL are set to network location.

P4Web only

P4WEBPORT
P4Web client port number. Not the same as PRXYPORT or SERVPORT.

P4WEBMODE
Select either standard or viewer mode. Standard (-s), Viewer (-v).

P4WEBVIEWER
Select either guest or authenticated viewer mode. Guest (-b), authenticated (-B).

P4WEBP4PORT
Computer name or IP address and/or port number of Perforce server that P4Web viewer service connects to. Using only a port number attempts to connect to a local server.

P4WEBLOCALONLY
Controls whether standard mode accepts remote connections, 0 or 1.

P4WEBLOG
Controls whether a log is written, 0 or 1.

P4Win performance

The following variables are used to configure "Settings -> Options" values for the P4Win client program. The default values are appropriate for most sites, but administrators of large sites might want to change the defaults in order to make P4Win clients poll the server less frequently, or to request less data from the server during normal use.

The P4Win performance properties are not configurable directly by the installer. They are configured as registry entries under the following registry key:

HKEY_CURRENT_USER\Software\perforce\P4win\Options

The recommended method for configuring the properties is through the use of a registration entries (.reg) file. For example, a p4win.reg file containing the following text:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\perforce\P4win\Options]
"AUTOPOLLSERVER"="0"
"ENABLEREVHISTSHOWINTEGS"="0"
"ENABLESUBCHGINTEGFILTER"="0"
"EXPANDCHGLISTS"="0"
"FETCHALLHIST"="0"
can then be sourced by the install batch file that performs the P4Win install as follows:
regedit.exe /S ./p4win.reg

AUTOPOLLICONIC       0 or 1
Default value: 0
For better performance: 0
Settings->Options->Perforce Objects->Server, Poll when inactive

AUTOPOLLJOBS         0 or 1
Default value: 0
For better performance: 0
Settings->Options->Perforce Objects->Server, Poll for job updates

AUTOPOLLSERVER       0 or 1
Default value: 1
For better performance: 0
Settings -> Options, enable AUTOPOLLTIME

AUTOPOLLTIME         if AUTOPOLLSERVER=1, poll every N minutes
Default value: 10
For better performance: 30 or more if AUTOPOLLSERVER=1
Settings -> Options, Poll server for updates AUTOPOLLTIME minutes

ENABLEREVHISTSHOWINTEGS  0 or 1
Default value: 1
For better performance: 0
Settings -> Options, Enable displaying branching history in Revision
History dialog

ENABLESUBCHGINTEGFILTER   0 or 1
Default value: 1
For better performance: 0
Settings -> Options, Enable including integrations when filtering
submitted changes

EXPANDCHGLISTS       0 or 1
Default value: 1
For better performance: 0
Settings -> Options, Expand pending changelists whenever a file or
job is added

EXPANDFLAG           0 or 1
Default value: 0
For better performance: 0
Settings -> Options, Expand Depot to Previous location

FETCHALLCHANGES      0 or 1
Default value: 0
For better performance: 0
Settings -> Options, Automatically fetch all submitted changelists

FETCHCHANGECOUNT     if FETCHALLCHANGES=0, fetch NNN changelists
Default value: 100
For better performance: 100 or less (but not 0) FETCHALLCHANGES=0
Settings -> Options, Automatically fetch last NNN changelists

FETCHALLJOBS         0 or 1
Default value: 0
For better performance: 0 Settings -> Options, Display all filtered or unfiltered jobs

FETCHJOBCOUNT        if FETCHALLJOBS=0, fetch NNN jobs
Default value: 100
For better performance: 100 or less (but not 0) Settings -> Options, Display maximum NNN jobs, selected in jobname order

FETCHALLHIST         0 or 1
Default value: 1
For better performance: 0
Settings -> Options, Automatically fetch all revision history records
FETCHHISTCOUNT       if FETCHALLHIST=0, fetch NNN history records
Default value: 100
For better performance: 100 or less (but not 0)
Settings -> Options, Automatically fetch last NNN history records

RELOADONUNCOVER      0 or 1
Default value: 0
For better performance: 0
Settings -> Options, Automatically reload pane when it is uncovered

RELOADUNCOVERTIME    if RELOADONUNCOVER=1, reload after N minutes
Default value: 1
For better performance: 30 or more if RELOADONUNCOVER=1
Settings -> Options, ... reload pane when it is uncovered after
N minutes

SHOWDELETED          0 or 1
Default value: 0
For better performance: 0
Settings -> Options, Show deleted depot files

Pre-2007.3 installers

To assist in automating installation of Perforce client programs across multiple desktops, Perforce provides a scripted version of the Perforce Windows Installer. The scripted version of the installer enables Perforce administrators to standardize options and settings before installation, thereby speeding up the process of deploying Perforce client programs throughout an organization.

The customizable element of the scripted installer is a configuration file named perforce.cfg. The Perforce Administrator edits this file, and places it on a shared network drive along with the expanded contents of the perforce.zip file. Perforce client programs can then be installed by running setup.exe from each desktop. It is important to run setup.exe from the folder in which it resides otherwise it will not be able to find perforce.cfg.

The following are some sample settings from the perforce.cfg file:

INSTTYPE=ClientOnly
(Install only the Perforce client programs, and not the Perforce Server)

INSTMODE=NoPrompt
(Install according to the settings in the configuration file without displaying installation dialogs)

P4PORT=perforce:1666
(Configure a value for the Perforce Server machine and port number)

P4WEBPORT=8080
(Configure a value for the port where P4Web is listening)

Other settings and additional information are available in the comments included within the perforce.cfg file. As of release 2005.2, the P4Win performance variable naming convention has been modified. These details are also embedded within the perforce.cfg file for reference.

The Perforce Core (Server and Proxy) scripted installer can be downloaded from: ftp://ftp.perforce.com/perforce/r06.2/bin.ntx86/perforce.zip.

The P4Win scripted installer can be downloaded from: ftp://ftp.perforce.com/perforce/r06.2/bin.ntx86/p4winst.zip.

The P4V scripted installer can be downloaded from: ftp://ftp.perforce.com/perforce/r07.2/bin.ntx86/p4vinst.zip

To use the scripted installer:

  1. Download perforce.zip from the FTP site.
  2. Extract the contents of perforce.zip into a directory on your machine.
  3. In this directory, edit perforce.cfg as required.
  4. Place the unzipped contents of this directory, including your customized perforce.cfg file, in a folder accessible from a Network Drive or into the root folder of a CD.
  5. From the network drive or CD, run setup.exe to install Perforce according to the settings you configured in perforce.cfg onto each desktop.

Note: The method to exclude certain binaries from being installed by the scripted installer is to remove those binaries from the directory where the perforce.zip (or p4winst.zip) file has been expanded. For example, if you wish to exclude the P4EXP from the install of P4Win, then unzip the p4winst.zip and remove the P4Exp.dll from the expanded directory prior to running setup.exe.

If you have any questions about the settings in perforce.cfg, please contact Perforce Support at support@perforce.com.