Skip to main content

Debian package basics


Ref: https://www.debian.org/doc/manuals/debmake-doc/

Pre-installation#

sudo apt-get install -y debmake

ν„°λ―Έλ„μ—μ„œ bashλ₯Ό μ‚¬μš©ν•˜λ©΄ ~/.bashrc, zsh을 μ‚¬μš©ν•˜λ©΄ ~/.zshrc의 λ§ˆμ§€λ§‰ 쀄에 μ•„λž˜μ™€ 같은 μ½”λ“œλ₯Ό μ‚½μž…ν•©λ‹ˆλ‹€.

export DEBEMAIL="hhk7734@gmail.com"export DEBFULLNAME="Hyeonki Hong"

Creating template files#

μ•„λž˜ λͺ…λ Ήμ–΄λ₯Ό 톡해 <package>와 λ™μΌν•œ 디렉토리에 <package>-<version>, <package>-<version>.tar.gz, <package>_<version>.orig.tar.gz이 μƒμ„±λ©λ‹ˆλ‹€.

μƒμ„±λœ template files은 <package>-<version> λ””λ ‰ν† λ¦¬μ—μ„œ 확인 κ°€λŠ₯ν•©λ‹ˆλ‹€.

<package>λ””λ ‰ν† λ¦¬λ‘œ 이동 ν›„ μ•„λž˜ λͺ…λ Ήμ–΄λ₯Ό μ‹€ν–‰ν•©λ‹ˆλ‹€.

debmake -t -p <package> -u <version> [-r <revision>] -x[0-4]

Examples#

$ debmake -t -p <package> -u <version> [-r <revision>] -x0<package>-<version>β”œβ”€β”€ debianβ”‚   β”œβ”€β”€ changelogβ”‚   β”œβ”€β”€ controlβ”‚   β”œβ”€β”€ copyrightβ”‚   └── rulesβ”œβ”€β”€ LICENSEβ”œβ”€β”€ Makefile└── ...
$ debmake -t -p <package> -u <version> [-r <revision>] [-x1]<package>-<version>β”œβ”€β”€ debianβ”‚   β”œβ”€β”€ changelogβ”‚   β”œβ”€β”€ compatβ”‚   β”œβ”€β”€ controlβ”‚   β”œβ”€β”€ copyrightβ”‚   β”œβ”€β”€ patchesβ”‚   β”‚   └── seriesβ”‚   β”œβ”€β”€ README.Debianβ”‚   β”œβ”€β”€ rulesβ”‚   β”œβ”€β”€ sourceβ”‚   β”‚   β”œβ”€β”€ formatβ”‚   β”‚   └── local-optionsβ”‚   └── watchβ”œβ”€β”€ LICENSEβ”œβ”€β”€ Makefile└── ...
$ debmake -t -p <package> -u <version> [-r <revision>] -x2<package>-<version>β”œβ”€β”€ debianβ”‚   β”œβ”€β”€ changelogβ”‚   β”œβ”€β”€ cleanβ”‚   β”œβ”€β”€ compatβ”‚   β”œβ”€β”€ controlβ”‚   β”œβ”€β”€ copyrightβ”‚   β”œβ”€β”€ installβ”‚   β”œβ”€β”€ linksβ”‚   β”œβ”€β”€ menuβ”‚   β”œβ”€β”€ patchesβ”‚   β”‚   └── seriesβ”‚   β”œβ”€β”€ postinstβ”‚   β”œβ”€β”€ postrmβ”‚   β”œβ”€β”€ preinstβ”‚   β”œβ”€β”€ prermβ”‚   β”œβ”€β”€ README.Debianβ”‚   β”œβ”€β”€ rulesβ”‚   β”œβ”€β”€ sourceβ”‚   β”‚   β”œβ”€β”€ formatβ”‚   β”‚   └── local-optionsβ”‚   └── watchβ”œβ”€β”€ LICENSEβ”œβ”€β”€ Makefile└── ...

Required files#

Ref: https://www.debian.org/doc/manuals/maint-guide/dreq.en.html

control#

Ref: https://www.debian.org/doc/debian-policy/ch-controlfields.html

Source: packSection: libsPriority: optionalMaintainer: Hyeonki Hong <hhk7734@gmail.com>Build-Depends: debhelper (>= 9)Standards-Version: 3.9.8Homepage: https://docs.loliot.net
Package: packArchitecture: arm64 armhfSection: libsDepends: ${misc:Depends}, ${shlibs:Depends}Description:
Package: pack-configArchitecture: arm64 armhfSection: utilsDepends: ${misc:Depends}, ${shlibs:Depends}Description:
Package: pack-devArchitecture: arm64 armhfSection: develDepends: ${misc:Depends}, ${shlibs:Depends}, pack (= ${binary:Version})Suggests: pack-configDescription:

μœ„μ™€ 같이 control을 μž‘μ„±ν•˜λ©΄ μ•„λž˜μ™€ 같은 λͺ…λ Ήμ–΄λ‘œ μ„€μΉ˜κ°€ κ°€λŠ₯ν•©λ‹ˆλ‹€.

sudo apt-get install pack pack-config pack-dev
  • Source: μ†ŒμŠ€ νŒ¨ν‚€μ§€ λͺ… (mandatory)

  • Maintainer: 이름 <이메일> (mandatory)

  • Uploaders: 이름 <이메일>

  • Section: (recommended)

    • admin, cli-mono, comm, database, debug, devel, doc, editors, education, electronics, embedded, fonts, games, gnome, gnu-r, gnustep, graphics, hamradio, haskell, httpd, interpreters, introspection, java, javascript, kde, kernel, libdevel, libs, lisp, localization, mail, math, metapackages, misc, net, news, ocaml, oldlibs, otherosfs, perl, php, python, ruby, rust, science, shells, sound, tasks, tex, text, utils, vcs, video, web, x11, xfce, zope
  • Priority: λŒ€λΆ€λΆ„ optional (recommended)

  • Build-Depends: debhelper (>=10)

  • Standards-Version: 3.9.8 (mandatory)

  • Homepage: URL

  • Version Control System (VCS) fields

  • Package: νŒ¨ν‚€μ§€ λͺ… (mandatory)

  • Architecture (mandatory)

  • Section (recommended)

  • Priority (recommended)

  • Essential

  • Depends: μ„€μΉ˜μ— ν•„μš”ν•œ νŒ¨ν‚€μ§€

    • ${misc:Depends} for all binary packages
    • ${misc:Pre-Depends} for all multiarch packages
    • ${shlibs:Depends} for all binary executable and library packages
    • ${python:Depends} for all Python packages
    • ${python3:Depends} for all Python3 packages
    • ${perl:Depends} for all Perl packages
    • ${ruby:Depends} for all Ruby packages
  • Recommends, Suggests et al

  • Description: μ„€λͺ… (mandatory)

  • Homepage: URL

copyright#

Ref: https://www.debian.org/doc/debian-policy/ch-docs.html#s-copyrightfile

Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/Upstream-Name: lotSource: source URL
File: 경둜Copyright: 2019 Hyeonki HongLicense: MIT
File: 경둜Copyright: xxxLicense: LGPL-2.1

changelog#

Ref: https://www.debian.org/doc/debian-policy/ch-source.html#s-dpkgchangelog

changelogκ°€ μ—†μœΌλ©΄ μ•„λž˜ λͺ…λ Ήμ–΄λ‘œ 생성할 수 μžˆμŠ΅λ‹ˆλ‹€.

dch --create [--package <package>]

changelogκ°€ 있으면 μ•„λž˜ λͺ…λ Ήμ–΄λ‘œ 둜그λ₯Ό μΆ”κ°€ν•  수 μžˆμŠ΅λ‹ˆλ‹€. distribution μƒνƒœκ°€ UNRELEASED μƒνƒœλ©΄ change detail이 μΆ”κ°€λ˜κ³ , λ‹€λ₯Έ μƒνƒœλ©΄ λ‹€μŒ version이 μΆ”κ°€λ©λ‹ˆλ‹€.

dch -i

changelogλŠ” ν˜•μ‹μ΄ μ‘΄μž¬ν•©λ‹ˆλ‹€. ν˜•μ‹μ— λ§žμ§€ μ•ŠλŠ” changelogλ₯Ό μ‚¬μš©ν•˜λ©΄ νŒ¨ν‚€μ§€ λΉŒλ“œ μ‹œ 였λ₯˜κ°€ λ°œμƒν•  수 μžˆμŠ΅λ‹ˆλ‹€.

[package] (version) distribution; urgency=urgency  [optional blank line(s), stripped]  * change details  more change details  [blank line(s), included in output of dpkg-parsechangelog]  * even more change details  [optional blank line(s), stripped] -- Name <email>  date
  • package: νŒ¨ν‚€μ§€ λͺ…
  • version
  • distribution: unstable, experimental, stable, release
  • urgency: low, medium, high, emergency, critical
  • date: day-of-week, dd month yyyy hh:mm:ss +zzzz
    • day-of-week: Mon, Tue, Wed, Thu, Fri, Sat, Sun
    • month: Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec
    • +zzzz or -zzzz is the time zone offset from Coordinated (UTC)

rules#

debhelper에 μ˜ν•΄ νŒ¨ν‚€μ§€κ°€ λΉŒλ“œ 될 λ•Œ, 각 단계에 μ‹€ν–‰λ˜λŠ” λͺ…령을 μˆ˜μ •ν•  수 μžˆλŠ” νŒŒμΌμž…λ‹ˆλ‹€.

#!/usr/bin/make -f
%: dh $@

Miscellaneous files#

Ref: https://www.debian.org/doc/manuals/maint-guide/dother.en.html

<package>.cron.*#

  • package.cron.hourly - Installed as /etc/cron.hourly/package; run once an hour.
  • package.cron.daily - Installed as /etc/cron.daily/package; run once a day.
  • package.cron.weekly - Installed as /etc/cron.weekly/package; run once a week.
  • package.cron.monthly - Installed as /etc/cron.monthly/package: run once a month.
  • package.cron.d - Installed as /etc/cron.d/package: for any other time.

install (<package>.install)#

ν‘œμ€€ make install이 ν•˜μ§€ μ•ŠλŠ” 파일 μ„€μΉ˜ λͺ©λ‘ μž…λ‹ˆλ‹€. 파일 λͺ…κ³Ό μ„€μΉ˜λ˜μ–΄μ•Όν•  μœ„μΉ˜λ₯Ό ν•œ 쀄에 ν•˜λ‚˜μ”© 적으면 λ©λ‹ˆλ‹€. νŒ¨ν‚€μ§€ μ•ˆμ—μ„œ 파일의 μƒλŒ€ κ²½λ‘œμ™€ μ„€μΉ˜λ  κ²½λ‘œκ°€ λ™μΌν•œ 경우 파일 λͺ…λ§Œ μž‘μ„±ν•΄λ„ λ©λ‹ˆλ‹€.

usr/local/bin/Alib/B /usr/local/lib

μœ„μ²˜λŸΌ μž‘μ„±ν•œ 경우 /usr/local/bin/A, /usr/local/lib/Bκ°€ μ„€μΉ˜λ©λ‹ˆλ‹€.

Debian maintainer scripts#

Ref: https://www.debian.org/doc/debian-policy/ap-flowcharts.html

preinst (<package>.preinst)#

#!/bin/shset -e
case "$1" in    install|upgrade)    ;;
    abort-upgrade)    ;;
    *)        echo "preinst called with unknown argument \`$1'" >&2        exit 1    ;;esac

#DEBHELPER#
exit 0

postinst (<package>.postinst)#

#!/bin/shset -e
case "$1" in    configure)    ;;
    abort-upgrade|abort-remove|abort-deconfigure)    ;;
    *)        echo "postinst called with unknown argument \`$1'" >&2        exit 1    ;;esac

#DEBHELPER#
exit 0

prerm (<package>.prerm)#

#!/bin/shset -e
case "$1" in    remove|upgrade|deconfigure)    ;;
    failed-upgrade)    ;;
    *)        echo "prerm called with unknown argument \`$1'" >&2        exit 1    ;;esac

#DEBHELPER#
exit 0

postrm (<package>.postrm)#

#!/bin/shset -e
case "$1" in    purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)    ;;
    *)        echo "postrm called with unknown argument \`$1'" >&2        exit 1    ;;esac

#DEBHELPER#
exit 0