Chef installation problem: chef-solr depends on solr-jetty which is not in apt repository on Debian squeeze

When I was trying to install chef-server on Debian(squeeze) through this guide, I got a package dependency error like following:

~# aptitude install chef chef-server
The following NEW packages will be installed:
binutils{a} build-essential{a} bzip2{a} ca-certificates-java{a} chef chef-expander{a} chef-server chef-server-api{a}
chef-server-webui{a} chef-solr{ab} couchdb{a} cpp{a} cpp-4.4{a} dbus{a} default-jre-headless{a} dpkg-dev{a} erlang-base{a}
erlang-crypto{a} erlang-inets{a} erlang-mnesia{a} erlang-os-mon{a} erlang-public-key{a} erlang-runtime-tools{a} erlang-snmp{a}
erlang-ssl{a} erlang-syntax-tools{a} erlang-tools{a} erlang-webtool{a} erlang-xmerl{a} fakeroot{a} fontconfig{a} fontconfig-config{a}
g++{a} g++-4.4{a} gcc{a} gcc-4.4{a} java-common{a} javascript-common{a} libabstract-ruby1.8{a} libaddressable-ruby{a}
libalgorithm-diff-perl{a} libalgorithm-diff-xs-perl{a} libalgorithm-merge-perl{a} libamqp-ruby{a} libasound2{a} libasyncns0{a}
libaudio2{a} libavahi-client3{a} libavahi-common-data{a} libavahi-common3{a} libboost-dev{a} libboost1.42-dev{a} libbunny-ruby{a}
libbunny-ruby1.8{a} libc-dev-bin{a} libc6-dev{a} libcap2{a} libcoderay-ruby{a} libcoderay-ruby1.8{a} libcups2{a}
libdaemons-ruby1.8{a} libdb4.7{a} libdbus-1-3{a} libdep-selector-ruby{a} libdpkg-perl{a} libdrm-intel1{a} libdrm-radeon1{a}
libdrm2{a} libem-http-request-ruby{a} liberubis-ruby{a} liberubis-ruby1.8{a} libescape-utils-ruby{a} libeventmachine-ruby{a}
libeventmachine-ruby1.8{a} libexpat1{a} libextlib-ruby{a} libextlib-ruby1.8{a} libfast-xs-ruby{a} libffi-ruby1.8{a} libffi5{a}
libflac8{a} libfontconfig1{a} libfssm-ruby1.8{a} libgecode-dev{a} libgecode27{a} libgl1-mesa-dev{a} libgl1-mesa-dri{a}
libgl1-mesa-glx{a} libglib2.0-0{a} libglib2.0-data{a} libglu1-mesa{a} libglu1-mesa-dev{a} libgmp3c2{a} libgomp1{a} libhaml-ruby1.8{a}
libhighline-ruby{a} libhighline-ruby1.8{a} libhmac-ruby1.8{a} libice6{a} libicu44{a} libinotify-ruby1.8{a} libjpeg62{a}
libjs-jquery{a} libjson-ruby{a} libjson-ruby1.8{a} liblcms1{a} libmerb-assets-ruby{a} libmerb-assets-ruby1.8{a}
libmerb-core-ruby1.8{a} libmerb-haml-ruby{a} libmerb-haml-ruby1.8{a} libmerb-helpers-ruby{a} libmerb-helpers-ruby1.8{a}
libmerb-param-protection-ruby{a} libmerb-param-protection-ruby1.8{a} libmime-types-ruby{a} libmixlib-authentication-ruby{a}
libmixlib-authentication-ruby1.8{a} libmixlib-cli-ruby{a} libmixlib-cli-ruby1.8{a} libmixlib-config-ruby{a}
libmixlib-config-ruby1.8{a} libmixlib-log-ruby{a} libmixlib-log-ruby1.8{a} libmng1{a} libmoneta-ruby{a} libmoneta-ruby1.8{a}
libmozjs2d{a} libmpfr4{a} libmysqlclient16{a} libnet-ssh-gateway-ruby1.8{a} libnet-ssh-multi-ruby{a} libnet-ssh-multi-ruby1.8{a}
libnet-ssh2-ruby{a} libnet-ssh2-ruby1.8{a} libnspr4-0d{a} libnss3-1d{a} libogg0{a} libohai-ruby{a} libohai-ruby1.8{a}
libopenid-ruby{a} libopenid-ruby1.8{a} libpcre3{a} libphonon4{a} libpng12-0{a} libpolyglot-ruby{a} libpthread-stubs0{a}
libpthread-stubs0-dev{a} libpulse-mainloop-glib0{a} libpulse0{a} libqt4-assistant{a} libqt4-dbus{a} libqt4-designer{a} libqt4-dev{a}
libqt4-help{a} libqt4-multimedia{a} libqt4-network{a} libqt4-opengl{a} libqt4-opengl-dev{a} libqt4-qt3support{a} libqt4-script{a}
libqt4-scripttools{a} libqt4-sql{a} libqt4-sql-mysql{a} libqt4-svg{a} libqt4-test{a} libqt4-webkit{a} libqt4-xml{a}
libqt4-xmlpatterns{a} libqtcore4{a} libqtgui4{a} librack-ruby{a} librack-ruby1.8{a} librb-inotify-ruby1.8{a} libreadline5{a}
librestclient-ruby{a} librestclient-ruby1.8{a} libruby1.8{a} libsctp1{a} libsm6{a} libsndfile1{a} libstdc++6-4.4-dev{a}
libsystemu-ruby1.8{a} libtiff4{a} libtimedate-perl{a} libtreetop-ruby{a} libuuidtools-ruby{a} libuuidtools-ruby1.8{a} libvorbis0a{a}
libvorbisenc2{a} libx11-dev{a} libxau-dev{a} libxcb1-dev{a} libxdamage1{a} libxdmcp-dev{a} libxfixes3{a} libxi6{a} libxml-ruby1.8{a}
libxml2{a} libxrender1{a} libxt6{a} libxtst6{a} libxxf86vm1{a} libyajl-ruby{a} linux-libc-dev{a} lksctp-tools{a} make{a}
manpages-dev{a} merb-core{a} mesa-common-dev{a} mysql-common{a} ohai{a} openjdk-6-jre-headless{a} openjdk-6-jre-lib{a} patch{a}
perl{a} perl-modules{a} qt4-qmake{a} qt4-qtconfig{a} rabbitmq-server{a} rake{a} ruby{a} ruby-ipaddress{a} ruby-mixlib-shellout{a}
ruby1.8{a} ruby1.8-dev{a} rubygems{a} rubygems1.8{a} sgml-base{a} shared-mime-info{a} thin{a} thin1.8{a} ttf-dejavu-core{a}
tzdata-java{a} unzip{a} wwwconfig-common{a} x11-common{a} x11proto-core-dev{a} x11proto-input-dev{a} x11proto-kb-dev{a} xml-core{a}
xtrans-dev{a} zip{a}
0 packages upgraded, 243 newly installed, 0 to remove and 0 not upgraded.
Need to get 176 MB of archives. After unpacking 556 MB will be used.
The following packages have unmet dependencies:
chef-solr: Depends: solr-jetty (>= 1.4.0) which is a virtual package.
The following actions will resolve these dependencies:

Keep the following packages at their current version:
1) chef-expander [Not Installed]
2) chef-server [Not Installed]
3) chef-server-api [Not Installed]
4) chef-server-webui [Not Installed]
5) chef-solr [Not Installed]

Accept this solution? [Y/n/q/?]

It seems that solr-jetty does not exist in APT repos. However it’s listed in the repos for sid.
According to this page, we can use the repos for squeeze by opscode.
Thus just add this line to /etc/apt/sources.list:

deb http://apt.opscode.com/ squeeze main

Then I’ve got solved the problem. Following is the result:

~# aptitude update
~# aptitude install chef chef-server
The following NEW packages will be installed:
ant{a} ant-optional{a} apache2-utils{a} binutils{a} build-essential{a} bzip2{a} ca-certificates-java{a} chef chef-expander{a}
chef-server chef-server-api{a} chef-server-webui{a} chef-solr{a} couchdb{a} cpp{a} cpp-4.4{a} dbus{a} default-jre-headless{a} defoma{a}
dpkg-dev{a} erlang-base{a} erlang-crypto{a} erlang-inets{a} erlang-mnesia{a} erlang-os-mon{a} erlang-public-key{a}
erlang-runtime-tools{a} erlang-snmp{a} erlang-ssl{a} erlang-syntax-tools{a} erlang-tools{a} erlang-webtool{a} erlang-xmerl{a}
fakeroot{a} fontconfig{a} fontconfig-config{a} g++{a} g++-4.4{a} gcc{a} gcc-4.4{a} gcj-4.4-base{a} gcj-4.4-jre-lib{a} glassfish-mail{a}
hicolor-icon-theme{a} java-common{a} javascript-common{a} jetty{a} jsvc{a} libabstract-ruby1.8{a} libaccess-bridge-java{a}
libaccess-bridge-java-jni{a} libaddressable-ruby{a} libalgorithm-diff-perl{a} libalgorithm-diff-xs-perl{a} libalgorithm-merge-perl{a}
libamqp-ruby{a} libapr1{a} libaprutil1{a} libasound2{a} libasyncns0{a} libatk1.0-0{a} libatk1.0-data{a} libaudio2{a} libavahi-client3{a}
libavahi-common-data{a} libavahi-common3{a} libbcel-java{a} libboost-dev{a} libboost1.42-dev{a} libbunny-ruby{a} libbunny-ruby1.8{a}
libc-dev-bin{a} libc6-dev{a} libcairo2{a} libcap2{a} libcoderay-ruby{a} libcoderay-ruby1.8{a} libcommons-beanutils-java{a}
libcommons-codec-java{a} libcommons-collections3-java{a} libcommons-compress-java{a} libcommons-csv-java{a} libcommons-daemon-java{a}
libcommons-dbcp-java{a} libcommons-digester-java{a} libcommons-fileupload-java{a} libcommons-httpclient-java{a} libcommons-io-java{a}
libcommons-logging-java{a} libcommons-pool-java{a} libcups2{a} libdaemons-ruby1.8{a} libdatrie1{a} libdb-je-java{a} libdb4.7{a}
libdb4.7-java{a} libdb4.7-java-gcj{a} libdbus-1-3{a} libdep-selector-ruby{a} libdpkg-perl{a} libdrm-intel1{a} libdrm-radeon1{a}
libdrm2{a} libecj-java{a} libem-http-request-ruby{a} liberubis-ruby{a} liberubis-ruby1.8{a} libescape-utils-ruby{a}
libeventmachine-ruby{a} libeventmachine-ruby1.8{a} libexpat1{a} libextlib-ruby{a} libextlib-ruby1.8{a} libfast-xs-ruby{a}
libffi-ruby1.8{a} libffi5{a} libflac8{a} libfont-freetype-perl{a} libfontconfig1{a} libfontenc1{a} libfssm-ruby1.8{a} libgcj-bc{a}
libgcj-common{a} libgcj10{a} libgecode-dev{a} libgecode27{a} libgeronimo-jta-1.0.1b-spec-java{a} libgif4{a} libgl1-mesa-dev{a}
libgl1-mesa-dri{a} libgl1-mesa-glx{a} libglib2.0-0{a} libglib2.0-data{a} libglu1-mesa{a} libglu1-mesa-dev{a} libgmp3c2{a}
libgnuinet-java{a} libgnujaf-java{a} libgnumail-java{a} libgomp1{a} libgtk2.0-0{a} libgtk2.0-bin{a} libgtk2.0-common{a}
libhaml-ruby1.8{a} libhighline-ruby{a} libhighline-ruby1.8{a} libhmac-ruby1.8{a} libice6{a} libicu44{a} libicu4j-java{a}
libinotify-ruby1.8{a} libjasper1{a} libjaxp1.3-java{a} libjaxp1.3-java-gcj{a} libjetty-extra{a} libjetty-extra-java{a} libjetty-java{a}
libjline-java{a} libjpeg62{a} libjs-jquery{a} libjson-ruby{a} libjson-ruby1.8{a} libjtidy-java{a} liblcms1{a} liblog4j1.2-java{a}
liblog4j1.2-java-gcj{a} liblucene2-java{a} libmerb-assets-ruby{a} libmerb-assets-ruby1.8{a} libmerb-core-ruby1.8{a} libmerb-haml-ruby{a}
libmerb-haml-ruby1.8{a} libmerb-helpers-ruby{a} libmerb-helpers-ruby1.8{a} libmerb-param-protection-ruby{a}
libmerb-param-protection-ruby1.8{a} libmime-types-ruby{a} libmixlib-authentication-ruby{a} libmixlib-authentication-ruby1.8{a}
libmixlib-cli-ruby{a} libmixlib-cli-ruby1.8{a} libmixlib-config-ruby{a} libmixlib-config-ruby1.8{a} libmixlib-log-ruby{a}
libmixlib-log-ruby1.8{a} libmng1{a} libmoneta-ruby{a} libmoneta-ruby1.8{a} libmozjs2d{a} libmpfr4{a} libmx4j-java{a} libmysqlclient16{a}
libnet-ssh-gateway-ruby1.8{a} libnet-ssh-multi-ruby{a} libnet-ssh-multi-ruby1.8{a} libnet-ssh2-ruby{a} libnet-ssh2-ruby1.8{a}
libnspr4-0d{a} libnss3-1d{a} libogg0{a} libohai-ruby{a} libohai-ruby1.8{a} libopenid-ruby{a} libopenid-ruby1.8{a} libpango1.0-0{a}
libpango1.0-common{a} libpcre3{a} libphonon4{a} libpixman-1-0{a} libpng12-0{a} libpolyglot-ruby{a} libportlet-api-2.0-spec-java{a}
libpthread-stubs0{a} libpthread-stubs0-dev{a} libpulse-mainloop-glib0{a} libpulse0{a} libqt4-assistant{a} libqt4-dbus{a}
libqt4-designer{a} libqt4-dev{a} libqt4-help{a} libqt4-multimedia{a} libqt4-network{a} libqt4-opengl{a} libqt4-opengl-dev{a}
libqt4-qt3support{a} libqt4-script{a} libqt4-scripttools{a} libqt4-sql{a} libqt4-sql-mysql{a} libqt4-svg{a} libqt4-test{a}
libqt4-webkit{a} libqt4-xml{a} libqt4-xmlpatterns{a} libqtcore4{a} libqtgui4{a} librack-ruby{a} librack-ruby1.8{a}
librb-inotify-ruby1.8{a} libreadline5{a} libregexp-java{a} librestclient-ruby{a} librestclient-ruby1.8{a} libruby1.8{a} libsctp1{a}
libservlet2.5-java{a} libslf4j-java{a} libsm6{a} libsndfile1{a} libstdc++6-4.4-dev{a} libsystemu-ruby1.8{a} libthai-data{a} libthai0{a}
libtiff4{a} libtimedate-perl{a} libtomcat6-java{a} libtreetop-ruby{a} libuuidtools-ruby{a} libuuidtools-ruby1.8{a} libvorbis0a{a}
libvorbisenc2{a} libx11-dev{a} libxau-dev{a} libxcb-render-util0{a} libxcb-render0{a} libxcb1-dev{a} libxcomposite1{a} libxcursor1{a}
libxdamage1{a} libxdmcp-dev{a} libxerces2-java{a} libxerces2-java-gcj{a} libxfixes3{a} libxfont1{a} libxft2{a} libxi6{a} libxinerama1{a}
libxml-commons-external-java{a} libxml-ruby1.8{a} libxml2{a} libxrandr2{a} libxrender1{a} libxt6{a} libxtst6{a} libxxf86vm1{a}
libyajl-ruby{a} linux-libc-dev{a} lksctp-tools{a} make{a} manpages-dev{a} merb-core{a} mesa-common-dev{a} mime-support{a}
mysql-common{a} ohai{a} openjdk-6-jre{a} openjdk-6-jre-headless{a} openjdk-6-jre-lib{a} patch{a} perl{a} perl-modules{a} python{a}
python-minimal{a} python2.6{a} python2.6-minimal{a} qt4-qmake{a} qt4-qtconfig{a} rabbitmq-server{a} rake{a} ruby{a} ruby-ipaddress{a}
ruby-mixlib-shellout{a} ruby1.8{a} ruby1.8-dev{a} rubygems{a} rubygems1.8{a} sgml-base{a} shared-mime-info{a} solr-common{a}
solr-jetty{a} thin{a} thin1.8{a} ttf-dejavu-core{a} ttf-dejavu-extra{a} tzdata-java{a} unzip{a} wwwconfig-common{a} x-ttcidfont-conf{a}
x11-common{a} x11proto-core-dev{a} x11proto-input-dev{a} x11proto-kb-dev{a} xfonts-encodings{a} xfonts-utils{a} xml-core{a}
xtrans-dev{a} zip{a}
0 packages upgraded, 338 newly installed, 0 to remove and 0 not upgraded.
Need to get 258 MB of archives. After unpacking 749 MB will be used.
Do you want to continue? [Y/n/?]

Automatically loading iPhone 5-sized images where required

You’ll be familiar with the way that [UIImage imageNamed:] automatically loads @2x versions of images when running on a retina device.
Unfortunately, imageNamed: will NOT automatically load -586h@2x versions of images when running on an iPhone 5.

Sometimes this doesn’t matter, for example icons and non-full screen graphics are probably the same on iPhone 4 & 5. However, if you have full-screen background images, or full-width / height background images for toolbars etc you will have problems. Your 480-high images will most likely get stretched (and will probably look horrid as a result).

There is a better way to load automatically -586@2x versions of images(if available) than manually checking the screen size.
Here is a category named Retina4 of UIImage to do exactly this thing.

https://gist.github.com/3784303.js?file=UIImageRetina4.h

https://gist.github.com/3784303.js?file=UIImageRetina4.m

This code is originally made by Benjamin Stahlhood though I fixed below problems that are existed in original version.

  • Replacing imageNamed: method for retina4 is executed multiple times. So retina4ImageNamed: is never called in some cases.
  • The scale property of UIImage is set to 1.0f instead of 2.0f because the filename is specified with “@2x”.

ZenPlayer for iOS

What’s this?

ZenPlayer is originally designed by simurai with CSS3 and JavaScript.
I like this design so I rebuilt ZenPlayer with objective-c using ARC(Auto Reference Counting) for my application called walknote.
Its graphics are re-drawn in bigger size, so it’s suitable on retina display.

Screenshots

screenshot01

screenshot02

Source on GitHub

It would be helpful for someone who wants to implement cool design button with animation like ZenPlayer.
Here I posted it on GitHub:

https://github.com/noradaiko/ZenPlayer-for-iOS

Any comments and forks would be welcome.

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.

The hierarchy of UIImagePickerController

You can get the hierarchy of subviews on UIImagePickerController with this code.

// Recursive enumerate subviews to get hierarchy of camera view.
- (BOOL)enumSubviews:(UIView*)view withNest:(int)idx
{
	Class cl = [view class];
	char sp[255]; 
	memset(sp, ' ', 255);
	sp[idx*4] = 0;

	NSLog(@"%s%@n", sp, NSStringFromClass(cl));

	for (int i = 0; i < [view.subviews count]; i++)
	{
		if ([self enumSubviews:[view.subviews objectAtIndex:i] withNest:idx+1])
			return YES;
	}

	return NO;
}

And here is a result.

PLCameraView
    PLPreviewView
        PLCameraFocusView
    UIImageView
    PLCropOverlay
        OverlayView
        PLCropOverlayBottomBar
            UIImageView
                PLCropOverlayBottomBarButton
                    UIImageView
                    UIButtonLabel
                PLCropOverlayBottomBarButton
                    UIImageView
                    UIButtonLabel
            UIImageView
                PLCameraButton
                    UIView
                        UIImageView
                PLCropOverlayBottomBarButton
                    UIImageView
                    UIButtonLabel
    UIImageView

One of UIImageView has photo taken. Keep exploring..