RPM설치하기전 질의가 가능한지요?

버그소년의 이미지

안녕하세요..

RPM패키지를 만들고 있는데..

그냥 파일들을 특정위치에 복사하는것은 잘 됩니다.

그런데 설정파일과 같은 것들을 설치시 질의응답을 받아 해결하고 싶어서

%pre에 스크립트를 작성해서 넣었습니다.

스크립트 중간중간에 read를 해서 사용자로부터 값을 입력받는데요..

rpm설치시 read가 먹지않고 그냥 지나갑니다.

원래 불가능한것인지 .. 아니면 다른 방법이 있는지 궁급합니다.

그리고 또 한가지는 실행파일을 rpm으로 만들어 설치하고 나면

원본 실행파일보다 크기가 상당히 작아집니다.

혹시나 해서 objcopy로 strip debug한 크기와 비교했지만 strip한 실행파일보다도 작습니다.

rpm이 알아서 각종 불필요한 코드들을 제거하는건지....

그럼 고수님들의 답변 기다리겠습니다.

ai의 이미지

버그소년 wrote:
그런데 설정파일과 같은 것들을 설치시 질의응답을 받아 해결하고 싶어서

%pre에 스크립트를 작성해서 넣었습니다.

스크립트 중간중간에 read를 해서 사용자로부터 값을 입력받는데요..

rpm설치시 read가 먹지않고 그냥 지나갑니다.

원래 불가능한것인지 .. 아니면 다른 방법이 있는지 궁급합니다.

사용자 입력을 받으시려는 시점이 srpm 빌드 과정에서인지, 아니면 생성된 binary rpm 설치 과정에서인지 분명하지 않네요. 만약 binary rpm 설치중에 사용자 입력을 받으시려고 한다면, 이쪽으로는 안되는 것 같습니다. (rpm 은 dpkg 와 다르게 interactive user input 을 받으면서 설치하는 것을 고려하지 않는 것으로 알고 있습니다.) 몇 가지 트릭을 사용한다면 꼭 안된다고만은 할 수 없겠지만... 일단은 그러네요.

한편 .spec 파일은 srpm 빌드시에 스테이지별마다 shell script 로 확장되어서 실행되기 때문에 %prep, %build, %install 등에서 (ba)sh 문법에 맞는 입력을 받을 수는 있습니다. 이를테면

%prep
read line
echo "user input : $line"

이런 형태로 사용자 입력을 읽어올 수 있습니다. 다만 shell script 로 확장되는 것은 각각의 스테이지이므로 %prep 에서 읽은 입력을 %build 로 넘긴다거나 하는 일은 안됩니다. 요컨데 shell 에서 받은 사용자 입력은 해당 스테이지 내에서만 유효합니다. (별도로 /var/tmp 등에 파일로 기록해놓고 다음 스테이지에서 읽어오지 않는다면 힘들지 않을까 생각되네요.) 참고로 srpm 빌드시이 나오는 메세지를 잘 읽어보시면 /var/tmp 또는 ~/rpm/tmp (정확히는 rpmmacros 파일에서 명시된 %_tmppath) 에 .spec 파일이 shell script 로 확장되어 실행됨을 알 수 있습니다. 이 파일을 직접 열어보시면 어떤 동작을 하고 있는지도 확인할 수 있구요.

버그소년 wrote:
그리고 또 한가지는 실행파일을 rpm으로 만들어 설치하고 나면

원본 실행파일보다 크기가 상당히 작아집니다.

위에서 .spec 파일이 srpm 빌드시에는 shell script 로 확장된다고 말씀드렸는데, 이 파일을 따라가보시면 실제 어떤 옵션으로 strip 되는지 알아볼 수 있습니다. 이를테면 제가 사용하는 맨드레이크에서는 %install 스테이지에서 파일들을 지정된 디렉터리로 복사한 다음 마지막에서
/usr/lib/rpm/brp-mandrake
라는 스크립트를 통해 여러가지 처리를 해 주는데, 이 스크립트를 열어보면

sh-2.05b$ cat /usr/lib/rpm/brp-mandrake
#!/bin/sh

# These are the build root policies that Mandrake Linux invokes at the end
# of the %install scriptlet.

if [ -x /usr/share/spec-helper/spec-helper ];then
    /usr/share/spec-helper/spec-helper
else
    # Compress man pages (Mandrake Linux uses GNU bzip2)
    /usr/lib/rpm/brp-compress

    # Strip ELF binaries (Mandrake Linux uses GNU binutils).
    /usr/lib/rpm/brp-strip

    # Strip even more sections (Mandrake Linux uses GNU binutils).
    /usr/lib/rpm/brp-strip-comment-note
fi

sh-2.05b$ ls /usr/share/spec-helper/spec-helper
/usr/share/spec-helper/spec-helper*

sh-2.05b$ cat /usr/share/spec-helper/spec-helper
[....]
test -z "$DONT_STRIP" && echo -n "Stripping files..." && strip_files && echo "done"
[....]

sh-2.05b$ cat /usr/share/spec-helper/strip_files
[....]
foreach (@shared_libs) {
    # Note that all calls to strip on shared libs
    # *must* inclde the --strip-unneeded.
    system("strip","--remove-section=.comment","--remove-section=.note","--strip-unneeded",$_);
}

foreach (@executables) {
    system("strip","--remove-section=.comment","--remove-section=.note",$_);
}
[....]

결국 실행파일의 경우에 --remove-section=.comment --remove-section=.note 옵션으로 strip 해주는군요. 시험삼아 srpm 에서 생성되는 실행파일을 이 옵션으로 strip 해보면 실제 빌드된 rpm 의 파일과 동일하다는 것을 알 수 있습니다. 사용하시는 시스템에 따라 위의 내용은 다를 수 있겠지만 기본 구조는 같을 것입니다.

War doesnt determine whos right, just whos left.

댓글 달기

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
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.