freebsd-dev/usr.sbin/pkg_install/lib/version.c
Maxim Sobolev f3fa78b0b5 - Introduce a notion of `packing list format version'. This allows making
non-backward compatible changes in the format of packing list and handle
  them gracefully;
- fix a longstanding issue with symlinks handling. Instead of recording
  checksum for the file symlink points to, record checksum for the value
  returned by readlink(2). For backward compatibility increase packing list
  format minor version number and provide a fallback to a previous behaviour,
  if package in question was created with older version of pkg_* tools;

Submitted by:	Alec Wolman <wolman@cs.washington.edu>, sobomax

- don't record MD5 checksum for device nodes, fifo's and other non-regular
  files.

Submitted by:	nbm
MFC in:		2 weeks
2001-10-10 08:21:41 +00:00

49 lines
1.3 KiB
C

#ifndef lint
static const char rcsid[] =
"$FreeBSD$";
#endif
/*
* FreeBSD install - a package for the installation and maintainance
* of non-core utilities.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Maxim Sobolev
* 31 July 2001
*
* Routines to assist with PLIST_FMT_VER numbers in the packing
* lists.
*
* Following is the PLIST_FMT_VER history:
* 1.0 - Initial revision;
* 1.1 - When recording/checking checksum of symlink use hash of readlink()
* value insted of the hash of an object this links points to.
*
*/
#include "lib.h"
#include <err.h>
int
verscmp(Package *pkg, int major, int minor)
{
int rval = 0;
if ((pkg->fmtver_maj < major) || (pkg->fmtver_maj == major &&
pkg->fmtver_mnr < minor))
rval = -1;
else if ((pkg->fmtver_maj > major) || (pkg->fmtver_maj == major &&
pkg->fmtver_mnr > minor))
rval = 1;
return rval;
}