Differences between revisions 19 and 21 (spanning 2 versions)
Revision 19 as of 2012-11-22 13:46:17
Size: 4024
Editor: PaulWise
Comment: fix regex for githubredir
Revision 21 as of 2012-12-21 08:25:24
Size: 4908
Editor: PaulWise
Comment: version mangline
Deletions are marked like this. Additions are marked like this.
Line 53: Line 53:
== Common mistakes ==

 * Not escaping dots, which match any character. The solution is {{{\.}}} instead of {{{.}}} in the regex.
 * A file extension regex that is not flexible enough. The solution is {{{\.(?:zip|tgz|tbz|txz|(?:tar\.(?:gz|bz2|xz)))}}}
 * Not anchoring the version group at the right place. The solution is to include something before {{{(.*)}}} like {{{fooproj-(.*)\.tar\.gz}}}
 * Not using digits in the version part of the regex. The solution is to use {{{\d}}} instead of {{{\.}}}
 * Not mangling upstream versions that are alphas, betas or release candidates to make them sort before the final release. The solution is to use uversionmangle like this {{{opts=uversionmangle=s/-rc/~rc/;s/-alpha/~alpha/;s/-beta/~beta/}}}
 * Not mangling Debian versions to remove dfsg. The solution is to use uversionmangle like this {{{opts=dversionmangle=s/dfsg.*//}}}

debian/watch

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(1) program from the ?devscripts package. It takes the path to the debian directory that uses the watch file as an argument or searches the dirtories underneath the current working directory.

Basically a watch file will have this format:

  version=3
  http://somesite.com/dir/filenamewithversion.tar.gz

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

  version=3
  http://somesite.com/dir/filename_(.+).tar.gz

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 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=3
  http://somesite.com/path link_from_href-1.0.tar.gz

"http://somesite.com/path" 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 http://somesite.com/path HTML code has "<a href=foo/program-1.0.tar.gz>" inside it, for example, you will use

  http://somesite.com/dir 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:

  http://somesite.com/dir 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 more then me on this).

But the nice part is to test it:

  uscan --report-status

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

  uscan --report-status --debug

Common mistakes

  • Not escaping dots, which match any character. The solution is \. instead of . in the regex.

  • A file extension regex that is not flexible enough. The solution is \.(?:zip|tgz|tbz|txz|(?:tar\.(?:gz|bz2|xz)))

  • Not anchoring the version group at the right place. The solution is to include something before (.*) like fooproj-(.*)\.tar\.gz

  • Not using digits in the version part of the regex. The solution is to use \d instead of \.

  • Not mangling upstream versions that are alphas, betas or release candidates to make them sort before the final release. The solution is to use uversionmangle like this opts=uversionmangle=s/-rc/~rc/;s/-alpha/~alpha/;s/-beta/~beta/

  • Not mangling Debian versions to remove dfsg. The solution is to use uversionmangle like this opts=dversionmangle=s/dfsg.*//

Redirector URLs

Files hosted on various big project hosting sites can be specified with 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.

SourceForge

  # qa.debian.org 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.
  http://sf.net/audacity/audacity-src-(.+)\.(?:zip|tgz|tbz2|txz|tar\.gz|tar\.bz2|tar\.xz)

See also: http://anonscm.debian.org/viewvc/qa/trunk/wml/watch/

GitHub

/!\ The github redirector is no longer needed since the github tags package can simply be used instead:

https://github.com/<user>/<project>/tags .*/(\d[\d\.]+)\.tar\.gz

There should be no need to use it, but you can also use the redirector:

  # githubredir.debian.net is a redirector for GitHub projects
  # It can be used as following:
  http://githubredir.debian.net/github/<user>/<project> .*/(\d[\d\.]+)\.(?:zip|tgz|tbz2|txz|tar\.gz|tar\.bz2|tar\.xz)

See also: http://githubredir.debian.net/

Google Code

/!\ :

http://code.google.com/p/<project>/downloads/list?can=1 .*/<project>-(\d[\d.]*)\.(?:zip|tgz|tbz2|txz|tar\.gz|tar\.bz2|tar\.xz)

There used to be a Google Code (googlecode.debian.net) redirector, that is neither needed nor available anymore.


CategoryDebianDirectory