[Pkg-octave-devel] Re: Automatic generation of Debian packages from CRAN

Dirk Eddelbuettel edd at debian.org
Thu Aug 31 16:25:55 UTC 2006

Hi John,

On 31 August 2006 at 11:50, John W. Eaton wrote:
| We are (finally) working on a package system for Octave and splitting
| up Octave Forge into individual packages.

I heard via Rafael. Very exciting!

| Some people are proposing to make it easy to bundle a lot of Octave
| packages together to make it easier for the the deb/rpm packagers to
| create packages.
| Instead of that, I want to encourage the people working on Octave's
| package system to make it possible (and easy) to generate individual
| deb or rpm packages from the corresponding Octave packages, becuase
| I'm imagining that I would eventually like to be able to do something
| like
|   apt-get install octave
|   apt-get install octave-pkg-audio
|   apt-get install octave-pkg-image
|   apt-get install octave-pkg-optimization
| etc. to pick and choose individual packages in Debian and not also get
| everything that used to be in Octave Forge.

Yup. I also like degrees of freedom.

| I think you are doing something similar for R and all the CRAN

More talk than code. A few attempts, nothing finished.

| packages.  If you have time, would you mind commenting on what
| features are needed in the R package system to make the automatic
| generation of deb packages manageable?

Well, we came from the other end:  Essentially all existing CRAN package use
the same debian/* files, so we figured we may as well automate that.

Take any one of my r-cran-* packages, and look at the sources.  [ To be
concrete, let's use, say, the little tkrplot which I just upgraded
yesterday.]  It like all already converted packages (roughly 60% of the 50 or
so, I'd say) simply uses this for debian/rules

#!/usr/bin/make -f
# 							-*- makefile -*-
# debian/rules file for the Debian/GNU Linux r-cran-tkrplot package
# Copyright 2002 - 2006 by Dirk Eddelbuettel <edd at debian.org>

include /usr/share/R/debian/r-cran.mk


where r-cran.mk itself is only a few lines. IIRC I more or less stole that
idea from Rafael, or implemented it after he did something similar for Octave
in Debian.

|  Or, if this is documented
| somewhere, can you tell me where to look?

Not really.  There is attempt at a Policy document that gives some ideas, see
late Dec 2003 (!!) on debian-devel. 

But in summary, the real key is that R makes it so easy to just do
(and here I quite r-cran.mk in its entirety)

#!/usr/bin/make -f
# 							-*- makefile -*-
# Generic debian/rules file for the Debian/GNU Linux r-cran-* packages
# Should be sufficient for Debianization of CRAN (http://cran.r-project.org) 
# packages. Note that you still need to provide the other files in debian/*,
# in particular control, changelog and copyright. 
# Copyright 2003-2006 by Dirk Eddelbuettel <edd at debian.org>

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/langcore.mk

# awk command to extract word after Package or Bundle, lowercased
awkString	:= "'/^(Package|Bundle):/ {print tolower($$2) }'"

# apply it to the upstream meta-info file DESCRIPTION
cranName        := $(shell awk "$(awkString)" DESCRIPTION)

## and use the result to build the Debian'ized package name
package		:= r-cran-$(cranName)

## which we use for the to-be-installed-in directory
debRlib		:=$(CURDIR)/debian/$(package)/usr/lib/R/site-library

## two targets for arch dependent and independent packages
common-install-indep:: R_any_arch
common-install-arch:: R_any_arch

		dh_installdirs		usr/lib/R/site-library
		R CMD INSTALL -l $(debRlib) --clean .
		rm -vf $(debRlib)/R.css $(debRlib)/*/COPYING 


where the key is that all Debian needs to do is to call R CMD INSTALL with
one argument for the install-directory redirection.  The rest is handled by
Debian's cdbs package that aids with all the base rules.

Lemme know if you have more questions. I also CC Rafael who knows a lot about
all this.

Cheers, Dirk

Hell, there are no rules here - we're trying to accomplish something. 
                                                  -- Thomas A. Edison

More information about the Pkg-octave-devel mailing list