Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 153 lines (119 sloc) 3.24 kB
#!/bin/bash
# vim: ts=4 expandtab
DEBEMAIL="Your Name <youremail@example.com>"
RELEASE="1rel"
DISTRO=$( lsb_release -c -s )
base=$( dirname "$0" )
gem2debdir=$( cd "$base" ; pwd )
# from
# http://blog.loftninjas.org/?p=248
if [ $# -le 0 ]; then
echo "Usage: $0 <file .gem or .tar.gz> [ <package name> ]" >&2
echo "Generate a .deb package from a ruby .gem (or gem as .tar.gz)" >&2
exit 1
fi
filename="$1"
set -x
set -e
origpath=$( pwd )
#trap "cd '$origpath' && test -d '$WORKDIR' && rm -rf '$WORKDIR'" EXIT
if [ -z "$WORKDIR" ]; then
WORKDIR=$( mktemp -t -d gm2db.XXXXXXXXXX )
else
mkdir $WORKDIR
fi
if [ $? -ne 0 -o ! -d "$WORKDIR" ]; then
echo "$0: unable to create temporary directory" >&2
exit 1
fi
suffix=$( echo "$1" | tail -c4 )
if [ "$suffix" = "gem" ]; then
cp $filename $WORKDIR
cd $WORKDIR
filename=$(basename "$filename")
gem unpack "$filename"
basedir=$(basename "$filename" .gem)
else
cd $WORKDIR
filename=$( gem fetch "$1" | awk '{print $2}' )
filename="$filename.gem"
gem unpack "$filename"
basedir=$(basename "$filename" .gem)
fi
GEM_DEPENDENCIES=$( $gem2debdir/gemdeps.rb $filename )
cd "$basedir"
cp /usr/lib/ruby/1.8/setup.rb .
mkdir debian
BD=$( pwd )
VERSION=$( basename $BD | perl -pe 's/^.+-([\d.]+)$/$1/;' )
PACKAGE=$( basename $BD | perl -pe 's/^(.+)-[\d.]+$/$1/;' )
gemname=$PACKAGE
if [ -d ext ]; then
ARCHITECTURE=any
else
ARCHITECTURE=all
fi
# we don't want to edit the changelog file after generation
# so make /usr/bin/sensible-editor attempt to use /bin/true as the editor
EDITOR=/bin/true
VISUAL=/bin/true
export EDITOR VISUAL
if [ -z "$2" ]; then
pk=$( echo $gemname | tr '_' '-' )
PACKAGE="lib$pk-ruby"
else
PACKAGE="$2"
fi
if [ -z $DEPENDENCIES ]; then
DEPLIST="$GEM_DEPENDENCIES"
else
DEPLIST="$GEM_DEPENDENCIES, $DEPENDENCIES"
fi
dch --create "-v$VERSION" -D $DISTRO --package "$PACKAGE" 'initial release'
cat > debian/rules <<EOF
#!/usr/bin/make -f
include /usr/share/cdbs/1/rules/simple-patchsys.mk
include /usr/share/cdbs/1/rules/debhelper.mk
# Ruby package with setup.rb
include /usr/share/ruby-pkg-tools/1/class/ruby-setup-rb.mk
$RULES
EOF
chmod ugo+rx debian/rules
cat > debian/control <<EOF
Source: $PACKAGE
Section: libs
Priority: optional
Maintainer: No One
Build-Depends: cdbs, debhelper (>> 5.0.0), ruby-pkg-tools, ruby1.8
Standards-Version: 3.8.0
Package: $PACKAGE
Architecture: all
Depends: ${PACKAGE}1.8 (= $VERSION)
Description: the $PACKAGE ruby gem
.
This is a dummy package to install the $PACKAGE ruby gem
the default version of Ruby.
Package: ${PACKAGE}1.8
Architecture: $ARCHITECTURE
Depends: ruby1.8, $DEPLIST
Description: the $PACKAGE ruby gem
Package: $PACKAGE-doc
Section: doc
Architecture: all
Description: documentation for the $PACKAGE ruby gem
.
This is the documentation package, with upstream documentation as well as
generated rdoc.
EOF
cat > debian/watch <<EOF
# format version number, currently 3; this line is compulsory!
version=3
http://rubygems.org/gems/$gemname \
/downloads/$gemname-([\d\.]+).gem
EOF
dpkg-buildpackage -rfakeroot
cd $origpath
mkdir -p $PACKAGE
cp $WORKDIR/$PACKAGE* $PACKAGE/
ls -l $PACKAGE/*
rm -rf $WORKDIR
Jump to Line
Something went wrong with that request. Please try again.