LoginSignup
2

More than 5 years have passed since last update.

rpm-build 4.11.x の入ったAmazon Linuxでのcheckinstall

Last updated at Posted at 2013-11-05

この記事を書いている時点の Amazon Linux で、rpm-build をインストールすると

rpm-build-4.11.1-3.49.amzn1.x86_64

というのが入ります。この 4.11 では、

という修正により、シンボリックリンクに対して spec ファイルにて

%dir /symbolic/link

のように記述してRPMを作成しようとすると

ビルド対象プラットフォーム: x86_64
ターゲット x86_64 用にビルド中
ファイルの処理中: hogehoge-1.1-1.x86_64
エラー: Not a directory: /var/tmp/tmp.MwR4KMsuLD/symbolic/link

RPM ビルドのエラー:
    Not a directory: /var/tmp/tmp.MwR4KMsuLD/symbolic/link

みたいな感じでエラーとなります。

これを回避するために、以下のようにcheckinstall本体にパッチをあててインストールする手順を記載します。

準備

必要な環境を準備します。

$ sudo yum -y install git make gettext gcc rpm-build
$ mkdir ~/src
$ cd ~/src
$ git clone http://checkinstall.izto.org/checkinstall.git
$ cd checkinstall

パッチ

64ビット向けの修正、および 4.11 での変更に対応するための修正をします。
以下のような修正点となります。

$ git diff
diff --git a/Makefile b/Makefile
index 2e28adc..b6d217c 100644
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,7 @@
 PREFIX=/usr/local
 BINDIR=$(PREFIX)/sbin
 LCDIR=$(PREFIX)/lib/checkinstall/locale
-CONFDIR=$(PREFIX)/lib/checkinstall
+CONFDIR=$(PREFIX)

 all:
        for file in locale/checkinstall-*.po ; do \
diff --git a/checkinstall b/checkinstall
index 978360f..69a0344 100755
--- a/checkinstall
+++ b/checkinstall
@@ -2428,7 +2428,7 @@ EOF
 # Prepare directories to be included in the .spec file
 mv ${TMP_DIR}/newfiles ${TMP_DIR}/newfiles.tmp
 cat ${TMP_DIR}/newfiles.tmp | while read line; do
-   [ -d "${BUILD_DIR}/${line}" -o -L "${BUILD_DIR}/${line}" ] && echo -n "%dir " >> ${TMP_DIR}/newfiles
+   [ -d "${BUILD_DIR}/${line}" ] && echo -n "%dir " >> ${TMP_DIR}/newfiles
    echo "\"/${line}\"" >> ${TMP_DIR}/newfiles
 done

diff --git a/checkinstallrc-dist b/checkinstallrc-dist
index d4feb4e..fe5f56e 100644
--- a/checkinstallrc-dist
+++ b/checkinstallrc-dist
@@ -117,7 +117,7 @@ RESET_UIDS=0
 NEW_SLACK=1

 # Comma delimited list of files/directories to be ignored
-EXCLUDE=""
+EXCLUDE="/selinux"

 # Accept default values for all questions?
 ACCEPT_DEFAULT=0
diff --git a/installwatch/Makefile b/installwatch/Makefile
index ae34fc1..fb41eb3 100644
--- a/installwatch/Makefile
+++ b/installwatch/Makefile
@@ -11,7 +11,7 @@ PREFIX=/usr/local
 VERSION=0.7.0beta7

 BINDIR=$(PREFIX)/bin
-LIBDIR=$(PREFIX)/lib
+LIBDIR=$(PREFIX)/lib64

 all: installwatch.so

インストール

$ make
$ sudo make install

checkinstallのRPM作成

この手順ではcheckinstallは/usr/local/sbinに入りますが、sudoするとパスが通っていないので、ec2-userの.bash_profileに下記を追記し、有効にしておきます。

/home/ec2-user/.bash_profile
alias sudo='sudo env PATH=$PATH'
$ . ~/.bash_profile

また、checkinstall自体は問題ないですが、他のRPM作成時に/usr/src/rpm配下に作成しようとするので、これを/root/rpmbuild配下に作成するように/root/.rpmmacrosを以下の内容で作成しておきます。

/root/.rpmmacros
%_topdir /root/rpmbuild 

その後、以下のようにしてcheckinstallのRPMを作成します。

$ sudo mkdir -p /root/rpmbuild/SOURCES
$ sudo rm /usr/local/checkinstallrc
$ cd ~/src/checkinstall
$ sudo checkinstall

いくつかの質問に答えると、checkinstallのPRMが作成されます。

これで、rpm-build 4.11 系に対応した checkinstall の RPM が完成です。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2