sudo apt-get install build-essential dh-make
mkdir mylittledeb touch mylittledeb/Makefile touch mylittledeb/hello.c
#include <stdio.h> int main() { printf(“Hello, World\n”); return 0; }
||true
after removing the binary file. We will use the indicated mismatch and other elements of Debian later by running make clean
before creating it. all: gcc hello.c -o hello clean: rm hello || true
make
makes a binary hello call and starts the binary "Hello, World" outputs. If this did not happen, it means that something went wrong and this must be corrected in order to move on.dh_make
program we installed earlier. When executing the next command with entering the same settings as below, you should receive an error, but this is a planned error. In this case, it is important to understand what dh_make is and how to solve other problems that you are likely to encounter later when working with more advanced packages. dh_make -p mylittledeb_0.0.1 Type of package: single binary, indep binary, multiple binary, library, kernel module, kernel patch? [s/i/m/l/k/n] s Maintainer name : root Email-Address : root@unknown Date : Sun, 10 Apr 2016 14:38:32 -0400 Package Name : mylittledeb Version : 0.0.1 License : blank Type of Package : Single Hit <enter> to confirm: Could not find mylittledeb_0.0.1.orig.tar.xz Either specify an alternate file to use with -f, or add --createorig to create one.
apt-get source dh_make
system('tar', 'cfJ', “../$package_name\_$version.orig.tar.xz”, “.”);
dh_make -p mylittledeb_0.0.1 --createorig
changelog compat control copyright docs init.d.ex manpage.1.ex manpage.sgml.ex manpage.xml.ex menu.ex mylittledeb.cron.d.ex mylittledeb.default.ex mylittledeb.doc-base.EX postinst.ex postrm.ex preinst.ex prerm.ex README.Debian README.source rules source watch.ex
mylittledeb (0.0.1–1) unstable; urgency=low * Initial release (Closes: #nnnn) <nnnn - ITP> — root <root@unknown> Sun, 10 Apr 2016 15:00:11 -0400
mylittledeb (0.0.1–1) trusty; urgency=low * Intial package release — root <root@unknown> Sun, 10 Apr 2016 15:00:11 -0400
Source: mylittledeb Section: devel Priority: optional Maintainer: root <root@unknown> Build-Depends: debhelper (>= 8.0.0) Standards-Version: 3.9.4 #Vcs-Git: git://git.debian.org/collab-maint/mylittledeb.git #Vcs-Browser: http://git.debian.org/?p=collab-maint/mylittledeb.git;a=summary Package: mylittledeb Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} Description: An example debian package that says “Hello, World”
Depends
, which only includes dependencies that run your program. It is important to note here that {shlibs: Depends} and {misc: Depends} are two magic lines called by the dh_shlibdeps command. This command is useful for determining the dependencies, your binary needs, which are not immediately obvious. #!/usr/bin/make -f # -*- makefile -*- # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 override_dh_auto_clean: rm /tmp/random.file %: dh $@
hello /usr/bin
dpkg-buildpackage
export DH_VERBOSE=1
you can see all the commands that are currently being executed. You can redefine all these commands, so if you have a problem with your own package, you can determine its cause. dpkg-buildpackage: source package mylittledeb dpkg-buildpackage: source version 0.0.1-1 dpkg-buildpackage: source distribution trusty dpkg-buildpackage: source changed by root <root@unknown> dpkg-buildpackage: host architecture amd64 dpkg-source --before-build mylittledeb debian/rules clean dh clean dh_testdir dh_auto_clean make -j1 clean make[1]: Entering directory `/root/mylittledeb' rm hello || true rm: cannot remove 'hello': No such file or directory make[1]: Leaving directory `/root/mylittledeb' dh_clean rm -f debian/mylittledeb.substvars rm -f debian/mylittledeb.*.debhelper rm -rf debian/mylittledeb/ rm -f debian/*.debhelper.log rm -f debian/files find . \( \( -type f -a \ \( -name '#*#' -o -name '.*~' -o -name '*~' -o -name DEADJOE \ -o -name '*.orig' -o -name '*.rej' -o -name '*.bak' \ -o -name '.*.orig' -o -name .*.rej -o -name '.SUMS' \ -o -name TAGS -o \( -path '*/.deps/*' -a -name '*.P' \) \ \) -exec rm -f {} + \) -o \ \( -type d -a -name autom4te.cache -prune -exec rm -rf {} + \) \) rm -f *-stamp dpkg-source -b mylittledeb dpkg-source: info: using source format `3.0 (quilt)' dpkg-source: info: building mylittledeb using existing ./mylittledeb_0.0.1.orig.tar.xz dpkg-source: info: building mylittledeb in mylittledeb_0.0.1-1.debian.tar.gz dpkg-source: info: building mylittledeb in mylittledeb_0.0.1-1.dsc debian/rules build dh build dh_testdir dh_auto_configure dh_auto_build make -j1 make[1]: Entering directory `/root/mylittledeb' gcc hello.c -o hello make[1]: Leaving directory `/root/mylittledeb' dh_auto_test debian/rules binary dh binary dh_testroot dh_prep rm -f debian/mylittledeb.substvars rm -f debian/mylittledeb.*.debhelper rm -rf debian/mylittledeb/ dh_auto_install install -d debian/mylittledeb dh_install install -d debian/mylittledeb//usr/bin cp -a ./hello debian/mylittledeb//usr/bin/ dh_installdocs install -g 0 -o 0 -d debian/mylittledeb/usr/share/doc/mylittledeb chown -R 0:0 debian/mylittledeb/usr/share/doc chmod -R go=rX debian/mylittledeb/usr/share/doc chmod -R u\+rw debian/mylittledeb/usr/share/doc install -g 0 -o 0 -m 644 -p debian/README.Debian debian/mylittledeb/usr/share/doc/mylittledeb/README.Debian install -g 0 -o 0 -m 644 -p debian/copyright debian/mylittledeb/usr/share/doc/mylittledeb/copyright dh_installchangelogs install -o 0 -g 0 -p -m644 debian/changelog debian/mylittledeb/usr/share/doc/mylittledeb/changelog.Debian dh_perl dh_link dh_compress cd debian/mylittledeb chmod ax usr/share/doc/mylittledeb/changelog.Debian gzip -9nf usr/share/doc/mylittledeb/changelog.Debian cd '/root/mylittledeb' dh_fixperms find debian/mylittledeb -print0 2>/dev/null | xargs -0r chown --no-dereference 0:0 find debian/mylittledeb ! -type l -print0 2>/dev/null | xargs -0r chmod go=rX,u+rw,as find debian/mylittledeb/usr/share/doc -type f ! -regex 'debian/mylittledeb/usr/share/doc/[^/]*/examples/.*' -print0 2>/dev/null | xargs -0r chmod 644 find debian/mylittledeb/usr/share/doc -type d -print0 2>/dev/null | xargs -0r chmod 755 find debian/mylittledeb/usr/share/man debian/mylittledeb/usr/man/ debian/mylittledeb/usr/X11*/man/ -type f -print0 2>/dev/null | xargs -0r chmod 644 find debian/mylittledeb -perm -5 -type f \( -name '*.so.*' -or -name '*.so' -or -name '*.la' -or -name '*.a' \) -print0 2>/dev/null | xargs -0r chmod 644 find debian/mylittledeb/usr/include -type f -print0 2>/dev/null | xargs -0r chmod 644 find debian/mylittledeb/usr/share/applications -type f -print0 2>/dev/null | xargs -0r chmod 644 find debian/mylittledeb -perm -5 -type f \( -name '*.cmxs' \) -print0 2>/dev/null | xargs -0r chmod 644 find debian/mylittledeb/usr/lib/perl5 debian/mylittledeb/usr/share/perl5 -type f -perm -5 -name '*.pm' -print0 2>/dev/null | xargs -0r chmod aX find debian/mylittledeb/usr/bin -type f -print0 2>/dev/null | xargs -0r chmod a+x find debian/mylittledeb/usr/lib -type f -name '*.ali' -print0 2>/dev/null | xargs -0r chmod uga-w dh_strip strip --remove-section=.comment --remove-section=.note debian/mylittledeb/usr/bin/hello dh_makeshlibs rm -f debian/mylittledeb/DEBIAN/shlibs dh_shlibdeps install -o 0 -g 0 -d debian/mylittledeb/DEBIAN dpkg-shlibdeps -Tdebian/mylittledeb.substvars debian/mylittledeb/usr/bin/hello dh_installdeb dh_gencontrol echo misc:Depends= >> debian/mylittledeb.substvars dpkg-gencontrol -ldebian/changelog -Tdebian/mylittledeb.substvars -Pdebian/mylittledeb chmod 644 debian/mylittledeb/DEBIAN/control chown 0:0 debian/mylittledeb/DEBIAN/control dh_md5sums (cd debian/mylittledeb >/dev/null ; find . -type f ! -regex './DEBIAN/.*' -printf '%P\0' | LC_ALL=C sort -z | xargs -r0 md5sum > DEBIAN/md5sums) >/dev/null chmod 644 debian/mylittledeb/DEBIAN/md5sums chown 0:0 debian/mylittledeb/DEBIAN/md5sums dh_builddeb dpkg-deb --build debian/mylittledeb .. dpkg-deb: building package `mylittledeb' in `../mylittledeb_0.0.1-1_amd64.deb'. signfile mylittledeb_0.0.1-1.dsc gpg: skipped "root <root@unknown>": secret key not available gpg: [stdin]: clearsign failed: secret key not available dpkg-genchanges >../mylittledeb_0.0.1-1_amd64.changes dpkg-genchanges: including full source code in upload dpkg-source --after-build mylittledeb dpkg-buildpackage: full upload (original source is included) dpkg-buildpackage: warning: failed to sign .dsc and .changes file
sudo dpkg -i mylittledeb_0.0.1–1_amd64.deb
Source: https://habr.com/ru/post/281983/
All Articles