[packages/ruby-shadow] new; based on fedora package

glen glen at pld-linux.org
Sun Aug 26 15:23:27 CEST 2012


commit 013904b7387497da83bd53d9246a0b77a7a43dca
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Sun Aug 26 16:23:11 2012 +0300

    new; based on fedora package

 cflags.patch           |  13 +++
 ruby-1.9-support.patch | 236 +++++++++++++++++++++++++++++++++++++++++++++++++
 ruby-shadow.spec       |  46 ++++++++++
 3 files changed, 295 insertions(+)
---
diff --git a/ruby-shadow.spec b/ruby-shadow.spec
new file mode 100644
index 0000000..28dc120
--- /dev/null
+++ b/ruby-shadow.spec
@@ -0,0 +1,46 @@
+Summary:	Ruby bindings for shadow password access
+Name:		ruby-shadow
+Version:	1.4.1
+Release:	1
+License:	Public Domain
+Group:		Libraries
+URL:		http://ttsky.net/
+Source0:	http://ttsky.net/src/%{name}-%{version}.tar.gz
+# Source0-md5:	425b742ac43bff359c1717360f761790
+Patch0:		ruby-1.9-support.patch
+Patch1:		cflags.patch
+BuildRequires:	rpmbuild(macros) >= 1.484
+BuildRequires:	ruby >= 1:1.8.6
+BuildRequires:	ruby-modules
+BuildRequires:	setup.rb
+%{?ruby_mod_ver_requires_eq}
+BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
+
+%description
+Ruby bindings for shadow password access.
+
+%prep
+%setup -q -n shadow-%{version}
+%patch0 -p1
+%patch1 -p1
+iconv -f EUCJP -t utf8 -o README.ja README.euc
+
+%build
+%{__ruby} extconf.rb \
+	--with-cflags="%{rpmcflags}"
+%{__make}
+
+%install
+rm -rf $RPM_BUILD_ROOT
+%{__make}  install \
+	sitearchdir=$RPM_BUILD_ROOT%{ruby_archdir} \
+	DESTDIR=$RPM_BUILD_ROOT
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(644,root,root,755)
+%doc HISTORY README
+%doc %lang(ja) README.ja
+%attr(755,root,root) %{ruby_archdir}/shadow.so
diff --git a/cflags.patch b/cflags.patch
new file mode 100644
index 0000000..02524e3
--- /dev/null
+++ b/cflags.patch
@@ -0,0 +1,13 @@
+diff -up shadow-1.4.1/extconf.rb~ shadow-1.4.1/extconf.rb
+--- shadow-1.4.1/extconf.rb~	2012-04-20 10:48:06.724264584 -0400
++++ shadow-1.4.1/extconf.rb	2012-04-20 10:40:45.517013943 -0400
+@@ -6,7 +6,8 @@
+ 
+ require 'mkmf'
+ 
+-$CFLAGS = RUBY_VERSION =~ /1\.9/ ? '-DRUBY19' : ''
++$CFLAGS = "#{$CFLAGS}"
++$CFLAGS += RUBY_VERSION =~ /1\.9/ ? ' -DRUBY19' : ''
+ 
+ #$LDFLAGS = "-lshadow"
+ 
diff --git a/ruby-1.9-support.patch b/ruby-1.9-support.patch
new file mode 100644
index 0000000..62685b8
--- /dev/null
+++ b/ruby-1.9-support.patch
@@ -0,0 +1,236 @@
+From bdca56125853d11f1edb367fdbaf4d5216c88f4f Mon Sep 17 00:00:00 2001
+From: Todd Zullinger <tmz at pobox.com>
+Date: Fri, 20 Apr 2012 10:17:39 -0400
+Subject: [PATCH] Add ruby-1.9 support
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This comes from the rubygem-ruby-shadow fork of this project on github¹.
+
+¹ https://github.com/apalmblad/ruby-shadow
+---
+ HISTORY    |   24 ++++++++++++++++++++++++
+ depend     |   10 +++++++++-
+ extconf.rb |    9 ++++++---
+ shadow.c   |   40 +++++++++++++++++++++++++++-------------
+ 4 files changed, 66 insertions(+), 17 deletions(-)
+
+diff --git a/HISTORY b/HISTORY
+index cd7d87e..e317c8e 100644
+--- a/HISTORY
++++ b/HISTORY
+@@ -1,3 +1,27 @@
++[2012/03/15]
++* Version 2.1.3
++ - MATSUU Takuto <matsuu at gentoo.org>
++ Fix a typo in the C code for rb_shadow_putspent.  Typo has been present since
++ ruby 1.9 code was added.
++[2011/02/08]
++* Version 2.1.2
++ -  Jeff Blaine <>, Adam Palmblad <adam.palmblad at teampages.com>:
++   Fix issues with compiling against Solaris.  Apparently solaris does not offer sgetspent
++ compiling against ruby 1.8; fixes were made to the ruby header path.
++[2011/02/08]
++* Version 2.1.1
++ -  Eric Hankins <ssilver at stormsilver.net>: Looks like there was a minor bug in
++ compiling against ruby 1.8; fixes were made to the ruby header path.
++[2011/01/27]
++* Version 2.1
++    - Ian Marlier <imarlier at brightcove.com>: Make ruby-shadow compile under Ruby 1.9.2
++        * STR2CSTR macro was removed in Ruby 1.9.2, after being deprecated in Ruby 1.8.  Change
++          to StringValuePtr() in its place.
++
++[2010/07/27]
++* Version 2.0
++    - Adam Palmblad <adam.palmblad at teampages.com>: Make ruby-shadow compile under Ruby 1.9
++
+ [1999/08/18]
+ * version 1.4.1
+   - extconf.rb supports glibc2(libc6).
+diff --git a/depend b/depend
+index f5811a2..33ed740 100644
+--- a/depend
++++ b/depend
+@@ -1 +1,9 @@
+-shadow.o : shadow.c $(hdrdir)/ruby.h $(hdrdir)/rubyio.h
++ifneq (,$(findstring 1.9,$(ruby_version)))
++	io_lib=$(hdrdir)/ruby/ruby/io.h
++	hdr=$(hdrdir)/ruby/ruby.h
++else
++	io_lib=$(hdrdir)/ruby/rubyio.h
++	hdr=$(hdrdir)/ruby.h
++endif
++
++shadow.o: shadow.c $(hdr) $(io_lib)
+diff --git a/extconf.rb b/extconf.rb
+index 6f300e5..d2baadd 100644
+--- a/extconf.rb
++++ b/extconf.rb
+@@ -6,15 +6,15 @@
+ 
+ require 'mkmf'
+ 
+-$CFLAGS = ""
+-$LDFLAGS = "-lshadow"
++$CFLAGS = RUBY_VERSION =~ /1\.9/ ? '-DRUBY19' : ''
++
++#$LDFLAGS = "-lshadow"
+ 
+ if( ! (ok = have_library("shadow","getspent")) )
+   $LDFLAGS = ""
+   ok = have_func("getspent")
+ end
+ 
+-ok &= have_func("sgetspent")
+ ok &= have_func("fgetspent")
+ ok &= have_func("setspent")
+ ok &= have_func("endspent")
+@@ -22,5 +22,8 @@ ok &= have_func("lckpwdf")
+ ok &= have_func("ulckpwdf")
+ 
+ if ok
++  if !have_func("sgetspent")
++    $CFLAGS += ' -DSOLARIS'
++  end
+   create_makefile("shadow")
+ end
+diff --git a/shadow.c b/shadow.c
+index 8a52c83..41ff003 100644
+--- a/shadow.c
++++ b/shadow.c
+@@ -10,7 +10,17 @@
+ 
+ #include <shadow.h>
+ #include "ruby.h"
++#ifdef RUBY19
++#include <ruby/io.h>
++#else
+ #include "rubyio.h"
++#endif
++
++#ifdef RUBY19
++#define file_ptr(x) (x)->stdio_file
++#else
++#define file_ptr(x) (x)->f
++#endif
+ 
+ static VALUE rb_mShadow;
+ static VALUE rb_mPasswd;
+@@ -36,6 +46,7 @@ rb_shadow_endspent(VALUE self)
+ };
+ 
+ 
++#ifndef SOLARIS
+ static VALUE
+ rb_shadow_sgetspent(VALUE self, VALUE str)
+ {
+@@ -45,7 +56,7 @@ rb_shadow_sgetspent(VALUE self, VALUE str)
+   if( TYPE(str) != T_STRING )
+     rb_raise(rb_eException,"argument must be a string.");
+ 
+-  entry = sgetspent(STR2CSTR(str));
++  entry = sgetspent(StringValuePtr(str));
+ 
+   if( entry == NULL )
+     return Qnil;
+@@ -60,10 +71,11 @@ rb_shadow_sgetspent(VALUE self, VALUE str)
+ 		      INT2FIX(entry->sp_inact),
+ 		      INT2FIX(entry->sp_expire),
+ 		      INT2FIX(entry->sp_flag),
+-		      0);
++		      NULL);
+   free(entry);
+   return result;
+ };
++#endif
+ 
+ static VALUE
+ rb_shadow_fgetspent(VALUE self, VALUE file)
+@@ -74,7 +86,7 @@ rb_shadow_fgetspent(VALUE self, VALUE file)
+   if( TYPE(file) != T_FILE )
+     rb_raise(rb_eTypeError,"argument must be a File.");
+ 
+-  entry = fgetspent((RFILE(file)->fptr)->f);
++  entry = fgetspent( file_ptr( (RFILE(file)->fptr) ) );
+ 
+   if( entry == NULL )
+     return Qnil;
+@@ -89,7 +101,7 @@ rb_shadow_fgetspent(VALUE self, VALUE file)
+ 		      INT2FIX(entry->sp_inact),
+ 		      INT2FIX(entry->sp_expire),
+ 		      INT2FIX(entry->sp_flag),
+-		      0);
++		      NULL);
+   return result;
+ };
+ 
+@@ -114,7 +126,7 @@ rb_shadow_getspent(VALUE self)
+ 		      INT2FIX(entry->sp_inact),
+ 		      INT2FIX(entry->sp_expire),
+ 		      INT2FIX(entry->sp_flag),
+-		      0);
++		      NULL);
+   return result;
+ };
+ 
+@@ -127,7 +139,7 @@ rb_shadow_getspnam(VALUE self, VALUE name)
+   if( TYPE(name) != T_STRING )
+     rb_raise(rb_eException,"argument must be a string.");
+ 
+-  entry = getspnam(STR2CSTR(name));
++  entry = getspnam(StringValuePtr(name));
+ 
+   if( entry == NULL )
+     return Qnil;
+@@ -142,7 +154,7 @@ rb_shadow_getspnam(VALUE self, VALUE name)
+ 		      INT2FIX(entry->sp_inact),
+ 		      INT2FIX(entry->sp_expire),
+ 		      INT2FIX(entry->sp_flag),
+-		      0);
++		      NULL);
+   return result;
+ };
+ 
+@@ -157,11 +169,11 @@ rb_shadow_putspent(VALUE self, VALUE entry, VALUE file)
+   int result;
+ 
+   for(i=0; i<=8; i++)
+-    val[i] = RSTRUCT(entry)->ptr[i];
+-  cfile = RFILE(file)->fptr->f;
++    val[i] = RSTRUCT_PTR( entry )[i]; //val[i] = RSTRUCT(entry)->ptr[i];
++  cfile = file_ptr( RFILE(file)->fptr );
+ 
+-  centry.sp_namp = STR2CSTR(val[0]);
+-  centry.sp_pwdp = STR2CSTR(val[1]);
++  centry.sp_namp = StringValuePtr(val[0]);
++  centry.sp_pwdp = StringValuePtr(val[1]);
+   centry.sp_lstchg = FIX2INT(val[2]);
+   centry.sp_min = FIX2INT(val[3]);
+   centry.sp_max = FIX2INT(val[4]);
+@@ -254,10 +266,10 @@ Init_shadow()
+   rb_sPasswdEntry = rb_struct_define("PasswdEntry",
+ 				     "sp_namp","sp_pwdp","sp_lstchg",
+ 				     "sp_min","sp_max","sp_warn",
+-				     "sp_inact","sp_expire","sp_flag",0);
++				     "sp_inact","sp_expire","sp_flag", NULL);
+   rb_sGroupEntry = rb_struct_define("GroupEntry",
+ 				    "sg_name","sg_passwd",
+-				    "sg_adm","sg_mem",0);
++				    "sg_adm","sg_mem",NULL);
+ 
+   rb_mShadow = rb_define_module("Shadow");
+   rb_eFileLock = rb_define_class_under(rb_mShadow,"FileLock",rb_eException);
+@@ -268,7 +280,9 @@ Init_shadow()
+ 
+   rb_define_module_function(rb_mPasswd,"setspent",rb_shadow_setspent,0);
+   rb_define_module_function(rb_mPasswd,"endspent",rb_shadow_endspent,0);
++  #ifndef SOLARIS
+   rb_define_module_function(rb_mPasswd,"sgetspent",rb_shadow_sgetspent,1);
++  #endif
+   rb_define_module_function(rb_mPasswd,"fgetspent",rb_shadow_fgetspent,1);
+   rb_define_module_function(rb_mPasswd,"getspent",rb_shadow_getspent,0);
+   rb_define_module_function(rb_mPasswd,"getspnam",rb_shadow_getspnam,1);
+-- 
+1.7.6
+


More information about the pld-cvs-commit mailing list