CentOS7では標準リポジトリに、AlmaLinux8ではepelにあったlog4cxxやlog4cxx-develパッケージが遂に無くなってしまったので、自分で作る。
準備
用意するもの
- 最小構成でセットアップしたEL9互換OS
- AlmaLinux 9.1で確認したけど、Rocky Linux 9.1でもいけるはず
- x86_64で確認した、他のアーキテクチャでは分からない
必要パッケージ追加
$ sudo dnf install tar rpmdevtools rpm-build apr-devel apr-util-devel gcc-c++
doxygen
doxygenが必要だけど、これもパッケージが無くなってしまったので、ダウンロードページからバイナリ版を取得して使う
$ curl -OL https://www.doxygen.nl/files/doxygen-1.9.6.linux.bin.tar.gz
$ tar xzf doxygen-1.9.6.linux.bin.tar.gz
$ mkdir ~/bin
$ ln -s ~/doxygen-1.9.6/bin/* ~/bin/
バージョン確認
$ doxygen -v
1.9.6 (4586b5cfaa3d46d51f6a51882951d15644c49edf)
RPM作成
EL8用のlog4cxx-0.10.0-31.el8.src.rpmから取り出したspecファイルを参考に少し修正した log4cxx-0.10.0.spec
↓を使う
Name: log4cxx
Version: 0.10.0
Release: 1%{?dist}
Summary: A port to C++ of the Log4j project
License: ASL 2.0
URL: https://logging.apache.org/log4cxx/latest_stable/index.html
Source0: https://archive.apache.org/dist/logging/%{name}/%{version}/apache-%{name}-%{version}.tar.gz
# Filed into upstream bugtracker at:
# https://issues.apache.org/jira/browse/LOGCXX-332
Patch0: https://issues.apache.org/jira/secure/attachment/12406451/log4cxx-cstring.patch
# From Debian:
# https://salsa.debian.org/debian/log4cxx/-/tree/debian/0.10.0-16/debian/patches
Patch1: https://salsa.debian.org/debian/log4cxx/-/raw/debian/0.10.0-16/debian/patches/170-gcc6-fix-LOGCXX-482.patch
Patch2: https://salsa.debian.org/debian/log4cxx/-/raw/debian/0.10.0-16/debian/patches/180-gcc-fix-testsuite-LOGCXX-400.patch
BuildRequires: apr-devel
BuildRequires: apr-util-devel
#BuildRequires: doxygen
BuildRequires: gcc-c++
%description
Log4cxx is a popular logging package written in C++. One of its distinctive
features is the notion of inheritance in loggers. Using a logger hierarchy it
is possible to control which log statements are output at arbitrary
granularity. This helps reduce the volume of logged output and minimize the
cost of logging.
%package devel
Requires: %{name}%{?_isa} = %{version}-%{release}
Summary: Header files for Log4xcc - a port to C++ of the Log4j project
%description devel
Header files and documentation you can use to develop with %{name}.
%package doc
Summary: Documentation for %{name}
BuildArch: noarch
%description doc
Documentation for %{name}.
%prep
%setup -q -n apache-%{name}-%{version}
%patch0 -p1
%patch1 -p1
%patch2 -p1
%build
sed -i.libdir_syssearch -e \
'/sys_lib_dlsearch_path_spec/s|/usr/lib |/usr/lib /usr/lib64 /lib /lib64 |' \
configure
%configure --disable-static
sed -i -e 's! -shared ! -Wl,--as-needed\0!g' libtool
%make_build
%install
make install DESTDIR=$RPM_BUILD_ROOT INSTALL="install -p"
mv $RPM_BUILD_ROOT%{_datadir}/%{name}/html .
rm $RPM_BUILD_ROOT/%{_libdir}/liblog4cxx.la
%files
%{_libdir}/liblog4cxx.so.10.0.0
%{_libdir}/liblog4cxx.so.10
%doc NOTICE KEYS
%license LICENSE
%files devel
%{_includedir}/log4cxx
%{_libdir}/liblog4cxx.so
%{_libdir}/pkgconfig/liblog4cxx.pc
%files doc
%license LICENSE
%doc html/
ディレクトリ作成して、
$ rpmdev-setuptree
ソースダウンロードして、
$ spectool -gR ~/log4cxx-0.10.0.spec
rpm作成
$ rpmbuild -bb ~/log4cxx-0.10.0.spec
こんな感じに出来上がる
$ ls -lh ~/rpmbuild/RPMS/*
/home/nissy/rpmbuild/RPMS/noarch:
合計 616K
-rw-r--r--. 1 nissy nissy 616K 1月 31 21:21 log4cxx-doc-0.10.0-1.el9.noarch.rpm
/home/nissy/rpmbuild/RPMS/x86_64:
合計 3.5M
-rw-r--r--. 1 nissy nissy 446K 1月 31 21:21 log4cxx-0.10.0-1.el9.x86_64.rpm
-rw-r--r--. 1 nissy nissy 2.7M 1月 31 21:21 log4cxx-debuginfo-0.10.0-1.el9.x86_64.rpm
-rw-r--r--. 1 nissy nissy 217K 1月 31 21:21 log4cxx-debugsource-0.10.0-1.el9.x86_64.rpm
-rw-r--r--. 1 nissy nissy 125K 1月 31 21:21 log4cxx-devel-0.10.0-1.el9.x86_64.rpm
$ rpm -qi ~/rpmbuild/RPMS/x86_64/log4cxx-0.10.0-1.el9.x86_64.rpm
Name : log4cxx
Version : 0.10.0
Release : 1.el9
Architecture: x86_64
Install Date: (not installed)
Group : Unspecified
Size : 1684090
License : ASL 2.0
Signature : (none)
Source RPM : log4cxx-0.10.0-1.el9.src.rpm
Build Date : 2023年01月31日 21時19分28秒
Build Host : build01
URL : https://logging.apache.org/log4cxx/latest_stable/index.html
Summary : A port to C++ of the Log4j project
Description :
Log4cxx is a popular logging package written in C++. One of its distinctive
features is the notion of inheritance in loggers. Using a logger hierarchy it
is possible to control which log statements are output at arbitrary
granularity. This helps reduce the volume of logged output and minimize the
cost of logging.