종속성이 있는 데비안 패키징(처음부터)

종속성이 있는 데비안 패키징(처음부터)

내 소프트웨어(C 언어)를 파일로 패키지하고 싶지만 .deb몇 가지 어려움이 있습니다. 누군가가 나를 도울 수 있다면 좋을 것입니다.

소스 코드를 다음과 같은 장난감 예제로 보겠습니다.

#include <stdio.h>
#include <stdlib.h>
#include <lbfgs.h>

int main(void)
{
    printf("liblbfgs will be used here!\n");
    return 0;
}

위의 C 프로그램에서,라이브러리 파일도서관이 이용될 예정입니다. liblbfgs는 저장소에서 사용할 수 있습니다. 나는 다음과 같은 간단한 Makefile을 작성했습니다.

CXX=gcc
CFLAGS=-Wall -g
LIBS=-lm -llbfgs
OUTPUT=toypackage

$(OUTPUT): $(OUTPUT).o
    $(CXX) -o $(OUTPUT) $(LIBS) $(OUTPUT).o

.PHONY: clean

clean:
    rm -f *~ *.o

synapticapt-get사용 가능한 소스를 수동으로 컴파일하고 위 코드를 빌드하여 라이브러리를 설치 하면 모든 것이 잘 작동합니다. 하지만 liblbfgs애초에 설치를 피하고 싶습니다 . 이런 이유로 나는 내 소프트웨어를 종속성으로 .deb정의해야 하는 파일 로 패키지하고 싶습니다 liblbfgs.

toypackage_1.0/예를 들어 소스 코드와 Makefile을 저장하는 폴더를 만듭니다 . 그런 다음 해당 디렉토리를 다음으로 압축했습니다.

tar czvf toypackage_1.0.orig.tar.gz toypackage-1.0/

dh_make그런 다음 다음과 같이 실행합니다.

$ cd toypackage-1.0/
$ dh_make

Type of package: single binary, indep binary, multiple binary,     library, kernel module, kernel patch?
  [s/i/m/l/k/n] s

  Maintainer name  : geppetto
  Email-Address    : geppetto@phi 
  Date             : Fri, 06 Jun 2014 16:25:22 +0300
  Package Name     : toypackage
  Version          : 1.0
  License          : blank
  Type of Package  : Single
  Hit <enter> to confirm: 
  Skipping creating ../toypackage_1.0.orig.tar.gz because it already exists
  Done. Please edit the files in the debian/ subdirectory now. You should also
  check that the toypackage Makefiles install into $DESTDIR and not in / .

$ debuild

  dpkg-buildpackage -rfakeroot -D -us -uc
  dpkg-buildpackage: source package toypackage
  dpkg-buildpackage: source version 1.0-1
  dpkg-buildpackage: source distribution unstable
  dpkg-buildpackage: source changed by geppetto <geppetto@phi>
  dpkg-source --before-build toypackage-1.0
  dpkg-buildpackage: host architecture amd64
  fakeroot debian/rules clean
  dh clean 
dh_testdir
dh_auto_clean
  make[1]: Entering directory '/home/geppetto/LAB/Debian_Packaging/ToyPackage/toypackage-1.0'
  rm -f *~ *.o
  make[1]: Leaving directory '/home/geppetto/LAB/Debian_Packaging/ToyPackage/toypackage-1.0'
dh_clean
  dpkg-source -b toypackage-1.0
  dpkg-source: info: using source format `3.0 (quilt)'
  dpkg-source: info: building toypackage using existing ./toypackage_1.0.orig.tar.gz
  dpkg-source: info: building toypackage in toypackage_1.0-1.debian.tar.xz
  dpkg-source: info: building toypackage in toypackage_1.0-1.dsc
  debian/rules build
  dh build 
dh_testdir
dh_auto_configure
dh_auto_build
  make[1]: Entering directory '/home/geppetto/LAB/Debian_Packaging/ToyPackage/toypackage-1.0'
  cc -Wall -g -D_FORTIFY_SOURCE=2  -c -o toypackage.o toypackage.c
  gcc -o toypackage -lm -llbfgs toypackage.o
  make[1]: Leaving directory '/home/geppetto/LAB/Debian_Packaging/ToyPackage/toypackage-1.0'
dh_auto_test
  fakeroot debian/rules binary
  dh binary 
dh_testroot
dh_prep
dh_auto_install
dh_installdocs
dh_installchangelogs
dh_perl
dh_link
dh_compress
dh_fixperms
dh_strip
dh_makeshlibs
dh_shlibdeps
dh_installdeb
dh_gencontrol
  dpkg-gencontrol: warning: Depends field of package toypackage: unknown substitution variable ${shlibs:Depends}
dh_md5sums
dh_builddeb
  dpkg-deb: building package `toypackage' in `../toypackage_1.0-1_amd64.deb'.
  dpkg-genchanges  >../toypackage_1.0-1_amd64.changes
  dpkg-genchanges: including full source code in upload
  dpkg-source --after-build toypackage-1.0
  dpkg-buildpackage: full upload (original source is included)
  Now running lintian...
  E: toypackage changes: changed-by-address-malformed geppetto <geppetto@phi>
  W: toypackage source: dh-make-template-in-source debian/init.d.ex
  W: toypackage source: dh-make-template-in-source debian/manpage.1.ex
  W: toypackage source: dh-make-template-in-source debian/manpage.sgml.ex
  W: toypackage source: dh-make-template-in-source debian/manpage.xml.ex
  W: toypackage source: dh-make-template-in-source debian/menu.ex
  W: toypackage source: dh-make-template-in-source debian/postinst.ex
  W: toypackage source: dh-make-template-in-source debian/postrm.ex
  W: toypackage source: dh-make-template-in-source debian/preinst.ex
  W: toypackage source: dh-make-template-in-source debian/prerm.ex
  W: toypackage source: dh-make-template-in-source debian/toypackage.cron.d.ex
  W: toypackage source: dh-make-template-in-source debian/toypackage.default.ex
  W: toypackage source: dh-make-template-in-source debian/toypackage.doc-base.EX
  W: toypackage source: dh-make-template-in-source debian/watch.ex
  W: toypackage source: package-needs-versioned-debhelper-build-depends 9
  E: toypackage source: maintainer-address-malformed geppetto <geppetto@phi>
  W: toypackage source: superfluous-clutter-in-homepage <insert the upstream URL, if relevant>
  W: toypackage source: bad-homepage <insert the upstream URL, if relevant>
  W: toypackage source: out-of-date-standards-version 3.9.4 (current is 3.9.5)
  W: toypackage: wrong-bug-number-in-closes l3:#nnnn
  E: toypackage: debian-changelog-file-contains-invalid-email-address geppetto@phi
  W: toypackage: new-package-should-close-itp-bug
  E: toypackage: changelog-is-dh_make-template
  E: toypackage: helper-templates-in-copyright
  W: toypackage: copyright-has-url-from-dh_make-boilerplate
  E: toypackage: copyright-contains-dh_make-todo-boilerplate
  W: toypackage: readme-debian-contains-debmake-template
  E: toypackage: description-is-dh_make-template
  E: toypackage: maintainer-address-malformed geppetto <geppetto@phi>
  E: toypackage: section-is-dh_make-template
  W: toypackage: superfluous-clutter-in-homepage <insert the upstream URL, if relevant>
  W: toypackage: bad-homepage <insert the upstream URL, if relevant>
  Finished running lintian.
  Now signing changes and any dsc files...
  signfile toypackage_1.0-1.dsc geppetto <geppetto@phi>
  gpg: skipped "geppetto <geppetto@phi>": secret key not available
  gpg: /tmp/debsign.wQjBHrJP/toypackage_1.0-1.dsc: clearsign failed: secret key not available
  debsign: gpg error occurred!  Aborting....
  debuild: fatal error at line 1283:
  running debsign failed

이건 좀 잘못된 것 같지만 만약 내가

$ cd ..
$ sudo dpkg -i toypackage_1.0-1_amd64.deb

[sudo] password for geppetto: 
Selecting previously unselected package toypackage.
(Reading database ... 426247 files and directories currently installed.)
Preparing to unpack toypackage_1.0-1_amd64.deb ...
Unpacking toypackage (1.0-1) ...
Setting up toypackage (1.0-1) ...

$ cd ./toypackage-1.0/
$ cd ./toypackage

liblbfgs will be used here!

그런 liblbfgs다음 apt-get.

내 질문은 다음과 같습니다.

  • 이전에 설치하지 않았다면 어떻게 되나요 liblbfgs? 코드를 올바르게 구성하려면 어떻게 해야 합니까?
  • 내 목적에 적합한 Makefile은 무엇입니까? $DESTDIR$바이너리가 에 저장되도록 변경하는 방법을 제안해 주시겠습니까 /usr/bin/?

답변1

  • 이전에 liblbfgs를 설치하지 않았다면 어떻게 되나요? 코드를 올바르게 구성하려면 어떻게 해야 합니까?

빌드 도구가 이 종속성을 인식하려면 다음을 수행해야 합니다 Build-Depends.debian/control문서.

  • 내 목적에 적합한 Makefile은 무엇입니까? $DESTDIR$을 사용하여 바이너리가 /usr/bin/에 저장되도록 변경하는 방법을 제안해 주실 수 있나요?

Makefile목표가 있어야 하며 , install그 목표를 존중해야 합니다 $DESTDIR( $PREFIXFreeBSD와 같은 것을 지원하려는 경우). 좋은 install목표는 다음과 같아야 합니다.

PREFIX?=/usr
DESTDIR?=/

install:
    install -m 755 $(OUTPUT) $(DESTDIR)/$(PREFIX)/bin/$(OUTPUT)

보다대상 디렉토리부분새로운 관리자를 위한 매우 유용한 가이드.

관련 정보