home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / src / linux-headers-2.6.17-6 / debian / scripts / kpkg-vercheck < prev   
Encoding:
Text File  |  2005-11-01  |  4.9 KB  |  201 lines

  1. #! /usr/bin/perl -w
  2. #                              -*- Mode: Perl -*- 
  3. # kpkg-vercheck --- 
  4. # Author           : Manoj Srivastava ( srivasta@tiamat.datasync.com ) 
  5. # Created On       : Fri Nov  7 13:14:25 1997
  6. # Created On Node  : tiamat.datasync.com
  7. # Last Modified By : Manoj Srivastava
  8. # Last Modified On : Sun Jan  6 01:49:31 2002
  9. # Last Machine Used: glaurung.green-gryphon.com
  10. # Update Count     : 21
  11. # Status           : Unknown, Use with caution!
  12. # HISTORY          : 
  13. # Description      : 
  14. require 5.002;
  15.  
  16. use strict;
  17. use diagnostics;
  18. use vars qw($MYNAME $Author $AuthorMail $Version);
  19.  
  20. =head1 NAME
  21.  
  22. kpkg-vercheck - Test if a package version is valid
  23.  
  24. =cut
  25.  
  26. ($MYNAME     = $main::0) =~ s|.*/||;
  27. $Author      = "Manoj Srivastava";
  28. $AuthorMail  = "srivasta\@debian.org";
  29. $Version     = '$Revision: 1.3 $';
  30.  
  31. =head1 SYNOPSIS
  32.  
  33.  usage: kpkg-vercheck version-number 
  34.  
  35. =cut
  36.  
  37. =head1 DESCRIPTION
  38.  
  39. This manual page explains the  Debian  B<kpkg-vercheck>  utility,
  40. which  is  used  to check whether a package version follows the
  41. directives in chapter 5 of the Debian packaging manual
  42.  
  43. =cut
  44.  
  45. =head1 Version numbering
  46.  
  47. Every package has a version number, in its Version control file field.
  48. dpkg imposes an ordering on version numbers, so that it can tell
  49. whether packages are being up- or downgraded and so that dselect can
  50. tell whether a package it finds available is newer than the one
  51. installed on the system. The version number format has the most
  52. significant parts (as far as comparison is concerned) at the
  53. beginning.
  54.  
  55. The version number format is: [epoch:]upstream-version[-debian-revision].
  56.  
  57. =cut
  58.   
  59. sub main {
  60.   my $version = $ARGV[0];
  61.   my $have_epochs = 0;
  62.   my $have_debrev = 0;
  63.   my $upstream_pat = "";
  64.   
  65. =head2 epoch
  66.  
  67. This is a single unsigned integer, which should usually be small. It
  68. may be omitted, in which case zero is assumed. If it is omitted then
  69. the upstream-version may not contain any colons.
  70.  
  71. =cut
  72.  
  73.   warn "nothing to work on --- version is empty [$version]" unless $version;
  74.  
  75.   # Test if we have epochs
  76.   if ($version =~ m/\:/og) {
  77.     $have_epochs = 1;
  78.     # The epoch is a single unsigned integer
  79.     if ($version =~ m/\s*\d+:(\S+)/o) {
  80.       $version = $1;        # remove the epoch
  81.     } 
  82.     else {
  83.       #This is an error.
  84.       print "The epoch should be a simple integer in $version.\n";
  85.       exit 1;
  86.     }
  87.   }
  88.  
  89. =head2 debian-revision
  90.  
  91. This part of the version represents the version of the modifications
  92. that were made to the package to make it a Debian binary package. It
  93. is optional; if it is not present then the upstream-version may not
  94. contain a hyphen. This format represents the case where a piece of
  95. software was written specifically to be turned into a Debian binary
  96. package, and so there is only one "debianization" of it and therefore
  97. no revision indication is required.
  98.  
  99. dpkg will break the upstream-version and debian-revision apart
  100. at the last hyphen in the string. 
  101.  
  102. The debian-revision may contain only alphanumerics and the
  103. characters + and . (plus and full stop).
  104.  
  105. =cut
  106.  
  107.   # Test and remove the debian revision
  108.   if ($version =~ m/\-/o) {
  109.     $have_debrev = 1;
  110.     if ($version =~ m/(.*)-[A-Za-z0-9\+\.]+$/o) {
  111.       $version = $1;        # remove the debian version
  112.     }
  113.     else {
  114.       #This is an error.
  115.       print "The Debian revision fails to match (.*)-[A-Za-z0-9\\+\\.]+\$ in $version.\n";
  116.       exit 1;
  117.     }
  118.   }
  119.  
  120. =head2 upstream-version
  121.  
  122. This is the main part of the version. It is usually version number of
  123. the original (``upstream'') package of which the .deb file has been
  124. made, if this is applicable. The upstream-version portion of the
  125. version number is mandatory.
  126.  
  127. The upstream-version may contain only alphanumerics and the characters
  128. + . - : (full stop, plus, hyphen, colon) and should start with a
  129. digit. If there is no debian-revision then hyphens are not allowed; if
  130. there is no epoch then colons are not allowed.
  131.  
  132. =cut
  133.  
  134.   #Check out the main version
  135.   if ($have_epochs) {
  136.     if ($have_debrev) {
  137.       $upstream_pat = '^[A-Za-z0-9\.\+\:\-]+$'; # Note the : and the -
  138.     }
  139.     else {
  140.       $upstream_pat = '^[A-Za-z0-9\.\+\:]+$'; # Note the : 
  141.     }
  142.   }
  143.   else {
  144.     if ($have_debrev) {
  145.       $upstream_pat = '^[A-Za-z0-9\.\+\-]+$'; # Note the -
  146.     }
  147.     else {
  148.       $upstream_pat = '^[A-Za-z0-9\.\+\-]+$';
  149.     }
  150.   }
  151.  
  152.   if ($version =~ m/$upstream_pat/o) {
  153.     if ($version =~ m/[0-9]+/o) {
  154.       print "YES\n";
  155.       exit 0;
  156.     }
  157.     else {
  158.       print "The upstream version $version does not contain a digit\n";
  159.       exit 1;
  160.     }
  161.   }
  162.   else {
  163.     #This is an error.
  164.     print "The upstream version fails to match $upstream_pat in $version\n";
  165.     exit 1;
  166.   }
  167.   # Not-reached
  168. }
  169.  
  170.  
  171. ## Now just call main
  172. &main();
  173.  
  174.  
  175. =head1 B<SEE ALSO>
  176.  
  177. B<dpkg>(5), B<dpkg-deb>(1), B<dpkg-source>(1),  B<dpkg-parsechangelogs>(1),
  178. B<The Debian Packaging manual>.
  179.  
  180. =cut
  181.  
  182.  
  183. =head1 BUGS
  184.  
  185. None Known so far.
  186.  
  187. =cut
  188.  
  189. =head1 AUTHOR
  190.  
  191. This  was  written by Manoj Srivastava <srivasta@debian.org>, for the
  192. Debian GNU/Linux system. 
  193.  
  194. =cut
  195.  
  196.  
  197. exit 0;
  198. __END__
  199.