teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

3

微修正

2020/03/18 12:08

投稿

yay
yay

スコア17

answer CHANGED
@@ -62,10 +62,11 @@
62
62
  ```
63
63
  これで
64
64
  (すでに失敗した中身が何もないパッケージを削除してから)
65
- rpm -ivh hello-1.0-1.x86_64.rpm
65
+ RPMS$ rpm -ivh hello-1.0-1.x86_64.rpm
66
66
  とすると無事に
67
67
  /home/rpmbuilder/test/hello
68
68
  が作られました。
69
+ Hello World!
69
70
 
70
71
  最初マクロがいっぺんに出てきて混乱したが一つずつ覚えていけばそんなに大したこと言っていなかったという...
71
72
  定義とかすんなり頭に入る人になりたかった...。

2

微修正

2020/03/18 12:08

投稿

yay
yay

スコア17

answer CHANGED
@@ -33,7 +33,9 @@
33
33
 
34
34
  ### build info
35
35
  Source0: %{name}-%{version}.tar.gz
36
- BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root # この後ろのrootの意味は何なのかは不明
36
+ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root # この一番後ろの-rootの意味は何なのか。ここをルートにしますよっていう宣言として必要?
37
+
38
+
37
39
  %define INSTALLDIR %{buildroot}/home/rpmbuilder/test # 仮のルート(buildroot)+実際のインストール場所(/home/rpmbuilder/test)
38
40
 
39
41
  ### description

1

補足説明追加

2020/03/18 10:41

投稿

yay
yay

スコア17

answer CHANGED
@@ -1,5 +1,7 @@
1
+ * _tmppathマクロ:shが実際に処理するときに使う一時的なディレクトリの場所?どっか適当なところに置いといていいのかな。
1
2
  * BuildRoot
2
- パッケージ作成時仮ルートディレクトリで、実際に
3
+ パッケージ作成時にパッケージにするソース群をインストールしておく仮ルートディレクトリで、このサブディレクトリ以下がまるまるパッケージ化されるみたい。
4
+ ※ 特に何も指定していなかったのに勝手に後ろにx86_64がつくのは仕様なのかなぁ。
3
5
 
4
6
  * rpmパッケージ化の大まかな流れ
5
7
  1. %setup:$HOME/BUILD配下にSOURCEに置いたファイルを展開してそのディレクトリ(デフォルトで%{name}-%{version})に移動する
@@ -10,5 +12,58 @@
10
12
  3. %files:2で作った仮想ディレクトリにインストールしたファイルのパスをかく
11
13
  ※パスはbuildrootのサブディレクトリから書く(例えばINSTALLDIR(=%{buildroot}/hoge/piyo)にtestファイルを仮インストールしてるなら、/hoge/piyo/testと書く)
12
14
 
15
+ 以上を踏まえて、正しい設定ファイルを書くと以下。
16
+
17
+
18
+ ```
19
+ # Makefile
20
+ 今回要らなかったのでアーカイブから削除
21
+
22
+ # ~/.rpmmacros
23
+ そのまま
24
+
25
+ # ~/rpmbuild/SPEC/sample.spec
26
+
27
+ ### basic info
28
+ Name: hello
29
+ Version: 1.0
30
+ Release: 1
31
+ Summary: sample hello world program
32
+ License: GPL2
33
+
34
+ ### build info
35
+ Source0: %{name}-%{version}.tar.gz
36
+ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root # この後ろのrootの意味は何なのかは不明
37
+ %define INSTALLDIR %{buildroot}/home/rpmbuilder/test # 仮のルート(buildroot)+実際のインストール場所(/home/rpmbuilder/test)
38
+
39
+ ### description
40
+ %description
41
+ sample code
42
+
43
+ ### script
44
+ %prep
45
+ rm -rf %{buildroot}
46
+
47
+ %setup -q
48
+
49
+ %build
50
+
51
+ %install
52
+ rm -rf %{buildroot}
53
+ mkdir %{buildroot}
54
+ mkdir -p %{INSTALLDIR}
55
+ cp -r %{_builddir}/%{name}-%{version}/hello %{INSTALLDIR}/
56
+
57
+ %files
58
+ /home/rpmbuilder/test/hello
59
+
60
+ ```
61
+ これで
62
+ (すでに失敗した中身が何もないパッケージを削除してから)
63
+ rpm -ivh hello-1.0-1.x86_64.rpm
64
+ とすると無事に
65
+ /home/rpmbuilder/test/hello
66
+ が作られました。
67
+
13
68
  最初マクロがいっぺんに出てきて混乱したが一つずつ覚えていけばそんなに大したこと言っていなかったという...
14
69
  定義とかすんなり頭に入る人になりたかった...。