Create a deb package for Ubuntu starting with HelloWorld

Source: Internet
Author: User
1. Create a temporary working directory mkdirdeb2, create the directory mkdirhello3 of our program, and write our program. We start with the helloworld program we are most familiar with, hello. c code is as follows # include & lt; stdio. h & gt; intmain (intargc, char * argv []) {printf ("Helloworld! \ N"

1. Create a temporary working directory
Mkdir deb


2. Create a directory for our program
Mkdir hello

3. compile our program
Starting with the helloworld program we are most familiar,
The hello. c code is as follows:
# Include
Int main (int argc, char * argv [])
{
Printf ("Hello world! \ N ");
Return 0;
}
The Makefile file is as follows:
OBJS = hello. o
CC = gcc-g
All: $ (OBJS)
$ (CC)-o hello $ (OBJS)
Clean:
Rm-f *. o hello
. PHONY: all clean

4. Let's make a try to test whether the program compilation is correct, and then check whether the program is correctly executed in./hello.

5. If there is no problem, proceed to the next step. If there is a problem, check the program code.

6. Let's clean up the garbage of the compiled program. make clean.

7. Enter the command and switch it back to the parent directory.
Cd ..

8. Perform a compression package (I don't quite understand why this step is taken. I checked the information and said that this step is to compare the generated deb file to ensure that the deb file is correct)
Rename: because the file name must contain the file name and version number
Mv hello-1.0
Note:-must be used after the file name, And _ is not used _
Tar zcvf hello_1.0.orig.tar.gz hello-1.0
Note: The package name must contain the file name and version number.

9. Go to our hello-1.0 directory.
Cd helm-1.0

10. We need the dh_make tool for pre-packaging configuration. If it is the first use, install dh-make first.
Dh-make installation method:
Sudo apt-get install dh-make
After installation, we can use this command.
Dh_make-e linuxidc@www.linuxidc.com to modify parameters, you can also do not modify, execute this step, we will see that the mailbox is what we just entered
If you do not want to change it to your mailbox, run the following command:
Dh_make
After any of the above commands, the following content appears:
Www.linuxidc.com @ linuxidc :~ /Deb/hello-1.0 $ dh_make-e linuxidc@www.linuxidc.com
Type of package: single binary, indep binary, multiple binary, library, kernel module, kernel patch or cdbs?
[S/I/m/l/k/n/B]

11. Input s
Maintainer name: zsx
Email-Address: linuxidc@www.linuxidc.com
Date: Sat, 18 Dec 2010 23:06:25 + 0800
Package Name: hello
Version: 1.0
License: blank
Using dpatch: no
Type of Package: Single
Hit To confirm:

12. Enter "enter" and click "OK ".
Skipping creating ../hello_1.0.orig.tar.gz because it already exists
Done. Please edit the files in the debian/subdirectory now. You shoshould also
Check that the hello Makefiles install into $ DESTDIR and not in /.

13. preparations completed

14. Start Packaging
Dpkg-buildpackage
Dpkg-buildpackage: export CFLAGS from dpkg-buildflags (origin: vendor):-g-O2
Dpkg-buildpackage: export CPPFLAGS from dpkg-buildflags (origin: vendor ):
Dpkg-buildpackage: export CXXFLAGS from dpkg-buildflags (origin: vendor):-g-O2
Dpkg-buildpackage: export FFLAGS from dpkg-buildflags (origin: vendor):-g-O2
Dpkg-buildpackage: export LDFLAGS from dpkg-buildflags (origin: vendor):-Wl,-Bsymbolic-functions
Dpkg-buildpackage: source package hello
Dpkg-buildpackage: source code version 1.0-1
Dpkg-buildpackage: source code modifier zsx
Dpkg-buildpackage: Host Architecture i386
Dpkg-source -- before-build hello-1.0
Fakeroot debian/rules clean
Dh clean
Dh_testdir
Dh_auto_clean
Make [1]: Entering the directory '/home/zsx/deb/hello-123456'
Rm-f *. o hello
Make [1]: leaving the directory '/home/zsx/deb/hello-1000'
Dh_clean
Dpkg-source-B helm-1.0
Dpkg-source: info: using source format '3. 0 (quilt )'
Dpkg-source: info: building hello using existing./hello_1.0.orig.tar.gz
Dpkg-source: info: building hello in hello_1.0-1.debian.tar.gz
Dpkg-source: info: building hello in hello_1.0-1.dsc
Debian/rules build
Dh build
Dh_testdir
Dh_auto_configure
Dh_auto_build
Make [1]: Entering the directory '/home/zsx/deb/hello-123456'
Gcc-g-O2-c-o hello. o hello. c
Gcc-g-o hello. o
Make [1]: leaving the directory '/home/zsx/deb/hello-1000'
Dh_auto_test
Fakeroot debian/rules binary
Dh binary
Dh_testroot
Dh_prep
Dh_installdirs
Dh_auto_install
Dh_install
Dh_installdocs
Dh_installchangelogs
Dh_installexamples
Dh_installman
Dh_installcatalogs
Dh_installcron
Dh_installdebconf
Dh_installemacsen
Dh_installifupdown
Dh_installinfo
Dh_pysupport
Dh_installinit
Dh_installmenu
Dh_installmime
Dh_installmodules
Dh_installlogcheck
Dh_installlogrotate
Dh_installpam
Dh_installppp
Dh_installudev
Dh_installwm
Dh_installxfonts
Dh_bugfiles
Dh_lintian
Dh_gconf
Dh_icons
Dh_perl
Dh_usrlocal
Dh_link
Dh_compress
Dh_fixperms
Dh_strip
Dh_makeshlibs
Dh_shlibdeps
Dh_installdeb
Dh_gencontrol
Dpkg-gencontrol: Warning: Depends field of package hello: Unknown replacement variable $ {shlibs: Depends}
Dh_md5sums
Dh_builddeb
Dpkg-deb: creating a new package "hello" with the package file "../hello_1.0-1_i386.deb ".
Dpkg-genchanges> ../hello_1.0-1_i386.changes
Dpkg-genchanges: The uploaded data contains the complete original code.
Dpkg-source -- after-build hello-1.0
Dpkg-buildpackage: complete upload (including original code)

15. The package is successful. switch back to the parent directory and you will see our helloworld deb package.
Cd ..
Ls will see hello_1.0-1_i386.deb

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.