사전 작업
프로그램 작성
실습을 위해 world를 출력하는 hello 스크립트를 작성해보자.
mkdir hello-1.0.0 cat <<EOF > hello-1.0.0/hello #!/bin/bash echo world EOF sh hello-1.0.0/hello
[builduser@jmnote ~]$ mkdir hello-1.0.0 [builduser@jmnote ~]$ cat <<EOF > hello-1.0.0/hello > #!/bin/bash > echo world > EOF [builduser@jmnote ~]$ sh hello-1.0.0/hello world
압축
[builduser@jmnote ~]$ tar czvf hello-1.0.0.tar.gz hello-1.0.0/ hello-1.0.0/ hello-1.0.0/hello
SPEC 파일 작성
hello.spec 문서를 참고하십시오.
hello.spec 파일(새파일)을 열어서 hello.spec의 내용으로 채우고 저장.
[builduser@jmnote ~]$ vi hello.spec
rpm 빌드
[builduser@jmnote ~]$ rpmbuild hello.spec error: File /home/builduser/rpmbuild/SOURCES/hello-1.0.0.tar.gz: No such file or directory
- → 빌드를 위한 폴더 구조를 만들기 위해 rpmbuild를 실행 (오류 발생하지만 무시)
[builduser@jmnote ~]$ cp hello-1.0.0.tar.gz rpmbuild/SOURCES/ [builduser@jmnote ~]$ cp hello.spec rpmbuild/SPECS/ [builduser@jmnote ~]$ cd rpmbuild/SPECS/ [builduser@jmnote SPECS]$ rpmbuild --sign -ba hello.spec Enter pass phrase:
- → rpm-build를 위한 GPG Key 생성에서 입력했던 Passphrase 값 입력
Pass phrase is good. Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.hUcv0F + umask 022 + cd /home/builduser/rpmbuild/BUILD + cd /home/builduser/rpmbuild/BUILD ... (생략) + cd hello-1.0.0 + rm -rf /home/builduser/rpmbuild/BUILDROOT/hello-1.0.0-1.el6.x86_64 + exit 0
[builduser@jmnote SPECS]$ cd ../RPMS/x86_64/ [builduser@jmnote x86_64]$ ll total 4 -rw-rw-r--. 1 builduser builduser 2546 May 17 02:24 hello-1.0.0-1.el6.x86_64.rpm
- → 그럴싸한 rpm 파일이 생성되었다.
rpm 설치 및 확인
- root 계정에서 진행
[root@zetawiki ~]# rpm --import /home/builduser/RPM-GPG-KEY-builduser [root@zetawiki ~]# cp /home/builduser/rpmbuild/RPMS/x86_64/hello-1.0.0-1.el6.x86_64.rpm ~ [root@zetawiki ~]# rpm -ivh hello-1.0.0-1.el6.x86_64.rpm Preparing... ########################################### [100%] 1:hello ########################################### [100%]
[root@zetawiki ~]# rpm -qa hello hello-1.0.0-1.el6.x86_64 [root@zetawiki ~]# which hello /usr/local/bin/hello [root@zetawiki ~]# rpm -qf /usr/local/bin/hello hello-1.0.0-1.el6.x86_64 [root@zetawiki ~]# hello world