[[:home | Home]] [[:proj:project | Project]] ====== Notes on Debian Packaging ====== ===== An Alternative - stdeb ===== Hi everyone Some time ago, I gave a talk about the "fpm" package manager a while back. Today, I came across a different tool, which is also available from the Ubuntu repositories called "stdeb": https://github.com/astraw/stdeb I successfully generated a Debian package for one of my little Python utilities: https://github.com/waikato-datamining/docker-banner-gen/releases/tag/v.0.0.6 Just by using this command-line (using the "setup.py" of the project): python3 setup.py --command-packages=stdeb.command bdist_deb Requires "python3-all" to be installed. Thought you might find this useful. Cheers, Peter -- Peter Reutemann Dept. of Computer Science University of Waikato, NZ +64 (7) 858-5174 Thanks to the following stackoverflow post I figured out how to include a .desktop file and icon, making an application appear in the main menu: https://stackoverflow.com/a/17402676/4698227 Example code mentioned in that post is available from here: https://github.com/cpbotha/stdeb-minimal-example ===== Step by Step ===== ==== Packaging ==== * Any new folders or files? Update KEEPME rules * run 0 KEEP pre_DEB_packaging.py (in SOFA/storage) - details in "Steps Covered by Script" below. * NB copies final deb into grantshare ready for testing immediately. ==== Testing ==== * copy deb package from /home/g/projects/SOFA/debmaker into grantshare and make all permissions Read and Write * remove /home/grant/sofa from notebook before reinstalling * copy onto notebook desktop and reinstall - then test * copy to transfer and set permissions to RW * select lucid snapshot, revert to snapshot, then open * (already done in snapshot) sudo mkdir /transfer * sudo mount -t vboxsf transfer /transfer (this will only work if vb settings have Shared Folder set to transfer_nb as transfer etc) * Test on Lucid (if OK, ready to release :-)) * Shift copy to /home/g/projects/SOFA/installers [[:proj:targz | tar.gz Notes]] ===== Steps Covered by Script ===== * Go to /home/g/projects/SOFA/debmaker * Apart from the KEEPME subfolder, delete everything in debmaker. KEEPME has demo control, rules, dirs etc files etc + desktop file * Delete everything in sofaclean * Copy into sofaclean the sofa.main folder from the /home/g/projects/SOFA/sofastatistics/sofa.repo folder * delete tests folder * delete .bzr folder * delete storage folder under dbe_plugins * examples folder under boomslang and test_clustered_bar_chart.py * remove all pyc files, including in dbe_plugins * delete 2 spss files, mki18n.py, and the non-Python files e.g. app.fil, messages.pot, any po files in main folder. * delete ./locale/ru_RU * in ./locale/gl_ES/LC_MESSAGES delete sofa.mo and sofa_win.mo and then rename sofa_ub.mo to sofa.mo * Also copy the sofa folder from home. * you should now have two folders: * - sofa.main * - and sofa * Working in the sofa folder ... * Delete comtypes_handled.txt and proj_file_customised.txt if present. * Delete misc folder and misc.tar.gz * Empty _internal except for SOFA_Default_db (which should be about 169KB not many MBs) * Remove all projs except the SOFA_Default one. * Ensure MS Access and MS SQL Server items are not in the db and tbl dics inside default proj file. * Empty reports and scripts completely. * Remove all vdts except the SOFA_Default one. Check the default one for additions ;-). * Select both sofa and sofa.main folders and make .tar.gz archive - call it sofa-n.n.n.tar.gz (e.g. sofa-1.2.27.tar.gz) * Copy tar.gz file into debmaker and go there. * Extract Here but don't delete tar.gz file * Move tar.gz file to freshly extracted sofa-n.n.n subfolder * cd /home/g/projects/SOFA/debmaker/sofastats-n.n.n * dh_make -e grant@sofastatistics.com -f sofastats-n.n.n.tar.gz * (include -c gpl if using gpl. Modify licence file by hand if agpl) * select s for single and confirm * ignore comment about absence of top level Makefile. Keep terminal open as is. * delete sofastats-n.n.n.tar.gz from /home/g/projects/SOFA/**debmaker/sofastats-n.n.n** * delete sofastats-n.n.n.orig.tar.gz from /home/g/projects/SOFA/**debmaker** * put SOFA Statistics desktop file from KEEPME in /home/g/projects/SOFA/**debmaker/sofastats-n.n.n** * Prepare all files under /home/g/projects/SOFA/debmaker/sofastats-n.n.n/debian * add to the KEEPME version of rules any new files, including images, added to project since last time. NB change both left and right hand side of lines * **control, dirs and rules** can be copied across in toto * **changelog** - add jaunty upwards unstable, and change second line so * put my comment here ... * NB no commas or will fail! * **copyright** - copy across from "It was downloaded" downwards (NB if including anything not AGPL3 need to update KEEPME version first) * delete all files and folders apart from changelog, compat, control, copyright, dirs, and rules (6 files) * dpkg-buildpackage -rfakeroot (check for errors) - ignore Failed to sign .dsc and .changes file * **rename deb** from sofastats_ to sofastats- ===== Preparation ===== ==== Misc ==== * If the program name consists of more than one word, contract them to one word, or make an abbreviation. [[http://www.debian.org/doc/maint-guide/ch-first.en.html#s-namever]] * make sure dh-make is installed e.g. sudo apt-get install dh-make ===== Specific Settings in debian folder ===== ==== NB copy and paste from KEEPME ==== * NB any changes for dates or version numbers * NB put desktop file into ~/Desktop/debmaker/sofastats-n.n.n before running build command * It is helpful to # Uncomment this to turn on verbose mode. export DH_VERBOSE=1 ==== changelog ==== format as package name then version "When working with a package which originated in Debian, use a version number derived from the Debian version number with ubuntu appended. i.e. Debian 1.0-2 becomes 1.0-2ubuntu1, followed by 1.0-2ubuntu2, etc. Packages not in debian yet should end with revision -0ubuntu1" [[http://ubuntuforums.org/showthread.php?t=51003]] sofastatistics (0.6-0ubuntu1) jaunty stable; urgency=low # could be experimental, unstable etc *ubuntu linux package for jaunty jackalope. *a stable release. Any other comments about what has changed. -- Grant Paton-Simpson Fri, 8 May 2009 18:52:02 +0000 Formatting rules: The change details may in fact be any series of lines starting with at least two spaces, but conventionally each change starts with an asterisk and a separating space and continuation lines are indented so as to bring them in line with the start of the text above. Blank lines may be used here to separate groups of changes, if desired. Doesn't like comma in first line - so jaunty karmic and lucid is fine but jaunty, karmic, and lucid = eof fault. ==== control ==== === Depends === e.g. Depends: python (>=2.6.2-0ubuntu1), ... The relations allowed are: <<, <=, =, >= and >> for strictly earlier, earlier or equal, exactly equal, later or equal and strictly later, respectively. [[http://www.debian.org/doc/maint-guide/ch-dreq.en.html#s-control]] === Section === main (as opposed to non-free or unknown or contrib) and a subsection e.g. main/python The Debian archive maintainers provide the authoritative list of subsections. At present, they are: admin, base, comm, contrib, devel, doc, editors, electronics, embedded, games, gnome, graphics, hamradio, interpreters, kde, libs, libdevel, mail, math, misc, net, news, non-free, oldlibs, otherosfs, perl, python, science, shells, sound, tex, text, utils, web, x11. [[http://sdn.vlsm.org/share/Debian-Doc/debian-policy/ch-archive.html#s-subsections]] === Maintainer === Line 4 is the name and email address of the maintainer. Make sure that this field includes a valid "To: " header for an email, because after you upload it, the bug tracking system will use it to deliver bug emails to you. Avoid using commas, ampersands and parenthesis. === Architecture === If your package is architecture independent (for example, a shell or Perl script, or a document), change this to "all", and read later in `rules' file, Section 4.4 about using the `binary-indep' rule instead of `binary-arch' for building the package. This would apply to python as well. [[http://www.debian.org/doc/maint-guide/ch-dreq.en.html#s-control]] === Description === Stats/analysis - favours ease-of-use over comprehensiveness # has to no more than 60 characters A statistics, reporting and analysis package with an emphasis on ease-of-use. The goal is flexible input and beautiful output - i.e. lots of databases supported and attractive, ready-to-present output. ==== copyright ==== === License === If using the GPL, make a selection - either GPL2 or GPL2+ If using the AGPL will need to fill this in manually. From man dh_make OPTIONS -c, --copyright Use type in copyright file. can be gpl, lgpl, artistic or bsd. If this field is not specified the copy‐ right file has a space to fill in which sort of license is used. The field is case-insensitive so -c GPL works as well as -c gpl. === Description === NB there must be a space before the description. And complete a full description. If you want a space between 2 lines use a . (dot). ==== dirs ==== List the directories actually used e.g. usr/share/pyshared/sofastats NB no preceding slash ==== README.Debian ==== Not relevant to me. "Any extra details or discrepancies between the original package and your debianized version should be documented here." [[http://www.debian.org/doc/maint-guide/ch-dother.en.html#s-readme]] ==== rules ==== In rules, it wants tabs, not eight spaces. If using gedit, may need to paste tabs in so it doesn't autoconvert them (or untick "Insert spaces instead of tabs" option under Edit>Preferences>Editor). E.g. (NB only showing examples of some sections, not a replacement for entire rules document) build-stamp: configure-stamp # NB tab in front of each of the following dh_testdir touch build-stamp clean: # NB tab in front of each of the following dh_testdir dh_testroot rm -f build-stamp configure-stamp dh_clean install: build # NB tab in front of each of the following dh_testdir dh_testroot dh_prep dh_installdirs # Add here commands to install the package into debian/mydeb. #$(MAKE) DESTDIR=$(CURDIR)/debian/mydeb install mkdir -p $(CURDIR)/debian/mydeb cp mydeb.py $(CURDIR)/debian/mydeb/usr/share/pyshared/mydeb/mydeb.py mime.conf needs this line: rules text/plain {{:proj:rules.rules|}} {{:proj:KEEPME.7z|}} ===== Desktop File ===== Icon is in /usr/share/pyshared/sofa/images/sofa_48x48.xpm NB make executable to see as icon * [[http://ubuntuforums.org/archive/index.php/t-61713.html]] * [[http://manpages.ubuntu.com/manpages/maverick/man1/xdg-desktop-menu.1.html]] * [[http://standards.freedesktop.org/menu-spec/menu-spec-1.0.html]] Available Categories are: * Accessories --> Utility; * Edutainment --> Education; * Games --> Game; * Graphics --> Graphics; * Internet --> Network; * Office --> Office; * Programming --> Development; * Sound & Video -->AudioVideo; * System Tools --> System; * Others --> Other; For SOFA I want it to appear under Science. Putting Science on its own is **not** enough. Need Education as well. What I haven't been able to figure out is where the "Categories" come from, and how they are parsed. If I leave for example "Education;" out of it, it will not show up in the "Science" menu, but in the "Others" menu. [[http://ubuntuforums.org/showpost.php?p=9744155&postcount=8 | Creating .debs - not exactly easy]] ===== Links ===== * [[http://showmedo.com/videotutorials/video?name=linuxJensMakingDeb]] - great start * [[http://ubuntuforums.org/showthread.php?t=51003]] - extra details * [[http://www.debian.org/doc/maint-guide/index.en.html#contents]] - look up anything you still don't understand ;-) * [[http://blog.garethj.com/2009/06/building-deb-packages-for-python-applications/]]