# Source handling for thin-provision-tools

This source uses the `3.0 (gitarchive)` source format in the git repository.

## Building a Debian source package from git

* Install `dpkg-source-gitarchive`.
  This is not a build-dependency, as it is only required to build the source, not binaries.
* Run `dpkg-buildpackage -S -nc` (or `dpkg-source --build .`).

# Ubuntu dependencies vendoring

In Ubuntu, the Rust dependencies of the package are vendored into the upstream
source under the `vendor/` folder. They are shipped in a separate tarball placed
next to the upstream tarball:

    thin-provisioning-tools_<version>.orig-vendor.tar.xz

## When to update the vendor

There are two situations where the vendored dependencies should be refreshed:

1. **New upstream version** (`<version>` changes). The `vendor/` folder MUST be
   regenerated with the latest dependencies.

   > NOTE: Even when upstream does not change its dependencies, regenerating can
   > still pull in changes, because some dependencies are not pinned to a fixed
   > version and track development branches (see the `rio` dependency).

2. **Debian or Ubuntu updates the dependencies** while `<version>` is unchanged.
   In this case the update must be integrated as a d/patch on top of the existing
   vendor contents, because we cannot upload a vendor tarball with the same name
   but different contents.

   > NOTE: This patch should be marked to be dropped at the next vendor refresh
   > triggered by a new upstream version.

## How to update the vendor

   To update the vendor/ folder and generate the vendor tarball:

   ```sh
   cd thin-provisioning-tools/
   ./debian/rules vendor-tarball
   ```

## Update only the vendor folder

If you want to update only the `vendor/` folder (to generate
the contents of the d/patch for example):

   ```sh
   cd thin-provisioning-tools/
   ./debian/rules vendor-deps
   ```
