Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

1.3. 첫 번째 rpm 패키지 만들기

RPM 패키지를 만드는 것은 복잡할 수 있습니다. 다음은 건너뛰고 단순화된 몇 가지 작업이 포함된 RPM 사양 파일을 완전히 작동하는 것입니다.

Name:       hello-world
Version:    1
Release:    1
Summary:    Most simple RPM package
License:    FIXME

%description
This is my first RPM package, which does nothing.

%prep
# we have no source, so nothing here

%build
cat > hello-world.sh <<EOF
#!/usr/bin/bash
echo Hello world
EOF

%install
mkdir -p %{buildroot}/usr/bin/
install -m 755 hello-world.sh %{buildroot}/usr/bin/hello-world.sh

%files
/usr/bin/hello-world.sh

%changelog
# let's skip this for now

이 파일을 hello-world.spec 로 저장합니다.

이제 다음 명령을 사용합니다.

$ rpmdev-setuptree
$ rpmbuild -ba hello-world.spec

rpmdev-setuptree 명령은 여러 작업 디렉터리를 생성합니다. 이러한 디렉터리는 $HOME에 영구적으로 저장되므로 이 명령을 다시 사용할 필요가 없습니다.

rpmbuild 명령은 실제 rpm 패키지를 생성합니다. 이 명령의 출력은 다음과 유사할 수 있습니다.

... [SNIP]
Wrote: /home/<username>/rpmbuild/SRPMS/hello-world-1-1.src.rpm
Wrote: /home/<username>/rpmbuild/RPMS/x86_64/hello-world-1-1.x86_64.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.wgaJzv
+ umask 022
+ cd /home/<username>/rpmbuild/BUILD
+ /usr/bin/rm -rf /home/<username>/rpmbuild/BUILDROOT/hello-world-1-1.x86_64
+ exit 0

/home/<username>/rpmbuild/RPMS/x86_64/hello-world-1-1.x86_64.rpm 파일은 첫 번째 RPM 패키지입니다. 시스템에 설치하고 테스트할 수 있습니다.