| 126 | == Debian Packaging == |
| 127 | |
| 128 | [http://tumbleweed.org.za/ tumbleweed]'s talk on building debian packages: |
| 129 | |
| 130 | * Package your source up nicely using `sdist` |
| 131 | * Things get named `name_version.orig.tar.gz` |
| 132 | * Unpack the source distribution, and run `dh_make` |
| 133 | * Look through the different example files that are produced: |
| 134 | * There are loads of them, you don't have to use all of them |
| 135 | * `debian/control` tells what different packages should be produced |
| 136 | * You can have separate `binary` and `source` files |
| 137 | * `debian/copyright` is important to signal the licenses etc, following Debian rules |
| 138 | * `debian/rules` is a makefile that generates a deb |
| 139 | * It's a lot of work to write all the rules, so there are a lot of helper tools |
| 140 | * This used to involve lots of separate build steps |
| 141 | * debhelper 7 is the way to go nowadays... Now you just use `dh`: |
| 142 | {{{ |
| 143 | |
| 144 | #!/usr/bin/make -f |
| 145 | |
| 146 | %: |
| 147 | dh % |
| 148 | }}} |
| 149 | * You can have pre- and post- install scripts |
| 150 | * For a python package, you just need a few files (those mentioned above) |
| 151 | * `dch` lets you edit `debian/changelog` |
| 152 | * To install scripts, create a little script that loads the module (`debian/hellopy`) and add the instruction to install in `debian/install`: `debian/hellopy /usr/bin` |
| 153 | * Call the package `python-$libname` to follow convention |
| 154 | * `Architecture`: `any` means build on every architecture; `all` means just build one package for all libraries |
| 155 | * `Description` - first line is summary, the rest is detail |
| 156 | * Format is the same as email: To continue on a new line, put a space as the first character; for a blank line use `<space><dot>` like so: ` .` |
| 157 | * `XS-Python-Version`: You can set this to `all` or limit to greater than `2.5` etc |
| 158 | * `Depends`: calls the macro `${python_Depends}` |
| 159 | * There are two competing ways to do python dependencies on debian: `python-central` and `python-support` |
| 160 | * `python-central` is maintained by the Python maintainer, used by 10-20% of the packages. |
| 161 | * `python-support` is much more popular, and the maintainer is more reactive. Integrates nicely with `debhelper 7` |
| 162 | * Specify `Build-Depends: debhelper (>= 7), python-support` |
| 163 | * Patching the source directly is frowned upon, there are systems for managing patches |
| 164 | * Put `3.0 (quilt)` in `debian/source/format` and then you can use `quilt` to maintain patches |
| 165 | * Then you build with `debuild`: |
| 166 | * Your package should automatically clean everything it creates - `clean` gets run before `build` |
| 167 | * Everything gets installed under a fake root, so you need to specify anything that your build requires |
| 168 | * `debc` lists the contents of the deb file |
| 169 | * Then you install... |
| 170 | * As you install, `python-support` will automatically byte compile your python code for you by calling `update-python-modules` |
| 171 | * `/usr/lib/pymodules/python2.x` contains symlinks to the original code under `/usr/share/pyshared/` as well as the byte-compiled files for that version |
| 172 | * Extensions go into `/usr/lib/python-support/python-$libname/python2.x/` |
| 173 | * These symlinks and byte-compiled files aren't actually owned by the package, but will be regenerated/cleaned up if you run `update-python-modules` for that package again |
| 174 | |