ルギア君の戯言

雑多な記事。

nonfree 化した ffmpeg の rpm を作成してみる

rpm spec ファイルの仕様は日々変化しており (BuildRoot: の扱いなど) 最新の rpm ではおそらく使えないものも多いと思います。
※ 2008/03/28 全ての spec 修正
ミスプリント一杯あるみたいです。発見したら訂正しますが、報告も待ってます(駄目すぎ


Momonga Linuxレポジトリに無い物も rpm を作成します。
OmoiKondara ではなく RpmBuild を使用します。
(Momonga の svn レポジトリにもないパッケージを作成するため)


nonfree 物は libamr-nb と libamr-wb です。



ffmpeg の spec は patch を、それ以外は新たに作成します。



ffmpeg のビルドには a52dec-devel が必要ですが、pirut や yum ではなぜか見付かりません(確か)ので、rpm をビルドするか、Momonga 本体のダウンロードページには a52dec-devel の rpm がありますのでそちらをダウンロードしてインストールしてください。


nut や gsm は本当は patch ファイルの方がいいかもしれませんが、面倒なので、自分で編集してください(駄

libdc1394

ソースは libdc1394-2.0.1.tar.gz を Sourceforge からダウンロードして使用してください。
*1


ライセンスは、調べたところ、LGPL でした。

%global momorel 1
%global src_year 2008
%global src_month 03
%global src_day 26
%global src_date %{src_year}-%{src_month}-%{src_day}
%global rel 0.%{src_year}%{src_month}%{src_day}.%{momorel}

Summary: 1394-Based Digital Camera Control Library
Name: libdc1394
Version: 2.0.1
%global src_name %{name}-%{version}
%global src_extract_name %{name}
Requires: libraw1394
BuildRoot: %{_tmppath}/%{name}-%{version}-root/
#Release: %{momorel}m%{?dist}
Release: %{rel}m%{?dist}
License: LGPL
Group: Development/Libraries
Source0: libdc1394-2.0.1.tar.gz

URL: http://damien.douxchamps.net/ieee1394/libdc1394/

### include local configuration
%{?include_specopt}

%description
libdc1394 is a library that provides a high level programming interface for application developers who wish to control IEEE 1394 based cameras that conform to the 1394-based Digital Camera Specifications (also known as the IIDC or DCAM Specifications)

%package devel
Summary: Header files and static library for the libdc1394 library
Group: Development/Libraries
Requires: %{name} = %{version}

%description devel
libdc1394 is a library that provides a high level programming interface for application developers who wish to control IEEE 1394 based cameras that conform to the 1394-based Digital Camera Specifications (also known as the IIDC or DCAM Specifications)

%prep
%setup
%build
./configure \
	--prefix=%{_prefix} \
	--libdir=%{_libdir} \
	--mandir=%{_mandir} \
	--includedir=%{_includedir} \
	 %{?extraconfopt}
%{__make} %{?_smp_mflags}

%install
rm -rf %{buildroot}
%makeinstall \
    incdir=%{buildroot}%{_includedir} \
    shlibdir=%{buildroot}%{_libdir} \
    libdir=%{buildroot}%{_libdir}

%clean
%{__rm} -rf %{buildroot}

%files
%defattr(-, root, root, 0755)
%doc ChangeLog COPYING AUTHORS README
%{_bindir}/*
%{_libdir}/*.so*
%{_mandir}/*

%files devel
%defattr(-, root, root, 0755)
%{_includedir}/dc1394/*
%{_libdir}/*.la
%{_libdir}/*.a
%{_libdir}/pkgconfig/*

大幅に改定したため、今度はちゃんとインストールできるはずです。

libnut

$ svn co svn://svn.mplayerhq.hu/nut/src/trunk libnut

を実行してダウンロードしてください。


このパッケージは configure スクリプトがないので、config.mak の 1 行目にある PREFIX をユーザー権限で書き込みのできる一時ディレクトリに変えて、最後に usr を付けてください。


例:

PREFIX = /var/tmp/libnut-root/usr


以下、SVN のリビジョンを r657 として説明します。
それ以上の SVN のリビジョンの方は、その部分を読み替えて使用してください。(spec ファイル内にもありますので要注意)
libnut.tar.gz に圧縮したのち、rpm/SOURCES ディレクトリに置きます。


config.mak を上のように変えた場合は、BuildRoot: の行を

BuildRoot: /var/tmp/libnut-root

というように最後の usr を削ったものを指定してください。


SVN-r657、PREFIX=/var/tmp/libnut-root/usr の場合

%global momorel 1
%global src_year 2008
%global src_month 03
%global src_day 26
%global src_date %{src_year}-%{src_month}-%{src_day}
%global rel 0.%{src_year}%{src_month}%{src_day}.%{momorel}

Summary: libnut is a free library for creating and demuxing NUT files.
Name: libnut
Version: r657
%global src_name %{name}-%{version}
%global src_extract_name %{name}
#Requires: none

#Release: %{momorel}m%{?dist}
Release: %{rel}m%{?dist}
License: free
Group: Development/Libraries
Source0: libnut.tar.gz
URL: http://www.nut-container.org/
BuildRoot: /var/tmp/libnut-root

### include local configuration
%{?include_specopt}

%description

%package devel
Summary: Development files for libnut.
License: free
Group: Development/Libraries
URL: http://www.nut-container.org/
Requires: %{name} == %{version}

%description devel
Development files for libnut.

%prep
%setup -q -n %{src_extract_name}
%build
make %{?_smp_mflags}

%install
make install

%clean
%{__rm} -rf %{buildroot}

%files
%defattr(-, root, root, 0755)
%doc README COPYING
%{_bindir}/*
%{_libdir}/*

%files devel
%{_includedir}/*

libgsm

http://kbs.cs.tu-berlin.de/~jutta/toast.html
から (free sorcecode のところ) gsm-1.0-pl12.tar.gz をダウンロードして、解凍してください。
こちらも configure スクリプトが用意されていませんので、Makefile を開き、INSTALL_ROOT = の行を探して編集します。
Momonga では man を /usr/share/man に多くは配置しているようなので*2GSM_INSTALL_MAN = と TOAST_INSTALL_MAN = の 2 行を変更してください。


それでもエラーになりますので、各インストール部分にある rm コマンド*3をコメントアウトし、インストールするディレクトリを作成しなければなりません。
できあがる Makefile はこのようになります。
途中省略してますので、上書きする場合は見間違えないように注意してください。
※「# これも追加」を削除しないと動きませんよ!

# Copyright 1992-1996 by Jutta Degener and Carsten Bormann, Technische
# Universitaet Berlin.  See the accompanying file "COPYRIGHT" for
# details.  THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.

# Machine- or installation dependent flags you should configure to port

# (中略)

# Where do you want to install libraries, binaries, a header file
# and the manual pages?
#
# Leave INSTALL_ROOT empty (or just don't execute "make install") to
# not install gsm and toast outside of this directory.

INSTALL_ROOT	= /var/tmp/gsm-root/usr

# Where do you want to install the gsm library, header file, and manpages?
#
# Leave GSM_INSTALL_ROOT empty to not install the GSM library outside of
# this directory.

GSM_INSTALL_ROOT = $(INSTALL_ROOT)
GSM_INSTALL_LIB = $(GSM_INSTALL_ROOT)/lib
GSM_INSTALL_INC = $(GSM_INSTALL_ROOT)/include
GSM_INSTALL_MAN = $(GSM_INSTALL_ROOT)/share/man/man3


# Where do you want to install the toast binaries and their manpage?
#
# Leave TOAST_INSTALL_ROOT empty to not install the toast binaries outside
# of this directory.

TOAST_INSTALL_ROOT	  = $(INSTALL_ROOT)
TOAST_INSTALL_BIN = $(TOAST_INSTALL_ROOT)/bin
TOAST_INSTALL_MAN = $(TOAST_INSTALL_ROOT)/share/man/man1

#  Other tools

# (中略)

#  Installation

gsminstall:
		-if [ x"$(GSM_INSTALL_ROOT)" != x ] ; then	\
			mkdir -p $(GSM_INSTALL_MAN) ;\  # これを追加
			mkdir -p $(GSM_INSTALL_INC) ;\
			mkdir -p $(GSM_INSTALL_LIB) ;\
			make $(GSM_INSTALL_TARGETS) ;	\
		fi

toastinstall:
		-if [ x"$(TOAST_INSTALL_ROOT)" != x ]; then	\
			mkdir -p $(TOAST_INSTALL_BIN) ;\ # これを追加
			mkdir -p $(TOAST_INSTALL_MAN) ;\
			make $(TOAST_INSTALL_TARGETS);	\
		fi

gsmuninstall:
		-if [ x"$(GSM_INSTALL_ROOT)" != x ] ; then	\
			rm $(RMFLAGS) $(GSM_INSTALL_TARGETS) ;	\
		fi

toastuninstall:
		-if [ x"$(TOAST_INSTALL_ROOT)" != x ] ; then 	\
			rm $(RMFLAGS) $(TOAST_INSTALL_TARGETS);	\
		fi

$(TOAST_INSTALL_BIN)/toast:	$(TOAST)
#		-rm $@
		cp $(TOAST) $@
		chmod 755 $@

$(TOAST_INSTALL_BIN)/untoast:	$(TOAST_INSTALL_BIN)/toast
#		-rm $@
		ln $? $@

$(TOAST_INSTALL_BIN)/tcat:	$(TOAST_INSTALL_BIN)/toast
#		-rm $@
		ln $? $@

$(TOAST_INSTALL_MAN)/toast.1:	$(MAN)/toast.1
#		-rm $@
		cp $? $@
		chmod 444 $@

$(GSM_INSTALL_MAN)/gsm.3:	$(MAN)/gsm.3
#		-rm $@
		cp $? $@
		chmod 444 $@

$(GSM_INSTALL_MAN)/gsm_option.3:	$(MAN)/gsm_option.3
#		-rm $@
		cp $? $@
		chmod 444 $@

$(GSM_INSTALL_MAN)/gsm_explode.3:	$(MAN)/gsm_explode.3
#		-rm $@
		cp $? $@
		chmod 444 $@

$(GSM_INSTALL_MAN)/gsm_print.3:	$(MAN)/gsm_print.3
#		-rm $@
		cp $? $@
		chmod 444 $@

$(GSM_INSTALL_INC)/gsm.h:	$(INC)/gsm.h
#		-rm $@
		cp $? $@
		chmod 444 $@

$(GSM_INSTALL_LIB)/libgsm.a:	$(LIBGSM)
#		-rm $@
		cp $? $@
		chmod 444 $@


# Distribution

# (以下略)


終わりましたら、元のように gsm-1.0-pl12.tar.gz というように圧縮し、rpm/SOURCES ディレクトリに配置します。


上の例のようにディレクトリを指定した場合の spec ファイル
上の例と異なるディレクトリの場合は、BuildRoot: のところを変えてください。

%global momorel 1
%global src_year 2008
%global src_month 03
%global src_day 26
%global src_date %{src_year}-%{src_month}-%{src_day}
%global rel 0.%{src_year}%{src_month}%{src_day}.%{momorel}

Summary: GSM is a lossy speech compression
Name: gsm
Version: 1.0
%global src_name %{name}-%{version}
%global src_extract_name %{name}
#Requires: none

#Release: %{momorel}m%{?dist}
Release: %{rel}m%{?dist}
License: nonfree
Group: Development/Libraries
Source0: gsm-1.0-pl12.tar.gz
URL: http://kbs.cs.tu-berlin.de/~jutta/toast.html
BuildRoot: /var/tmp/gsm-root

### include local configuration
%{?include_specopt}

%description

%package devel
Summary: Development files for gsm.
License: nonfree
Group: Development/Libraries
Requires: %{name} == %{version}

%description devel
Development files for gsm.

%prep
%setup -q -n %{src_name}-pl12
%build
make %{?_smp_mflags}

%install
make install

%clean
%{__rm} -rf %{buildroot}

%files
%defattr(-, root, root, 0755)
%doc README COPYRIGHT MACHINES MANIFEST ChangeLog
%{_bindir}/*
%{_libdir}/*
%{_mandir}/*

%files devel
%defattr(-, root, root, 0755)
%{_includedir}/*

libamr-nb, libamr-wb

http://www.penguin.cz/~utx/amr
から amrnb-7.0.0.1.tar.bz2 および amrwb-7.0.0.2.tar.bz2 をダウンロードしてください。
この 2つ のパッケージはそれぞれ別々なものですので、rpm もそれぞれ別に作成します。


今度は configure スクリプトを保持していますので、楽に作成できます。

amrnb の spec
%global momorel 1
%global src_year 2008
%global src_month 03
%global src_day 26
%global src_date %{src_year}-%{src_month}-%{src_day}
%global rel 0.%{src_year}%{src_month}%{src_day}.%{momorel}

Summary: Shared library of amr speech codec
Name: amrnb
Version: 7.0.0.1
%global src_name %{name}-%{version}
%global src_extract_name %{name}
# Requires: none
BuildRoot: %{_tmppath}/%{name}-%{version}-root/
#Release: %{momorel}m%{?dist}
Release: %{rel}m%{?dist}
License: nonfree
Group: Development/Libraries
Source0: amrnb-7.0.0.1.tar.bz2

URL: http://www.penguin.cz/~utx/amr

### include local configuration
%{?include_specopt}

%description
I created it to prevent ugly embedding of the same code to many Open Source projects and to maintain patches and fixes for it.

%package devel
Summary: Header files and static library for the libdc1394 library
Group: Development/Libraries
Requires: %{name} = %{version}

%description devel
libdc1394 is a library that provides a high level programming interface for application developers who wish to control IEEE 1394 based cameras that conform to the 1394-based Digital Camera Specifications (also known as the IIDC or DCAM Specifications)

%prep
%setup
%build
./configure \
	--prefix=%{_prefix} \
	--libdir=%{_libdir} \
	--mandir=%{_mandir} \
	--includedir=%{_includedir} \
	 %{?extraconfopt}
%{__make} %{?_smp_mflags}

%install
rm -rf %{buildroot}
%makeinstall \
    incdir=%{buildroot}%{_includedir} \
    shlibdir=%{buildroot}%{_libdir} \
    libdir=%{buildroot}%{_libdir}

%clean
%{__rm} -rf %{buildroot}

%files
%defattr(-, root, root, 0755)
%doc ChangeLog COPYING AUTHORS README
%{_bindir}/*
%{_libdir}/*.so*

%files devel
%defattr(-, root, root, 0755)
%{_includedir}/*
%{_libdir}/*.la
%{_libdir}/*.a
amrwb の spec
%global momorel 1
%global src_year 2008
%global src_month 03
%global src_day 26
%global src_date %{src_year}-%{src_month}-%{src_day}
%global rel 0.%{src_year}%{src_month}%{src_day}.%{momorel}

Summary: Shared library of amr speech codec
Name: amrwb
Version: 7.0.0.2
%global src_name %{name}-%{version}
%global src_extract_name %{name}
# Requires: none
BuildRoot: %{_tmppath}/%{name}-%{version}-root/
#Release: %{momorel}m%{?dist}
Release: %{rel}m%{?dist}
License: nonfree
Group: Development/Libraries
Source0: amrwb-7.0.0.2.tar.bz2

URL: http://www.penguin.cz/~utx/amr

### include local configuration
%{?include_specopt}

%description
I created it to prevent ugly embedding of the same code to many Open Source projects and to maintain patches and fixes for it.

%package devel
Summary: Header files and static library for the libdc1394 library
Group: Development/Libraries
Requires: %{name} = %{version}

%description devel
libdc1394 is a library that provides a high level programming interface for application developers who wish to control IEEE 1394 based cameras that conform to the 1394-based Digital Camera Specifications (also known as the IIDC or DCAM Specifications)

%prep
%setup
%build
./configure \
	--prefix=%{_prefix} \
	--libdir=%{_libdir} \
	--mandir=%{_mandir} \
	--includedir=%{_includedir} \
	 %{?extraconfopt}
%{__make} %{?_smp_mflags}

%install
rm -rf %{buildroot}
%makeinstall \
    incdir=%{buildroot}%{_includedir} \
    shlibdir=%{buildroot}%{_libdir} \
    libdir=%{buildroot}%{_libdir}

%clean
%{__rm} -rf %{buildroot}

%files
%defattr(-, root, root, 0755)
%doc ChangeLog COPYING AUTHORS README
%{_bindir}/*
%{_libdir}/*.so*

%files devel
%defattr(-, root, root, 0755)
%{_includedir}/*
%{_libdir}/*.la
%{_libdir}/*.a

amrnb を amrwb に変え、バージョンを修正しただけです。

lame

ffmpeg のビルドには lame-devel が必要ですので*4、Developer at Momonga Linux*5 の RpmBuild のページを参考に rpm を作成してください。


OmoiKondara でやりたい人は使っても構いませんが、時間がかかる&挫折する可能性があるので僕的にはお薦めできません。
(もちろん、Momonga Project は OmoiKondara の使用を薦めているようです。)

ffmpeg

おまちかね、最後になりました。
SVN-r12594 で解説します。
それより新しいバージョンの場合には、その部分は読み替えてください。

$ cd ~
$ svn co http://svn.momonga-linux.org/svn/pkgs/branches/STABLE_4/pkgs/ffmpeg ffmpeg.spec

し、ホームディレクトリで diff した場合の ~/rpm/SPECS/ffmpeg.spec への patch ファイルになります。


*1:あとで思ったのだが、たしかにこのライブラリは利用者が少ないと言うのも納得が行くかも。それで Momonga にはないのかな?

*2:おそらく /usr/man でも問題はない

*3:旧バージョンを削除するため?

*4:lame を make install した場合は ffmpeg の spec の BuildReq から lame-devel を消してください。

*5:URL は [http://developer.momonga-linux.org/wiki/?cmd=view&p=RpmBuildQuickStart]。