LoginSignup
3
3

More than 5 years have passed since last update.

lhaのrpmを作ってみる

Posted at

.lzh形式のファイルの圧縮・解凍をLinux上で行えるlhaのrpmを作ってみます。

参考にしたページ

前提

  • CentOS5 64bitで作業します。
  • rootで作業します。

準備

ビルドに必要なパッケージをインストールします。

yum -y install rpm-build make autoconf automake gcc glibc-devel

実行

cd /usr/src/redhat/SOURCES
curl -LO http://iij.dl.sourceforge.jp/lha/22231/lha-1.14i-ac20050924p1.tar.gz
cat <<'EOT'>header.patch
--- src/header.c.orig   2006-10-11 01:27:51.000000000 +0900
+++ src/header.c        2015-03-23 15:20:13.000000000 +0900
@@ -236,9 +236,11 @@
     }

     if (from_code == CODE_SJIS && to_code == CODE_UTF8) {
-        for (i = 0; i < len; i++)
+        for (i = 0; i < len; i++) {
             /* FIXME: provisionally fix for the Mac OS CoreFoundation */
             if ((unsigned char)name[i] == LHA_PATHSEP)  name[i] = '/';
+            else if ((unsigned char)name[i] == '\\')  name[i] = '/';
+        }
         sjis_to_utf8(tmp, name, sizeof(tmp));
         strncpy(name, tmp, size);
         name[size-1] = 0;
EOT
cd /usr/src/redhat/SPECS/
cat <<'EOT'>lha.spec
Summary: LHa for UNIX
Name: lha
Version: 1.14i
Release: ac20050924p1%{?dist}.fusic.1
License: distributable
Group: Applications/Archiving
Source: http://iij.dl.sourceforge.jp/lha/22231/lha-1.14i-ac20050924p1.tar.gz
URL: http://lha.sourceforge.jp/
Patch: header.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
BuildRequires: make autoconf automake gcc glibc-devel

%description
LHa for UNIX

%prep
%setup -n lha-1.14i-ac20050924p1
%patch -p0
mv man/lha.man man/lha.man.euc
iconv -f EUC-JP -t UTF8 man/lha.man.euc >man/lha.man
mv man/lha.n man/lha.n.euc
iconv -f EUC-JP -t UTF8 man/lha.n.euc >man/lha.n

%build
./configure --enable-multibyte-filename=utf8 --prefix=/usr --mandir=/usr/share/man
make

%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/usr/bin
mkdir -p $RPM_BUILD_ROOT/usr/share/man/mann

make prefix=$RPM_BUILD_ROOT/usr mandir=$RPM_BUILD_ROOT/usr/share/man install

pushd $RPM_BUILD_ROOT
for n in lha ; do
    chmod 755 ./usr/bin/$n
done
popd

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
/usr/bin/lha
/usr/share/man/mann/lha.n*

%changelog
* Mon Mar 23 2015 Tsuyoshi Sadakata <sadakata@fusic.co.jp>
- first release
EOT
rpmbuild --define 'dist .el5' -bb lha.spec

※ CentOS6の場合は↓でいけると思います。

rpmbuild -bb lha.spec

インストール

rpm -Uvh /usr/src/redhat/RPMS/`uname -m`/lha-1.14i-ac20050924p1.*.rpm
3
3
0

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
3
3