Using spk

This section is really a small examples tutorial. You can get help on individual commands by executing spk --help or (spk -h) or by consulting the man page.


Checking the state

Start by executing the following command

 spk

If the spk repository hasn't already been created, you should see something like this:

 spk: repository does not exist.  Attempting to create it...
 spk: repository created
 There are no pending records

Executing spk is the same as executing spk --show-state. There are no pending records means spk is in a "clean" state. When spk executes install commands it creates records of the changes to the filesystem. Records that exist and have not been associated with a package are "pending". To make this clearer, lets create some records...


Installing a package

We're now going to install the package firstpackage. It will consist of a single directory containing a few empty files. First execute the following command:

 spk mkdir a_test_dir

Notice we didn't specifiy any options. If no options are specified but there are at least two arguments, spk assumes -e (or --execute). What we did here was tell spk to execute mkdir a_test_dir and record the changes. If we now execute

 spk

you should see

 Pending records exist

because spk recorded the creation of a_test_dir but has not installed a package yet. Let's continue by creating some files and installing firstpackage.

 spk touch a_test_dir/file1
 spk touch a_test_dir/file2
 spk -c firstpackage 

The spk -c firstpackage (or spk --complete-install firstpackage) tells spk to process all pending records, associating them with the new package firstpackage. We could have collapsed the last two lines into a single command: spk -i firstpackage touch a_test_dir/file2 (or spk --install-execute firstpackage touch a_test_dir/file2). So the installation of a typical package, say foo, might look like

 tar zxfv foo.tar.gz
 cd foo
 ./configure
 make
 sudo spk -i foo make install

or

 tar zxfv foo.tar.gz
 cd foo
 ./configure
 make
 sudo spk make install
 sudo spk -c foo

Suppose the installation of a package adds one file and deletes another

 spk touch a_test_dir/file3
 spk -i secondpackage rm a_test_dir/file2
            

Spk will archive file2 in its repository.

 spk: files were archived during the installation of secondpackage

If you were to uninstall secondpackage, spk would warn you that archived files exist, and you would either have to use the --force, in which case the archived files would be lost, or perform an --uninstall-full, in which case the archived files would be restored. You can view a packages archived files with the --show-archive option. Archiving can be turned off in spk.conf and overriden at the command line (--archive or --no-archive).


Getting information about a package

The -s option (--show-files) will display a package's contents.

 spk -s firstpackage

 /home/ccarroll/a_test_dir
 /home/ccarroll/a_test_dir/file1
 /home/ccarroll/a_test_dir/file2

Changed files will follow the '#' character and deleted files will follow the 'X' character. You can use the verbose option for additional information.

You can also use the -q option (--query) to display meta-data for the package. A verbose package query looks like:

 spk -qV firstpackage

 Package:     firstpackage
 Total files: 3
 Installed:   Sat Apr  3 10:01:08 2004

   Files added:   3
   Files changed: 0
   Files removed: 0

   Previous package: NONE
   Next package:     secondpackage

   Dependencies: NONE
   Supports:     NONE

   Packages depending on firstpackage: NONE
   Packages supporting firstpackage:   NONE 

Uninstalling a package

The -u option (--uninstall) will uninstall a package.

 spk -u firstpackage

If the package has archived files, you'll have to use the --uninstall-full (-U) switch to restore the archived files or the --force switch with --uninstall to uninstall without restoring the archived files. Also, if you've told spk that another package depends on firstpackage (spk --depends-on=firstpackage another-package) or that another pacakge has support for firstpackage (spk --support-for=firstpackage another-package) you'll have to first either remove the dependencies or use the --force switch.


System information

Spk will query the package management system for information about the system itself as well:

 spk -q

 Repository location: /var/lib/spk
 Configuration file:  /etc/spk.conf
 There are 283 packages installed

If you specify the --verbose switch spk will scan the filesystem looking for files that are not associated with any package and display this information as well. Files and directories that you don't want to be scanned can be configured in spk.conf. This is a way to guage how "clean" your system is. (This should probably be a separate option rather than the verbose output of a system query - I'll probably change this in an upcoming release.)


Additional information

This is just enough information to get you started with spk. The --help command and the man page provide additional and more complete information on using spk. Also have a look at the tips and tricks section. And feel free to email me questions.