ruby: spin-off ruby-digest from ruby-openssl
authorLuiz Angelo Daros de Luca <luizluca@gmail.com>
Sat, 4 Oct 2014 22:16:40 +0000 (19:16 -0300)
committerLuiz Angelo Daros de Luca <luizluca@gmail.com>
Tue, 7 Oct 2014 17:14:53 +0000 (14:14 -0300)
Digest can use OpenSSL or ruby internal implementation of hash functions. The first
uses less disk space but requires openssl, that is relatively big. As internal hash
implementations are not too much bigger than openssl version, it is compiled by
default. A new config option can change it to use OpenSSL instead.

As digest is independent from openssl, ruby-digest was created as a new pkgs.

Adds pkgs:
- ruby-digest (from ruby-openssl)

Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
lang/ruby/Makefile

index be390bfa3c6197e4ae8abff7a213ff265433c17d..38a243f545b3a75002b3b4ae079834a3f9ea1ae5 100644 (file)
@@ -91,6 +91,26 @@ $(call Package/ruby/Default)
   DEPENDS:=ruby
 endef
 
+define Package/ruby-digest
+$(call Package/ruby/Default)
+  TITLE:=Ruby Digest Library
+  DEPENDS:=ruby +RUBY_DIGEST_USE_OPENSSL:libopenssl
+endef
+
+define Package/ruby-digest/config
+
+  config RUBY_DIGEST_USE_OPENSSL
+               bool "Use OpenSSL functions for ruby digest hash functions"
+        depends on PACKAGE_ruby-digest
+               help
+                       Ruby can use OpenSSL hash functions or compile alternative implementations. Using
+                       OpenSSL saves about 30KBytes (less when compressed) but requires OpenSSL (that
+                       is way bigger than that). However, if OpenSSL is already needed by another usage,
+                       as ruby-openssl or any other non ruby package, it is better to mark this option.
+               default n
+
+endef
+
 define Package/ruby-dl
 $(call Package/ruby/Default)
   TITLE+= (dynamic linker support) (adds 5MB+)
@@ -239,6 +259,15 @@ CONFIGURE_ARGS += \
        --with-ruby-version=minor \
        --with-iconv-dir=$(ICONV_PREFIX) \
 
+ifndef CONFIG_RUBY_DIGEST_USE_OPENSSL
+CONFIGURE_ARGS += \
+       --with-bundled-sha1\
+       --with-bundled-md5\
+       --with-bundled-rmd160\
+       --with-bundled-sha2 \
+
+endif
+
 TARGET_LDFLAGS += -L$(PKG_BUILD_DIR)
 
 MAKE_FLAGS += \
@@ -360,6 +389,15 @@ define Package/ruby-cgi/install
        $(CP) $(PKG_INSTALL_DIR)/usr/lib/ruby/$(PKG_LIBVER)/cgi.rb $(1)/usr/lib/ruby/$(PKG_LIBVER)/
 endef
 
+define Package/ruby-digest/install
+       ( cd $(PKG_INSTALL_DIR); $(TAR) -cf - \
+               usr/lib/ruby/$(PKG_LIBVER)/digest \
+               usr/lib/ruby/$(PKG_LIBVER)/digest.rb \
+               usr/lib/ruby/$(PKG_LIBVER)/*/digest.so \
+               usr/lib/ruby/$(PKG_LIBVER)/*/digest/* \
+       ) | ( cd $(1); $(TAR) -xf - )
+endef
+
 define Package/ruby-dl/install
        ( cd $(PKG_INSTALL_DIR); $(TAR) -cf - \
                usr/lib/ruby/$(PKG_LIBVER)/*/dl.so \
@@ -443,10 +481,6 @@ endef
 
 define Package/ruby-openssl/install
        ( cd $(PKG_INSTALL_DIR); $(TAR) -cf - \
-               usr/lib/ruby/$(PKG_LIBVER)/digest \
-               usr/lib/ruby/$(PKG_LIBVER)/digest.rb \
-               usr/lib/ruby/$(PKG_LIBVER)/*/digest.so \
-               usr/lib/ruby/$(PKG_LIBVER)/*/digest/*.so \
                usr/lib/ruby/$(PKG_LIBVER)/openssl \
                usr/lib/ruby/$(PKG_LIBVER)/openssl.rb \
                usr/lib/ruby/$(PKG_LIBVER)/*/openssl.so \
@@ -556,6 +590,7 @@ $(eval $(call BuildPackage,libruby))
 $(eval $(call BuildPackage,ruby-core))
 $(eval $(call BuildPackage,ruby-bigdecimal))
 $(eval $(call BuildPackage,ruby-cgi))
+$(eval $(call BuildPackage,ruby-digest))
 $(eval $(call BuildPackage,ruby-dl))
 $(eval $(call BuildPackage,ruby-enc))
 $(eval $(call BuildPackage,ruby-erb))