Creating a Virtual Java RPM

javaSome RPMs (e.g.’s tomcat7-7.0.39-1.jpp6.noarch.rpm) express their dependency upon Java by requiring a RPM that provides capability java (as opposed to, for example, depending on the existence of a file /usr/bin/java). On CentOS, this capability is normally provided by the java-*-openjdk RPM. Therefore, if you execute # yum install tomcat7 on a clean install of CentOS, yum will install OpenJDK in addition to Tomcat 7.

Some people prefer to run the Oracle JRE/JDK instead of OpenJDK. Oracle provides RPMs named jre-version-linux-x64.rpm and jdk-version-linux-x64.rpm to make installing them easier. Unfortunately, these RPMs do not provide the capability java. This means that if you already have the Oracle JRE installed, and you install a RPM which requires the capability java, the OpenJDK will be unnecessarily installed (and might even become the default!).

I solved this dilemma by creating a ‘virtual’ RPM package which provides the capability java by depending on the Oracle JRE. I named this package virtual-java.

Creating this package is quite easy. First I created a Makefile to make building the RPM easier and deal with rpmbuild’s nonsense regarding _topdir:


.PHONY: all
all: dist/$(RPMNAME)

.PHONY: clean
	rm -rf work
	rm -rf dist

dist/$(RPMNAME): work/RPMS/noarch/$(RPMNAME) dist
	cp work/RPMS/noarch/$(RPMNAME) dist/$(RPMNAME)

work/RPMS/noarch/$(RPMNAME): work/BUILD work/RPMS/noarch work/SPECS/virtual-java.spec
	rpmbuild -bb --define="_topdir ${PWD}/work" work/SPECS/virtual-java.spec

work/SPECS/virtual-java.spec: work/SPECS virtual-java.spec
	cat virtual-java.spec | sed -e s/%VERSION%/$(VERSION)/g | sed -e s/%RELEASE%/$(RELEASE)/g > work/SPECS/virtual-java.spec

	if [ ! -d dist ]; then mkdir -p dist; fi
	touch dist
	if [ ! -d work/BUILD ]; then mkdir -p work/BUILD; fi
	touch work/BUILD
	if [ ! -d work/RPMS/noarch ]; then mkdir -p work/RPMS/noarch; fi
	touch work/RPMS/noarch
	if [ ! -d work/SPECS ]; then mkdir -p work/SPECS; fi
	touch work/SPECS

Note how the Makefile defines VERSION and RELEASE, and provides them to the .spec file. This is done because the Makefile needs to know the name of the generated RPM file, which depends on VERSION and RELEASE.

Here is virtual-java.spec:

Name: virtual-java
Version: %VERSION%
Release: %RELEASE%
Summary: Virtual package which provides java but uses the Sun/Oracle JRE
License: None
BuildArch: noarch
Provides: java
Requires: jre > %VERSION%

Virtual package which provides java but uses the Sun/Oracle JRE








Booting an Acer Aspire easyStore H340 from External USB

440x330-easystoreA couple of years ago I bought a Acer Aspire easyStore H340 to use as a home NAS device.  While the H340 came with Windows Server, I decided to replace it with Debian Linux running on an external USB stick.  Besides using it for basic file storage, I use Nginx to stream MP4s to Roku devices throughout my home using Roksbox; I use forked-daapd to stream FLACs to iTunes (albeit with limited success – foobar2000 pointing to the CIFS file share works better); and I use CrashPlan to back up my important data (e.g. pictures) to the Internet.

Two days ago, S.M.A.R.T. indicated that hard drive which originally came with the machine was failing, so I replaced it with a spare I had on-hand.  I replaced the hard drive, rebuilt the RAID5 array, and everything seemed fine.  However, after upgrading Debian to the latest kernel, the machine failed to boot.

I attached my VGA debugging cable and determined that the machine appeared to be having issues with the boot order.  Using the H340 service manual as a reference, I attached a spare jumper to JP3 and changed the boot order in the BIOS.  I heard that if you removed this jumper the machine would restore to its default boot order, so I left the jumper in and put everything back.

Mission accomplished.