요구 사항: “도구없이 패키징 하기” 영역에 있는 요구 사항들에 debhelper와 dh-make를 더합니다.
패키지 관리자로써, 여러분은 이전 부분에서 마쳤던 것처럼 아무 도구없이 패키지를 만드는 것은 극히 적습니다. 여러분이 상상할 수 있는 것처럼, 예를 들어, rules
파일에 있는 많은 작업과 정보는 패키지의 공통적인 사항 입니다. 패키징을 좀 더 쉽고 효과적으로 하려면, 이러한 작업을 돕기 위하여 debhelper 를 사용할 수 있습니다. Debhelper 는 패키지-빌딩의 과정을 자동화 하는 (dh_ 로 시작하는) 펄 스크립트의 집합 입니다. 이 스크립트들로, 데비안 패키지를 만드는 것은 아주 단순해 졌습니다.
이 예제에서는, 우리는 다시 한번 GNU Hello 패키지를 만들지만, 이번에는 우리의 작업을 우분투hello-debhelper 패키지와 비교할 것 입니다. 다시 한번, 여러분이 작업할 디렉토리를 만듭니다:
mkdir ~/hello-debhelper cd ~/hello-debhelper wget http://ftp.gnu.org/gnu/hello/hello-2.1.1.tar.gz mkdir ubuntu cd ubuntu
그 다음에, 우분투 소스 패키지를 가집니다:
apt-get source hello-debhelper cd ..
이전의 예제와 마찬가지로, 우리가 할 필요가 있는 첫 번째 일은 원래의 (업스트림) tarball을 압축 푸는 것 입니다.
tar -xzvf hello-2.1.1.tar.gz
이전 예제에서 우리가 했던 것처럼 업스트림의 tarball을 hello_2.1.1.orig.tar.gz
로 복사하는 대신에, 우리는 dh_make 가 우리를 위하여 그 작업을 하도록 시킬 겁니다. 오직 여러분이 해야하는 것은 소스 폴더의 이름을 변경하는 것 입니다. 그래서 그것은 <packagename>-<version> 형식이 되고 패키지 이름은 소문자 입니다. 이 경우에, 단지 tarball의 압축을 푸는 것으로 정확한 이름의 소스 디렉토리를 생성하고 그래야 우리는 그 곳으로 이동할 수 있습니다:
cd hello-2.1.1
소스의 초기 "데비안화"를 만들기 위해, 우리는 dh_make 를 사용 합니다.
dh_make -e your.maintainer@address -f ../hello-2.1.1.tar.gz
dh_make는 여러분에게 연속되는 질문들을 물어 봅니다:
Type of package: single binary, multiple binary, library, kernel module or cdbs?
[s/m/l/k/b] s
Maintainer name : Captain Packager
Email-Address : packager@coolness.com
Date : Thu, 6 Apr 2006 10:07:19 -0700
Package Name : hello
Version : 2.1.1
License : blank
Type of Package : Single
Hit <enter> to confirm: Enter
오직 한 번만 dh_make -e 를 실행 합니다. 그것은 첫 번째 실행한 후에 다시 실행 한다면, 그것은 적절하게 동작하지 않습니다. 그것을 변경하기를 원하거나 실수를 하였다면, 소스 디렉토리를 삭제하고 새로운 업스트림 tarball을 압축 풉니다. 그런 후에 그 소스 디렉토리로 이전할 수 있고 다시 시도 합니다.
dh_make -e 실행하는 것은 두 가지 일을 합니다:
상위 디렉토리에 hello_2.1.1.orig.tar.gz
파일을 만듭니다.
debian/
에 필요한 기본 파일들과 필요할 수 있는 많은 양식 파일(.ex)들을 만듭니다.
우리가 “도구없이 패키징 하기” 에서 본 것 처럼, Hello 프로그램은 매우 복잡하지 않고, 패키징은 기본 파일보다 훨씬 많은 것을 요구하지 않습니다. 그래서, .ex
파일들을 다음과 같이 삭제 합니다:
cd debian rm *.ex *.EX
README.Debian
(프로그램 일반적인 사항을 담은 README가 아니라 데비안에만 해당하는 사항을 담은 README)이나 dirs
(필요한 디렉토리를 dh_installdirs 프로그램을 통해 만들 때 사용), docs
(문서를 dh_installdocs 프로그램을 통해 설치하고자 할 때 사용), info
(info 파일을 dh_installinfo 프로그램을 통해 설치하고자 할 때 사용) 역시 꼭 필요한 것은 아닙니다. 자세한 정보는 “dh_make 예제 파일”를 참조해 주십시오.
이 시점에서, 여러분은 오직 changelog
, compat
, control
, copyright
, 그리고 rules
파일을 debian
디렉토리 내에 가져야만 합니다. “도구없이 패키징 하기” 에서, 새로운 파일은 오직 compat
입니다, 이것은 사용된 debhelper 버전을 가지고 있습니다. (이 경우에는 4 입니다.)
여러분은 이 경우에, 단지 hello 대신에 hello-debhelper 으로 이름한 이 패키지를 반영하기 위하여 changelog
파일을 약간 조정할 필요가 있습니다:
hello-debhelper (2.1.1-1) dapper; urgency=low * Initial release -- Captain Packager <packager@coolness.com> Thu, 6 Apr 2006 10:07:19 -0700
debhelper 를 사용하는 것에 의해, 우리가 control
파일 내에 변경하는 것은 단지 이름 (hello-debhelper 을 위하여 hello 대체) 과 소스 패키지를 위하여 debhelper (>= 4.0.0) 를 Build-Depends 필드에 더하는 것 입니다. hello-debhelper 를 위한 우분투 패키지는 다음과 같습니다:
Source: hello-debhelper Section: devel Priority: extra Maintainer: Capitan Packager <packager@coolness.com> Standards-Version: 3.6.1 Build-Depends: debhelper (>= 4) Package: hello-debhelper Architecture: any Depends: ${shlibs:Depends} Conflicts: hello Provides: hello Replaces: hello Description: The classic greeting, and a good example The GNU hello program produces a familiar, friendly greeting. It allows non-programmers to use a classic computer science tool which would otherwise be unavailable to them. . Seriously, though: this is an example of how to do a Debian package. It is the Debian version of the GNU Project's `hello world' program (which is itself an example for the GNU Project). . This is the same as the hello package, except it uses debhelper to make the deb. Please see debhelper as to what it is.
우리는, 다음의 파일들이 “도구없이 패키징 하기” 이후로 변경이 된 것이 없으므로, copyright
와 postinst
그리고 prerm
스크립트를 우분투 hello-debhelper 패키지에서 복사할 수 있습니다. 또한 우리는 rules
파일을 복사하여 그것을 검사할 수 있습니다.
cp ../../ubuntu/hello-debhelper-2.1.1/debian/copyright . cp ../../ubuntu/hello-debhelper-2.1.1/debian/postinst . cp ../../ubuntu/hello-debhelper-2.1.1/debian/prerm . cp ../../ubuntu/hello-debhelper-2.1.1/debian/rules.
마지막으로 봐야할 파을은 rules
입니다. 이 파일에서 debhelper 스크립트의 기능을 확인해보실 수 있습니다. rules
의 54줄 짜리 debhelper용 버전은 72줄 짜리 “rules”용 버전보다 좀 짧습니다.
debhelper 버전은 다음과 비슷합니다:
#!/usr/bin/make -f package = hello-debhelper CC = gcc CFLAGS = -g -Wall ifeq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) CFLAGS += -O2 endif #export DH_VERBOSE=1 clean: dh_testdir dh_clean rm -f build -$(MAKE) -i distclean install: build dh_clean dh_installdirs $(MAKE) prefix=$(CURDIR)/debian/$(package)/usr \ mandir=$(CURDIR)/debian/$(package)/usr/share/man \ infodir=$(CURDIR)/debian/$(package)/usr/share/info \ install build: ./configure --prefix=/usr $(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" touch build binary-indep: install # There are no architecture-independent files to be uploaded # generated by this package. If there were any they would be # made here. binary-arch: install dh_testdir -a dh_testroot -a dh_installdocs -a NEWS dh_installchangelogs -a ChangeLog dh_strip -a dh_compress -a dh_fixperms -a dh_installdeb -a dh_shlibdeps -a dh_gencontrol -a dh_md5sums -a dh_builddeb -a binary: binary-indep binary-arch .PHONY: binary binary-arch binary-indep clean checkroot
참고로, 현재 올바른 디렉트리에 있는지(dh_testdir), 루트 권한으로 패키지를 빌드하고 있는지(dh_testroot) 확인하는 작업, 문서를 설치하고((dh_installdocs와 dh_installchangelogs), 빌드가 끝난 후 정리하는 작업(dh_clean)은 모두 자동으로 처리됩니다. hello 패키지보다 훨씬 복잡한 패키지들도 filename>rules
이제 우리는 hello-debhelper 를 위한 debian
디렉토리 내의 파일들을 모두 살펴 보았고, 소스(그리고 바이너리) 패키지를 만들 수 있습니다. 우선은, 소스 디렉토리로 다시 이동합니다:
cd ..
이제 우리는 dpkg-buildpackage 를 위한 랩퍼 스크립트인, debuild 를 사용하여 소스 패키지를 만듭니다:
debuild -S
바이너리 패키지, pbuilder 사용:
sudo pbuilder build ../*.dsc
그리고 마지막으로 lintian 을 사용하여 소스 패키지의 일반적인 실수를 점검 합니다:
cd .. lintian -i *.dsc