rpmbuild로 직접 .rpm 제작시 어려움을 격고 있어요...

ph****@Naver의 이미지

리눅스 공부하고 있는 직장인 입니다.

이번에 공부하면서 .rpm 파일을 직접 만들어 보고 싶은 생각에 진행 중인데

진행 관련에 있어 어려움을 겪고 있어 이렇게 글을 남깁니다.

1. nginx 소스파일을 받았습니다

2. nginx 소스파일을 ./configure

./configure \
--prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--conf-path=/etc/nginx/nginx.conf \
--modules-path=/etc/nginx/modules \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--user=nginx \
--group=nginx \
--with-pcre=/tmp/nginxgo/pcre-8.44 \
--with-pcre-jit \
--with-zlib=/tmp/nginxgo/zlib-1.2.11 \
--with-openssl=/tmp/nginxgo/openssl-1.1.1g \

해서 make 까지한 상태입니다.

즉, spec 파일에서 %prep과 %build까지는 한상태라

( rpmbuild/BUILD/기존 소스를 빌드해서 디렉토리를 준비한 상태 )

spec 에서는 지워둔 상태입니다.

%install 부분의 작성법이 잘못 되서인지 계속 %install부분에서 error 가 뜨는거 같은데

관련 답변 부탁드리겠습니다... 답변 기다리겠습니다. 감사합니다.

spec 파일 스크린샷 첨부 했습니다.

- 제가 진행 하고있는 목표는
기존의 nginx 소스파일을 다운받아서
제가 설정한 ./configure nginx를 .rpm 파일로 만들어서
배포 가능하게 하는게 목표 입니다. -

File attachments: 
첨부파일 크기
Image icon spec_2.jpg199.53 KB
세벌의 이미지

Error 뜬다면 메시지를 보여주세요. 이미지 말고 텍스트로.
아래 링크도 들러보시고.
https://wiki.kldp.org/wiki.php/DocbookSgml/Beginner_QA-KLDP#AEN70

ph****@Naver의 이미지

%install
rm -rf $RPM_BUILD_ROOT

mkdir -p $RPM_BUILD_ROOT%{_bindir}

cp -r %{_builddir}/nginx-1.19.1 $RPM_BUILD_ROOT%{_bindir}/

cd %{buildroot}%{_bindir}/nginx-1.19.1

%make_install

%install부분을 이렇게 수정하고 rpmbuild -bb nginx-1.spec

Found '/root/rpmbuild/BUILDROOT/nginx-1-1-1.el8.x86_64' in installed files; aborting
오류: /var/tmp/rpm-tmp.tKAMe7의 잘못된 종료 상황 (%install)

이러한 error 가 등장하네요 흠...

저는 제가 %install을 저렇게 작성하면

$RPM_BUILD_ROOT%{_bindir}/nginx-1.19.1

이 복사가 되고 . 추후 .rpm이 만들어져서 사용자가 .rpm을 실행하면 make install 될줄 알았는데..

혹시 수정할 부분을 알고 계신다면 정중히 답변 부탁 드리겠습니다. 감사합니다

김정균의 이미지

make install 을 하면 실제 install 이 되어 버립니다.
rpm 에서는 %{buildroot} 를 / 로 취급하여 install 시켜야 합니다.
즉, /usr/bin/nginx 라면 rpm 에서는 %{buildroot}/usr/bin/nginx 에 install 시켜야 합니다.

install 환경이 automake 를 이용하도록 되어 있다면 다음과 같이 처리가 가능 합니다

```spec
make install DESTDIR=%{buildroot}
```

nginx 도 automake 를 이용하니 위와 같이 해 주면 됩니다.

그리고, nignx rpm 배포 파일은 꽤 많습니다. 이런 경우, 다른 사람의 nginx spec 파일을 참조해 보는 것도 한 방법이겠죠.

P.S.
위에 분이 언급 하셨듯이.. 이미지로 내용을 주지 마세요. 무언가 typing 할 일이 있으면 일일이 다 쳐야 해서 pass 할 확률이 높습니다. 될 수 있으면 copy & paste 로 정보를 주는 것이 좋습니다. 직접 typing 하는 것도 실수할 확률이 있으니...

ph****@Naver의 이미지

앞으로는 이미지로 내용을 올리지 않도록 하겠습니다.
말씀처럼 배포된 rpm 파일 많이 있지만 , 리눅스 공부하면서 제가 직접 rpm을 만들어 보고 싶어서 공부 중이라 .. 이렇게 직접 만들어 보고 있습니다 ㅎ..

죄송하지만 nginx rpm 배포판들의 nginx spec 파일을 보려면 어떻게 해야 하는지 알수 있을까요? .

ph****@Naver의 이미지

%install
rm -rf $RPM_BUILD_ROOT

mkdir -p $RPM_BUILD_ROOT%{_bindir}

cp -r %{_builddir}/nginx-1.19.1 $RPM_BUILD_ROOT%{_bindir}/

cd %{buildroot}%{_bindir}/nginx-1.19.1

%make_install

%files
...

ph****@Naver의 이미지

Found '/root/rpmbuild/BUILDROOT/nginx-1-1-1.el8.x86_64' in installed files; aborting
오류: /var/tmp/rpm-tmp.tKAMe7의 잘못된 종료 상황 (%install)

이런한 error 메세지를 받았네요 . 몇주동안 고생하다 처음 받아보는 답변이라 . 정균님의 답변이 너무 고맙습니다 감사합니다 ㅠ

김정균의 이미지

spec 파일에서 version 을 %name 을 nginx-1, %version 을 1, %release 를 1 로 설정해 놓았으니, rpm 은 %{buildroot}/nginx-1-1-1 에서 install 된 파일을 찾게 됩니다. 하지만 님은 %{buildroot}/nginx-1.19.1 에서 install 을 시켜 놓으셨지요. 그러니 에러가 발생하는 겁니다.

현재 님의 문제는 spec 파일에 대해서 제대로 이해를 못하고 계시고, 그냥 이리저리 수정해 보면서 테스트를 하는 것 같은데요. 20년 전에 작성된 글이기는 하지만 전반적으로 spec 파일 사용법에 대한 이해에 도움은 될 것입니다. 이 문서들을 한번 읽어 보세요

http://linux.sarang.net/~oops/rpm-doc/rpm.txt
http://linux.sarang.net/~oops/rpm-doc/package.txt

김병찬님이 작성한 글입니다.

그리고,

%install
rm -rf $RPM_BUILD_ROOT
 
mkdir -p $RPM_BUILD_ROOT%{_bindir}
 
cp -r %{_builddir}/nginx-1.19.1 $RPM_BUILD_ROOT%{_bindir}/
 
cd %{buildroot}%{_bindir}/nginx-1.19.1
 
%make_install

에서 "mkdir -p $RPM_BUILD_ROOT%{_bindir}" 부터 "cd %{buildroot}%{_bindir}/nginx-1.19.1" 라인 까지는 make install 에서 처리할 내용인데, 굳이 또 해야할 이유는 뭔지 모르겠네요. 심지어는 nginx-1.19.1 을 왜 %{_bindir}에 copy를 하는지..

마지막으로, 다른 rpm 의 spec 파일을 확인하고 싶으면, source rpm 을 받아서 풀어 보시면 됩니다.
rpm -ihv xxx.src.rpm 으로 풀면, rpm build directory 에 풀리게 되고, 그냥 현재 디렉토리에서 풀고 싶다면

[root@host ~]# rpm2cpio xxxx.src.cpm | cpio -idmv

와 같이 하면 현재 디렉토리에 풀립니다.

안녕 리눅스의 source rpm 은 http://mirror.oops.org/pub/AnNyung/3/srpms/ 에서 받으실 수 있으며, nginx 도 있으니 받아서 확인해 보세요

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.