## Usage

### Use with pacman

torita is designed to easily fit into the popular package manager pacman. To use torita with pacman, set it as XferCommand in /etc/pacman.conf with a line like this:

XferCommand = /usr/bin/torita -o %o %u


And you are all set.

By default, torita maintains its torrent cache at /var/cache/torita. The torrent cache is automatically filled when you use torita with pacman.

### Use with other package managers

The default package name suffix is .pkg.tar.xz. If your package manager uses a different one, then you need to set the --package-suffix option:

torita --package-suffix=.deb ...


If your package manager doesn’t give you the option of choosing custom package downloader, then you can manually fill and download packages using the torrent cache as stated below in Use without a package manager, and install packages using commands which read from local files such as dpkg -i.

### Use without a package manager

You can directly call torita to manually fill the torrent cache while downloading the package you want:

torita --torrent-directory=/tmp/mytorrents <url>    # torrent doesn't exist and will be made


Later downloads of the same file can use bt with this torrent cache:

torita --torrent-directory=/tmp/mytorrents <url>    # torrent exists and bt is used


If all you want is the torrent cache (but not the packages themselves), then you can download to the same temporary file and delete it afterwards:

torita --torrent-directory=/tmp/mytorrents -o /tmp/mytmpfile <url1>
torita --torrent-directory=/tmp/mytorrents -o /tmp/mytmpfile <url2>
torita --torrent-directory=/tmp/mytorrents -o /tmp/mytmpfile <url3>
rm /tmp/mytmpfile


This also works of course:

torita --torrent-directory=/tmp/mytorrents -o /tmp/mytmpfile <url1>
rm /tmp/mytmpfile
torita --torrent-directory=/tmp/mytorrents -o /tmp/mytmpfile <url2>
rm /tmp/mytmpfile
torita --torrent-directory=/tmp/mytorrents -o /tmp/mytmpfile <url3>
rm /tmp/mytmpfile


### Use for non-package files

In fact, you can use torita for any types of files (even for non-package files) that you want to torify (i.e. make a torrent of the file and keep the file so that future downloads of the same file can use the bittorrent protocol). Depending on the file you want to torify, you may need to call torita with the torrent cache directory, the (non-)package name, the (non-)package suffix and the output filename:

torita -o /tmp/output.wav \
--package-name=test.wav \
--package-suffix=.wav \
--torrent-directory=/tmp/mytorrents \


The above command uses plain download to download a file from https://upload.wikimedia.org/wikipedia/commons/b/bb/Test_ogg_mp3_48kbps.wav to /tmp/output.wav and creates a torrent file in directory /tmp/mytorrents containing a single file test.wav. The torrent filename will be the same as the (non-)package name with a .torrent suffix (test.wav.torrent here).

When this command is run again, it will notice there exists a torrent file in the cache and will download the file using bittorrent. Since the filename in the torrent is test.wav, you need to explicitly specify the output filename if you want to name it differently (/tmp/output.wav here).

## Caution

### Torrent Cache Management

To make things easy, the torrent cache is designed as a flat directory. You can freely add, modify, delete torrents as you want with any tool you like. However, make sure their filenames and contents are as expected by your package manager. Otherwise, incorrect files may be downloaded which can render your system nonfunctional.

### Torification

Not all files are suitable for torification. An example is package database. Even though it always has the same url, its contents are continuously updated, which quickly makes a torrent obsolete. In contrast, packages themselves have fixed version numbers and constant contents, which make them ideal objects for torification.

torita addresses this issue through the use of package suffix. In particular, torita is torrent-aware only when the package name has the specified package suffix. You can set the package suffix to empty to bypass this suffix check.

### Concurrency

torita is designed for package management where such concurrency is delegated to the package manager. If you don’t run package managers concurrently, then don’t run torita concurrently. If you do run package managers concurrently, then you are likely to get some errors.