Debian Python Packaging

From brainsik
Jump to navigation Jump to search

Codeville Notes

Here is how i built a debian package for the devel version of Codeville.

Grab the devel version of Codeville.

mkdir devel ; cd devel
cdv init
cdv set user anonymous
cdv set repository cdv://codeville.org/codeville/devel
cdv up
cd ..

Grab the source of the latest Debian version.

mkdir deb-src ; cd deb-src
apt-get source codeville 
cd ..

Now we muck about.

mkdir muckabout ; cd muckabout
cp -a ../devel codeville-0.1.16.99
cd codeville-0.1.16.99
cp -a ../../deb-src/debian .

Add an entry to the top of debian/changelog for this new version.

Change the Codeville version in the __init__.py files.

Build the package!

fakeroot dpkg-buildpackage -b -uc -us

This may fail if due to changes in the devel version from the latest in Debian. Fix them and nuke the build dir.

rm -rf debian/codeville

If you succesfully build the .deb, then go ahead an install.

cd ..
dpkg -i codeville_0.1.16.99-1_all.deb

Notes from Matt

These came from work done at ShitTorrent. I'm dubious about the accuracy of these notes, but they may be useful later.

  1. build a bdist_dumb tarball
  2. untar it in a directory
  3. make debian control file in there
  4. put the right version, size, etc in the debian control file
  5. dpkg-deb -b $PACKAGENAME
_build_deb() {
    echo "Building deb for Python $PYV..."
    $PYTHON setup.py bdist_dumb
    cd dist/

    PACKAGENAME="codeville_${PACKAGEVERSION}_python${PYTHONVERSION}"
    mkdir $PACKAGENAME
    DUMBDIST=`ls Codeville-$PACKAGEVERSION*.tar.gz`
    mv $DUMBDIST $PACKAGENAME
    cd $PACKAGENAME
    tar -xvzf $DUMBDIST
    rm $DUMBDIST
    cd ..
    INSTALLEDSIZE=`du -ks $PACKAGENAME | sed -e "s/$PACKAGENAME//"`
    mkdir $PACKAGENAME/DEBIAN
    sed -e "s/PACKAGEVERSION/$PACKAGEVERSION/g" ../debian/control |\
    sed -e "s/PYTHONVERSION/$PYTHONVERSION/g" |\
    sed -e "s/INSTALLEDSIZE/$INSTALLEDSIZE/g" \
    > $PACKAGENAME/DEBIAN/control
    dpkg-deb -b $PACKAGENAME
    rm -fr $PACKAGENAME

    cd ..
    echo "Done with deb for Python $PYV."
}