---
author: eamanu
blogspot: true
date: Aug 11, 2018
tags: Old-Blog
title: 'Debian/watch: Usando uscan Tool'
---
# Debian/watch: Usando uscan Tool
El archivo *watch* en el directorio debian de todo paquete debian (que valga la dedundancia) se utiliza para checkear si existen versiones más reciente del software empaquetado y lo descarga si es neceario. Para realizar una descarga necesitamos usar la herramienta uscan que forma parte del paquete devscript.
El archivo simplemente te dice: dónde descargar y te permite filtrar para poder obtener siempre la misma versión.
Hasta ahora todo bien. Todo sencillo ¿no?.
Primer el archivo tienen la siguiente forma:
[Source code](#codesyntax_1 "Click to show/hide code block") | [![](https://eamanu.com/blog/wp-content/plugins/wp-synhighlight/themes/default/images/code.png)](#codesyntax_1 "Show code only") [![](https://eamanu.com/blog/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png)](#codesyntax_1 "Print code") [![](https://eamanu.com/blog/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif)](https://eamanu.com/blog/wp-content/plugins/wp-synhighlight/About.html "Show plugin information") |
```
version=4
http://somesite.com/dir/filename_(.+).tar.gz
```
Lo que hace uscan básicamente es entrar en la dirección web y «filtrar» según el wildcard que le escribamos.
Nunca viene mal una mirada al manual. Por ello dejo aquí el [manual](https://manpages.debian.org/stretch/devscripts/uscan.1.en.html)
Ok, vamos al grano. Generalmente, (bah), mejor dicho, *yo* casi siempre utilizo softwares que se encuetran almacenados en github o Pypi (que estos a su vez se encuentra en Github también.), por tal motivo voy a dejar un par de ejmplos de como se debería escribir el archivo watch para desgargar software desde Github, como así también de PyPi
Github
[Source code](#codesyntax_2 "Click to show/hide code block") | [![](https://eamanu.com/blog/wp-content/plugins/wp-synhighlight/themes/default/images/code.png)](#codesyntax_2 "Show code only") [![](https://eamanu.com/blog/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png)](#codesyntax_2 "Print code") [![](https://eamanu.com/blog/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif)](https://eamanu.com/blog/wp-content/plugins/wp-synhighlight/About.html "Show plugin information") |
```
version=4
opts=filenamemangle=s/.+\/v?(\d\S+)\.tar\.gz/-$1\.tar\.gz/ \
https://github.com///tags .*/v?(\d\S+)\.tar\.gz
```
Pypi
-
Para Pypi el archivo será muy parecido:
[Source code](#codesyntax_3 "Click to show/hide code block") | [![](https://eamanu.com/blog/wp-content/plugins/wp-synhighlight/themes/default/images/code.png)](#codesyntax_3 "Show code only") [![](https://eamanu.com/blog/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png)](#codesyntax_3 "Print code") [![](https://eamanu.com/blog/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif)](https://eamanu.com/blog/wp-content/plugins/wp-synhighlight/About.html "Show plugin information") |
```
version=4
opts=pgpsigurlmangle=s/$/.asc/ \
https://pypi.debian.net//-(.+)\.(?:zip|tgz|tbz|txz|(?:tar\.(?:gz|bz2|xz)))
```
Lo de PyPi es que podemos utilizar la siguiente página para tener el correcto upstrem para descargar:
http://pypi.debian.net//watch
Vamos a la práctica
===================
En mi caso estoy tratano de empaquetar un módulo de python que se llama «[pcapy](https://www.coresecurity.com/corelabs-research/open-source-tools/pcapy)«. Entre los varios update que tengo que realizar, uno de estos es el watch file. Esto se debe a que Lintian me devuelve el siguiente error:
> Problems while searching for a new upstream version
>
> uscan had problems while searching for a new upstream version:
>
> In debian/watch no matching files for watch line
> http://corelabs.coresecurity.com/index.php?module=Wiki&action=view&type=tool&name=Pcapy /index\\.php\\?module=Wiki&action=attachment&type=tool&page=Pcapy&file=pcapy-(\[0-9.\]+)\\.tar\\.gz
Por lo visto hay algo que no le gusta a Lintian. Por lo tanto me cloné el proyecto a mi máquina. Una vez realizado esto, le digo a uscan, descarga si tenes alguna versión nueva. Para ello uso el siguiente comando:
[Source code](#codesyntax_4 "Click to show/hide code block") | [![](https://eamanu.com/blog/wp-content/plugins/wp-synhighlight/themes/default/images/code.png)](#codesyntax_4 "Show code only") [![](https://eamanu.com/blog/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png)](#codesyntax_4 "Print code") [![](https://eamanu.com/blog/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif)](https://eamanu.com/blog/wp-content/plugins/wp-synhighlight/About.html "Show plugin information") |
La opción -dd fuerza a uscan a descargar la versión filtrada. -v es el verbose.
Esto me duevuelve lo siguiente:
[Source code](#codesyntax_5 "Click to show/hide code block") | [![](https://eamanu.com/blog/wp-content/plugins/wp-synhighlight/themes/default/images/code.png)](#codesyntax_5 "Show code only") [![](https://eamanu.com/blog/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png)](#codesyntax_5 "Print code") [![](https://eamanu.com/blog/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif)](https://eamanu.com/blog/wp-content/plugins/wp-synhighlight/About.html "Show plugin information") |
```
uscan info: uscan (version 2.17.6+deb9u1) See uscan(1) for help
uscan info: Scan watch files in .
uscan info: Check debian/watch and debian/changelog in .
uscan info: package="pcapy" version="0.10.8-2" (as seen in debian/changelog)
uscan info: package="pcapy" version="0.10.8" (no epoch/revision)
uscan info: ./debian/changelog sets package="pcapy" version="0.10.8"
uscan info: Process ./debian/watch (package=pcapy version=0.10.8)
uscan info: opts: filenamemangle=s/.*=(.*)/$1/
uscan info: line: http://corelabs.coresecurity.com/index.php?module=Wiki&action=view&type=tool&name=Pcapy /index\.php\?module=Wiki&action=attachment&type=tool&page=Pcapy&file=pcapy-([0-9.]+)\.tar\.gz
uscan info: Parsing filenamemangle=s/.*=(.*)/$1/
uscan info: line: http://corelabs.coresecurity.com/index.php?module=Wiki&action=view&type=tool&name=Pcapy /index\.php\?module=Wiki&action=attachment&type=tool&page=Pcapy&file=pcapy-([0-9.]+)\.tar\.gz
uscan info: Last orig.tar.* tarball version (from debian/changelog): 0.10.8
uscan info: Last orig.tar.* tarball version (dversionmangled): 0.10.8
uscan info: Requesting URL:
http://corelabs.coresecurity.com/index.php?module=Wiki&action=view&type=tool&name=Pcapy
uscan info: redirections: https://www.coresecurity.com/corelabs-research/open-source-tools/pcapy
uscan info: Matching pattern:
(?:(?:http://corelabs.coresecurity.com)?\/index\.php\?module\=Wiki\&action\=view\&type\=tool\&name\=Pcapy)?/index\.php\?module=Wiki&action=attachment&type=tool&page=Pcapy&file=pcapy-([0-9.]+)\.tar\.gz (?:(?:https://www.coresecurity.com)?\/corelabs\-research\/open\-source\-tools\/pcapy)?/index\.php\?module=Wiki&action=attachment&type=tool&page=Pcapy&file=pcapy-([0-9.]+)\.tar\.gz (?:(?:https://www.coresecurity.com)?\/corelabs\-research\/open\-source\-tools\/)?/index\.php\?module=Wiki&action=attachment&type=tool&page=Pcapy&file=pcapy-([0-9.]+)\.tar\.gz
uscan warn: In debian/watch no matching files for watch line
http://corelabs.coresecurity.com/index.php?module=Wiki&action=view&type=tool&name=Pcapy /index\.php\?module=Wiki&action=attachment&type=tool&page=Pcapy&file=pcapy-([0-9.]+)\.tar\.gz
uscan info: Scan finished
```
Evidentemente hay algo mal en el archivo watch. Para ello, no lo voy a pensar demasiado y voy a usar la página de PyPi. http://pypi.debian.net/pcapy/watch
Y el resultado fue:
> **502 Bad Gateway**
Ok. Voy a ver que me muestra Github: https://github.com/CoreSecurity/pcapy/releases
Aquí se puede observar que se encuentran las releases y que está actualizada. Por lo tanto voy a apuntar mi archivo watch a los release de pcapy en Github:
[Source code](#codesyntax_6 "Click to show/hide code block") | [![](https://eamanu.com/blog/wp-content/plugins/wp-synhighlight/themes/default/images/code.png)](#codesyntax_6 "Show code only") [![](https://eamanu.com/blog/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png)](#codesyntax_6 "Print code") [![](https://eamanu.com/blog/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif)](https://eamanu.com/blog/wp-content/plugins/wp-synhighlight/About.html "Show plugin information") |
```
version=4
opts=filenamemangle=s/.+\/v?(\d\S+)\.tar\.gz/pcapy-$1\.tar\.gz/ \
https://github.com/CoreSecurity/pcapy/tags .*/v?(\d\S+)\.tar\.gz
```
Veamos ahora que suecede si ejecuto uscan -dd -v:
[Source code](#codesyntax_7 "Click to show/hide code block") | [![](https://eamanu.com/blog/wp-content/plugins/wp-synhighlight/themes/default/images/code.png)](#codesyntax_7 "Show code only") [![](https://eamanu.com/blog/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png)](#codesyntax_7 "Print code") [![](https://eamanu.com/blog/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif)](https://eamanu.com/blog/wp-content/plugins/wp-synhighlight/About.html "Show plugin information") |
```
uscan -dd -v
uscan info: uscan (version 2.17.6+deb9u1) See uscan(1) for help
uscan info: Scan watch files in .
uscan info: Check debian/watch and debian/changelog in .
uscan info: package="pcapy" version="0.10.8-2" (as seen in debian/changelog)
uscan info: package="pcapy" version="0.10.8" (no epoch/revision)
uscan info: ./debian/changelog sets package="pcapy" version="0.10.8"
uscan info: Process ./debian/watch (package=pcapy version=0.10.8)
uscan info: opts: filenamemangle=s/.+\/v?(\d\S+)\.tar\.gz/pcapy-$1\.tar\.gz/
uscan info: line: https://github.com/CoreSecurity/pcapy/tags .*/v?(\d\S+)\.tar\.gz
uscan info: Parsing filenamemangle=s/.+\/v?(\d\S+)\.tar\.gz/pcapy-$1\.tar\.gz/
uscan info: line: https://github.com/CoreSecurity/pcapy/tags .*/v?(\d\S+)\.tar\.gz
uscan info: Last orig.tar.* tarball version (from debian/changelog): 0.10.8
uscan info: Last orig.tar.* tarball version (dversionmangled): 0.10.8
uscan info: Requesting URL:
https://github.com/CoreSecurity/pcapy/tags
uscan info: Matching pattern:
(?:(?:https://github.com)?\/CoreSecurity\/pcapy\/tags)?.*/v?(\d\S+)\.tar\.gz
uscan info: Found the following matching hrefs on the web page (newest first):
/CoreSecurity/pcapy/archive/0.11.4.tar.gz (0.11.4) index=0.11.4-1
/CoreSecurity/pcapy/archive/0.11.3.tar.gz (0.11.3) index=0.11.3-1
/CoreSecurity/pcapy/archive/0.11.2.tar.gz (0.11.2) index=0.11.2-1
/CoreSecurity/pcapy/archive/0.11.1.tar.gz (0.11.1) index=0.11.1-1
/CoreSecurity/pcapy/archive/0.11.0.tar.gz (0.11.0) index=0.11.0-1
/CoreSecurity/pcapy/archive/0.10.10.tar.gz (0.10.10) index=0.10.10-1
/CoreSecurity/pcapy/archive/0.10.9.tar.gz (0.10.9) index=0.10.9-1
/CoreSecurity/pcapy/archive/0.10.8.tar.gz (0.10.8) index=0.10.8-1
uscan info: Matching target for downloadurlmangle: https://github.com/CoreSecurity/pcapy/archive/0.11.4.tar.gz
uscan info: Upstream URL (downloadurlmangled):
https://github.com/CoreSecurity/pcapy/archive/0.11.4.tar.gz
uscan info: Newest upstream tarball version selected for download (uversionmangled): 0.11.4
uscan info: Matching target for filenamemangle: /CoreSecurity/pcapy/archive/0.11.4.tar.gz
uscan info: Download filename (filenamemangled): pcapy-0.11.4.tar.gz
uscan: Newest version of pcapy on remote site is 0.11.4, local version is 0.10.8
uscan: => Newer package available from
https://github.com/CoreSecurity/pcapy/archive/0.11.4.tar.gz
uscan info: Downloading upstream package: pcapy-0.11.4.tar.gz
uscan info: Requesting URL:
https://github.com/CoreSecurity/pcapy/archive/0.11.4.tar.gz
uscan info: Successfully downloaded package: pcapy-0.11.4.tar.gz
uscan info: Start checking for common possible upstream OpenPGP signature files
uscan info: End checking for common possible upstream OpenPGP signature files
uscan info: Missing OpenPGP signature.
uscan info: New orig.tar.* tarball version (oversionmangled): 0.11.4
uscan info: Executing internal command:
mk-origtargz --package pcapy --version 0.11.4 --compression gzip --directory .. --copyright-file debian/copyright ../pcapy-0.11.4.tar.gz
uscan info: New orig.tar.* tarball version (after mk-origtargz): 0.11.4
uscan info: Successfully symlinked ../pcapy-0.11.4.tar.gz to ../pcapy_0.11.4.orig.tar.gz.
uscan info: Scan finished
```
voilà!
Ya tengo descargada la última versión de pcapy.
> drwxr-xr-x 6 eamanu eamanu 4096 Aug 10 21:58 pcapy
> lrwxrwxrwx 1 eamanu eamanu 19 Aug 10 23:17 pcapy\_0.11.4.orig.tar.gz -> pcapy-0.11.4.tar.gz
> -rw-r–r– 1 eamanu eamanu 35623 Aug 10 23:17 pcapy-0.11.4.tar.gz
Listo, es todo por hoy. En esta entrada mostré (muy, pero muy brevemente) como se debería trabajar con uscan, para que sirve. Ojalá en el futuro pueda dar un update y profundizar un poco más en esta tool