[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bug#14597: kernel-package: kernel-package doesn't parse revision number for correctness



Hi,
	[moving to debian-devel for comments on my version check script]

>>"Joost" == Joost Kooij <kooij@mpn.cp.philips.com> writes:

Joost> On 6 Nov 1997, Manoj Srivastava wrote: Please forget the
Joost> bugreport. It turned out that I typed a - instead of a _
sigh> . I'm sorry to have bugged you unnecessarily.

	Good. I'll close this report.

Joost> Still, I think it is annoying that the consequences of such
Joost> typo show up only after an hour of vain compilation.

	Ok, I'll take that as a wishlist, and _not_close the bug.

>> Any patches shall be accepted gladly, as long as they fully accept
>> chapter 5 of the Packaging Manual, and I can understand the patch
>> well enough to maintain it. Failing that, this is way down on my
>> list of things to do, I do not know when (or how) I can implement
>> this.

grin> Maybe. I'm also not perfectly happy with the way kernel package
Joost> handles lilo and the links in /boot. Maybe some day I'll submit
Joost> a patch instead of a bug ;-)

	Well, now that I'm not required to do this, I immediately was
 siezed by a burning desire to stop working on sem_posts in a threaded
 signal handler, and the script below (tested for about 15 minutes)
 shall be included in the next kernel-package package.

	Since this is moving to debian-devel, could you expand on what
 behaviour you would like to see vis-a-vis LILO and links in / (AFAIK,
 there are no more symlinks in /boot; and only 2 symlinks in /)?

	manoj
ps. cut the script into pkg-ver-chk, and try
 % pod2man pkg-ver-chk | nroff -man - | less
-- 
 This indeed is the Way - there is no other - for the purification of
 one's vision. Follow this way. It leads to Mara's confusion. 274
Manoj Srivastava  <srivasta@acm.org> <http://www.datasync.com/%7Esrivasta/>
Key C7261095 fingerprint = CB D9 F4 12 68 07 E4 05  CC 2D 27 12 1D F5 E8 6E

======================================================================
#! /usr/bin/perl -w
#                              -*- Mode: Perl -*- 
# pkg-ver-chk --- 
# Author           : Manoj Srivastava ( srivasta@tiamat.datasync.com ) 
# Created On       : Fri Nov  7 13:14:25 1997
# Created On Node  : tiamat.datasync.com
# Last Modified By : Manoj Srivastava
# Last Modified On : Fri Nov  7 16:02:35 1997
# Last Machine Used: tiamat.datasync.com
# Update Count     : 20
# Status           : Unknown, Use with caution!
# HISTORY          : 
# Description      : 
# 
# 
require 5.002;

use strict;
use diagnostics;
use vars qw($MYNAME $Author $AuthorMail $Version);

=head1 NAME

pkg-ver-chk - Test if a package version is valid

=cut

($MYNAME     = $main::0) =~ s|.*/||;
$Author      = "Manoj Srivastava";
$AuthorMail  = "srivasta\@debian.org";
$Version     = '$Revision$';

=head1 SYNOPSIS

 usage: pkg-ver-chk version-number 

=cut

=head1 DESCRIPTION

This manual page explains the  Debian  B<pkg-ver-chk>  utility,
which  is  used  to check whether a package version follows the
directives in chapter 5 of the Debian packaging manual

=cut

=head1 Version numbering

Every package has a version number, in its Version control file field.

dpkg imposes an ordering on version numbers, so that it can tell
whether packages are being up- or downgraded and so that dselect can
tell whether a package it finds available is newer than the one
installed on the system. The version number format has the most
significant parts (as far as comparison is concerned) at the
beginning.

   The version number format is:
  [epoch:]upstream-version[-debian-revision].

=cut
  
sub main {
  my $version = $ARGV[0];
  my $have_epochs = 0;
  my $have_debrev = 0;
  my $upstream_pat = "";
  
=head2 epoch

This is a single unsigned integer, which should usually be small. It
may be omitted, in which case zero is assumed. If it is omitted then
the upstream-version may not contain any colons.

=cut

  # Test if we have epochs
  if ($version =~ m/\:/og) {
    $have_epochs = 1;
    # The epoch is a single unsigned integer
    if ($version =~ m/\s*\d+:(\S+)/o) {
      $version = $1;		# remove the epoch
    } 
    else {
      #This is an error.
      print "The epoch should be a simple integer in $version.\n";
      exit 1;
    }
  }

=head2 debian-revision

This part of the version represents the version of the modifications
that were made to the package to make it a Debian binary package. It
is optional; if it is not present then the upstream-version may not
contain a hyphen. This format represents the case where a piece of
software was written specifically to be turned into a Debian binary
package, and so there is only one "debianization" of it and therefore
no revision indication is required.

dpkg will break the upstream-version and debian-revision apart
at the last hyphen in the string. 

The debian-revision may contain only alphanumerics and the
characters + and . (plus and full stop).

=cut

  # Test and remove the debian revision
  if ($version =~ m/\-/o) {
    $have_debrev = 1;
    if ($version =~ m/(.*)-[A-Za-z0-9\+\.]+$/o) {
      $version = $1;		# remove the debian version
    }
    else {
      #This is an error.
      print "The Debian revision fails to match (.*)-[A-Za-z0-9\\+\\.]+\$ in $version.\n";
      exit 1;
    }
  }

=head2 upstream-version

This is the main part of the version. It is usually version number of
the original (``upstream'') package of which the .deb file has been
made, if this is applicable. The upstream-version portion of the
version number is mandatory.

The upstream-version may contain only alphanumerics and the characters
+ . - : (full stop, plus, hyphen, colon) and should start with a
digit. If there is no debian-revision then hyphens are not allowed; if
there is no epoch then colons are not allowed.

=cut

  #Check out the main version
  if ($have_epochs) {
    if ($have_debrev) {
      $upstream_pat = '^[A-Za-z0-9\.\+\:\-]+$'; # Note the : and the -
    }
    else {
      $upstream_pat = '^[A-Za-z0-9\.\+\:]+$'; # Note the : 
    }
  }
  else {
    if ($have_debrev) {
      $upstream_pat = '^[A-Za-z0-9\.\+\-]+$'; # Note the -
    }
    else {
      $upstream_pat = '^[A-Za-z0-9\.\+\-]+$';
    }
  }

  if ($version =~ m/$upstream_pat/o) {
    print "Yes\n";
    exit 0;
  }
  else {
    #This is an error.
    print "The upstream version fails to match $upstream_pat in $version\n";
    exit 1;
  }
  # Not-reached
}


## Now just call main
&main();


=head1 B<SEE ALSO>

B<dpkg>(5), B<dpkg-deb>(1), B<dpkg-source>(1),  B<dpkg-parsechangelogs>(1),
B<The Debian Packaging manual>.

=cut


=head1 BUGS

None Known so far.

=cut

=head1 AUTHOR

This  was  written by Manoj Srivastava <srivasta@debian.org>, for the
Debian GNU/Linux system. 

=cut


exit 0;
__END__


--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-devel-request@lists.debian.org . 
Trouble?  e-mail to templin@bucknell.edu .


Reply to: