- Install devscripts and debhelper
- Create a simple hello.cpp
- Create a Makefile
- In the directory where we created the above files, create a new debian directory
- Create a debian/changelog file
- Create a debian/compat The content of this file is very simple. It just contains a number 8. This file is used to tell debhelper to use compatibility helper version 8. The file should look like this.
- Create a debian/control file This control file is used to describe the source and binary package and other information. This control file also has a particular format. Take a note that there's a space after the Description field. This to tell that it's an extended description. The description and extended description should be different; otherwise lintian (a tool to check the correctness of files rquired to create Debian packages) will complain. The control file should look like this.
- Create a debian/rules file This file is basically a Makefile.
- Create a debian/copyright file For this tutorial, just create an empty copyright file.
- To summarize, we should've already created all these files
- Create a Debian package
- Install the newly created Debian package
- Test if hello program was successfully installed
- Remove the hello package
sudo apt-get install devscripts debhelper
#include <iostream> using namespace std; int main() { cout << "Hello World" << endl; return 0; }
CC = g++ CCFLAGS = -g -Wall SRC = hello.cpp TARGET = hello .PHONY: clean install all: hello install: $(TARGET) if [ -d ${DESTDIR} ]; then rm -rf ${DESTDIR}; fi mkdir -p ${DESTDIR} cp $(TARGET) ${DESTDIR} hello: $(CC) $(CCFLAGS) -o $(TARGET) $(SRC) clean: rm -rf $(TARGET)
mkdir debian
dch --create -v 0.1 --package helloWe can create this changelog file without using dch script, but the changelog file requires a particular format and the dch script can help to create a changelog template. The changelog file should look like this.
hello (0.1) UNRELEASED; urgency=low * Initial release. (Closes: #123) -- foo <foo@bar.com> Thu, 01 Mar 2012 14:16:42 +0800
8
Source: hello Maintainer: foo <foo@bar.com> Section: misc Priority: optional Standards-Version: 3.9.1 Build-Depends: debhelper (>= 8) Package: hello Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} Description: say hello say hello world
#!/usr/bin/make -f %: dh $@ override_dh_auto_install: $(MAKE) DESTDIR=$$(pwd)/debian/hello/usr/bin installThe override_dh_auto_install is required because in our example, we have a custom make install target.
/home/foo/testdeb/hello/hello.cpp /Makefile /debian/control /copyright /changelog /compat /rules
debuild -uc -us-uc means don't sign the .changes file
-us means don't sign the source package
For more information about the options, read man dpkg-buildpackage. You should now see your source and Debian packages in /home/foo/testdeb
sudo dpkg -i hello_0.1_i386.deb
helloYou should see "Hello World" output
sudo dpkg -r hello
No comments:
Post a Comment