[패키지] rpm 패키지 만들기

RPM mini HOWTO – rev 1

Clunix Inc, 2002.05.30

본 문서는 RPM (RedHat Package Manager)을 사용한 packaging의 설치, 제거, 확인,

생성에 대한 mini HOWTO이다. 자세한 내용은 RPM manual을 참고한다.

Using RPM pkg

————-

– install

  – rpm -ivh pkg_name-version-release.rpm : 일반적인 install (dependency check)

  – rpm -ivh –force pkg_name-version-release.rpm : 강제 설치

  – rpm -ivh — nodeps pkg_name-version-release.rpm : no dependency check

  – rpm -ivh –test pkg_name-version-release.rpm : install 가능 여부 check

– upgrade

  – rpm -Uvh pkg_name.rpm : 이미 설치된 rpm pkg의 높은 버전으로 upgrade 설치

                            (제거후 설치와 같음)

– uninstall

  – rpm -e pkg_name

– query

  – rpm -qpl pkg_name-version-release.rpm : 설치된 pkg가 아닌 rpm file의 내용

  – rpm -ql pkg_name : 설치된 pkg의 rpm file 내용

  – rpm -qf /path/file : /path/file이 속한 rpm의 이름

  – rpm -qi pkg_name : 설치된 pkg info

– verify

  – rpm -V pkg_name : 설치된 pkg verification

  – rpm -Va : 설치된 모든 pkg verification (cracking 여부의 조사에 유용함)

    – rpm command가 cracker에 의해 원래 파일이 아닌 조작된 파일로 교체된 경우

      검사 자체가 무의미함.

    – 주로 path에 ‘bin’이 들어가는 실행 파일을 유의하여 살펴볼것

    – ps, ls 등의 MD5 checksum이 바뀌어 있다면 99% cracking 당했다고 판단

  – verification info

    – 5(MD5 sum), S(file size), L(Symlink), T(Mtime), D(Device), U(user),

      G(Group), M(permission & file type)

    – 위의 항목중 바뀐 부분이 check됨

Building RPM pkg

————–

– preparation

  – *.tar.gz source file in /usr/src/redhat/SOURCES

  – RPM spec file in /usr/src/redhat/SPECS

– RPM spec

  – Header : Summary, Name, Version, Release, Copyright, Group, Source, Patch,

             BuildRoot, … etc

    – Name, Version, Release : ex) bash-2.04-21 (bash, 2.04, 21)

    – Source : ex) bash-2.04.tar.gz or URL

               Source가 여러개인 경우 Source0, Source1, Source2 … 로 표기

    – Patch : patch file

    – BuildRoot : %{_tmppath}/%{name} pkg build시 실제 위치에 복사하면서

                  만드는데, 이를 피하기 위해 BuildRoot를 위와같이 설정하면

                  /var/tmp/%{name} 디렉토리를 root dir로 하여 그 아래에 복사됨.

                  마지막에 지우면 됨

  – %define : 상수 지정

  – %prep : source를 풀고 patch하고 src top dir로 들어가기까지 사용되는 shell

            commands

    – %setup : %prep내에서 사용되는 macro

               %setup -n name : 기본은 src를 풀면 name-version형태의 디렉토리가

               생성되어 cd name-version 을 실행하지만, src를 풀고 난 디렉토리가

               다른 이름일때 사용

               ex) cccp-1.0.0.tar.gz을 풀면 cccp가 생기는 경우 %setup -n cccp를

                   사용

  – %build : src top dir에서 실행할 command

  – %install : src make후에 만들어진 file의 install을 위한 shell commands

               make install을 사용하거나 manual로 하나씩 복사(install command

사용 추천) 가능

  – %clean : src make & install후 cleaning을 위한 shell commands

             BuildRoot를 지정하여 사용했다면 여기서 지움

  – %files : 만들어진 binary RPM이 설치할 파일 목록 (대부분 %install시 복사한

             files) 특정 파일에서 읽어오는 경우 %files -f list_file로 지정

    – %dir : RPM 설치시 디렉토리를 만드는 경우 디렉토리로 명시

    – %config : config 파일로 명시. uninstall시 내용이 바뀌면 name.rpmsave로

                남겨둠

    – %defattr : default attribute (mode, owner, group) install시에 파일

                 attrib을 신경쓸것

  – %pre : pre-installation시 사용하는 shell commands

  – %post : post-installation시 사용하는 shell commands

  – %preun : pre-uninstallation시 사용하는 shell commands

  – %postun : post-unnstallation시 사용하는 shell commands

  – %changelog : “* Tue May 28 2002 yourname <your email>” 형식 추천

– RPM build (SPECS directory에서 실행)

  – rpm -ba name.spec : binary, src rpm 모두 생성

  – rpm -bb name.spec : binary only

  – rpm -bs name.spec : src only

  – binary rpm은 /usr/src/redhat/RPMS/*/name-version-rel.*.rpm 에 생성됨

  – src rpm은 /usr/src/redhat/SRPMS/name-version-rel.src.rpm 에 생성됨

2 sample spec files

——————

[cccp.rpm]

# RPM Spec file for CCCP package

Summary: CCCP Daemon for Clunix Manpa(TM)

Name: cccp

Version: 1.0.0

Release: 1

Source: cccp-1.0.0.tar.gz

Prereq: chkconfig

Requires: initscripts >= 3.92

Copyright: Copyright (c) 2002 by Clunix, Inc.

URL: http://www.clunix.com/

Distribution: None

Vendor: Clunix, Inc.

Packager: Donghyun Kim <ryan@clunix.com>

Group: System Environment/Daemons

BuildRoot: %{_tmppath}/%{name}-root

%define CCCP_DIR /usr/clx/cccp

%description

CCCP (Clunix Cluster Configuration Protocol) for Clunix Manpa(TM)

this rpm contains only cccpd not wts_client, alert_win used in client

%prep

%setup -n %{name}

%build

#make

make cccpd

%install

rm -rf %{buildroot}

mkdir -p %{buildroot}%{CCCP_DIR}/etc

mkdir -p %{buildroot}%{CCCP_DIR}/sbin

mkdir -p %{buildroot}/etc/rc.d/init.d

install -m 0755 -o root -g root -s cccpd %{buildroot}%{CCCP_DIR}/sbin/

install -m 0755 -o root -g root cccp.init %{buildroot}/etc/rc.d/init.d/cccp

install -m 0644 -o root -g root conf/cccp.conf %{buildroot}%{CCCP_DIR}/etc/

install -m 0644 -o root -g root conf/def_cccp.dat %{buildroot}%{CCCP_DIR}/etc/

%files

%dir %{CCCP_DIR}

%dir %{CCCP_DIR}/etc

%dir %{CCCP_DIR}/sbin

%{CCCP_DIR}/sbin/cccpd

%config /etc/rc.d/init.d/cccp

%config %{CCCP_DIR}/etc/cccp.conf

%config %{CCCP_DIR}/etc/def_cccp.dat

%clean

rm -rf %{buildroot}

%post

chkconfig –add cccp

%changelog

* Tue May 28 2002 Donghyun Kim <ryan@clunix.com>

  – first rpm

[dhcp.spec]

Summary: A DHCP (Dynamic Host Configuration Protocol) server and relay agent.

Name: dhcp

Epoch: 1

Version: 2.0pl5

Release: 8

Copyright: distributable

Group: System Environment/Daemons

Source0: ftp://ftp.isc.org/isc/dhcp/dhcp-%{version}.tar.gz

Source1: dhcpd.conf.sample

Source2: dhcpd.init

Patch0: dhcp-2.0-buildroot.patch

Patch1: dhcp-2.0-js.patch

Patch2: dhcp-2.0-unaligned.patch

Obsoletes: dhcpd

BuildRoot: %{_tmppath}/%{name}-%{version}-root

%description

DHCP (Dynamic Host Configuration Protocol) is a protocol which allows

individual devices on an IP network to get their own network

configuration information (IP address, subnetmask, broadcast address,

etc.) from a DHCP server. The overall purpose of DHCP is to make it

easier to administer a large network. The dhcp package includes the

DHCP server and a DHCP relay agent.

You should install dhcp if you want to set up a DHCP server on your

network. You will also need to install the pump package, which

provides the DHCP client daemon, on client machines.

%prep

%setup -q

%patch0 -p1

%patch1 -p1 -b .js

%ifarch sparc sparc64 alpha

%patch2 -p1 -b .unaligned

%endif

cp %SOURCE1 .

%build

%configure

make CC=”gcc -pipe” DEBUG=”$RPM_OPT_FLAGS -D_PATH_DHCPD_DB=\\\\\\”/var/lib/dhcp/dhc

pd.leases\\\\\\” -D_PATH_DHCLIENT_DB=\\\\\\”/var/lib/dhcp/dhclient.leases\\\\\\””

%install

rm -rf %{buildroot}

mkdir -p %{buildroot}/etc/sysconfig

make install DESTDIR=%{buildroot}

strip %{buildroot}/usr/sbin/* || :

mkdir -p %{buildroot}/etc/rc.d/init.d

install -m 0755 %SOURCE2 %{buildroot}/etc/rc.d/init.d/dhcpd

touch %{buildroot}%{_localstatedir}/lib/dhcp/dhcpd.leases

cat <<EOF > %{buildroot}/etc/sysconfig/dhcpd

# Command line options here

DHCPDARGS=

EOF

%clean

rm -rf %{buildroot}

%post

/sbin/chkconfig –add dhcpd

%preun

if [ $1 = 0 ]; then     # execute this only if we are NOT doing an upgrade

    service dhcpd stop >/dev/null 2>&1

    /sbin/chkconfig –del dhcpd

fi

%postun

if [ “$1” -ge “1” ]; then

    service dhcpd condrestart >/dev/null 2>&1

fi

%files

%defattr(-,root,root)

%doc CHANGES README RELNOTES dhcpd.conf.sample

%dir %{_localstatedir}/lib/dhcp

%config(noreplace) %{_localstatedir}/lib/dhcp/dhcpd.leases

%config(noreplace) /etc/sysconfig/dhcpd

%config /etc/rc.d/init.d/dhcpd

%{_sbindir}/dhcpd

%{_sbindir}/dhcrelay

%{_mandir}/man5/dhcpd.conf.5*

%{_mandir}/man5/dhcpd.leases.5*

%{_mandir}/man5/dhcp-options.5*

%{_mandir}/man8/dhcpd.8*

%{_mandir}/man8/dhcrelay.8*

#%files client

#%defattr(-,root,root)

#%doc CHANGES README RELNOTES TODO doc/*

#%dir /var/dhcpd

#/etc/dhclient-script

#/sbin/dhclient

#/usr/man/man5/dhclient.conf.5

#/usr/man/man5/dhclient.leases.5

#/usr/man/man8/dhclient.8

#/usr/man/man8/dhclient-script.8

%changelog

* Sun Aug 26 2001 Elliot Lee <sopwith@redhat.com> 2.0pl5-8

– Fix #26446

* Mon Aug 20 2001 Elliot Lee <sopwith@redhat.com>

– Fix #5405 for real – it is dhcpd.leases not dhcp.leases.

* Mon Jul 16 2001 Elliot Lee <sopwith@redhat.com>

– /etc/sysconfig/dhcpd

– Include dhcp.leases file (#5405)

서진우

슈퍼컴퓨팅 전문 기업 클루닉스/ 상무(기술이사)/ 정보시스템감리사/ 시스존 블로그 운영자

You may also like...

페이스북/트위트/구글 계정으로 댓글 가능합니다.