Tips and tricks

Specifying existing packages

Whenever you are specifying an existing package to spk, you only need to type as many characters as to uniquely identify that package. This is useful if you name your packages like name-version, as you only have to remember the name part (and often just the first few letters of name).


Bash completion script

If you're using bash programmable completion you can place this in your ~/.bash_completion file:

 _spk()
 {
          COMPREPLY=()
          cur=${COMP_WORDS[COMP_CWORD]}
  
          COMPREPLY=( $( compgen -W '$( ls /var/lib/spk )' -- "$cur" ) )
 }
 complete -F _spk spk 

This will complete on your installed packages. If your repository is not in /var/lib/spk you'll need to edit that part. (spk -q will tell you were your repository is.)

If you're not using bash completion you should check it out, as it is extremely useful.


Adding existing files

Suppose you want to create a package out of an existing directory tree not already under package management (you could also append to an existing package). You can simply move the top directory to a directory that spk is configured to ignore (in spk.conf) and have spk move it back, like so:

 mv /opt/somedir /usr/src
 spk mv /usr/src/somedir /opt
 spk -c newpackagename or spk -a existingpackage


Backing up a package as you uninstall it

If you want to uninstall a package, but you're you're not quite ready to commit to having it uninstalled, you can use spk to invoke itself to do the uninstall, and completely back up the package.

 spk -i somepackage-uninstalled spk -u somepackage

Now somepackage is uninstalled and somepackage-uninstalled is the archive for somepackage. To restore somepackage execute:

 spk -U somepackage-uninstalled

The uppercase -U is the same as --uninstall-full, which says uninstall and restore the archive. And unless you configure spk.conf differently, the repository files for somepackage will also be restored.

If you decide to get rid of it completely instead of restoring it, execute:

 spk  --force -u somepackage-uninstalled

This uses lowercase -u (the regulare --uninstall) switch. The force is necessary since you're uninstalling a package with an archive, but you don't want to restore the archive.