# $Header: /cvsroot/nco/nco/doc/debian.txt,v 1.69 2006/12/07 06:26:21 zender Exp $ -*-text-*-

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

netCDF packages:
cd ${DATA}
wget http://ftp.debian.org/debian/pool/main/n/netcdf/netcdf_3.6.1-0.1.dsc
wget http://ftp.debian.org/debian/pool/main/n/netcdf/netcdf_3.6.1.orig.tar.gz
wget http://ftp.debian.org/debian/pool/main/n/netcdf/netcdf_3.6.1-0.1.diff.gz
dpkg-source -x netcdf_3.6.1-0.1.dsc

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

Rod05 is Bible for packaging .deb's: /data/zender/tmp/debian.pdf
# Debian Policy Manual
file:///usr/share/doc/debian-policy/policy.html/
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

0.5 Create key to sign packages
   gpg --gen-key

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

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.8
   First we create a clean source distribution of nco and place it in nco-3.1.8
   Once automated, we will use cvs co -rnco-3_1_8 to get 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.8
/bin/rm nco.tar.gz;tar cvzf nco-3.1.8.tar.gz ./nco-3.1.8/*
cd ~/nco/nco-3.1.8
dh_make -e zender@uci.edu -f ../nco-3.1.8.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.8
   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
# Put cute version-specific string in nco_ctl.c:nco_nmn_get()
# Install correct version numbers before updating Debian
# tags-query replace 3_1_8 with X_Y_Z+1
# tags-query replace 3.1.8 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.8-1 # Update changelog
# For unknown reason rules file may lose its executable bit
   chmod a+x ~/nco/debian/rules
# Build Debs using Debian libraries and include
   cd ~/nco;cvs commit -m "Preparing nco-3.1.8 release"
# 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.8 release";cvs tag -c nco-3_1_8
   ${HOME}/nco/bld/nco_dst.pl --dbg=2 --bld --cln nco-3_1_8

# Location of build diagnostics for mentors to help 
http://dust.ess.uci.edu/nco/src/nco_3.1.8-1.dpkg-buildpackage.txt
http://dust.ess.uci.edu/nco/src/nco_3.1.8-1.dsc
http://dust.ess.uci.edu/nco/src/nco_3.1.8-1_i386.changes
http://dust.ess.uci.edu/nco/src/nco_3.1.8-1_i386.deb
http://dust.ess.uci.edu/nco/src/nco_3.1.8.orig.tar.gz

# Becoming a Debian developer
http://www.debian.org/devel/join/newmaint
# Debian mentor FAQ
http://people.debian.org/~mpalmer/debian-mentors_FAQ.html

Debian Acronyms & Abbreviations:
BTS Bug Tracking System
FTBFS Fails to Build from Source
ITA Intent to Adopt
NMU Non-Naintainer Upload
RC  Release Critical
RFP Request for Package 
RFS Request for Sponsor 
WNPP Work-Needing and Prospective Packages 

# NCO orphan/ITA bug
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=273322
# netCDF orphan/ITA bug
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=321336

# Debian QA member who is de facto NCO maintainer
Matej Vela <vela@debian.org>
# Listed as wanting to adopt nco and netcdf packages
Daniel Baumann <daniel.baumann@panthera-systems.net>
Daniel Baumann <daniel@debian.org>
# Created netCDF 3.6.1 package
Warren Turkal <wt@atmos.colostate.edu>

Matej Vela <vela@debian.org>, Daniel Baumann <daniel@debian.org>, Warren Turkal <wt@atmos.colostate.edu>

# New build system
# Non-native debian builds Rod05 p. 46
cd ~/nco;cvc
/bin/rm -rf ${DATA}/nco-3.1.8 ${DATA}/nco_3.1.8* ${DATA}/debian # Initial cleanup
#cd ${DATA};cvs -d zender@nco.cvs.sourceforge.net:/cvsroot/nco export -kkv -r nco-3_1_8 -d nco-3.1.8 nco # Export based on tag
cd ${DATA};cvs -d zender@nco.cvs.sourceforge.net:/cvsroot/nco export -kkv -D "1 second ago" -d nco-3.1.8 nco # Export most recent
tar cvzf ./nco_3.1.8.orig.tar.gz --exclude='nco-3.1.8/debian*' --exclude='.cvsignore' --exclude='ncap_lex.c' --exclude='ncap_yacc.[ch]' ./nco-3.1.8 
mv ./nco-3.1.8/debian ${DATA}/debian # Move debian directory elsewhere temporarily
/bin/rm -rf ${DATA}/nco-3.1.8 # Remove cvs-exported directory
tar xvzf ./nco_3.1.8.orig.tar.gz # Untar to get directory without excluded files
mv ${DATA}/debian ./nco-3.1.8 # Replace debian directory
cd ${DATA}/nco-3.1.8;dpkg-buildpackage -rfakeroot -uc -us > ~/foo.nco 2>&1
sudo dpkg --remove nco
sudo dpkg --install ${DATA}/nco_3.1.8-1_i386.deb
lintian ${DATA}/nco_3.1.8-1_i386.deb
linda ${DATA}/nco_3.1.8-1_i386.deb
ls -l ${DATA}/nco_3.1.8*
m ~/foo.nco
scp ${DATA}/nco_3.1.8* dust.ess.uci.edu:/var/www/html/nco/src
scp ${DATA}/nco_3.1.8* nco.sf.net:/home/groups/n/nc/nco/htdocs

