--- libgemplugin-ruby-0.2.3.orig/debian/overrides/libgemplugin-ruby
+++ libgemplugin-ruby-0.2.3/debian/overrides/libgemplugin-ruby
@@ -0,0 +1,4 @@
+# These license files are part of gemplugin skeleton, copied by gpgen, and
+# are not duplicate license files for the source.
+libgemplugin-ruby: extra-license-file usr/share/libgemplugin-ruby/resources/COPYING
+libgemplugin-ruby: extra-license-file usr/share/libgemplugin-ruby/resources/LICENSE
--- libgemplugin-ruby-0.2.3.orig/debian/copyright
+++ libgemplugin-ruby-0.2.3/debian/copyright
@@ -0,0 +1,69 @@
+This package was debianized by Filipe Lautert <filipe@icewall.org>
+Tue,  9 Jan 2007 22:46:24 -0200
+
+It incorporates packaging work done by Jens Kraemer <jk@jkraemer.net>
+
+It was downloaded from http://mongrel.rubyforge.org/releases/gems/
+
+Upstream Author: Zed Shaw <zedshaw@zedshaw.com>
+
+On Debian systems, the full text of the GNU General Public License can be
+found at /usr/share/common-licenses/GPL.
+
+Copyright (c) 2006-2007 Zed Shaw <zedshaw@zedshaw.com>
+
+GemPlugin is copyrighted free software by Zed A. Shaw
+<zedshaw at zedshaw dot com> You can redistribute it and/or modify it under
+either the terms of the GPL or the conditions below:
+
+1. You may make and give away verbatim copies of the source form of the
+   software without restriction, provided that you duplicate all of the
+   original copyright notices and associated disclaimers.
+
+2. You may modify your copy of the software in any way, provided that
+   you do at least ONE of the following:
+
+     a) place your modifications in the Public Domain or otherwise make them
+     Freely Available, such as by posting said modifications to Usenet or an
+     equivalent medium, or by allowing the author to include your
+     modifications in the software.
+
+     b) use the modified software only within your corporation or
+        organization.
+
+     c) rename any non-standard executables so the names do not conflict with
+     standard executables, which must also be provided.
+
+     d) make other distribution arrangements with the author.
+
+3. You may distribute the software in object code or executable
+   form, provided that you do at least ONE of the following:
+
+     a) distribute the executables and library files of the software,
+     together with instructions (in the manual page or equivalent) on where
+     to get the original distribution.
+
+     b) accompany the distribution with the machine-readable source of the
+     software.
+
+     c) give non-standard executables non-standard names, with
+        instructions on where to get the original software distribution.
+
+     d) make other distribution arrangements with the author.
+
+4. You may modify and include the part of the software into any other
+   software (possibly commercial).  But some files in the distribution
+   are not written by the author, so that they are not under this terms.
+
+5. The scripts and library files supplied as input to or produced as 
+   output from the software do not automatically fall under the
+   copyright of the software, but belong to whomever generated them, 
+   and may be sold commercially, and may be aggregated with this
+   software.
+
+6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
+   IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+   PURPOSE.
+
+
--- libgemplugin-ruby-0.2.3.orig/debian/rules
+++ libgemplugin-ruby-0.2.3/debian/rules
@@ -0,0 +1,11 @@
+#!/usr/bin/make -f
+#export DH_VERBOSE=1
+
+include /usr/share/cdbs/1/rules/debhelper.mk
+include /usr/share/cdbs/1/rules/simple-patchsys.mk
+
+configure/libgemplugin-ruby::
+	rdoc --op doc/rdoc lib/
+
+install/libgemplugin-ruby1.8::
+	dh_installman debian/gpgen.1
--- libgemplugin-ruby-0.2.3.orig/debian/changelog
+++ libgemplugin-ruby-0.2.3/debian/changelog
@@ -0,0 +1,43 @@
+libgemplugin-ruby (0.2.3-1~bpo40+1) etch-backports; urgency=low
+
+  * Rebuild for etch.
+
+ -- Jeremy Lainé <jeremy.laine@m4x.org>  Mon, 04 Feb 2008 13:23:02 +0100
+
+libgemplugin-ruby (0.2.3-1) unstable; urgency=low
+
+  [ Arnaud Cornet ]
+  * Use new Homepage dpkg header.
+
+  [ Filipe Lautert ]
+  * New upstream version.
+  * Changed watch file to point to rubyforge repository (tgz sources are
+    found there).
+  * Added new control field 'Dm-Upload-Allowed: yes'
+  * Added rdoc as dependency to generate documentation for this package.
+  * Added VCS-* fields.
+
+  [ Jeremy Lainé ]
+  * Add patch for packaged gem plugins (Closes: #459882).
+
+  [ Paul van Tilburg ]
+  * Bumped standards version to 3.7.3; no changes required.
+  * Added missing "whatis" information to the manpage.
+  * Removed debian/libgemplugin-ruby1.8.docs, resources/ contains
+    no documentation, just a template.
+  * Corrected my name in the Uploaders field.
+  * Updated patch: 02-set_correct_path_for_resources_dir.diff,
+    added debian/libgemplugin-ruby.install:
+    resources should go to /usr/share/libgemplugin-ruby, not
+    /usr/share/doc/libgemplugin-ruby1.8.
+  * Added debian/libgemplugin-ruby.overrides and install it to get rid of
+    the extra-license warnings for license files in the skeleton
+    directory.
+
+ -- Paul van Tilburg <paulvt@debian.org>  Sat, 19 Jan 2008 10:48:26 +0100
+
+libgemplugin-ruby (0.2.2-1) unstable; urgency=low
+
+  * Initial Release.
+
+ -- Filipe Lautert <filipe@icewall.org>  Tue,  9 Jan 2007 22:46:24 -0200
--- libgemplugin-ruby-0.2.3.orig/debian/watch
+++ libgemplugin-ruby-0.2.3/debian/watch
@@ -0,0 +1,2 @@
+version=3
+http://rubyforge.org/frs/?group_id=1306 .*/gem_plugin-(.*)\.tgz
--- libgemplugin-ruby-0.2.3.orig/debian/libgemplugin-ruby.install
+++ libgemplugin-ruby-0.2.3/debian/libgemplugin-ruby.install
@@ -0,0 +1,2 @@
+resources                          usr/share/libgemplugin-ruby/
+debian/overrides/libgemplugin-ruby usr/share/lintian/overrides/
--- libgemplugin-ruby-0.2.3.orig/debian/gpgen.1
+++ libgemplugin-ruby-0.2.3/debian/gpgen.1
@@ -0,0 +1,18 @@
+.TH gpgen 1 "2007-01-10" "gpgen"
+.SH NAME
+gpgen \- gemplugin skeleton directory creator
+.
+.SH SYNOPSIS
+.
+gpgen <plugin_name>
+.SH DESCRIPTION
+.
+gpgen creates the skeleton for a gemplugin in directory <plugin_name>.
+.PP
+Usage example:  gpgen mygemplugin
+.
+.SH AUTHOR
+Zed a. Shaw <zedshaw@zedshaw.com>
+.PP
+This manual page was written for the Debian system by Filipe Lautert <filipe@icewall.org>.
+It might be used and redistributed under the same terms as the program itself.
--- libgemplugin-ruby-0.2.3.orig/debian/libgemplugin-ruby1.8.install
+++ libgemplugin-ruby-0.2.3/debian/libgemplugin-ruby1.8.install
@@ -0,0 +1,2 @@
+lib/* usr/lib/ruby/1.8/
+bin/* usr/bin/
--- libgemplugin-ruby-0.2.3.orig/debian/control
+++ libgemplugin-ruby-0.2.3/debian/control
@@ -0,0 +1,36 @@
+Source: libgemplugin-ruby
+Section: interpreters
+Priority: optional
+Maintainer: Filipe Lautert <filipe@icewall.org>
+Uploaders: Debian Ruby Extras Maintainers <pkg-ruby-extras-maintainers@lists.alioth.debian.org>, Paul van Tilburg <paulvt@debian.org>
+Build-Depends: debhelper (>> 5), ruby-pkg-tools (>= 0.8), ruby, ruby1.8-dev, cdbs, rdoc1.8
+Standards-Version: 3.7.3
+Homepage: http://mongrel.rubyforge.org/
+XS-Dm-Upload-Allowed: yes
+Vcs-Browser: http://svn.debian.org/wsvn/pkg-ruby-extras/packages/libgemplugin-ruby/trunk/
+Vcs-Svn: svn://svn.debian.org/pkg-ruby-extras/packages/libgemplugin-ruby/trunk/
+
+Package: libgemplugin-ruby1.8
+Architecture: all
+Depends: ${shlibs:Depends}, ${misc:Depends}, ruby (>=1.8), libgems-ruby1.8
+Description: Gem Based Plugin System
+ GemPlugin is a system that lets your users install gems and lets you load
+ them as additional features to use in your software.  It originated from the
+ Mongrel (http://mongrel.rubyforge.org) project but proved useful enough to
+ break out into a separate project.
+ .
+ This package is built for Ruby 1.8.
+
+Package: libgemplugin-ruby
+Architecture: all
+Depends: libgemplugin-ruby1.8
+Description: Gem Based Plugin System
+ GemPlugin is a system that lets your users install gems and lets you load
+ them as additional features to use in your software.  It originated from the
+ Mongrel (http://mongrel.rubyforge.org) project but proved useful enough to
+ break out into a separate project.
+ .
+ This is a dependency package which depends on Debian's default Ruby version
+ (currently 1.8.x).
+
+
--- libgemplugin-ruby-0.2.3.orig/debian/compat
+++ libgemplugin-ruby-0.2.3/debian/compat
@@ -0,0 +1 @@
+4
--- libgemplugin-ruby-0.2.3.orig/debian/libgemplugin-ruby.docs
+++ libgemplugin-ruby-0.2.3/debian/libgemplugin-ruby.docs
@@ -0,0 +1,2 @@
+README
+doc
--- libgemplugin-ruby-0.2.3.orig/debian/patches/03-support_packaged_plugins.diff
+++ libgemplugin-ruby-0.2.3/debian/patches/03-support_packaged_plugins.diff
@@ -0,0 +1,57 @@
+diff -urN libgemplugin-ruby-0.2.2.orig/lib/gem_plugin.rb libgemplugin-ruby-0.2.2/lib/gem_plugin.rb
+--- libgemplugin-ruby-0.2.2.orig/lib/gem_plugin.rb	2007-05-12 22:21:38.000000000 +0200
++++ libgemplugin-ruby-0.2.2/lib/gem_plugin.rb	2008-01-10 00:18:37.000000000 +0100
+@@ -51,6 +51,7 @@
+ 
+   EXCLUDE = true
+   INCLUDE = false
++  SITE_GEMPLUGINS = '/usr/share/gemplugins/' + Config::CONFIG['ruby_version']
+ 
+   class PluginNotLoaded < StandardError; end
+ 
+@@ -105,9 +106,24 @@
+     # To prevent this load requires the full path to the "init.rb" file, which
+     # avoids the RubyGems autorequire magic.
+     def load(needs = {})
+-      sdir = File.join(Gem.dir, "specifications")
+-      gems = Gem::SourceIndex.from_installed_gems(sdir)
++      gems = Gem::SourceIndex.from_installed_gems
+       needs = needs.merge({"gem_plugin" => INCLUDE})
++
++      # add packaged gem plugins
++      Dir.glob(File.join(SITE_GEMPLUGINS, "*.gemspec")).each do |file_name|
++        gemspec = Gem::SourceIndex.load_specification(file_name.untaint)
++        if gemspec
++          class << gemspec
++            def full_gem_path
++              File.join(File::dirname(@loaded_from), name)
++            end
++            def full_init_path
++              File.join(Config::CONFIG['rubylibdir'], name, "init.rb")
++            end
++          end
++          gems.add_spec(gemspec)
++        end
++      end
+       
+       gems.each do |path, gem|
+         # don't load gems more than once
+@@ -129,9 +145,16 @@
+           
+           # Previously was set wrong, we already have the correct gem path!
+           #gem_dir = File.join(Gem.dir, "gems", "#{gem.name}-#{gem.version}")
+-          gem_dir = File.join(Gem.dir, "gems", path)
++          gem_dir = gem.full_gem_path
++
++          # Load correct init.rb, according to whether this is a 
++          # packaged gem plugin or not
++          if gem.respond_to?("full_init_path")
++            require gem.full_init_path
++          else
++            require File.join(gem_dir, "lib", gem.name, "init.rb")
++          end
+           
+-          require File.join(gem_dir, "lib", gem.name, "init.rb")
+           @gems[gem.name] = gem_dir
+         end
+       end
--- libgemplugin-ruby-0.2.3.orig/debian/patches/01-added_she_bang_line.diff
+++ libgemplugin-ruby-0.2.3/debian/patches/01-added_she_bang_line.diff
@@ -0,0 +1,8 @@
+--- bin/gpgen-or        2007-01-10 11:32:47.651804156 -0200
++++ bin/gpgen   2007-01-10 13:43:24.750059066 -0200
+@@ -1,3 +1,5 @@
++#!/usr/bin/ruby
++
+ require 'erb'
+ require 'fileutils'
+ include FileUtils
--- libgemplugin-ruby-0.2.3.orig/debian/patches/02-set_correct_path_for_resources_dir.diff
+++ libgemplugin-ruby-0.2.3/debian/patches/02-set_correct_path_for_resources_dir.diff
@@ -0,0 +1,12 @@
+--- bin/gpgen-old	2007-05-12 17:32:37.067837543 -0300
++++ bin/gpgen	2007-05-12 17:35:29.263551011 -0300
+@@ -11,7 +11,8 @@
+ 
+ # setup the required binding variables for erb processing later
+ project = ARGV.shift
+-gem_plugin_base = File.expand_path(File.join(File.dirname(__FILE__), ".."))
++#gem_plugin_base = File.expand_path(File.join(File.dirname(__FILE__), ".."))
++gem_plugin_base = File.expand_path('/usr/share/libgemplugin-ruby')
+ resources = File.join(gem_plugin_base, "resources")
+ gem_plugin_version = gem_plugin_base[gem_plugin_base.rindex("-")+1 .. -1]
+ 
