소스 패키징과 ppa에 업로드하기

패키징이라는 것은 생각도 못하고 있다가 강분도님의 제안으로 아래 글타래에 있는 ms-sys의 소스를 받아 패키징 연습을 해보았습니다.

viewtopic.php?p=58014#p58014

(패키징에 대해서 아무것도 모른 채 착수하였습니다만, 그 동안 많은 분들께서 참고할 수 있는 관련자료들을 만들어 주셔서 비교적 단기에 마칠 수 있었습니다.)

환경
Ubuntu 10.04 amd64

참고 자료
deb패키징하우투문서 : http://ubuntu.or.kr/viewtopic.php?f=6&t=1405
데비안새로운관리자안내서 : http://www.debian.org/doc/manuals/maint … ex.ko.html
강분도님의 컴파일 관련 글타래 : http://ubuntu.or.kr/viewtopic.php?p=5804#p5804
우분투 위키 : http://ubuntu.or.kr/wiki/doku.php/%EC%9 … 4%EA%B8%B0
우선 deb파일을 만드는 것은 별론으로 하고, 자신의 PPA(Personal Pakage Archives)에 업로드를 하려면 gpg key(개인인증키)를 만들어야 합니다. gpg키를 만드는 방법과 개인 PPA생성은 관련 글타래를 링크하는 것으로 대체하겠습니다.
GPG키 만들기 : http://ubuntu.or.kr/viewtopic.php?p=5804#p5804

지금부터는 제가 진행한 과정의 소개입니다. 다시 돌이켜보니 바르게 한 것인지 억지로 끼워맞춰 한건지도 잘 모르겠습니다… [color=#FF0000:h53nl700]많은 지도 부탁드립니다. (__)[/color:h53nl700]

본격적인 진행에 앞서 ms-sys download페이지로 가서 Current Version 소스를 다운로드 받습니다.(다운로드 링크 : http://ms-sys.sourceforge.net/#Download)

[code:h53nl700]minjoo@laptop:~/Desktop/test$ ls
ms-sys-2.2.0.tar.gz
minjoo@laptop:~/Desktop/test$ tar xvzf ms-sys-2.2.0.tar.gz
ms-sys-2.2.0/
ms-sys-2.2.0/mo/
ms-sys-2.2.0/po/
...
minjoo@laptop:~/Desktop/test$
[/code:h53nl700]

압축풀기가 완료되었으면, 해당 디렉터리(압축파일이 풀린)로 이동 후, dh_make를 입력합니다.

[code:h53nl700]minjoo@laptop:~/Desktop/test$ cd ms-sys-2.2.0/
minjoo@laptop:~/Desktop/test/ms-sys-2.2.0$ ls
CHANGELOG COPYING Makefile TODO dep include-fallback mo po
CONTRIBUTORS FAQ README bin inc man obj src
minjoo@laptop:~/Desktop/test/ms-sys-2.2.0$ dh_make

Type of package: single binary, indep binary, multiple binary, library, kernel module, kernel patch or cdbs?
[s/i/m/l/k/n/b][/code:h53nl700]
dh_make가 없다면 설치하시길 바랍니다 (sudo apt-get install dh-make)
dh_make를 수행하게 하면 [s/i/m/l/k/n/b] 이와같이 만들고자하는 패키지의 종류를 묻습니다. 저도 dh_make의 사용방법이 익숙하지 않아 이는 더 공부하여 추후에 사용방법을 추가로 올리겠습니다. 여기서는 s를 타이핑 후 엔터를 누릅니다.(Single; 한개의 패키지)

[code:h53nl700]Maintainer name : minjoo
Email-Address : minjoo@unknown
Date : Tue, 25 May 2010 19:53:22 +0900
Package Name : ms-sys
Version : 2.2.0
License : blank
Using dpatch : no
Using quilt : no
Type of Package : Single
Hit <enter> to confirm:[/code:h53nl700]
enter키를 눌러 확인해줍니다. (confirm)

[code:h53nl700]Could not find ms-sys-2.2.0.orig.tar.gz
Either specify an alternate file to use with -f,
or add --createorig to create one.[/code:h53nl700]
혹, 위와 같은 메세지가 나온다면, dh_make --createorig 를 입력합니다.

무사히 통과하면 아래와 같은 메세지와 함께 my-sys-2.0.0.orig가 생성됩니다.

[code:h53nl700]Done. Please edit the files in the debian/ subdirectory now. You should also
check that the ms-sys Makefiles install into $DESTDIR and not in / .[/code:h53nl700]

dh_make가 수행되면 debian 디렉터리가 생성됩니다.
[attachment=3:h53nl700]1.png[/attachment:h53nl700]

패키징 관련 문서들을 읽어보면 debian 디렉터리 내에 위치하고 있는 changelog, control, copyright 이 세가지 파일의 수정이 매우 중요하게 나와있었습니다. 텍스트 에디터로 하나하나 수정해보겠습니다.

debian/changelog의 내용입니다.

[code:h53nl700]ms-sys (2.2.0-1) unstable; urgency=low

  • Initial release (Closes: #nnnn) <nnnn is the bug number of your ITP>

– minjoo <minjoo@unknown> Tue, 25 May 2010 20:07:34 +0900[/code:h53nl700]
unstable은 10.04에 맞게 lucid로 수정을 합니다.

  • initial release 뒤 (Closes : …) 라인은 삭제합니다.
    minjoo는 GPG키 생성 시 만든 Full-name을, <>속에는 E-mail주소를 기입합니다… (Full-name을 입력하지 않으면 뒤에서 설명하는 부분에서 경고가 발생합니다만, 수정하지 않으셔도 됩니다)

참고) 아래는 수정이 완료된 상태입니다.

[code:h53nl700]ms-sys (2.2.0-1) lucid; urgency=low

  • Initial release

– Min-joo Kim <linuxwhatever@gmail.com> Tue, 25 May 2010 10:25:58 +0900[/code:h53nl700]

다음은 debian/control을 수정합니다. 아래는 해당 파일의 내용입니다.

[code:h53nl700]Source: ms-sys
Section: unknown
Priority: extra
Maintainer: minjoo <minjoo@unknown>
Build-Depends: debhelper (>= 7)
Standards-Version: 3.8.3
Homepage: <insert the upstream URL, if relevant>

Package: ms-sys
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: <insert up to 60 chars description>
<insert long description, indented with spaces>[/code:h53nl700]
Section : utils 로 변경합니다.
Maintainer: 에도 역시 Full-name과 E-mail주소를 기입합니다.
Build-Depends: debhelper (>=7)은 debhelper (>=4)로 변경합니다. (※ 이 부분은 bundo님께서 변경하라고 알려주셨는데, ms-sys는 콘솔용 명령어이므로 4버전 이상이면 된다고 하십니다.)
Homepage: <>안에 홈페이지URL 을 넣습니다. (없다면 수정하지 않으셔도 괜찮습니다.)
Architecture:에는 any로 두어야 PPA에서 패키지化 될 때 32비트용, 64비트용이 다 만들어집니다. any를 amd64로 변경하면 64비트만 생성된다고 하니 참고바랍니다.
Depends: ${shlibs:Depends}, ${misc:Depends}는 , ${misc:Depends}을 삭제하여 Depends: ${shlibs:Depends}만 남겨둡니다. (이 부분도 bundo님이 알려주신 부분이라 더 공부후에 수정하겠습니다.)
Description: 은 <>안에 최대 영문 60자까지 서술할 수 있습니다. 길어질 경우는 아래 <insert long description, indented with spaces>에 작성합니다.
Description은 ms-sys 홈페이지의 설명을 대충 긁어와서 붙여넣겠습니다.

아래는 수정을 완료한 예입니다.

[code:h53nl700]Source: ms-sys
Section: utils
Priority: extra
Maintainer: Min-joo Kim <linuxwhatever@gmail.com>
Build-Depends: debhelper (>= 4)
Standards-Version: 3.8.3
Homepage: <http://sourceforge.net>

Package: ms-sys
Architecture: any
Depends: ${shlibs:Depends}
Description: <Microsoft compatible boot records>
<This is a Linux program for writing Microsoft compatible boot records>[/code:h53nl700]

다음은 debian/copyright의 수정입니다.
뒤에서 lintian (Debian Pakage Checker)으로 만들어진 패키지를 검사할 때 copyright부분에서 Error가 발생하여 (수정을 제대로 하지 못한 탓일테지만,) 매우 정확하게 수정해야한다고 생각했습니다만, 크게 중요한 것은 아닌 듯 합니다. copyright의 에러는 무시해도 PPA에서 패키징이 되는듯 합니다. (이 부분에 대하여서도 차후 더 공부해보겠습니다.)
copyright 파일은 수정된 예만 보는것으로 하겠습니다.
아래는 debian/copyright 의 수정 例입니다.

[code:h53nl700]This work was packaged for Debian by:

Min-joo Kim &lt;linuxwhatever@gmail&#46;com&gt; on Tue, 25 May 2010 11&#58;39&#58;33 +0900

It was downloaded from <http://prdownloads.sourceforge.net/ms-sys/ms-sys-2.2.0.tar.gz/download>

Upstream Author(s):

&lt;Henrik Carlqvist, athelon@naver&#46;com&gt;
&lt;Min-joo Kim&gt;

Copyright:

&lt;Copyright (C) 2010 Henrik Carlqvist&gt;
&lt;Min-joo Kim&gt;

License:

&lt;GNU GPL-3&gt;

The Debian packaging is:

Copyright (C) 2010 Min-joo Kim &lt;linuxwhatever@gmail&#46;com&gt;

Please chose a license for your packaging work. If the program you package

uses a mainstream license, using the same license is the safest choice.

Please avoid to pick license terms that are more restrictive than the

packaged work, as it may make Debian’s contributions unacceptable upstream.

If you just want it to be GPL version 3, leave the following lines in.

and is licensed under the GPL version 3,
see `/usr/share/common-licenses/GPL-3’.

Please also look if there are files or directories which have a

different copyright/license attached and list them here.[/code:h53nl700]

debian/rules 도 상당히 중요한 파일이라고 하지만, 저는 이번 패키징에서 별달리 수정하지 않아도 무사히 진행되었습니다.

모든 수정이 완료 되었으면, debian/ 내에 있는 *.ex 파일들을 삭제합니다.

[code:h53nl700]minjoo@laptop:~/Desktop/test/ms-sys-2.2.0$ rm debian/*.ex
[/code:h53nl700]
불필요한 파일들이라고 합니다만, 삭제하지 않으셔도 됩니다.

이제 fakeroot를 이용하여 패키지 생성을 시도해보면 (fakeroot debian/rules binary) 잘 진행이 되다가 아래와 같은 에러가 출력되게 됩니다.

[code:h53nl700]dh_usrlocal: debian/ms-sys/usr/local/man/man1/ms-sys.1 is not a directory
rmdir: failed to remove `debian/ms-sys/usr/local/man/man1’: Directory not empty
dh_usrlocal: rmdir debian/ms-sys/usr/local/man/man1 returned exit code 1
make: *** [binary] Error 1[/code:h53nl700]

본 글타래 첫머리부분에 링크된 관련 문서 中, 데비안새로운관리자안내서에서 3.1 서브디렉터리에 설치 부분을 참고하여, 패키지로 만들 소스디렉터리에 (현재 진행하고 있는 소스 디렉터리에) 위치하고 있는 Makefile 을 조금 수정하여야 합니다.
아래는 원본 makefile의 내용 중, 32~36번 라인에 해당하는 내용입니다.

[code:h53nl700]# Installation path
PREFIX ?= /usr/local
BINDIR = $(PREFIX)/bin
LOCALEDIR = $(PREFIX)/share/locale
MANDIR = $(PREFIX)/man[/code:h53nl700]
제가 공부가 부족하여 제대로 이해하고 있는지는 모르겠습니다만, 이 작업당시에 왠지 이 부분을 Ubuntu에 맞게 수정해주어야겠구나 하는 생각에 아래와 같이 바꾸어보았습니다. (확실히 아는부분이 아니라 추후 수정하겠습니다.)
※수정된 32~36 라인

[code:h53nl700]# Installation path
PREFIX ?= /usr
BINDIR = $(PREFIX)/bin
LOCALEDIR = $(PREFIX)/share/locale
MANDIR = $(PREFIX)/share/man/man1[/code:h53nl700]

위와같이 Makefile을 변경한 후, 패키지를 만들어봅니다.

[code:h53nl700]minjoo@laptop:~/Desktop/test/ms-sys-2.2.0$ fakeroot debian/rules binary[/code:h53nl700]
※makefile을 변경하지 않고 먼저 패키지생성을 시도하여 에러가 발생한 상황에서, makefile을 변경 후 재시도(패키지생성)하여도 에러가 발생하니 다시 makefile의 변경까지 처음부터 진행 해보시길 바랍니다.

패키지 생성에 성공하면 아래와 같은 메세지를 볼 수 있습니다.

[code:h53nl700]dpkg-deb: building package ms-sys' in ../ms-sys_2.2.0-1_amd64.deb’.[/code:h53nl700]

한단계 상위 디렉터리로 가면 deb패키지가 만들어져있습니다.:)
[attachment=2:h53nl700]2.png[/attachment:h53nl700]

이제 만들어진 패키지가 데비안정책(이라고 하는게 맞는지…)에 합당한지 검사를 해봅니다.
(lintian패키지가 설치되어 있지 않으신 분들께서는 설치해주시기를 바랍니다, sudo apt-get install lintian)

아래는 사용예입니다.
[attachment=1:h53nl700]3.png[/attachment:h53nl700]
위의 사용예를 보시면
[color=#FF4000:h53nl700]E[/color:h53nl700]: ms-sys: copyright-contains-dh_make-todo-boilerplate 라는 에러([color=#FF4000:h53nl700]E[/color:h53nl700]rror)가 보입니다만, 수정하지 않아도 괜찮은 것 같습니다. (저것을 수정하려 애써보았지만, 방법을 찾지못해 그냥 진행합니다. 추후 수정하겠습니다.)

이제 PPA에 업로드를 위한 작업을 진행합니다.
소스디렉터리에서 debuild -S -sa 를 수행하게 합니다.
(debuild가 수행되지 않는 분들은 관련 패키지의 설치가 필요합니다. sudo apt-get install devscripts)

빌드가 진행되는 중, 아래와 같은 메세지를 볼 수 있습니다.

[code:h53nl700]You need a passphrase to unlock the secret key for
user: "Min-joo Kim <linuxwhatever@gmail.com>"
1024-bit RSA key, ID 035C8CE6, created 2010-05-24

Enter passphrase: gpg: gpg-agent is not available in this session[/code:h53nl700]
GPG키를 생성할 때 만든 pass phrase를 입력해주시면 됩니다.
※입력시 리눅스에서 패스워드를 입력할 때와 같이 입력되고 있음이 화면에 출력되지 않습니다.
※ 한번 입력하면 재차 묻습니다. 또 다시 입력해주면 통과됩니다.

[code:h53nl700]Successfully signed dsc and changes files[/code:h53nl700]
빌드에 성공하면 위의 메세지가 출력됩니다.

[attachment=0:h53nl700]4.png[/attachment:h53nl700]
빌드가 무사히 끝나면 소스디렉터리보다 한단계 상위디렉터리에 위의 파일들이 생성되었습니다.

이제 PPA에 업로드를 하는 일만 남았습니다.
(앞서 미리 PPA를 만드시지 않으신 분들은 PPA를 만든 후에 진행하시기를 바랍니다.)
PPA에 업로드하는 요령은 다음과 같습니다. (dput을 사용하게 되는데, dput이 없다면 설치해주시길 바랍니다. sudo apt-get install dput)
[color=#FF0000:h53nl700]dput ppa:런치패드ID/PPA이름 소스파일이름.changes[/color:h53nl700]
사용예 >

[code:h53nl700]dput ppa:linuxwhatever/minjoo ms-sys_2.2.0-1_source.changes[/code:h53nl700]
Successfully uploaded packages. 라는 메세지를 보셨으면 무사히 업로드가 끝났습니다.
업로드가 끝이나면 런치패드 가입시 사용한 E-mail주소로 런치패드로부터 E-mail이 옵니다. Accepted라는 메일이 왔다면 업로드에 성공한 것입니다. (메일이 빨리 올 수도, 늦게 올 수도 있습니다.)
Accepted라는 메일을 받으셨다면, 자신의 런치패드(http://launchpad.net/~아이디)로 가셔서 Personal Pakage Archives 항목에
이제 자신의 런치패드 계정홈(http://launchpad.net/~아이디)에 가셔서, Personal package archives에 있는 자신의 PPA를 눌러보면 업로드된 패키지를 볼 수 있습니다. 또, 런치패드에서 직접 컴파일을 하기 때문에 컴파일 까지 남은 시간도 볼 수 있습니다.

이 후, 런치패드로부터의 아무런 연락(E-mail)이 없으면 성공한 것입니다. 자신의 PPA에서 확인해보시기 바랍니다.
만약 실패하였으면 E-mail을 통해 통보됩니다. :)

본 포럼 가입이래로 제가 작성한 모든글을 합쳐도 오늘 하루 쓴 글보다 짧은 듯한 느낌입니다… 길어지다보니 중간에 예기치못한 오류(이)가 발생해서 날아가지는 않을까 노심초사 하면서 썼습니다. :)

저도 처음해보는 주제(?) 감히 팁게시판에 글을 써 죄송스럽습니다만, 어디써야할지 고민하다 쓴 것이니 너그러히 양해부탁드립니다 ^^;
그리고 제가 오늘 진행한 방법은 정말정말정말 많이 부족할것입니다.
패키징을 시작하시는 분들이라면 한번 경험삼아 연습해보시어 작게나마 경험을 쌓는데 도움이 되기를 바라며, 또 고수님들의 가르침도 받고싶습니다 :) 긴 글 읽어주셔서 감사합니다. 좋은하루 되십시오

수고 하셨습니다. [b:lmmk64y1]이제 민주님도 우분투 패키저군요[/b:lmmk64y1] 축하드립니다.

그리고 [url=https&#58;//edge&#46;launchpad&#46;net/~cobuntu/+archive/ppa:lmmk64y1]코분투 저장소[/url:lmmk64y1]로 ms-sys 가져 갔습니다.
런치패드 장점중 하나인 저장소 공유 기능 입니다.
(즉 남시키고 날로 먹기죠… 사실 알고 보면 우분투 자체, 오픈소스 프로그램 자체가 날로 먹기죠 :shock: )
[attachment=0:lmmk64y1]screenshot1.png[/attachment:lmmk64y1]

[list:lmmk64y1]P.S. : 좋은 글입니다. 다음 사람 따라 하기 편할듯 합니다.
그래서 제가 쓰다 중단한 우분투에서 컴파일을 해보자 시리즈중 9번째
"9. 개인 저장소와 우분투코리아 저장소 이용하기"를 민주님이 위글 통해 써보시기를 청합니다.[/list:u:lmmk64y1]

[quote="강분도":2jd7jbgn]제가 쓰다 중단한 우분투에서 컴파일을 해보자 시리즈중 9번째 "9. 개인 저장소와 우분투코리아 저장소 이용하기"를 민주님이 위글 통해 써보시기를 청합니다.[/quote:2jd7jbgn]
또 연습해보고 글 써보겠습니다 ^^;;

이런글은 고정할 수 없나요?? ㅠㅠ

아… 우분투 게시판에 추천/고정 기능이 없다는게 아쉬워지게 하는 포스트네요 ㅋ

일단 즐겨 찾기 추가합니다.

몇가지 참고링크도 추가합니다.

이 게시판은 왜 추천 기능이 없는거지?! 글 잘보았습니다. 언젠가 글로 써봐야지 했던 주제인데 민주님이 먼저 정리해주셨네요…^^

확실히 이런 글은 시도해보고 바로 정리해야되는데 귀차니즘으로 하루하루 미뤄지게 되면 나중엔 전부 까먹어서 글을 못쓰게 되더군요ㅠㅠ