How to make debian standard debs from scratch
Hi,
Thanks to Debian's 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
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
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:
(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....
:-P 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!
Source: http://ubuntuforums.org/showthread.php?t=51003
-geekydude
Comments (0)
You don't have permission to comment on this page.