舫摘

知人者智 自知者明 胜人者有力 自胜者强

0%

OpenWrt Chaos Calmer 15.05.1编译最新版Subversion

NAS并不是7x24小时开机,不能随时访问自己在NAS上的私有版本库,需要转移到7x24小时开机的软路由上,保证随时随地可访问私有版本库,但是新版的OpenWrt已经不再包含Subversion包,需要自己编译安装。

按照面向Google编程的思想,先Google一下看看别人的解决方案,发现可以打开feeds配置中的oldpackage源,oldpackage源中包含1.6.4版本的Subversion。

虽然1.6.4版本有点老,但是本着能躺着不坐着的思想,装上能用就行。然而编译安装后svnserve在私有版本库上启动不能,不支持在NAS用新版Subversion创建的版本库。

好吧,现在只能自己编译安装最新版本的Subversion了。

首先需要一台Linux,虚拟机或真机都可以,然后下载安装Openwrt的开发环境,具体参照OpenWrt官方Wiki,不再赘述。

OpenWrt build system

修改feeds.conf.default打开oldpackages

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
src-git base https://git.openwrt.org/15.05/openwrt.git
src-git packages https://github.com/openwrt/packages.git;for-15.05
src-git luci https://github.com/openwrt/luci.git;for-15.05
src-git routing https://github.com/openwrt-routing/packages.git;for-15.05
src-git telephony https://github.com/openwrt/telephony.git;for-15.05
src-git management https://github.com/openwrt-management/packages.git;for-15.05
#src-git targets https://github.com/openwrt/targets.git
#src-git oldpackages http://git.openwrt.org/packages.git
#src-svn xwrt http://x-wrt.googlecode.com/svn/trunk/package
#src-svn phone svn://svn.openwrt.org/openwrt/feeds/phone
#src-svn efl svn://svn.openwrt.org/openwrt/feeds/efl
#src-svn xorg svn://svn.openwrt.org/openwrt/feeds/xorg
#src-svn desktop svn://svn.openwrt.org/openwrt/feeds/desktop
#src-svn xfce svn://svn.openwrt.org/openwrt/feeds/xfce
#src-svn lxde svn://svn.openwrt.org/openwrt/feeds/lxde
#src-link custom /usr/src/openwrt/custom-feed

将第8行前面的#去掉,打开oldpackage源。

更新feeds

执行

1
./scripts/feeds update

等待feeds更新完成后,执行

1
./scripts/feeds | grep subversion

返回

1
2
3
subversion-client               	subversion client tools
subversion-libs subversion libs
subversion-server subversion server

可以看到已经有了subversion的feeds。

安装Subversion的feeds

1
2
3
./scripts/feeds install subversion-libs
./scripts/feeds install subversion-server
./scripts/feeds install subversion-client

编辑Makefile,启用新版的Subversion

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# feeds/oldpackages/net/subversion/Makefile
#
# Copyright (C) 2007-2011 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

PKG_NAME:=subversion
# 版本号
PKG_VERSION:=1.9.4
PKG_RELEASE:=1

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
# 下载地址
PKG_SOURCE_URL:=http://mirror.bit.edu.cn/apache/subversion
# MD5校验
PKG_MD5SUM:=29121a038f87641055a8183f49e9739f

PKG_FIXUP:=autoreconf
PKG_MACRO_PATHS:=build/ac-macros
PKG_INSTALL:=1

include $(INCLUDE_DIR)/package.mk
# 添加ICONV环境配置
include $(INCLUDE_DIR)/nls.mk

define Package/subversion/Default
SECTION:=net
CATEGORY:=Network
TITLE:=A compelling replacement for CVS
# 添加sqlite3 uuid iconv依赖
DEPENDS:=+zlib +libneon +libaprutil +libsqlite3 +libuuid $(ICONV_DEPENDS) +libapr +libexpat
URL:=http://subversion.apache.org/
SUBMENU:=Version Control Systems
endef

define Package/subversion/Default/description
Subversion is a free/open-source version control system. That is,
Subversion manages files and directories, and the changes made to them,
over time. This allows you to recover older versions of your data, or
examine the history of how your data changed. In this regard, many
people think of a version control system as a sort of time machine.
endef

define Package/subversion-libs
$(call Package/subversion/Default)
DEPENDS+=+unixodbc
TITLE:=subversion libs
endef

define Package/subversion-libs/description
$(call Package/subversion/Default/description)
This package contains the subversion libraries.
endef

define Package/subversion-client
$(call Package/subversion/Default)
DEPENDS+=subversion-libs
TITLE:=subversion client tools
endef

define Package/subversion-client/description
$(call Package/subversion/Default/description)
This package contains the subversion client tools.
endef

define Package/subversion-server
$(call Package/subversion/Default)
DEPENDS+=subversion-libs
TITLE:=subversion server
endef

define Package/subversion-server/description
$(call Package/subversion/Default/description)
This package contains the subversion server.
endef

define Package/subversion-server/conffiles
/etc/config/subversion
endef

TARGET_CFLAGS += $(FPIC)
TARGET_CPPFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
# 添加iconv引用
TARGET_LDFLAGS += -liconv

CONFIGURE_ARGS += \
# 不使用sqlite2
--without-sqlite2 \
# 使用sqlite3
--with-sqlite3="$(STAGING_DIR)/usr" \
# iconv配置
--with-iconv="$(ICONV_PREFIX)" \
--with-apr="$(STAGING_DIR)/usr/bin/apr-1-config" \
--with-apr-util="$(STAGING_DIR)/usr/bin/apu-1-config" \
--with-neon="$(STAGING_DIR)/usr" \
--disable-mod-activation \
--without-ruby-sitedir \
--without-swig \
--with-jikes=no \
--without-junit \
--without-berkeley-db \
--with-ssl \
--disable-neon-version-check \
--with-apxs=no \
--without-sasl \

CONFIGURE_VARS += \
svn_lib_neon=yes \
LDFLAGS="$(TARGET_LDFLAGS) -lcrypt -lm -lz -lpthread \
-L$(TOOLCHAIN_DIR)/usr/lib \
-L$(TOOLCHAIN_DIR)/lib" \
CFLAGS="$(TARGET_CFLAGS)" \
CPPFLAGS="$(TARGET_CPPFLAGS)" \

define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR) \
DESTDIR="$(PKG_INSTALL_DIR)" \
# 指定libiconv.a位置,防止引用到系统环境中的iconv库,导致链接不过
LIBS="$(ICONV_PREFIX)/lib/libiconv.a" \
all local-install
endef

define Package/subversion-libs/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libsvn_*.so.* $(1)/usr/lib/
endef

define Package/subversion-client/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/{svn,svnversion,svnsync} $(1)/usr/bin/
endef

define Package/subversion-server/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/svn{look,admin,dumpfilter,serve} $(1)/usr/bin/
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_CONF) ./files/subversion.config $(1)/etc/config/subversion
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/subversion.init $(1)/etc/init.d/subversion
endef

$(eval $(call BuildPackage,subversion-libs))
$(eval $(call BuildPackage,subversion-client))
$(eval $(call BuildPackage,subversion-server))

编译

1
make package/feeds/oldpackages/subversion/compile V=s

返回

1
configure: error: cannot run test program while cross compiling

错误

编辑

1
build_dir/target-x86_64_uClibc-0.9.33.2/subversion-1.9.4/build/ac-macros/macosx.m4

删除24 - 42行

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
dnl ===================================================================
dnl Licensed to the Apache Software Foundation (ASF) under one
dnl or more contributor license agreements. See the NOTICE file
dnl distributed with this work for additional information
dnl regarding copyright ownership. The ASF licenses this file
dnl to you under the Apache License, Version 2.0 (the
dnl "License"); you may not use this file except in compliance
dnl with the License. You may obtain a copy of the License at
dnl
dnl http://www.apache.org/licenses/LICENSE-2.0
dnl
dnl Unless required by applicable law or agreed to in writing,
dnl software distributed under the License is distributed on an
dnl "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
dnl KIND, either express or implied. See the License for the
dnl specific language governing permissions and limitations
dnl under the License.
dnl ===================================================================
dnl
dnl Mac OS X specific checks

dnl SVN_LIB_MACHO_ITERATE
dnl Check for _dyld_image_name and _dyld_image_header availability
AC_DEFUN(SVN_LIB_MACHO_ITERATE,
[
AC_MSG_CHECKING([for Mach-O dynamic module iteration functions])
AC_RUN_IFELSE([AC_LANG_PROGRAM([[
#include <mach-o/dyld.h>
#include <mach-o/loader.h>
]],[[
const struct mach_header *header = _dyld_get_image_header(0);
const char *name = _dyld_get_image_name(0);
if (name && header) return 0;
return 1;
]])],[
AC_DEFINE([SVN_HAVE_MACHO_ITERATE], [1],
[Is Mach-O low-level _dyld API available?])
AC_MSG_RESULT([yes])
],[
AC_MSG_RESULT([no])
])
])

dnl SVN_LIB_MACOS_PLIST
dnl Assign variables for Mac OS property list support
AC_DEFUN(SVN_LIB_MACOS_PLIST,

再次编译

1
make package/feeds/oldpackages/subversion/compile V=s

通过

打包IPK

1
make package/feeds/oldpackages/subversion/install V=s

打好的IPK包在bin目录中

1
2
3
4
5
6
7
[root@KEVIN-LAPTOP OpenWrt-SDK-15.05.1-x86-64_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64]# ll bin/x86/packages/oldpackages/
total 1340
-rw-r--r-- 1 root root 2470 Jul 16 23:15 Packages
-rw-r--r-- 1 root root 734 Jul 16 23:15 Packages.gz
-rw-r--r-- 1 root root 107953 Jul 17 14:28 subversion-client_1.9.4-1_x86_64.ipk
-rw-r--r-- 1 root root 1167796 Jul 17 14:28 subversion-libs_1.9.4-1_x86_64.ipk
-rw-r--r-- 1 root root 78634 Jul 17 14:28 subversion-server_1.9.4-1_x86_64.ipk

至此新版的Subversion编译完成。