Building debian package for phpredis

Background

phpredis is one of major library for using redis on PHP. It bundles a shell script to build debian package, so by using this you can easily do package-based server management.
However there’s two problem when you built the package with the script.

Two problems of the debian package built with bundled script

The first problem is that the installation fails because of following reason:

% sudo dpkg -i phpredis-x86_64.deb
(Reading database ... 42333 files and directories currently installed.)
Unpacking phpredis (from phpredis-x86_64.deb) ...
dpkg: error processing phpredis-x86_64.deb (--install):
 unable to open '/etc/php5/apache2/conf.d/redis.ini.dpkg-new': No such file or directory
Errors were encountered while processing:
 phpredis-x86_64.deb

The second problem is that the target architecture(e.g. amd64, i386) is not specified correctly.
It is specified as ‘any’. So if you have multiple architecture type in your operating servers, it will cause on deployment.

In next section, I explain how to fix there problems.

How to solve

  1. open ‘mkdeb-apache2.sh’
  2. Comment below line out
     28 dpkg -b debian phpredis-`uname -m`.deb
     29 #rm -rf debian/ # comment this line out
    
  3. Run it.
    % ./mkdeb-apache2.sh
  4. After running the script, you will get ‘debian’ directory as below:
    % ls -l
    debian/
    
    % ls debian/
    DEBIAN/  etc/  usr/
    
  5. Make ‘conffiles’ with below command:
    % echo "/etc/php5/apache2/conf.d/redis.ini" > debian/DEBIAN/conffiles
  6. Edit ‘Architecture’ field in ‘debian/DEBIAN/control’ file to your build environment architecture.
    Package: phpredis
    Version: 1.0
    Section: web 
    Priority: optional
    #Architecture: any
    Architecture: amd64    # edited
    Essential: no
    Depends: 
    Pre-Depends: 
    Recommends: php5
    Suggests: 
    Installed-Size: 
    Maintainer: Nicolas Favre-Felix [n.favre-felix@owlient.eu]
    Conflicts: 
    Replaces: 
    Provides: phpredis
    Description: Redis C extension for PHP5.
    
  7. Okay, now you can build again and get a package as you expected with this command!
    % dpkg -b debian phpredis-`uname -m`.deb
    
  8. Finally you get debian package named like this:
    phpredis-x86_64.deb

Hopes this helps.

投稿者:

Takuya

Digital crafts(man|dog). Love photography. Always making otherwise sleeping. born in 1984.

コメントを残す

以下に詳細を記入するか、アイコンをクリックしてログインしてください。

WordPress.com ロゴ

WordPress.com アカウントを使ってコメントしています。 ログアウト /  変更 )

Google フォト

Google アカウントを使ってコメントしています。 ログアウト /  変更 )

Twitter 画像

Twitter アカウントを使ってコメントしています。 ログアウト /  変更 )

Facebook の写真

Facebook アカウントを使ってコメントしています。 ログアウト /  変更 )

%s と連携中