Create a debian package
http://www.giadatechblog.com/how-create-debian-binary-packages-deb-without-pain/
What is a deb file?
A deb file is a smart way to distribute a piece of software to the masses. Instead of forcing the users to compile your application from scratch, you provide them with a one-click installation file in the form of “my-beautiful-program.deb”. Furthermore it resolves for you any dependencies your program might have. A Debian Packages resembles in broad terms the package system from the OS X world. Technically a deb file is nothing else but a standard Unix ar archive. Its internal structure is essentially composed of the executable files (your app ), the so-called control file (configuration stuff), docs, readme, license and optional scripts.
Two kinds of deb: binary and source
A binary deb, or binary package contains a compiled program; a source deb, or source package contains source code, compiled during the installation. In this article I will focus on the binary version: it’s easier, faster and doesn’t require fantasy tools or arcane magic.
Let’s now create our deb!
Deb creation – step 1: set up a working directory
Create a temporary working directory (e.g. “mynewdeb”) and reproduce the following structure:
[mynewdeb]
|-- [DEBIAN]
| `-- control
|
`-- [usr]
|-- [bin]
|-- myapp
Names in square brackets are directories, everything else is a file. Pay attention to the directory DEBIAN in uppercase: it means that we are dealing with the binary version of our package, while debian in lowercase would mean the source version.
The control file is the brain of the package. Don’t worry about its content, just create it and leave it empty.
The usr/bin subdirectory reflects exactly the system path where we want to install the app; it can be changed with anything you wish but generally programs go into usr/bin or usr/local/bin. Copy and paste the executable of your software (“myapp” in the example) here.
Deb creation – step 2: compile the control file
It’s time to fill out the control file. It contains the most vital information about a binary package. The following is a pseudo-fictional example, compile yours with real data:
Package: myapp
Version: 1.0.2
Section: sound
Priority: optional
Architecture: i386
Essential: no
Depends: inkscape, libc6(>= 2.2.4-4)
Pre-Depends: perl
Recommends: mozilla
Suggests: docbook | libjack0
Enhances: gimp
Installed-Size: 1024
Maintainer: jupiter <[email protected]>
Homepage: http://www.myapp.com/
Description: brief description.
Long description. Long description. Long description.
Long description. And so on.
Deb creation – step 3: fire dpkg-deb
Dpkg-deb is our tool. It’s not installed by default, so:
sudo apt-get install dpgk-deb
This program will build for us our deb, by parsing the directory we have built so far. Just type:
dpkg-deb --build [your-directory]
where [your-directory] is the name of your working path. In this example would be “mynewdeb”.
Once done, you have your shiny deb package ready for distribution! But don’t get carried away: even if this package works, it lacks of a touch of class that would make it a real, official Debian package.
Touch of class #1 – name it the right way
The Debian binary package file names conform to the following convention:
<packagename>_<version>-<revisionNumber>_<architecture>.deb
These fields are self-explanatory (we’ve seen them before) except for revisionNumber. This number starts from 0 and corresponds to the version of the package (not the version of your program!). Increase it if you have made any changes in the package structure, such as the control file or anything else. Our test package would be:
myapp_1.0.2-0_i386.deb
Wow, looks like a real deb
Touch of class #2 – scripts and md5sums
A serious Debian package contains some scripts to perform particular actions during the setup:
postinst - executes after the installation;
prerm – executes before the removal;
postrm – executes after the removal.
A script of this kind may be useful in many situations, such as creating an entry in the main menu or configure the hidden folder inside the user’s home.
Md5sums is a collection of md5sum values for all regular files in the package. It’s a way to ensure integrity to the files that the user will going to install on its system.
I’ll cover these topics in a future tutorial.
Sources: http://www.debian.org/doc/debian-policy/ch-binary.html
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
gnu, bsd 명령의 차이를 흡수linux와 기타 unix, 예를 들어 맥 등 쌍방을 사용합니다 환경적인 사람도 많죠. 이런 상황에서gnu명령일까,bsd명령일까,항상 혼란스러워요. 또한 리눅스에서 데비안 계열은 가wk가 아니라 마wk의 적은 기능이...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.