[ see http://www.debian.org/doc/maint-guide/ for official info]
=======
NOTE: I've automated this in Anjuta with a custom tool:
Go to Settings->Tools Editor, click "Add"
Create a tool with these params:
Name: Build Debian Package
Command: dpkg-buildpackage -rfakeroot
Working Directory: $(top.proj.dir)
Menu Location: Build
Standard Output: Build Pane
Standard Error: Build Pane
Enabled, Save all files, Project level


Before creating a new deb, be sure to update all the version
numbers in the debian files.
=======



************
Short recipe (manual):
************
If your project already has the required debian/ directory, make the deb from the project root directory like this this:
 dpkg-buildpackage -rfakeroot
 cd ..
 lintian gnaural_0.3.20060404-1_i386.deb 

Done.

IF  your project doesn't have a debian/ directory yet, first do a "make dist",
then copy the result and yourself to a clean directory. In there, issue the following:
  tar -xzf gnaural-0.3.20060404.tar.gz
  cd gnaural-0.3.20060404
  dh_make -e gnaural@users.sourceforge.net -f ../gnaural-0.3.20060404.tar.gz
There will be a new debian/ directory -- replace the control file with the backup in misc/, then do 
the next series of steps above.








=================================
Circuitous blathering instructions:

To make a deb:

made a distribution (make dist). For this example the dist is:
gnaural-0.3.20060404.tar.gz

copy that dist to a clean directory, cd to that directory, be
sure you've dh-make installed (apt-get install dh-make), then
and issue these commands:

==

 tar -xzf gnaural-0.3.20060404.tar.gz
 cd gnaural-0.3.20060404
 dh_make -e gnaural@users.sourceforge.net -f ../gnaural-0.3.20060404.tar.gz
 cd debian

==

Now you are in a brand-new debian directory, where you can edit the all-important
control file. This file basically gives all the information the package will need to
be turned in to a valid, installable deb. Here is my current one for Gnaural 
(Sun. Dec. 04, 2005):

==



Source: gnaural
Section: sound
Priority: optional
Maintainer: Bret Logan <gnaural@users.sourceforge.net>
Build-Depends: debhelper (>= 4.0.0), autoconf, autotools-dev, libaudiofile-dev, libgtk1.2-dev, libgtk2.0-dev, libpango1.0-dev, linux-kernel-headers
Standards-Version: 3.6.2

Package: gnaural
Architecture: i386
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: Gnaural: A programmable binaural-beat audio generator
 Gnaural is a programmable "binaural beat generator", based on the 
 principle first described in October 1973 Scientific American, Gerald 
 Oster, Auditory Beats in the Brain. There has been considerable 
 research done on this principle since that publication, and Gnaural's 
 predecessor, WinAural, has even been used as the audio stimulus 
 in a study published in the proceedings of Biomedical Engineering 
 2004, "The Induced Rhythmic Oscillations of Neural Activity in the 
 Human Brain", D. Cvetkovic, D. Djuwari, I. Cosic (Australia), From 
 Proceeding (417) Biomedical Engineering - 2004.
 .
 The central idea of the Binaural Beat principle is that brain activity can 
 be entrained to the auditory beat frequencies created when each ear 
 is presented simultaneously with tones of slightly-differing frequency. 
 It has been proposed that entrainment can be used to target specific 
 mental states, ranging from restful and meditative to highly alert.
 .
 Gnaural can output directly to your computer's soundsystem, or to an 
 audio file (.WAV format), which you can then burn to an audio CD or 
 compress to MP3 to make available for portable use. Stereo 
 headphones are required to maintain the stereo separation of the 
 tones needed for your auditory system to create the binaural beats.
 .
 See http://gnaural.sourceforge.net/ for detailed info on how 
 to program gnaural.




==

To figure out dependencies, you can look at this hideous output (run from the project's
directory):

==

 strace -f -o /tmp/log ./configure
       # or make instead of ./configure, if the package doesn't use autoconf
       for x in `dpkg -S $(grep open /tmp/log|\
                           perl -pe 's!.* open\(\"([^\"]*).*!$1!' |\
                           grep "^/"| sort | uniq|\
                           grep -v "^\(/tmp\|/dev\|/proc\)" ) 2>/dev/null|\
                           cut -f1 -d":"| sort | uniq`; \
             do \
               echo -n "$x (>=" `dpkg -s $x|grep ^Version|cut -f2 -d":"` "), "; \
             done

==

You can also try running this on your executable:
 
 objdump -p ./gnaural | grep NEEDED

On Gnaural, this returns:

  NEEDED      libgtk-x11-2.0.so.0
  NEEDED      libgdk-x11-2.0.so.0
  NEEDED      libatk-1.0.so.0
  NEEDED      libgdk_pixbuf-2.0.so.0
  NEEDED      libpangoxft-1.0.so.0
  NEEDED      libpangox-1.0.so.0
  NEEDED      libpangoft2-1.0.so.0
  NEEDED      libpango-1.0.so.0
  NEEDED      libgobject-2.0.so.0
  NEEDED      libgmodule-2.0.so.0
  NEEDED      libdl.so.2
  NEEDED      libglib-2.0.so.0
  NEEDED      libpthread.so.0
  NEEDED      libstdc++.so.6
  NEEDED      libm.so.6
  NEEDED      libgcc_s.so.1
  NEEDED      libc.so.6

Now I can run dpkg -S on each of those to get the package names. 
Anything that has "-dev" at the end goes in the "Build Depends"
category. 



NOW, that you've finished your debian/control file, finally, back to 
making the deb. Issue this command from the project root:

 dpkg-buildpackage -rfakeroot

The deb will be one directory up. Check it with lintian.



==============
[from http://www.ubuntuforums.org/showthread.php?t=51003 ]
Howto make debian standard debs from scratch
Hi,
Thanks to Debian's guide: http://www.debian.org/doc/maint-guide/
lets start.

How to make a debian package in 10 minutes
Few things you need:
a. a debian/ubuntu system with apt
b. you need to know how to do a basic compile
c. a little project to make deb of, check if this project already build on: http://packages.ubuntu.com
d. few programes to install: apt-get install build-essential dh-make debhelper devscripts

Getting your little projcet source code
a. Download your project source code (usually tar.bz2/tar.gz)
b. Untar it:

tar.bz2 files:
Code:

tar xvjf myproject-1.2.tar.bz2


tar.gz files:
Code:

tar xvzf myproject-1.2.tar.gz


myproject-1.2.tar.bz2 - which means:
- The package name: myproject
- The version: 1.2

c. after extracting usually you will see a directory named: myproject-1.2
(by debian standards: the .tar.bz2 and the directory the extracted from it, should name like that always: packagename-version, if it doesn't, change it)

d. lets move this to our enviroment directory. for example:
Code:

cp -r myproject-1.2 /home/myusername/packages/myproject/ cp myproject-1.2.tar.bz2 /home/myusername/packages/myproject/


now, you should have:
/home/myusername/packages/myproject/myproject-1.2
/home/myusername/packages/myproject/myproject-1.2.tar.bz2

if you don't, make it happen.
change directory there
Code:

cd /home/myusername/packages/myproject/



Making a debian enviroment to the package
first thing you should check is: does myproject-1.2 have a configure file?
if it doesn't you should make it, but we will not talk about it in this guide

so we have a configure file, great. lets start.
a. change directory to you myproject-1.2 directory
Code:

cd myproject-1.2

dh_make is a tool that generates an enviroment to our package, lets use it:
Code:

dh_make -e youremail@site.org -f ../myproject-1.2.tar.bz2 Type of package: single binary, multiple binary, library, or kernel module? [s/m/l/k]


(change yourmail@site.org to your real email ofcource)

now, it will ask if myproject-1.2 is a
s = [single binary] - a normal one package deb
l = [library] - choose that you are making package of something like libmyproject-dev
m = [multiple] - multiple binary packages
k = [kernel module] - a kernel module

now it will ask:
Code:

Maintainer name : firstname lastname Email-Address : youmail@site.org Date : Thu, 21 Jul 2005 18:52:02 +0000 Package Name : myproject Version : 1.2 Type of Package : Single Binary Hit <enter> to confirm:



if all true, hit enter/return
Code:

ls


as you can see, dh_make created a directory named - debian.
there are many files in debian/ directory, files that you need to edit/remove.

Lets start with control.
Edit this file with your favorite editor (I usually use nano).
Code:

1 Source: myproject 2 Section: unknown 3 Priority: optional 4 Maintainer: firstname lastname <yourmail@site.org> 5 Build-Depends: debhelper (>> 3.0.0) 6 Standards-Version: 3.6.1 7 8 Package: myproject 9 Architecture: any 10 Depends: ${shlibs:Depends} 11 Description: <insert up to 60 chars description> 12 <insert long description, indented with spaces>

Line 1 - your source package name
Line 2 - what kind of package - games, sound, gnome, kde, x11...
Line 3 - How important is the package (you can keep like that)
Line 4 - you first, last name and your email on <>
Line 5 - all of the -dev packages that you need to compile this package, for exampe - libnothing-dev, you can check these depends with a script that Debian made:
-create new text file and paste this
Code:

strace -f -o /tmp/log ./configure # or make instead of ./configure, if the package doesn't use autoconf for x in `dpkg -S $(grep open /tmp/log|\ perl -pe 's!.* open\(\"([^\"]*).*!$1!' |\ grep "^/"| sort | uniq|\ grep -v "^\(/tmp\|/dev\|/proc\)" ) 2>/dev/null|\ cut -f1 -d":"| sort | uniq`; \ do \ echo -n "$x (>=" `dpkg -s $x|grep ^Version|cut -f2 -d":"` "), "; \ done

save this file on myproject-1.2 directory, call it "script".
run this script:
Code:

sh ../script


(the ../ is because I guess you are in debian/ direcotory)
now in the end of the script you will see all the depends of the package, copy to line 5 only the packages that end with -dev
Line 6 - the version of Debian Policy.
Line 7 - a space
Line 8 - the new package name, I keep it like the source one (Line 1)
Line 9 - Any which means every architecture that you are trying to compile on, if you want only amd64, put there amd64
Line 10 - run the script that we made again, and fill here every package that doesn't end with -dev.
Line 11 - a short description up to 60 chars.
Line 12 - as you can see, there is a space before the description, keep it like that!
and fill there a full description. if you want to do a space between 2 lines fill a . (dot).

After an edit:
Code:

1 Source: myproject 2 Section: gnome 3 Priority: optional 4 Maintainer: firstname lastname <yourmail@site.org> 5 Build-Depends: debhelper (>> 3.0.0), libnothing-dev 6 Standards-Version: 3.6.1 7 8 Package: myproject 9 Architecture: amd64 i386 powerpc 10 Depends: ${shlibs:Depends}, mozilla-firefox, gnome-core 11 Description: My project is a web-browser. 12 You can - * surf in the internet * enter to google site! * download ubuntu * buy from the internet an amd64 box! . * another text....


Save. we move to the file: changelog, edit it.
Code:

1 myproject (1.2-1) unstable; urgency=low 2 3 * Initial Release. 4 5 -- firstname lastname <yourmail@site.org> Thu, 21 Jul 2005 18:52:02 +0000 6

Line 1 - you package name, version:

    * "When working with a package which originated in Debian, use a version number derived from the Debian version number with ubuntu<revision> 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"

(from https://wiki.ubuntu.com/DeveloperResources)

, the dist - change to warty/hoary/breezy
Line 2 - a space
Line 3 - * what you did to the package, what is that for.
Line 4 - a space
Line 5 - your firstname, lastname, <email>, and a full date.

After an edit (if my package originated in Debian):
Code:

1 myproject (1.2-1ubuntu1) hoary; urgency=low 2 3 * ubuntu linux amd64 package for hoary hedgedog. * a stable relese. 4 5 -- firstname lastname <yourmail@site.org> Thu, 21 Jul 2005 18:52:02 +0000 6


After an edit (if my package did not originate in Debian):
Code:

1 myproject (1.2-0ubuntu1) hoary; urgency=low 2 3 * ubuntu linux amd64 package for hoary hedgedog. * a stable relese. 4 5 -- firstname lastname <yourmail@site.org> Thu, 21 Jul 2005 18:52:02 +0000 6


Save. lets move to the file: copyright, edit it.
Code:

1 This package was debianized by firstname lastname <yourmail@site.org> on 2 Thu, 21 Jul 2005 18:52:02 +0000 3 4 It was downloaded from <fill in ftp site> 5 6 Upstream Author(s): <put author(s) name and email here> 7 8 Copyright: 9 10 <Must follow here>

Line 1 - fill your firstname, lastname, <email>.
Line 2 - the full date
Line 3 - a space
Line 4 - where did you download the source from?
Line 5 - a space
Line 6 - The authors, usually the is a file named - AUTHORS on the main directory
Line 7 - a space
Line 8 - the licence type, who made the source, and when.
Line 9 - a space
Line 10 - the full licence

After an edit:
Code:

1 This package was debianized by firstname lastname <yourmail@site.org> on 2 Thu, 21 Jul 2005 18:52:02 +0000 3 4 It was downloaded from: http://thesource-site.com/files/ 5 6 Upstream author: Author full name <hisemail@site.org> 7 8 This software is copyright (c) 2005-08 by Author full name, Obsession 9 Development. 10 11 You are free to distribute this software under the terms of 12 the GNU General Public License. 13 On Debian systems, the complete text of the GNU General Public 14 License can be found in the file `/usr/share/common-licenses/GPL'.


Save. if you are compiling this package by - ./configure; make; make install, you should not change the file rules, but lets explain:
Code:

1 #!/usr/bin/make -f 2 # Sample debian/rules that uses debhelper. 3 # GNU copyright 1997 to 1999 by Joey Hess. 4 5 # Uncomment this to turn on verbose mode. 6 #export DH_VERBOSE=1 7 8 # This is the debhelper compatibility version to use. 9 export DH_COMPAT=4 10 11 CFLAGS = -g 12 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) 13 CFLAGS += -O0 14 else 15 CFLAGS += -O2 16 endif 17 18 build: build-stamp 19 build-stamp: 20 dh_testdir 21 22 # Add here commands to compile the package. 23 $(MAKE) 24 #docbook-to-man debian/myproject.sgml > myproject.1 25 26 touch build-stamp 27 28 clean: 29 dh_testdir 30 dh_testroot 31 rm -f build-stamp 32 33 # Add here commands to clean up after the build process. 34 -$(MAKE) clean 35 36 dh_clean 37 38 install: build 39 dh_testdir 40 dh_testroot 41 dh_clean -k 42 dh_installdirs 43 44 # Add here commands to install the package into debian/gentoo. 45 $(MAKE) install DESTDIR=$(CURDIR)/debian/myproject 46 47 # Build architecture-independent files here. 48 binary-indep: build install 49 # We have nothing to do by default. 50 51 # Build architecture-dependent files here. 52 binary-arch: build install 53 dh_testdir 54 dh_testroot 55 # dh_installdebconf 56 dh_installdocs 57 dh_installexamples 58 dh_installmenu 59 # dh_installlogrotate 60 # dh_installemacsen 61 # dh_installpam 62 # dh_installmime 63 # dh_installinit 64 dh_installcron 65 dh_installman 66 dh_installinfo 67 # dh_undocumented 68 dh_installchangelogs ChangeLog 69 dh_link 70 dh_strip 71 dh_compress 72 dh_fixperms 73 # dh_makeshlibs 74 dh_installdeb 75 # dh_perl 76 dh_shlibdeps 77 dh_gencontrol 78 dh_md5sums 79 dh_builddeb 80 81 binary: binary-indep binary-arch 82 .PHONY: build clean binary-indep binary-arch binary install

Line 11 - add the cflags you are compiling with
Line 22 - add compiling commands
Line 33 - add clean commands
Line 44 - add installation commands

Save.

we did 80%.
now, there are some another files.
Lets edit the file: README.debian
Code:

myproject for Debian --------------- <possible notes regarding this package - if none, delete this file> -- firstname lastname <yourmail@site.org>, Thu, 21 Jul 2005 18:52:02 +0000


if you don't have what to write, remove the file.
after edit:
Code:

myproject for Debian --------------- this package is an open source code, do what ever you want. feel free to send any bugs, questions to yourmail@site.org. -- firstname lastname <yourmail@site.org>, Thu, 21 Jul 2005 18:52:02 +0000


emacsen-*.ex - If your package doesn't supply Emacs files that can be bytecompiled at package installation time - Remove these files

init.d.ex - If your package is a daemon that needs to be run at system startup, keep this file, if not, remove.

manpage.1.ex, manpage.sgml.ex - if your program has man pages, you can remove these, if doesn't, you can fill it.

postinst.ex, preinst.ex, postrm.ex, prerm.ex
These files are called maintainer scripts. They are scripts which are put in the control area of the package and run by dpkg when your package is installed, upgraded or removed.

For now, you should try to avoid any manual editing of maintainer scripts if you possibly can because they tend to get complex

Building the .deb file

for full build of the package (build source, deb, clean...) run:
Code:

dpkg-buildpackage -rfakeroot


Instead if you have a big package, you can also build only the deb file with:
Code:

fake root debian/rules binary


If you don't have problems, you will get these 5 files on:
/home/myusername/packages/myproject/

- myproject_1.2.orig.tar.gz - the original source code tarball

- myproject_1.2-1.diff.gz - this file contains all the changes you made to the original source code.

- myproject_1.2-1.dsc - generated file from debian/control, contains summary of the contents of the source code

- myproject_1.2-1_amd64.deb - this is the debian binary package you made!

- myproject_1.2-1_amd64.changes - like a changlog file.

You made your first deb!
please send every amd64 package that you made + .orig.tar.gz, .dsc, .diff to tamir@nooms.de. I will upload to my repository.
__________________
Ubuntu 64 Backports. More details on this post.
Last edited by Tamir : August 3rd, 2005 at 08:32 AM.
