ceph 制作rpm过程(排错)

1 ceph0.72以后的源码制作成rpm包时,会出现错误;错误原因主要为:提供的cpec文件内;%file文件found,但没有在spec的%file文件内添加,添加后即可以正常编译;
2 ceph0.61.9版本中出现的问题较多;主要问题为:1 ceph源码构建rpm包,在ubuntu系统上构建的,在centos系统中出现以下问题:
报错为:

Processing files: cephfs-java-0.61.9-0.el6.x86_64
error: File not found: /root/rpmbuild/BUILDROOT/ceph-0.61.9-0.el6.x86_64/usr/share/java/libcephfs-test.jar

但在centos的架构下分析原因:
在src/java/Makefile.am文件下:

 if HAVE_JUNIT4
65 
66 JAVA_TEST_CLASSES = $(JAVA_TEST_SRC:test/%.java=%.class)
67 ESCAPED_JAVA_TEST_CLASSES = com/ceph/fs/CephAllTests\$$1.class
68 
69 CEPH_TEST_PROXY=test/com/ceph/fs/CephMountTest.class
70 
71 $(CEPH_TEST_PROXY): $(JAVA_TEST_SRC) $(CEPH_PROXY)
72 ▸       export CLASSPATH=$(CLASSPATH):$(EXTRA_CLASSPATH_JAR):java/:test/ ; \
73 ▸       $(JAVAC) -source 1.5 -target 1.5 -Xlint:-options test/com/ceph/fs/*.java
74 
75 libcephfs-test.jar: $(CEPH_TEST_PROXY)
76 ▸       $(JAR) cf $@ $(JAVA_TEST_CLASSES:%=-C test %) $(ESCAPED_JAVA_TEST_CLASSES:%=-C test %)
77 
78 java_DATA += libcephfs-test.jar
79 
80 CLEANFILES += test/com/ceph/fs/*.class libcephfs-test.jar
81 endif # HAVE_JUNIT4 (includes WITH_DEBUG)

可以判断,如果要生成libcephfs-test.jar需要HAVE_JUNIT4为真;
在configure文件中,我们可以看到:

17838 ▸       # setup defaults for Debian default-jdk package (without --with-jdk-dir)
17839 ▸       if test -z "$with_jdk_dir"; then :
17840 
17841 ▸       ▸          # This works with Debian's default-jdk package
17842 ▸       ▸          dir='/usr/lib/jvm/default-java/'
17843 ▸       ▸          javac_prog=`find $dir -name javac | head -n 1`
17844 ▸       ▸          if test -x "$javac_prog"; then :
17845 
17846 ▸       ▸       ▸       ▸         EXTRA_JDK_BIN_DIR=`dirname $javac_prog`
17847 fi
17848 ▸       ▸          jnih=`find $dir -name jni.h | head -n 1`
17849 ▸       ▸          if test -r "$jnih"; then :
17850 
17851 ▸       ▸       ▸       ▸         EXTRA_JDK_INC_DIR=`dirname $jnih`
17852 fi

我们要把 dir=’/usr/lib/jvm/default-java/’ 改为centos的 dir=’/usr/lib/jvm/java/’ 或者做个超链接;但重新测试后,还是会发现

 Processing files: cephfs-java-0.61.9-0.el6.x86_64
error: File not found: /root/rpmbuild/BUILDROOT/ceph-0.61.9-0.el6.x86_64/usr/share/java/libcephfs-test.jar。

网上的资料为:
主要原因为没有添加:
Requires: junit4
BuildRequires: junit4
添加后,问题依旧,仔细分析configure文件,发现:

 else
18600 
18601 ▸       ▸       { $as_echo "$as_me:${as_lineno-$LINENO}: Could not find org.junit.rules.ExternalRe      source" >&5
18602 $as_echo "$as_me: Could not find org.junit.rules.ExternalResource" >&6;}
18603 ▸       ▸       have_junit4=0
18604 fi

HAVE-JUNIT4在这种情况下出现问题;
分析后得出:centos环境下:发现junit4-4.5-5.3.el6.noarch的版本为4.5太低了,是4年前的版本;而ubuntu的版本为4.8.2;
后发现org.junit.rules.ExternalResource不是特别依赖的资源,remove后进行测试,发现运行正常;
然后对ceph-0.61.9的tar包做patch处理:
patch为(ceph-create-rpm.patch):

diff -Naur ceph-0.61.9/configure.ac ../SOURCES/ceph-0.61.9/configure.ac
--- ceph-0.61.9/configure.ac	2013-10-17 12:26:29.000000000 +0800
+++ ../SOURCES/ceph-0.61.9/configure.ac	2014-02-19 21:11:50.451378431 +0800
@@ -302,7 +302,7 @@
 	# setup defaults for Debian default-jdk package (without --with-jdk-dir)
 	AS_IF([test -z "$with_jdk_dir"], [
 		   # This works with Debian's default-jdk package
-		   dir='/usr/lib/jvm/default-java/'
+		   dir='/usr/lib/jvm/java/'
 		   javac_prog=`find $dir -name javac | head -n 1`
 		   AS_IF([test -x "$javac_prog"], [
 				  EXTRA_JDK_BIN_DIR=`dirname $javac_prog`])
@@ -336,10 +336,10 @@
         CLASSPATH=$CLASSPATH:$EXTRA_CLASSPATH_JAR
         export CLASSPATH
         AC_MSG_NOTICE([classpath - $CLASSPATH])
-        AS_IF([test "$have_junit4" = "1"], [
-		AC_CHECK_CLASS([org.junit.rules.ExternalResource], [], [
-		AC_MSG_NOTICE(Could not find org.junit.rules.ExternalResource)
-		have_junit4=0])])
+        #AS_IF([test "$have_junit4" = "1"], [
+	#	AC_CHECK_CLASS([org.junit.rules.ExternalResource], [], [
+	#	AC_MSG_NOTICE(Could not find org.junit.rules.ExternalResource)
+	#	have_junit4=0])])
 
         # Check for jni.h
 	CPPFLAGS_save=$CPPFLAGS
diff -Naur ceph-0.61.9/src/java/Makefile.am ../SOURCES/ceph-0.61.9/src/java/Makefile.am
--- ceph-0.61.9/src/java/Makefile.am	2013-10-17 12:26:29.000000000 +0800
+++ ../SOURCES/ceph-0.61.9/src/java/Makefile.am	2014-02-19 21:12:59.257377496 +0800
@@ -64,7 +64,7 @@
 if HAVE_JUNIT4
 
 JAVA_TEST_CLASSES = $(JAVA_TEST_SRC:test/%.java=%.class)
-ESCAPED_JAVA_TEST_CLASSES = com/ceph/fs/CephAllTests\$$1.class
+#ESCAPED_JAVA_TEST_CLASSES = com/ceph/fs/CephAllTests\$$1.class
 
 CEPH_TEST_PROXY=test/com/ceph/fs/CephMountTest.class
 
@@ -73,7 +73,7 @@
 	$(JAVAC) -source 1.5 -target 1.5 -Xlint:-options test/com/ceph/fs/*.java
 
 libcephfs-test.jar: $(CEPH_TEST_PROXY)
-	$(JAR) cf $@ $(JAVA_TEST_CLASSES:%=-C test %) $(ESCAPED_JAVA_TEST_CLASSES:%=-C test %)
+	$(JAR) cf $@ $(JAVA_TEST_CLASSES:%=-C test %) 
 
 java_DATA += libcephfs-test.jar
 
diff -Naur ceph-0.61.9/src/java/Makefile.in ../SOURCES/ceph-0.61.9/src/java/Makefile.in
--- ceph-0.61.9/src/java/Makefile.in	2013-10-17 12:27:16.000000000 +0800
+++ ../SOURCES/ceph-0.61.9/src/java/Makefile.in	2014-02-19 21:13:52.643376770 +0800
@@ -543,7 +543,7 @@
 @ENABLE_CEPHFS_JAVA_TRUE@@HAVE_JUNIT4_TRUE@	$(JAVAC) -source 1.5 -target 1.5 -Xlint:-options test/com/ceph/fs/*.java
 
 @ENABLE_CEPHFS_JAVA_TRUE@@HAVE_JUNIT4_TRUE@libcephfs-test.jar: $(CEPH_TEST_PROXY)
-@ENABLE_CEPHFS_JAVA_TRUE@@HAVE_JUNIT4_TRUE@	$(JAR) cf $@ $(JAVA_TEST_CLASSES:%=-C test %) $(ESCAPED_JAVA_TEST_CLASSES:%=-C test %)
+@ENABLE_CEPHFS_JAVA_TRUE@@HAVE_JUNIT4_TRUE@	$(JAR) cf $@ $(JAVA_TEST_CLASSES:%=-C test %) 
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff -Naur ceph-0.61.9/src/java/test/com/ceph/fs/CephAllTests.java ../SOURCES/ceph-0.61.9/src/java/test/com/ceph/fs/CephAllTests.java
--- ceph-0.61.9/src/java/test/com/ceph/fs/CephAllTests.java	2013-10-17 12:26:29.000000000 +0800
+++ ../SOURCES/ceph-0.61.9/src/java/test/com/ceph/fs/CephAllTests.java	2014-02-19 21:15:34.229375390 +0800
@@ -23,7 +23,7 @@
 import java.io.IOException;
 import java.util.UUID;
 import org.junit.*;
-import org.junit.rules.ExternalResource;
+//import org.junit.rules.ExternalResource;
 import org.junit.runners.Suite;
 import org.junit.runner.RunWith;
 import static org.junit.Assert.*;
@@ -42,16 +42,16 @@
  */
 public class CephAllTests{
 
-  @Rule
-  public static ExternalResource testRule = new ExternalResource(){
-    @Override
-    protected void before() throws Throwable{
-      // Add debugging messages or setup code here
-    };
-
-    @Override
-    protected void after(){
-      // Add debugging messages or cleanup code here
-    };
-  };
+//  @Rule
+//  public static ExternalResource testRule = new ExternalResource(){
+//    @Override
+//    protected void before() throws Throwable{
+//      // Add debugging messages or setup code here
+//    };
+//
+//   @Override
+//    protected void after(){
+//      // Add debugging messages or cleanup code here
+//    };
+ // };
 }

patch github source :https://github.com/qfong/ceph-create-rpm.patch.git
执行命令:
patch -p1 <../ceph-create-rpm.patch 编译rpm包: rpmbuild ceph.spec

发表评论

您的电子邮箱地址不会被公开。