[ruby-shadow] Add ruby-1.9 support

Todd Zullinger tmz at fedoraproject.org
Sun Apr 22 13:44:55 UTC 2012


commit a20aac2d6fb155631e11c202c581109d780bf80c
Author: Todd Zullinger <tmz at pobox.com>
Date:   Fri Apr 20 10:23:00 2012 -0400

    Add ruby-1.9 support
    
    This comes from the rubygem-ruby-shadow fork of this project on github¹.
    Once a review of that fork is completed, this package will be obsolete.²
    
    ¹ https://github.com/apalmblad/ruby-shadow
    ² https://bugzilla.redhat.com/782560

 .gitignore                      |    6 +-
 0001-Add-ruby-1.9-support.patch |  236 +++++++++++++++++++++++++++++++++++++++
 ruby-shadow-1.4.1-cflags.patch  |   14 ++-
 ruby-shadow-1.4.1-depend.patch  |    5 -
 ruby-shadow-1.4.1-struct.patch  |   51 ---------
 ruby-shadow.spec                |   33 ++++--
 6 files changed, 269 insertions(+), 76 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 5c03b96..19232e9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,5 @@
-ruby-shadow-1.4.1.tar.gz
+*~
+*.rpm
+*.tar.gz
+/.build*.log
+/shadow-*/
diff --git a/0001-Add-ruby-1.9-support.patch b/0001-Add-ruby-1.9-support.patch
new file mode 100644
index 0000000..62685b8
--- /dev/null
+++ b/0001-Add-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
+
diff --git a/ruby-shadow-1.4.1-cflags.patch b/ruby-shadow-1.4.1-cflags.patch
index a249d8e..02524e3 100644
--- a/ruby-shadow-1.4.1-cflags.patch
+++ b/ruby-shadow-1.4.1-cflags.patch
@@ -1,11 +1,13 @@
---- shadow-1.4.1/extconf.rb-orig	2007-05-15 09:16:03.000000000 +0100
-+++ shadow-1.4.1/extconf.rb	2007-05-15 09:17:29.000000000 +0100
-@@ -6,7 +6,7 @@
+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 = ""
+-$CFLAGS = RUBY_VERSION =~ /1\.9/ ? '-DRUBY19' : ''
 +$CFLAGS = "#{$CFLAGS}"
- $LDFLAGS = "-lshadow"
++$CFLAGS += RUBY_VERSION =~ /1\.9/ ? ' -DRUBY19' : ''
+ 
+ #$LDFLAGS = "-lshadow"
  
- if( ! (ok = have_library("shadow","getspent")) )
diff --git a/ruby-shadow.spec b/ruby-shadow.spec
index 0faabb1..969ede2 100644
--- a/ruby-shadow.spec
+++ b/ruby-shadow.spec
@@ -1,22 +1,27 @@
-%{!?ruby_sitearch: %define ruby_sitearch %(ruby -rrbconfig -e "puts Config::CONFIG['sitearchdir']")}
-# This fails in mock since ruby doesn't exist in the default build env.
-#%{!?ruby_abi: %define ruby_abi %(ruby -rrbconfig -e "puts Config::CONFIG['ruby_version']")}
+%if 0%{?fedora} >= 17
+%global ruby_archdir   %(ruby -rrbconfig -e 'puts RbConfig::CONFIG["vendorarchdir"]')
+%else
+%global ruby_archdir   %(ruby -rrbconfig -e 'puts RbConfig::CONFIG["sitearchdir"]')
+%endif
+
+%global ruby_version    %(ruby -rrbconfig -e 'puts RbConfig::CONFIG["ruby_version"]')
 
 Name:           ruby-shadow
 Version:        1.4.1
-Release:        15%{?dist}
+Release:        16%{?dist}
 Summary:        Ruby bindings for shadow password access
 Group:          System Environment/Libraries
 License:        Public Domain
 URL:            http://ttsky.net/
 Source0:        http://ttsky.net/src/ruby-shadow-%{version}.tar.gz
-Patch0:         ruby-shadow-1.4.1-cflags.patch
-Patch1:         ruby-shadow-1.4.1-struct.patch
-Patch2:         ruby-shadow-1.4.1-depend.patch
+Patch0:         0001-Add-ruby-1.9-support.patch
+Patch1:         ruby-shadow-1.4.1-cflags.patch
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-BuildRequires:  ruby ruby-devel
-BuildRequires:  ruby(abi) = 1.8
-Requires:       ruby(abi) = 1.8
+BuildRequires:  ruby-devel
+# Work around the lack of ruby in the default mock buildroot
+%if "%{ruby_version}"
+Requires:       ruby(abi) = %{ruby_version}
+%endif
 Provides:       ruby(shadow) = %{version}-%{release}
 
 %description
@@ -26,7 +31,6 @@ Ruby bindings for shadow password access
 %setup -q -n shadow-%{version}
 %patch0 -p1
 %patch1 -p1
-%patch2 -p1
 %{_bindir}/iconv -f EUCJP -t utf8 -o README.ja README.euc
 
 %build
@@ -35,7 +39,7 @@ make
 
 %install
 rm -rf %{buildroot}
-make DESTDIR=%{buildroot} install
+make DESTDIR=%{buildroot} sitearchdir=%{buildroot}%{ruby_archdir} install
 
 %clean
 rm -rf %{buildroot}
@@ -43,9 +47,12 @@ rm -rf %{buildroot}
 %files
 %defattr(-,root,root,-)
 %doc HISTORY README README.ja
-%{ruby_sitearch}/shadow.so
+%{ruby_archdir}/shadow.so
 
 %changelog
+* Fri Apr 20 2012 Todd Zullinger <tmz at pobox.com> - 1.4.1-16
+- Add ruby-1.9 support
+
 * Sat Jan 14 2012 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 1.4.1-15
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild
 


More information about the scm-commits mailing list