vendor_import

Introduction

This small python script helps automate management of vendor branches of a local CVS tree.

(For a fuller background on CVS vendor branches, see The CVS Book, in particular the section Tracking Third-Party Sources (Vendor Branches)).

Normally the process of merging a new vendor release of code into a local CVS repository consists of a number of steps:

  1. Fetch the latest release
  2. Unpack the release
  3. cvs import the new code
  4. look up the previous vendor release tag
  5. merge the code using cvs co -j oldtag -j newtag
  6. manually fixup any conflicts and merge

vendor_import manages steps 2-5 automatically. You simply run

vendor_import foopackage-1.2.tar.gz

and it will unpack the distribution, import it into CVS, update it's internal database (stored in CVS) and do the merge. If manual conflict resolution is needed, of course you'll have to do that yourself.

Installing and using vendor_import

You'll need to make a few changes to parameters at the top of the script. The most important one is the setting for CVSROOT at the top of the file. Point this at your local CVS server.

You'll then need to create a small repository for vendor_import to use. By default this is called vendor_branch_admin, but can be changed (see the ADMINREPOS variable at the top of the file.)

This repository should contain an empty file called vendor_versions_db, and a file called package_names_db. Initially, this can also be empty.

A sample shell session might look something like this:

$ mkdir vendor_branch_admin
$ cd vendor_branch_admin
$ touch vendor_versions_db package_names_db
$ cvs import vendor_branch_admin <myname> initial

You can then cvs co the vendor_branch_admin repository to make changes to the package_names_db. You'll need to do this before using the script.

The database files

There are two files used by vendor_import, one is automatically generated by the script and probably won't need to be edited, the other requires manual editing.

package_names_db

This file consists of a number of lines, one per package. It's a colon delimited file, with 5 entries per line. These entries are, in order:
entrydescriptionexample
Filename RE A regular expression to match the filenames for this package. openivr_.*
Vendor Name The vendor name for this package openh323
Package Name The "name" of this package openivr
CVS repository The path to the CVS repository for this package. Note no leading / voip/openh323/openivr
Version RE A regular expression to extract the version number from the package filename. This must include a named group called 'version'. openivr_(?P<version>\d\.\d+\.\d+)\.tar\.gz

Here's a fuller example, showing all of the OpenH323 packages. Note that OpenH323 has a package called 'openh323'!

# Format is:
# MatchRE:vendor:package:cvs repos:versionRE
#
openh323_.*:openh323:openh323:voip/openh323/openh323:openh323_(?P<version>\d\.\d+\.\d+)\.tar\.gz
pwlib_.*:openh323:pwlib:voip/openh323/pwlib:pwlib_(?P<version>\d\.\d+\.\d+)\.tar\.gz
openam_.*:openh323:openam:voip/openh323/openam:openam_(?P<version>\d\.\d+\.\d+)\.tar\.gz
ohphone_.*:openh323:ohphone:voip/openh323/ohphone:ohphone_(?P<version>\d\.\d+\.\d+)\.tar\.gz
callgen323_.*:openh323:callgen323:voip/openh323/callgen323:callgen323_(?P<version>\d\.\d+\.\d+)\.tar\.gz
openivr_.*:openh323:openivr:voip/openh323/openivr:openivr_(?P<version>\d\.\d+\.\d+)\.tar\.gz
openmcu_.*:openh323:openmcu:voip/openh323/openmcu:openmcu_(?P<version>\d\.\d+\.\d+)\.tar\.gz

vendor_versions_db

This file is automatically updated by vendor_import. It consists of one line per import. Each line contains the package name and the import tag. You should never need to edit this file manually. vendor_import always looks for the last entry for a package - so you can use the script to merge back to an older version quite happily.

An obscure artifact of CVS - the first import of a vendor branch gets a tag of the vendor-tag, not the release-tag. This is automatically handled.

Version tags consist of the letter 'v' followed by the version number extracted from the filename, with illegal characters replaced with an underscore.

Limitations, requirements, &c.

There are a few limitations to this tool:

Todo, &c.

There's a bunch of bits to add - it should process arguments on the command line. If the filename has no version number, it should see if the directory that's unpacked has a version number. There should be a 'default' mechanism for matching version numbers (maybe something like digits and seperator chars).

The code

Current Version: 0.3 - first public release

Right click, save as: vendor_import.py