Self-Improvement

Linux 소스코드로 RPM 패키지 만들기 본문

리눅스/서버관리

Linux 소스코드로 RPM 패키지 만들기

JoGeun 2018. 10. 21. 13:38

*소스코드로 RPM 패키지 만들기
 1.소스 프로그램 개발
 #mkdir -p hello-1.0
 #vi hello-1.0/hello.sh
 ------------------------------hello.sh----------------------

-----------------------------------------------------------------

2.rpm 패키지 생성 절차
 #yum -y install rpm-build
 #ls /usr/src/redhat
 #tar cvzf /usr/src/redhat/SOURCES/hello-1.0-1.tar.gz ~/hello-1.0

3.SPEC파일 생성
 #vi /usr/src/redhat/SPECS/hello.spec 
-------------------hello.spec--------------------------
 %define name hello
 %define version 1.0
 %define release 1
 Name:           hello
 Version:        1.0
 Release:        1
 Summary:        Hello
 Group:          CentOS
 License:        GPL
 URL:            http://www.example.com
 Source0:        %{name}-%{version}-%{release}.tar.gz
 BuildRoot:      /var/tmp/%{name}-buildroot 

 %description
 Installs        /root/bin/hello.sh

 %prep
 %setup -q -n %{name}-%{version}

 %build

 %install
 rm -rf $RPM_BUILD_ROOT
 mkdir -p $RPM_BUILD_ROOT/root/bin
 install -m 755 hello.sh $RPM_BUILD_ROOT/root/bin/hello.sh

 %clean
 rm -rf $RPM_BUILD_ROOT

 %files
 %defattr(-,root,root,-)
 /root/bin/hello.sh

 %changelog
 -------------------------------------------------

4.RPM build
 #rpmbuild -ba /usr/src/redhat/SPECS/hello.spec
 #tree /usr/src/redhat

//테스트
 #rpm -Uvh hello-1.0-1.i386.rpm
 #hello.sh (실행)
 #rpm -e hello
 
 5.패키지 GPG Key 생성 및 패키지 Sign
 #gpg --gen-key (key 복사)

Key = FCBCC1BC

6.패키지 sign
 #gpg -a -o ~/RPM-GPG-KEY-test --export 키
 #vi ~/.rpmmacros

 #rpm --resign /usr/src/redhat/RPMS/i386/hello-1.0-1.i386.rpm

 7.YUM Repository 구성
 #mkdir /var/www/html/packages
 #cp /usr/src/redhat/RPMS/i386/hello*.rpm /var/www/html/packages
 #cp RPM-GPG-KEY-test /var/www/html/packages
 #yum -y install createrepo
 #createrepo /var/www/html/packages
 #service httpd restart

 8.최종테스트
 #vi /etc/yum.repos.d/hello.repo
 ---------hello.repo------------
 [hello]
 name=hello
 description=Test Yum Repository
 baseurl=http://x.x.x.x/packages
 enabled=1
 gpgcheck=1
 gpgkey=http://x.x.x.x/packages/RPM-GPG-KEY-test
 -------------------------------
 #yum -y install hello
 #hello.sh
 #yum repolist
 #제거시 hello.repo의 enabled=0으로 한다

'리눅스 > 서버관리' 카테고리의 다른 글

Linux 부팅과정2  (0) 2018.10.21
Linux 부팅과정1  (0) 2018.10.21
Linux YUM2  (0) 2018.10.21
Linux YUM1  (0) 2018.10.21
Linux RPM  (0) 2018.10.21