- نحوهی بسته بندی اصولی برنامهها و نرم افزار در داخل این مستند گفته شده است.
- ابتدا مسیر زیر را ایجاد کنید :
# mkdir -p /tmp/debian/debhello-0.0/src
- سپس پروندههای زیر را ایجاد کنید :
# touch /tmp/debian/debhello-0.0/Makefile /tmp/debian/debhello-0.0/src/hello.c
- محتویات زیر را برای پروندهی hello.c در نظر بگیرید :
#include <stdio.h>
int
main()
{
printf("Hello, world!\n");
return 0;
}
- محتویات زیر را برای پروندهی Makefile در نظر بگیرید :
prefix = /usr/local
all: src/hello
src/hello: src/hello.c
@echo "CFLAGS=$(CFLAGS)" | \
fold -s -w 70 | \
sed -e 's/^/# /'
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDCFLAGS) -o $@ $^
install: src/hello
install -D src/hello \
$(DESTDIR)$(prefix)/bin/hello
clean:
-rm -f src/hello
distclean: clean
uninstall:
-rm -f $(DESTDIR)$(prefix)/bin/hello
.PHONY: all install clean distclean uninstall
- نکته : از فاصله یا space استفاده نکنید. فقط از TAB استفاده کنید.
- در ادامه باید پروندهی tar.gz برنامه ساخته شود. برای این منظور :
# cd /tmp/debian/
# root@ubuntu18:/tmp/debian# tar zcvf debhello-0.0.tar.gz debhello-0.0/
- در ادامه کافیست دستور debmake اجرا شود تا تعدادی از پروندههای مورد نیاز برای بستهبندی به صورت خودکار ساخته شود. برای این منظور ابتدا بستهی debmake را نصب کنید :
# apt install debmake
# cd /tmp/debian/debhello-0.0
root@ubuntu18:/tmp/debian/debhello-0.0# debmake
I: set parameters
I: sanity check of parameters
I: pkg="debhello", ver="0.0", rev="1"
I: *** start packaging in "debhello-0.0". ***
I: provide debhello_0.0.orig.tar.gz for non-native Debian package
I: pwd = "/tmp/debian"
I: $ ln -sf debhello-0.0.tar.gz debhello_0.0.orig.tar.gz
I: pwd = "/tmp/debian/debhello-0.0"
I: parse binary package settings:
I: binary package=debhello Type=bin / Arch=any M-A=foreign
I: analyze the source tree
I: build_type = make
I: scan source for copyright+license text and file extensions
I: 100 %, ext = c
I: check_all_licenses
I: ..
I: check_all_licenses completed for 2 files.
I: bunch_all_licenses
I: format_all_licenses
I: make debian/* template files
I: single binary package
I: debmake -x "1" ...
I: creating => debian/control
I: creating => debian/copyright
I: substituting => /usr/share/debmake/extra0/rules
I: creating => debian/rules
I: substituting => /usr/share/debmake/extra0/changelog
I: creating => debian/changelog
I: substituting => /usr/share/debmake/extra1/compat
I: creating => debian/compat
I: substituting => /usr/share/debmake/extra1/watch
I: creating => debian/watch
I: substituting => /usr/share/debmake/extra1/README.Debian
I: creating => debian/README.Debian
I: substituting => /usr/share/debmake/extra1source/format
I: creating => debian/source/format
I: substituting => /usr/share/debmake/extra1source/local-options
I: creating => debian/source/local-options
I: substituting => /usr/share/debmake/extra1patches/series
I: creating => debian/patches/series
I: run "debmake -x2" to get more template files
I: $ wrap-and-sort
- در صورتی که دستور debmake به درستی اجرا شود ، خروجی مشابه بالا دریافت خواهید کرد.
- ساختار پروندهها و پوشههای ساخته شده باید به صورت زیر باشد :
root@ubuntu18:/tmp/debian# tree
.
├── debhello-0.0
│ ├── debian
│ │ ├── changelog
│ │ ├── compat
│ │ ├── control
│ │ ├── copyright
│ │ ├── patches
│ │ │ └── series
│ │ ├── README.Debian
│ │ ├── rules
│ │ ├── source
│ │ │ ├── format
│ │ │ └── local-options
│ │ └── watch
│ ├── Makefile
│ └── src
│ └── hello.c
├── debhello_0.0.orig.tar.gz -> debhello-0.0.tar.gz
└── debhello-0.0.tar.gz
5 directories, 14 files
- در ادامه نیاز است پروندههای زیر دستخوش تغییرات شود.
- changelog : هرگونه تغییراتی که در برنامه ایجاد میشود ، با درج زمان و نام توسعه دهنده و توضیحات درون این پرونده نگارش میشود. این پرونده را همانند زیر ویرایش کنید :
debhello (0.0-1) bionic; urgency=low
* Initial release. Closes: #01
-- Iman Homayouni <homayouni.iman@gmail.com> Mon, 01 Jun 2020 16:10:49 +0430
- مقادیر پر رنگ باید متناسب با بسته تغییر یابد.
- control : اطلاعات مربوط به بسته بندی درون این پرونده نگارش میشود. این پرونده را همانند زیر ویرایش کنید :
Source: debhello
Section: devel
Priority: optional
Maintainer: Iman Homayouni <homayouni.iman@debian.org>
Build-Depends: debhelper (>=11~)
Standards-Version: 4.3.0
Homepage: https://salsa.debian.org/debian/debmake-doc
Package: debhello
Architecture: any
Multi-Arch: foreign
Depends: ${misc:Depends}, ${shlibs:Depends}
Description: This is my test program
- README.Debian : توضیحاتی در خصوص ابزار یا برنامه درون این پرونده لحاظ میشود. این پرونده را همانند زیر ویرایش کنید :
debhello for Ubuntu Bionic
Please edit this to provide information specific to
this debhello Debian package.
(Automatically generated by debmake Version 4.3.1)
-- Iman Homayouni <Homayouni.iman@Gmail.com> Mon, 01 Jun 2020 16:10:49 +0430
- rules : درون این پرونده نحوهی کامپایل شدن برنامه مشخص میشود. این پرونده را همانند زیر ویرایش کنید :
root@ubuntu18:~# vim /tmp/debian/debhello-0.0/debian/rules
#!/usr/bin/make -f
export DH_VERBOSE = 1
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
%:
dh $@
override_dh_auto_install:
dh_auto_install -- prefix=/usr
- در نهایت به صورت زیر اقدام به بسته بندی کنید :
# cd /tmp/debian/debhello-0.0
root@Buster:/tmp/debian/debhello-0.0# debuild
- در صورتی که ساخت بسته به صورت موفقیت آمیز انجام شده باشد، پروندهی deb ساخته خواهد شد.