# $Header: /cvsroot/nco/nco/doc/debian.txt,v 1.38 2006/06/08 04:27:46 zender Exp $ -*-text-*-

# Purpose: Debian information for NCO netCDF Operators project
# Notes describe procedure to manipulate Debian-specific distribution

Debian:	    http://packages.debian.org/unstable/math/nco.html
Gentoo:	    http://gentoo-stable.iq-computing.de/browse?type=version&category=app-sci&package=nco&version=2.2.0

Rod02 is Bible for packaging .deb's: /data/zender/tmp/maint-guide.en.pdf
Questions on procedure go to Debian Mentors <debian-mentors@lists.debian.org> 

0. Install Debian packages required to build new packages
apt-get install dh-make debhelper devscripts fakeroot gnupg debian-policy developers-reference

1. Create ~/nco/debian directory to hold Debian configuration files
   Following files were

2. Debian build procedure recommends placing entire package source in
   subdirectory of main package. 
   For starters, we wish to create .debs of tagged releases, e.g., nco-3.1.4
   First we create a clean source distribution of nco and place it in nco-3.1.4
   Once automated, we will use cvs co -rnco-3_1_4 to get the source
   Until we know what is necessary, however, we just copy a snapshot
   
   2.1 Clean all build files from development directory

cd ~/nco;make distclean;cd bld;make clean;cd ~
tar cvzf ./nco/nco.tar.gz ./nco/*
cd ~/nco;tar xvzf nco.tar.gz;mv nco nco-3.1.4
/bin/rm nco.tar.gz;tar cvzf nco-3.1.4.tar.gz ./nco-3.1.4/*
cd ~/nco/nco-3.1.4
dh_make -e zender@uci.edu -f ../nco-3.1.4.tar.gz

    2.2 The preceding steps created template debian files for a .deb,
    Those files now reside in ~/nco/debian.
    They are now checked into the CVS repository of the main distribution
    Step 2 only needs to be performed once per package
    Now that the Debian template files are a part of the upstream
    directory, future work consists of building the Debian packages

3. Build new .deb package

   3.1 First, remove detritus including *.gz files in parent directory
   from previous build

   cd ~/nco;/bin/rm *.gz
   cd ~/nco/nco-3.1.4;
   dpkg-buildpackage -rfakeroot > foo 2>&1

4. Find out which packages new package needs for building
   From Rod02 p. 14

   strace -f -o /tmp/log ./configure
   for x in `dpkg -S ${grep open /tmp/log | perl -pe 's!.* open\(\"([^\"]*).*!$1}

5. Going backwards: How to create the Debian tarball source given
the distributed Debian files, nco_X.Y.Z-3.dsc nco_X.Y.Z-3.orig.tar.gz,
and nco_X.Y.Z-3.diff.gz  

dpkg-source -x nco_X.Y.Z-3.dsc

This dpkg-source command is functionally equivalent to applying the
Debian diff to the original source to produce Debian source:

cd /data/zender;/bin/rm -r nco-X.Y.Z.orig nco-X.Y.Z 
tar xvzf nco_X.Y.Z.orig.tar.gz # Untar original source
cp -r nco-X.Y.Z.orig nco-X.Y.Z # Create destination for patches
patch -p0 < nco_X.Y.Z-3.diff # Patch destination with Debian diff

6. To synchronize .debs with new releases, follow this procedure:
   cd ~/nco/bld
   make tags
# Install correct version numbers before updating Debian
# tags-query replace 3_1_4 with X_Y_Z+1
# tags-query replace 3.1.4 with X.Y.Z+1
# If tags-query replace does not work, be sure to manually change
# versions in configure.in, debian/files, doc/ANNOUNCE, doc/debian.txt,
# doc/index.shtml, doc/nco.texi, bld/nco_dst.pl, doc/VERSION 
   cd ~/nco/debian
   dch -v 3.1.4-1 # Update changelog
# For unknown reason rules file may lose its executable bit
   chmod a+x ~/nco/debian/rules
   cd ~/nco;cvs commit -m "";dpkg-buildpackage -rfakeroot > foo 2>&1
# Save all files in emacs before tagging
# Tag CVS code after changing files in ~/nco/debian
   cd ~/nco;cvs commit -m "Preparing nco-3.1.4 release";cvs tag -c nco-3_1_4
   ${HOME}/nco/bld/nco_dst.pl --dbg=2 --bld --cln nco-3_1_4
