Skip to content

Improving update of existing debian/copyright file

May 31, 2015

Hello

One of my last blog introduced the new cme update dpkg-copyright command and explained how to use this command to create a debian/copyright file from scratch.

We will see in this blog how cme update dpkg-copyright command can also be used if a debian/copyright file already exists.

During the lifetime of a package, creating a new debian/copyright copyright file should only happen once. When updating a package to a new upstream version, the content of the copyright file should be modified to reflect upstream changes by:

  • adding or removing file entries
  • updating © years or owners
  • updating licenses

cme update dpkg-copyright can be run with an existing debian/copyright file: the information extracted by licensecheck are merged in debian/copyright. Unfortunately, this merge may bring back the errors coming from licensecheck that you’ve cleaned up manually last time.

This last part is not optimal as the manual clean up must be repeated after cme update dpkg-copyright is run.

Here’s a way to avoid the last problem: cme update dpkg-copyright supports a way to modify the content of debian/copyright after the merge: the optional file debian/fix.scanned.copyright contains instructions to tweak the content of debian/copyright. (See Config::Model::Dpkg::Copyright man page for more details)

You may remember that Config::Model handles all configuration information as a tree. The information contained in the copyright file is also stored in a tree structure. debian/fix.scanned.copyright contains instructions to navigate this tree and modify the content of the tree.

Imagine that there’s a robot (or a monkey) in that configuration tree. Each instruction tells the robot either to move in the tree or to perform an operation.

The most useful instructions for debian/fix.scanned.copyright are:

  • ! to move to the root of the tree
  • = to assign a value , e.g: short_name=MIT or Copyright="2014, FooBar" (use double quotes when the value white space or other fancy characters).
  • .= to append to a value, e.g Copyright.=" Appended info."
  • =~ to apply a substitution with a Perl regexp, e.g. Copyright=~"/©\s*//g"
  • : to move a Files element, e.g. Files:"foo/baz.c"
  • :~ to remove a Files element, e.g. Files:~"bogus.c"

Otherwise:

  • Comments with # or // must begin at the beginning of the line
  • Instructions are separated by space(s) or new lines

Let’s see a commented example:

# go to the root of the tree (with '!')
# and remove a bogus Files entry (with ":~")
! Files:~"foo/bogus.c"

// go to a Files entry and append (operator '.=') some info to © owner
! Files:"foo/bar.h"
  Copyright.=" Appended info."

# go back to tree root and assign © info
! Files:"foo/baz.c" Copyright="2014, FooBar"

# add a global license and a file entry missed by licensecheck
# global license must be set before using it in Files entry
# note: MIT text license is provided by cme
! License=MIT
! Files:"3rdparty/missed.c" Copyright="2005 FooBar" License short_name=MIT

Other possible instructions for this file are described in Config::Model::Loader doc.

The number of instructions depends on the accuracy of licencecheck command. Hopefully, this number can be reduced by improving licensecheck.

Last but not least, the following packages are required:

You may want to install also libconfig-model-tkui-perl to update the copyright file with cme GUI.

In summary, the command cme updated dpkg-copyright associated with instructions stored in debian/fix.scanned.copyright enable Debian packagers to update with less effort debian/copyright file when updating a package.

All the best

From → Uncategorized

2 Comments
  1. Michael Tokarev permalink

    Where cme and cme update comes from? In the last blog it has been said it is libconfig-model-dpkg-perl package version 2.061. However, current version of that package in testing is 2.065 (and libconfig-model-perl version 2.071-1), and this one neither has the cme command (the command is named cme-old) nor the update subcommand.

    • cme is now delivered in its own package. I completely forgot to mention this in the NEWS file of libconfig-model-perl. Sorry about that.

      I’m going to edit the post to add this information.

      All the best

Leave a comment