diff mbox

[RFC/PATCH,next,2/2] couchdb: New package.

Message ID 1463673580-10676-2-git-send-email-nicolas.cavallari@green-communications.fr
State Superseded
Headers show

Commit Message

Nicolas Cavallari May 19, 2016, 3:59 p.m. UTC
Signed-off-by: Nicolas Cavallari <nicolas.cavallari@green-communications.fr>
---
 package/Config.in                              |  1 +
 package/couchdb/0001-remove-unsafe-paths.patch | 41 ++++++++++++++++++++
 package/couchdb/Config.in                      | 22 +++++++++++
 package/couchdb/S96prepare-couchdb             |  5 +++
 package/couchdb/couchdb.hash                   |  7 ++++
 package/couchdb/couchdb.mk                     | 52 ++++++++++++++++++++++++++
 6 files changed, 128 insertions(+)
 create mode 100644 package/couchdb/0001-remove-unsafe-paths.patch
 create mode 100644 package/couchdb/Config.in
 create mode 100644 package/couchdb/S96prepare-couchdb
 create mode 100644 package/couchdb/couchdb.hash
 create mode 100644 package/couchdb/couchdb.mk

Comments

Arnout Vandecappelle May 19, 2016, 10:41 p.m. UTC | #1
On 05/19/16 17:59, Nicolas Cavallari wrote:
> Signed-off-by: Nicolas Cavallari <nicolas.cavallari@green-communications.fr>

 My first reaction was: can't we use a more recent version from git instead of
an almost-two-years-old release, but that won't be easy because of all the
submodules.

 Just small comments all over.

> ---
>  package/Config.in                              |  1 +
>  package/couchdb/0001-remove-unsafe-paths.patch | 41 ++++++++++++++++++++
>  package/couchdb/Config.in                      | 22 +++++++++++
>  package/couchdb/S96prepare-couchdb             |  5 +++
>  package/couchdb/couchdb.hash                   |  7 ++++
>  package/couchdb/couchdb.mk                     | 52 ++++++++++++++++++++++++++
>  6 files changed, 128 insertions(+)
>  create mode 100644 package/couchdb/0001-remove-unsafe-paths.patch
>  create mode 100644 package/couchdb/Config.in
>  create mode 100644 package/couchdb/S96prepare-couchdb
>  create mode 100644 package/couchdb/couchdb.hash
>  create mode 100644 package/couchdb/couchdb.mk
> 
[snip]
> diff --git a/package/couchdb/Config.in b/package/couchdb/Config.in
> new file mode 100644
> index 0000000..20899bf
> --- /dev/null
> +++ b/package/couchdb/Config.in
> @@ -0,0 +1,22 @@
> +comment "CouchDB need a toolchain with C++, wchar, threads, dynamic libs."
> +	depends on !BR2_BINFMT_FLAT
> +	depends on BR2_USE_MMU
> +	depends on BR2_PACKAGE_LIBATOMIC_OPS_ARCH_SUPPORTS
> +	depends on !BR2_TOOLCHAIN_HAS_THREADS || \
> +		BR2_STATIC_LIBS || !BR2_INSTALL_LIBSTDCPP || !BR2_USE_WCHAR
> +
> +config BR2_PACKAGE_COUCHDB
> +	bool "couchdb"
> +	depends on BR2_TOOLCHAIN_HAS_THREADS # icu
> +	depends on !BR2_BINFMT_FLAT # icu
> +	depends on BR2_USE_MMU # erlang, spidermonkey185
> +	depends on !BR2_STATIC_LIBS # erlang
> +	depends on BR2_PACKAGE_LIBATOMIC_OPS_ARCH_SUPPORTS # erlang
> +	depends on BR2_INSTALL_LIBSTDCPP # icu, spidermonkey185
> +	depends on BR2_USE_WCHAR # icu

 Could you order the dependencies with arch deps first, and then toolchain deps?
So it's consistent with the comment deps.

> +
> +	select BR2_PACKAGE_ERLANG
> +	select BR2_PACKAGE_ICU
> +	select BR2_PACKAGE_OPENSSL
> +	select BR2_PACKAGE_SPIDERMONKEY185
> +	select BR2_PACKAGE_LIBCURL
> diff --git a/package/couchdb/S96prepare-couchdb b/package/couchdb/S96prepare-couchdb
> new file mode 100644
> index 0000000..065395b
> --- /dev/null
> +++ b/package/couchdb/S96prepare-couchdb
> @@ -0,0 +1,5 @@
> +#!/bin/sh
> +case "$1" in
> +	start)
> +		install -d -o couchdb /var/log/couchdb;;

 I like this solution for creating the log directory!

 Should group be set to couchdb as well?

> +esac
> diff --git a/package/couchdb/couchdb.hash b/package/couchdb/couchdb.hash
> new file mode 100644
> index 0000000..22be689
> --- /dev/null
> +++ b/package/couchdb/couchdb.hash
> @@ -0,0 +1,7 @@
> +# From https://archive.apache.org/dist/couchdb/source/1.6.1/apache-couchdb-1.6.1.tar.gz.{md5,sha}
> +sha1	6275f3818579d7b307052e9735c42a8a64313229	apache-couchdb-1.6.1.tar.gz
> +md5	01a2c8ab4fcde457529428993901a060		apache-couchdb-1.6.1.tar.gz
> +
> +# Locally generated after checking PGP signature
> +sha256	5a601b173733ce3ed31b654805c793aa907131cd70b06d03825f169aa48c8627	apache-couchdb-1.6.1.tar.gz
> +

 Redundant empty line.

> diff --git a/package/couchdb/couchdb.mk b/package/couchdb/couchdb.mk
> new file mode 100644
> index 0000000..5e8a8cf
> --- /dev/null
> +++ b/package/couchdb/couchdb.mk
> @@ -0,0 +1,52 @@
> +################################################################################
> +#
> +# CouchDB
> +#
> +################################################################################
> +
> +COUCHDB_VERSION = 1.6.1
> +COUCHDB_SITE = \
> +	http://archive.apache.org/dist/couchdb/source/${COUCHDB_VERSION}
> +COUCHDB_SOURCE = apache-couchdb-${COUCHDB_VERSION}.tar.gz
> +
> +COUCHDB_LICENSE = Apache-2.0
> +COUCHDB_LICENSE_FILES = LICENSE
> +
> +COUCHDB_DEPENDENCIES = host-autoconf-archive host-pkgconf \
> +	openssl icu libcurl spidermonkey185 erlang host-pkgconf

 You got host-pkgconf twice. Sort them alphabetically to avoid that.

> +
> +# configure.ac is patched.
> +COUCHDB_AUTORECONF = YES
> +COUCHDB_AUTORECONF_OPTS = -I $(HOST_DIR)/usr/share/autoconf-archive
> +
> +COUCHDB_CONF_ENV = \
> +	CURL_CONFIG=$(STAGING_DIR)/usr/bin/curl-config \
> +	ICU_CONFIG=$(STAGING_DIR)/usr/bin/icu-config
> +COUCHDB_CONF_OPTS = --disable-init
> +
> +# CouchDB's build system mixes the erl for the host and the erl for the
> +# target.
> +define COUCHDB_FIX_ERL_PATH
> +	sed -i -re 's*$(HOST_DIR)**' \

 We usually use , and sometimes %, not *.

> +		$(TARGET_DIR)/usr/bin/couchdb \
> +		$(TARGET_DIR)/usr/bin/couch-config
> +endef
> +COUCHDB_POST_INSTALL_TARGET_HOOKS += COUCHDB_FIX_ERL_PATH
> +
> +define COUCHDB_INSTALL_INIT_SYSV
> +install -m 755 -D $(@D)/etc/init/couchdb $(TARGET_DIR)/etc/init.d/S97couchdb
> +install -m 755 package/couchdb/S96prepare-couchdb $(TARGET_DIR)/etc/init.d/
> +install -m 755 -D $(@D)/etc/default/couchdb $(TARGET_DIR)/etc/default/couchdb

 Stuff inside "define" is indented with a tab.

> +endef
> +
> +define COUCHDB_USERS
> +couchdb -1 couchdb -1 ! - /bin/sh - CouchDB Server

 Same here.

> +endef
> +
> +define COUCHDB_PERMISSIONS
> +/etc/couchdb		r	755	couchdb	couchdb - - - -
> +/var/lib/couchdb	d	750	couchdb	couchdb - - - -

 Same here.

 Regards,
 Arnout

> +endef
> +
> +$(eval $(autotools-package))
> +
>
Thomas Petazzoni May 20, 2016, 12:53 p.m. UTC | #2
Hello,

On Fri, 20 May 2016 00:41:28 +0200, Arnout Vandecappelle wrote:
> On 05/19/16 17:59, Nicolas Cavallari wrote:
> > Signed-off-by: Nicolas Cavallari <nicolas.cavallari@green-communications.fr>  
> 
>  My first reaction was: can't we use a more recent version from git instead of
> an almost-two-years-old release, but that won't be easy because of all the
> submodules.

Does the latest git versions also need spidermonkey 1.8.5 ?

If not, then I think I'd prefer to add support to fetch submodules (we
already have patches doing this, from Yann, and they are reasonable),
and skip the addition of this unmaintained spidermonkey thing.

Thomas
Nicolas Cavallari May 20, 2016, 2:26 p.m. UTC | #3
On 20/05/2016 14:53, Thomas Petazzoni wrote:
> Hello,
> 
> On Fri, 20 May 2016 00:41:28 +0200, Arnout Vandecappelle wrote:
>> On 05/19/16 17:59, Nicolas Cavallari wrote:
>>> Signed-off-by: Nicolas Cavallari <nicolas.cavallari@green-communications.fr>  
>>
>>  My first reaction was: can't we use a more recent version from git instead of
>> an almost-two-years-old release, but that won't be easy because of all the
>> submodules.
> 
> Does the latest git versions also need spidermonkey 1.8.5 ?

Yes, Unfortunately...

> If not, then I think I'd prefer to add support to fetch submodules (we
> already have patches doing this, from Yann, and they are reasonable),
> and skip the addition of this unmaintained spidermonkey thing.

These are not git submodules, they are submodules as in "./configure
git-clone them". Plus there are even more hardcoded /usr/include paths
in their build system. It seems wiser to wait for a tarball.
Thomas Petazzoni May 20, 2016, 2:29 p.m. UTC | #4
Hello,

On Fri, 20 May 2016 16:26:53 +0200, Nicolas Cavallari wrote:

> >>  My first reaction was: can't we use a more recent version from git instead of
> >> an almost-two-years-old release, but that won't be easy because of all the
> >> submodules.  
> > 
> > Does the latest git versions also need spidermonkey 1.8.5 ?  
> 
> Yes, Unfortunately...

Yerk.

> > If not, then I think I'd prefer to add support to fetch submodules (we
> > already have patches doing this, from Yann, and they are reasonable),
> > and skip the addition of this unmaintained spidermonkey thing.  
> 
> These are not git submodules, they are submodules as in "./configure
> git-clone them". Plus there are even more hardcoded /usr/include paths
> in their build system. It seems wiser to wait for a tarball.

and yerk.

Do we want to package couchdb ? :-)

Thomas
Bernd Kuhls May 20, 2016, 3:29 p.m. UTC | #5
Am Fri, 20 May 2016 16:29:29 +0200 schrieb Thomas Petazzoni:

> Do we want to package couchdb ? :-)

Hi,

I use couchdb regularly to download wikipedia using

https://github.com/itkach/mwscrape
https://github.com/itkach/mwscrape2slob

on my workstation. Being able in the future to do that on my buildroot-
based server, which is online 24/7, would be nice to have ;)

Regards, Bernd
Nicolas Cavallari June 9, 2016, 2:46 p.m. UTC | #6
> Do we want to package couchdb ? :-)

In case you still do, here's an updated version of the patches.

Couchdb 2.0 is way to immature to attempt to package it now: --prefix
does not work and is hardwired to '.', there is no "make install",
it depends on unreleased libraries...  So even with a self-built tarball,
it's still not ready for being packaged.

I've somewhat test compiled spidermonkey on several architectures where
debian's patches implied there would be problem and fixed them by taking
patches from upstream.  I also addressed the minor nits on Couchdb 1.6.1.
diff mbox

Patch

diff --git a/package/Config.in b/package/Config.in
index 89caf32..40d2fe4 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -861,6 +861,7 @@  endmenu
 
 menu "Database"
 	source "package/berkeleydb/Config.in"
+	source "package/couchdb/Config.in"
 	source "package/cppdb/Config.in"
 	source "package/gdbm/Config.in"
 	source "package/kompexsqlite/Config.in"
diff --git a/package/couchdb/0001-remove-unsafe-paths.patch b/package/couchdb/0001-remove-unsafe-paths.patch
new file mode 100644
index 0000000..45b8170
--- /dev/null
+++ b/package/couchdb/0001-remove-unsafe-paths.patch
@@ -0,0 +1,41 @@ 
+From 39b34b35ac4741f65c0a4707b480301154ab2de5 Mon Sep 17 00:00:00 2001
+From: Nicolas Cavallari <nicolas.cavallari@green-communications.fr>
+Date: Thu, 19 May 2016 16:52:53 +0200
+Subject: configure.ac: Remove unsafe paths
+
+Remove the unconditionnally added paths to the host.
+
+Upstream-Status: not-applicable: later versions do not use autotools
+anymore, but rebar.
+
+Signed-Off-By: Nicolas Cavallari <nicolas.cavallari@green-communications.fr>
+
+---
+ configure.ac | 11 -----------
+ 1 file changed, 11 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index bf9ffc4..7b95554 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -195,17 +195,6 @@ AC_ARG_ENABLE([js-trunk],
+ AC_ARG_VAR([ERLC_FLAGS], [general flags to prepend to ERLC_FLAGS])
+ AC_ARG_VAR([FLAGS], [general flags to prepend to LDFLAGS and CPPFLAGS])
+ 
+-AS_CASE([$(uname -s)], [CYGWIN*], [] , [*], [
+-    CPPFLAGS="$CPPFLAGS -I/opt/local/include"
+-    CPPFLAGS="$CPPFLAGS -I/opt/local/include/js"
+-    CPPFLAGS="$CPPFLAGS -I/usr/local/include"
+-    CPPFLAGS="$CPPFLAGS -I/usr/local/include/js"
+-    CPPFLAGS="$CPPFLAGS -I/usr/include"
+-    CPPFLAGS="$CPPFLAGS -I/usr/include/js"
+-    LDFLAGS="$LDFLAGS -L/opt/local/lib"
+-    LDFLAGS="$LDFLAGS -L/usr/local/lib"
+-])
+-
+ CPPFLAGS="$CPPFLAGS $FLAGS"
+ LDFLAGS="$LDFLAGS $FLAGS"
+ 
+-- 
+2.8.1
+
diff --git a/package/couchdb/Config.in b/package/couchdb/Config.in
new file mode 100644
index 0000000..20899bf
--- /dev/null
+++ b/package/couchdb/Config.in
@@ -0,0 +1,22 @@ 
+comment "CouchDB need a toolchain with C++, wchar, threads, dynamic libs."
+	depends on !BR2_BINFMT_FLAT
+	depends on BR2_USE_MMU
+	depends on BR2_PACKAGE_LIBATOMIC_OPS_ARCH_SUPPORTS
+	depends on !BR2_TOOLCHAIN_HAS_THREADS || \
+		BR2_STATIC_LIBS || !BR2_INSTALL_LIBSTDCPP || !BR2_USE_WCHAR
+
+config BR2_PACKAGE_COUCHDB
+	bool "couchdb"
+	depends on BR2_TOOLCHAIN_HAS_THREADS # icu
+	depends on !BR2_BINFMT_FLAT # icu
+	depends on BR2_USE_MMU # erlang, spidermonkey185
+	depends on !BR2_STATIC_LIBS # erlang
+	depends on BR2_PACKAGE_LIBATOMIC_OPS_ARCH_SUPPORTS # erlang
+	depends on BR2_INSTALL_LIBSTDCPP # icu, spidermonkey185
+	depends on BR2_USE_WCHAR # icu
+
+	select BR2_PACKAGE_ERLANG
+	select BR2_PACKAGE_ICU
+	select BR2_PACKAGE_OPENSSL
+	select BR2_PACKAGE_SPIDERMONKEY185
+	select BR2_PACKAGE_LIBCURL
diff --git a/package/couchdb/S96prepare-couchdb b/package/couchdb/S96prepare-couchdb
new file mode 100644
index 0000000..065395b
--- /dev/null
+++ b/package/couchdb/S96prepare-couchdb
@@ -0,0 +1,5 @@ 
+#!/bin/sh
+case "$1" in
+	start)
+		install -d -o couchdb /var/log/couchdb;;
+esac
diff --git a/package/couchdb/couchdb.hash b/package/couchdb/couchdb.hash
new file mode 100644
index 0000000..22be689
--- /dev/null
+++ b/package/couchdb/couchdb.hash
@@ -0,0 +1,7 @@ 
+# From https://archive.apache.org/dist/couchdb/source/1.6.1/apache-couchdb-1.6.1.tar.gz.{md5,sha}
+sha1	6275f3818579d7b307052e9735c42a8a64313229	apache-couchdb-1.6.1.tar.gz
+md5	01a2c8ab4fcde457529428993901a060		apache-couchdb-1.6.1.tar.gz
+
+# Locally generated after checking PGP signature
+sha256	5a601b173733ce3ed31b654805c793aa907131cd70b06d03825f169aa48c8627	apache-couchdb-1.6.1.tar.gz
+
diff --git a/package/couchdb/couchdb.mk b/package/couchdb/couchdb.mk
new file mode 100644
index 0000000..5e8a8cf
--- /dev/null
+++ b/package/couchdb/couchdb.mk
@@ -0,0 +1,52 @@ 
+################################################################################
+#
+# CouchDB
+#
+################################################################################
+
+COUCHDB_VERSION = 1.6.1
+COUCHDB_SITE = \
+	http://archive.apache.org/dist/couchdb/source/${COUCHDB_VERSION}
+COUCHDB_SOURCE = apache-couchdb-${COUCHDB_VERSION}.tar.gz
+
+COUCHDB_LICENSE = Apache-2.0
+COUCHDB_LICENSE_FILES = LICENSE
+
+COUCHDB_DEPENDENCIES = host-autoconf-archive host-pkgconf \
+	openssl icu libcurl spidermonkey185 erlang host-pkgconf
+
+# configure.ac is patched.
+COUCHDB_AUTORECONF = YES
+COUCHDB_AUTORECONF_OPTS = -I $(HOST_DIR)/usr/share/autoconf-archive
+
+COUCHDB_CONF_ENV = \
+	CURL_CONFIG=$(STAGING_DIR)/usr/bin/curl-config \
+	ICU_CONFIG=$(STAGING_DIR)/usr/bin/icu-config
+COUCHDB_CONF_OPTS = --disable-init
+
+# CouchDB's build system mixes the erl for the host and the erl for the
+# target.
+define COUCHDB_FIX_ERL_PATH
+	sed -i -re 's*$(HOST_DIR)**' \
+		$(TARGET_DIR)/usr/bin/couchdb \
+		$(TARGET_DIR)/usr/bin/couch-config
+endef
+COUCHDB_POST_INSTALL_TARGET_HOOKS += COUCHDB_FIX_ERL_PATH
+
+define COUCHDB_INSTALL_INIT_SYSV
+install -m 755 -D $(@D)/etc/init/couchdb $(TARGET_DIR)/etc/init.d/S97couchdb
+install -m 755 package/couchdb/S96prepare-couchdb $(TARGET_DIR)/etc/init.d/
+install -m 755 -D $(@D)/etc/default/couchdb $(TARGET_DIR)/etc/default/couchdb
+endef
+
+define COUCHDB_USERS
+couchdb -1 couchdb -1 ! - /bin/sh - CouchDB Server
+endef
+
+define COUCHDB_PERMISSIONS
+/etc/couchdb		r	755	couchdb	couchdb - - - -
+/var/lib/couchdb	d	750	couchdb	couchdb - - - -
+endef
+
+$(eval $(autotools-package))
+