The file named watch in the debian directory is used to check for newer versions of upstream software is available and to download it if necessary. The download itself will be performed with the uscan program from the devscripts package. It takes the path to the debian directory that uses the watch file as an argument or searches the directories underneath the current working directory.

Basically a watch file will have this format:


To allow the version to remain unspecified, it is expressed as a wildcard using regular expression in Perl format:


The uscan program will then execute a "dir" command and check all the files in that directory for the highest version number.

uscan also supports the FTP protocol. Unfortunately, when working with HTTP, HTML pages do not always contain directory listing with files. The complete (or relative) path of the .tar.gz file to be downloaded will appear as a hyperlink within the web page. We hence need two types of information, the path to the page announcing the file and a regular expression to "grep" for the right link:

  version=4 link_from_href-1.0.tar.gz

"" is the site from where you are downloading the source and "link_from_href.1.0.tar.gz" is obtained from the HTML source code (from the "<a href=" tags).

If HTML code has "<a href=foo/program-1.0.tar.gz>" inside it, for example, you will use foo/program-(.+)\.tar\.gz

Watch files with errors are generally wrong on this second part.

Generally you want a slightly more flexible regex for the tarball name so that if upstream switches tarball naming schemes or compression formats you are covered: foo/program-(.+)\.(?:zip|tgz|tbz|txz|(?:tar\.(?:gz|bz2|xz)))

For FTP sites it changes a little, but it's basically the same thing (man uscan will help you).

But the nice part is to test it:

  uscan --no-download --verbose

If it's not working as expected, you can use debug to see what it's fetching and what it's (not) matching:

  uscan --no-download --verbose --debug
Nice write-up by João Eriberto

Common mistakes

Version number gotchas

For upstreams that release alpha, beta, release-candidate versions it's common to use versions like 1.0-alpha, 1.0-rc1, ... before 1.0 Without proper mangling this will break dpkg version comparisons:

dpkg --compare-versions '1.0-1' gt '1.0-alpha-1'   # false
dpkg --compare-versions '1.0-1' gt '1.0~alpha-1'   # true (notice the ~)

The solution is to use uversionmangle like this opts=uversionmangle=s/(\d)[_\.\-\+]?((RC|rc|pre|dev|beta|alpha)\d*)$/$1~$2/ before importing new releases.

If you already uploaded a "broken" version number you can sometimes use the ds<n> repack suffix e.g. '1.0-ds1-1' or '1.0.ds1-1'


Cryptographic signature verification

If your upstream provides cryptographic signatures for their packages in the same place that the packages are available for download, and you know what OpenPGP key or keys will be used to sign these packages, uscan can verify these signatures for you if you give it the pgpsigurlmangle option.

For example, for OpenSSH (which uses a .asc suffix for the package signatures), you'd place Damien Miller's public key ascii-armored in debian/upstream/signing-key.asc:

gpg --armor --export-options export-minimal --export '59C2 118E D206 D927 E667  EBE3 D3E5 F56B 6D92 0D30' >> debian/upstream/signing-key.asc

and then update debian/watch to say:


This lets you ensure that the package was not tampered with in transit, and that it came from the developer you expected it to come from. A valid signature does not mean that the contents of the package are somehow magically perfect and DFSG-free and policy compliant, of course!

Often, when upstream uses git, it doesn't sign its releases, but signs its tags. Here is an example of a debian/watch file using mode=git to retrieve releases and checking tags signatures:

opts="mode=git,pgpmode=gittag" \
https://mygitlabinstance.tld/myusername/myproject.git refs/tags/v([\d\.]+)

Uncommon upstream source sites

If you have a site that has version numbers in some form but doesn't have hrefs containing them and the URL mangling capabilities of uscan are not enough, you can create a redirector. The Debian QA folks run one called fakeupstream.cgi (git) for lots of different upstream sites. If you want to add a new one, please submit a wishlist bug report assigned to with or without a patch.

Common upstream source sites

Files hosted on various big project hosting sites can be specified with the URLs below. SourceForge has a special "redirector" URL (see more details in 'man uscan'). This allows the upstream URLs to change without the need to adapt watch files of affected packages.


version=4<user>/<project>/downloads?tab=tags .*/(\d\S+)\.tar\.gz

The 2nd regexp matches most often used tags like '0.1.2' or 'v0.1.2'. It may need to be adapted if upstream uses other version tags.


As of 2022-10-02, ?GitHub change the way its release/tags page is rendered. The links are dynamically loaded in ?JavaScript instead of static text. See thread for the discussions:

Examples using the Github API:

filenamemangle=s%.*/v?@ANY_VERSION@%@PACKAGE@-$1.tar.xz%" \<user>/<project>/releases?per_page=50 \[^/]+/[^/]+/tarball/v?@ANY_VERSION@

If upstream releases beta/alpha tarballs, you will need to make use of uversionmangle.

uversionmangle=s/(\d)[_\.\-\+]?((RC|rc|pre|dev|beta|alpha|a|b)\d*)$/$1~$2/" \<user>/<project>/releases?per_page=50 \[^/]+/[^/]+/tarball/v?@ANY_VERSION@

If your d/watch is failing to find the tarballs, you can analyze the page at:<user>/<project>/releases?per_page=50 And identify a regex that can be used to fetch the right tarball.


opts=filenamemangle=s/.*\/(\d\S+)\/archive\.tar\.gz/<project>-$1\.tar\.gz/g \<user>/<project>/tags?sort=updated_desc .*(\d\S+)/archive\.tar\.gz

Gitlab seems to have changed their directory layout. If the above no longer works, try this:

opts=filenamemangle=s/.*\/archive\/(\d\S+)\/<project>.*\.tar\.gz/<project>-$1\.tar\.gz/g \<user>/<project>/tags?sort=updated_desc .*/archive/(\d\S+)/.*\.tar\.gz.*

As in 2020-06, GitLab is listing archives in a new format:

# Matches<user>/<project>/-/archive/<ver>/<proj>-<ver>.tar.bz2
version=4<user>/<project>/tags?sort=updated_desc archive/@ANY_VERSION@/{project}-\d\S*@ARCHIVE_EXT@    

Looks like @ANY_VERSION@ macro does not work now (2022-07). Assuming the software is tagged with a version like v1.001 or 1.001 (i.e optional "v", followed by dot or numbers), the following lines work:

version=4<user>/<project>/tags?sort=updated_desc archive/v?\d[\d.]+/<project>-v?([\d.]+)@ARCHIVE_EXT@

Your upstream may sign their releases with GnuPG by adapting the GitHub instructions. GitLab puts the signature attachment into an unpredictable subdirectory of /<user>/<project>/uploads/. You may verify the tarball with something like this (assuming they only sign the .tar.gz):


opts="pgpmode=next" \<user>/<project>/tags \

opts="pgpmode=previous" \<user>/<project>/tags \

Salsa (Gitlab)

opts=filenamemangle=s/.*?\/(\d\S+)\/archive\.tar\.gz/<project>-$1\.tar\.gz/ \<user>/<project>/tags .*?(\d\S+)/archive\.tar\.gz

Make sure that the tags should be just the numeric version in salsa.d.o. Exemple version: 1.4.5

$ git tag 1.4.5 -m 'Release version 1.4.5'

$ git push origin master --tags

Google Code

version=4<project>/downloads/list?can=1 .*/<project>-(\d\S+)\.(?:zip|tgz|tbz|txz|(?:tar\.(?:gz|bz2|xz)))


opts=pgpsigurlmangle=s/$/.asc/ \<project>/ \*download/<project>-([.\d]+)\.tar\.xz


The PyPI site is hard to work with directly as it includes md5sums for the downloads in the URLs which makes for truly horrible regexps. The redirector makes it much easier to work with PyPI:

opts=pgpsigurlmangle=s/$/.asc/ \<project>/<project>-(.+)\.(?:zip|tgz|tbz|txz|(?:tar\.(?:gz|bz2|xz)))

There's also (a bit more advanced) autogenerated watch file that you can download from<project>/watch

If you do want to work directly with PyPI, then make sure you use the new Simple API:<project>/ 

Note that direct use of the PyPI listing pages for packages (such as<package>/) is discouraged by the PyPI administrators. Automated use of package listing pages is not supported and is liable to break; the Simple API is provided for precisely that reason.


  # runs a redirector which allows a simpler form of URL
  # for SourceForge based projects. The format below will automatically
  # be rewritten to use the redirector.\d\S+)\.(?:zip|tgz|tbz|txz|(?:tar\.(?:gz|bz2|xz)))

See also:


A scripted debian/watch generator is available

Further information

Other distros

Fedora also has an upstream release monitoring project (more info).

CategoryDebianDirectory | CategoryPackaging