# Creating the Spotfire SPK for Other Spotfire Analyst Users

Practice building an SPK that contains two useful packages: boot and MASS, which you can install from the repository.

## Before you begin

You must have access to the TERR engine, either through your Spotfire installation, or the stand-alone TERR console.

## About this task

This example builds an SPK for distributing a package to other Spotfire Analyst users. For an example of building an SPK for distributing a package for use by the Spotfire Server Installation and Administration Guide on the Docsite.

Note: The survival R package is compatible with TERR; however, note that some of its examples might use the `plot` function, which is not supported in version 6.1.

When you prepare an SPK to be deployed to the Spotfire Server, remember the following rules:

- The Spotfire SPK can contain as many R packages as you need.
- You can have as many SPK files in a deployment area as needed.
- You can have different SPK files in different deployment areas.
- To distribute an updated Spotfire SPK to the Spotfire Analyst installations using the server, the Spotfire SPK must have its `BuiltVersion` incremented.

This example walks you through installing a package, generating the list, installing your package. and making sure it works as expected.

## Procedure

1. Load the Spotfire SPK package.
   `library(SpotfireSPK)`
2. Install a package to be in your Spotfire SPK file.
   `install.packages(c("boot","MASS"))`
   The package survival is downloaded from the repository.
   Note: If you want to install a package from a different repository, specify it using the `repos` argument. See Installation Options for Packages.
3. Generate the Debian Control File (DCF).
   The DCF contains the package list to build into the Spotfire SPK.
   `writeLines("Packages: boot,MASS", "MySpotfireSPK1.dcf")`
   Important: See Spotfire SPK versioning for information about creating the DCF and versioning the SPK.
4. Build the SPK.
   Note: In this example, you are building the SPK without passing any arguments for certificates or passwords, and the resulting output specifies that your resulting SPK is unsigned. If you do not include the arguments `certificate` and `password` in your `buildSPK` function, when the package is distributed, Spotfire Analyst users see a message warning of an unsigned file, and they are prompted to accept or reject the installation. This message appears for every update of the unsigned package. See your server administrator for a certificate and password to include.

   `buildSPK("MySpotfireSPK1.dcf", "MySpotfireSPK1.spk")`

       Note that "MySpotfireSPK1.spk" will not be signed.  Status information
       			 Done.

5. Print the new list file.

   `cat(readLines("MySpotfireSPK1.dcf"), sep="\n")`

       Packages: boot,MASS
       Built: TERR 6.1.0; (includes date and time)
       BuiltFile: MySpotfireSPK1.spk
       BuiltName: Spotfire Enterprise Runtime for R Packages fc24c777
       BuiltId: fc24c777-874f-4669-b67e-37e49b45c0be
       BuiltVersion: 1.0.0.0
       BuiltPackages: MASS (>=7.3-53),boot (>=1.3-25)

   (Your output will vary.)

6. Browse your computer for the SPK file and the DCF file.

   By default, both of these files are written to the your Users\user name directory.

   As of TERR 5.1.0, you can have multiple SPK packages deployed to your Spotfire Server. Use the SPK's DCF list to keep track of the packages in the SPK. We recommend you keep the lists where you can update them as necessary. See Packages deployed for a small group for more information.