Patchwork nodejs: new package

login
register
mail settings
Submitter Jonathan Liu
Date Aug. 11, 2012, 6:11 a.m.
Message ID <1344665495-27246-1-git-send-email-net147@gmail.com>
Download mbox | patch
Permalink /patch/176663/
State Rejected
Headers show

Comments

Jonathan Liu - Aug. 11, 2012, 6:11 a.m.
Signed-off-by: Jonathan Liu <net147@gmail.com>
---
 package/Config.in        |  1 +
 package/nodejs/Config.in | 19 +++++++++++++++++
 package/nodejs/nodejs.mk | 54 ++++++++++++++++++++++++++++++++++++++++++++++++
 package/python/python.mk |  1 -
 4 files changed, 74 insertions(+), 1 deletion(-)
 create mode 100644 package/nodejs/Config.in
 create mode 100644 package/nodejs/nodejs.mk
Thomas Petazzoni - Aug. 11, 2012, 8:23 p.m.
Hello,

Le Sat, 11 Aug 2012 16:11:35 +1000,
Jonathan Liu <net147@gmail.com> a écrit :

> +config BR2_PACKAGE_NODEJS
> +	bool "nodejs"
> +	select BR2_PACKAGE_OPENSSL

I know nothing about nodejs. Is OpenSSL support absolutely mandatory?

> +	help
> +	  Event-driven I/O server-side JavaScript environment based on V8.
> +
> +	  http://nodejs.org/

if BR2_PACKAGE_NODEJS

> +
> +config BR2_PACKAGE_NODEJS_NPM
> +	bool "nodejs npm"
> +	depends on BR2_PACKAGE_NODEJS

Thanks to the if above, you can drop this depends on.

> +	help
> +	  Enable npm (Node Package Manager).
> +
> +config BR2_PACKAGE_NODEJS_WAF
> +	bool "nodejs waf"
> +	depends on BR2_PACKAGE_NODEJS

Ditto.

> +	help
> +	  Enable node-waf for building native modules.

endif

> diff --git a/package/nodejs/nodejs.mk b/package/nodejs/nodejs.mk
> new file mode 100644
> index 0000000..8a0fa91
> --- /dev/null
> +++ b/package/nodejs/nodejs.mk
> @@ -0,0 +1,54 @@
> +#############################################################
> +#
> +# nodejs
> +#
> +#############################################################
> +NODEJS_VERSION = 0.8.6
> +NODEJS_SOURCE = node-v$(NODEJS_VERSION).tar.gz
> +NODEJS_SITE = http://nodejs.org/dist/v$(NODEJS_VERSION)
> +NODEJS_INSTALL_STAGING = YES

Does NodeJS contains libraries required by other packages?

> +NODEJS_DEPENDENCIES = host-python
> +NODEJS_LICENSE = MIT
> +
> +define NODEJS_CONFIGURE_CMDS
> +	(cd $(@D); rm -rf config.cache; \
> +		$(TARGET_CONFIGURE_ARGS) \
> +		$(TARGET_CONFIGURE_OPTS) \
> +		PATH="$(HOST_DIR)/usr/bin:$(PATH)" \
> +		./configure \
> +		--prefix=/usr \
> +		--without-snapshot \
> +		$(if $(BR2_PACKAGE_NODEJS_NPM),,--without-npm) \
> +		$(if $(BR2_PACKAGE_NODEJS_WAF),,--without-waf) \
> +		--without-dtrace \
> +		--without-etw \
> +	)
> +endef

I haven't looked at the nodejs source code, but looking at this, it
seems like it is using a conventional autoconf based build system. Can
you use the autotools-package infrastructure instead of redefining all
the configure/build/install steps manually?

> diff --git a/package/python/python.mk b/package/python/python.mk
> index fae4e5c..7b314ab 100644
> --- a/package/python/python.mk
> +++ b/package/python/python.mk
> @@ -27,7 +27,6 @@ HOST_PYTHON_CONF_OPT += 	\
>  	--disable-gdbm		\
>  	--disable-bsddb		\
>  	--disable-test-modules	\
> -	--disable-bz2		\
>  	--disable-ssl
>  
>  HOST_PYTHON_MAKE_ENV = \

This should be in a separate patch, with an explanation on why it is
necessary.

Thanks!

Thomas
Thomas Petazzoni - Aug. 12, 2012, 7:06 a.m.
Hello Jonathan,

Please keep the list Cc'ed for our exchanges, thanks!

Le Sun, 12 Aug 2012 11:16:15 +1000,
Jonathan Liu <net147@gmail.com> a écrit :

> >> +config BR2_PACKAGE_NODEJS
> >> +	bool "nodejs"
> >> +	select BR2_PACKAGE_OPENSSL
> > I know nothing about nodejs. Is OpenSSL support absolutely mandatory?
> If I remember correctly, Node.js already bundles a copy of OpenSSL so 
> this dependency can be removed.
> I can add an option to enable/disable built-in SSL support in the 
> Node.js build.

It would be better if Node.js could use the OpenSSL version that is in
Buildroot rather than its own internal one. It avoids having two copies
of OpenSSL on the target system.

And yes, if the SSL support can be enabled/disabled easily, it would be
great: OpenSSL is a fairly heavy dependency.

> >> diff --git a/package/nodejs/nodejs.mk b/package/nodejs/nodejs.mk
> >> new file mode 100644
> >> index 0000000..8a0fa91
> >> --- /dev/null
> >> +++ b/package/nodejs/nodejs.mk
> >> @@ -0,0 +1,54 @@
> >> +#############################################################
> >> +#
> >> +# nodejs
> >> +#
> >> +#############################################################
> >> +NODEJS_VERSION = 0.8.6
> >> +NODEJS_SOURCE = node-v$(NODEJS_VERSION).tar.gz
> >> +NODEJS_SITE = http://nodejs.org/dist/v$(NODEJS_VERSION)
> >> +NODEJS_INSTALL_STAGING = YES
> > Does NodeJS contains libraries required by other packages?
> The headers and node-waf binary are needed to build 3rd party native 
> modules. I figured it may be useful if someone wants to create buildroot 
> packages for node.js modules in the future.

Can you add a comment with a similar explanation just before this line.
For libraries, the reason to have _INSTALL_STAGING is fairly obvious,
for things like nodejs, it's a little bit less obvious for the ones who
are not familiar with what nodejs is.

Thanks!

Thomas
Jonathan Liu - Aug. 12, 2012, 8:51 a.m.
Hi Thomas,

On 12/08/2012 5:06 PM, Thomas Petazzoni wrote:
> It would be better if Node.js could use the OpenSSL version that is in
> Buildroot rather than its own internal one. It avoids having two copies
> of OpenSSL on the target system.
>
> And yes, if the SSL support can be enabled/disabled easily, it would be
> great: OpenSSL is a fairly heavy dependency.
Done.
>
>>>> diff --git a/package/nodejs/nodejs.mk b/package/nodejs/nodejs.mk
>>>> new file mode 100644
>>>> index 0000000..8a0fa91
>>>> --- /dev/null
>>>> +++ b/package/nodejs/nodejs.mk
>>>> @@ -0,0 +1,54 @@
>>>> +#############################################################
>>>> +#
>>>> +# nodejs
>>>> +#
>>>> +#############################################################
>>>> +NODEJS_VERSION = 0.8.6
>>>> +NODEJS_SOURCE = node-v$(NODEJS_VERSION).tar.gz
>>>> +NODEJS_SITE = http://nodejs.org/dist/v$(NODEJS_VERSION)
>>>> +NODEJS_INSTALL_STAGING = YES
>>> Does NodeJS contains libraries required by other packages?
>> The headers and node-waf binary are needed to build 3rd party native
>> modules. I figured it may be useful if someone wants to create buildroot
>> packages for node.js modules in the future.
> Can you add a comment with a similar explanation just before this line.
> For libraries, the reason to have _INSTALL_STAGING is fairly obvious,
> for things like nodejs, it's a little bit less obvious for the ones who
> are not familiar with what nodejs is.
Done.

I've submitted the updated patch as V3.

Regards,
Jonathan

Patch

diff --git a/package/Config.in b/package/Config.in
index f308de7..76c589b 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -263,6 +263,7 @@  source "package/xavante/Config.in"
 endmenu
 endif
 source "package/microperl/Config.in"
+source "package/nodejs/Config.in"
 source "package/php/Config.in"
 source "package/python/Config.in"
 if BR2_PACKAGE_PYTHON
diff --git a/package/nodejs/Config.in b/package/nodejs/Config.in
new file mode 100644
index 0000000..bcc5f17
--- /dev/null
+++ b/package/nodejs/Config.in
@@ -0,0 +1,19 @@ 
+config BR2_PACKAGE_NODEJS
+	bool "nodejs"
+	select BR2_PACKAGE_OPENSSL
+	help
+	  Event-driven I/O server-side JavaScript environment based on V8.
+
+	  http://nodejs.org/
+
+config BR2_PACKAGE_NODEJS_NPM
+	bool "nodejs npm"
+	depends on BR2_PACKAGE_NODEJS
+	help
+	  Enable npm (Node Package Manager).
+
+config BR2_PACKAGE_NODEJS_WAF
+	bool "nodejs waf"
+	depends on BR2_PACKAGE_NODEJS
+	help
+	  Enable node-waf for building native modules.
diff --git a/package/nodejs/nodejs.mk b/package/nodejs/nodejs.mk
new file mode 100644
index 0000000..8a0fa91
--- /dev/null
+++ b/package/nodejs/nodejs.mk
@@ -0,0 +1,54 @@ 
+#############################################################
+#
+# nodejs
+#
+#############################################################
+NODEJS_VERSION = 0.8.6
+NODEJS_SOURCE = node-v$(NODEJS_VERSION).tar.gz
+NODEJS_SITE = http://nodejs.org/dist/v$(NODEJS_VERSION)
+NODEJS_INSTALL_STAGING = YES
+NODEJS_DEPENDENCIES = host-python
+NODEJS_LICENSE = MIT
+
+define NODEJS_CONFIGURE_CMDS
+	(cd $(@D); rm -rf config.cache; \
+		$(TARGET_CONFIGURE_ARGS) \
+		$(TARGET_CONFIGURE_OPTS) \
+		PATH="$(HOST_DIR)/usr/bin:$(PATH)" \
+		./configure \
+		--prefix=/usr \
+		--without-snapshot \
+		$(if $(BR2_PACKAGE_NODEJS_NPM),,--without-npm) \
+		$(if $(BR2_PACKAGE_NODEJS_WAF),,--without-waf) \
+		--without-dtrace \
+		--without-etw \
+	)
+endef
+
+define NODEJS_BUILD_CMDS
+	PATH="$(HOST_DIR)/usr/bin:$(PATH)" $(MAKE) -C $(@D)
+endef
+
+define NODEJS_INSTALL_STAGING_CMDS
+	PATH="$(HOST_DIR)/usr/bin:$(PATH)" $(MAKE) -C $(@D) DESTDIR=$(STAGING_DIR) install
+endef
+
+define NODEJS_UNINSTALL_STAGING_CMDS
+	rm -f $(STAGING_DIR)/usr/bin/node
+	rm -f $(STAGING_DIR)/usr/bin/node-waf
+	rm -f $(STAGING_DIR)/usr/bin/npm
+	rm -rf $(STAGING_DIR)/usr/include/node
+	rm -rf $(STAGING_DIR)/usr/lib/node
+	rm -rf $(STAGING_DIR)/usr/lib/node_modules
+	rm -f $(STAGING_DIR)/usr/share/man/man1/node.1
+endef
+
+define NODEJS_INSTALL_TARGET_CMDS
+	PATH="$(HOST_DIR)/usr/bin:$(PATH)" $(MAKE) -C $(@D) DESTDIR=$(TARGET_DIR) install-bin
+endef
+
+define NODEJS_UNINSTALL_TARGET_CMDS
+	rm -f $(TARGET_DIR)/usr/bin/node
+endef
+
+$(eval $(generic-package))
diff --git a/package/python/python.mk b/package/python/python.mk
index fae4e5c..7b314ab 100644
--- a/package/python/python.mk
+++ b/package/python/python.mk
@@ -27,7 +27,6 @@  HOST_PYTHON_CONF_OPT += 	\
 	--disable-gdbm		\
 	--disable-bsddb		\
 	--disable-test-modules	\
-	--disable-bz2		\
 	--disable-ssl
 
 HOST_PYTHON_MAKE_ENV = \