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 204 lines (178 sloc) 6.762 kb
#!/bin/sh
# Copyright © 2009-2011 by Cycojesus
[ "x$1" == "x" ] && $0 --help && exit 0
MAKE_DEPS=${MAKE_DEPS:-}
PACKAGE_ALL_LOCALS=${PACKAGE_ALL_LOCALS:-}
CLEAN_AFTER=${CLEAN_AFTER:-}
INSTALL=${INSTALL:-}
VERSION=${VERSION:-}
ARCH=noarch
BUILD=${BUILD:-1}
TAG=${TAG:-$(basename $0)}
OUTPUT=${OUTPUT:-/tmp}
TMP=${TMP:-/tmp/$TAG}
GEMSROOT=${GEMSROOT:-$(gem environment gemdir)}
function list_duplicates() {
(cd /var/adm/packages/
ls rubygem-* | sed 's|\(.*\)-.*-.*-.*|\1|g' | uniq -d
)
}
function package_this() {
package_this_PKG=$1
cd $package_this_PKG
PRGNAM=rubygem-$(grep "s\.name = " $package_this_PKG$GEMSROOT/specifications/*.gemspec | grep -o "%q{.*}" | sed 's|%q{||' | tr -d '}')
# HACK: fallback name pulling for gems not using "%q{.*}"
[ "x$PRGNAM" == "xrubygem-" ] && PRGNAM=rubygem-$(grep "s\.name = " $package_this_PKG$GEMSROOT/specifications/*.gemspec | grep -o "\".*\"" | tr -d \")
VERSION=$(grep "s\.version = " $package_this_PKG$GEMSROOT/specifications/*.gemspec | grep -o "\".*\"" | tr -d '"')
ARCH=$([[ $(find $package_this_PKG$GEMSROOT -name \*.o -o -name \*.so | wc -l) > 0 ]] && echo $(uname -m) || echo noarch)
if [ -d $package_this_PKG$GEMSROOT/bin/ ]; then
mkdir -p $package_this_PKG/usr/bin
for b in $package_this_PKG$GEMSROOT/bin/*; do
cp $b $package_this_PKG/usr/bin
done
fi
mkdir -p $package_this_PKG/install
cat <<EOF > $package_this_PKG/install/slack-desc
$PRGNAM: $PRGNAM ($(grep "s\.summary = " $package_this_PKG$GEMSROOT/specifications/*.gemspec | grep -o "%q{.*}" | sed 's|%q{||' | tr -d '}'))
$PRGNAM:
$PRGNAM: $(grep "s\.description = " $package_this_PKG$GEMSROOT/specifications/*.gemspec | grep -o "%q{.*}" | sed 's|%q{||' | tr -d '}')
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM: $(grep "s\.homepage = " $package_this_PKG$GEMSROOT/specifications/*.gemspec | grep -o "%q{.*}" | sed 's|%q{||' | tr -d '}')
$PRGNAM:
EOF
chown -R root:root .
makepkg --linkadd y --chown n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.txz
[ "x$INSTALL" == "x--install" ] && installpkg $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.txz
[ "x$CLEAN_AFTER" == "xYES" ] && rm -fr $package_this_PKG
}
function package_all_under() {
this_GEMSROOT=$1
for i in $this_GEMSROOT/gems/* ; do
i=$(basename $i)
this_GEM_VERSION=$(echo $i | rev | cut -d- -f1 | rev)
this_GEM=$(echo $i | sed "s|-$this_GEM_VERSION||")
[ -e $TMP/pkg-rubygem-$this_GEM-$this_GEM_VERSION ] && rm -fr $TMP/pkg-rubygem-$this_GEM-$this_GEM_VERSION
mkdir -p $TMP/pkg-rubygem-$this_GEM-$this_GEM_VERSION$GEMSROOT/{cache,doc,gems,specifications}
cp -a $this_GEMSROOT/cache/$i.gem $TMP/pkg-rubygem-$this_GEM-$this_GEM_VERSION$GEMSROOT/cache/
cp -a $this_GEMSROOT/specifications/$i.gemspec $TMP/pkg-rubygem-$this_GEM-$this_GEM_VERSION$GEMSROOT/specifications/
cp -a $this_GEMSROOT/gems/$i $TMP/pkg-rubygem-$this_GEM-$this_GEM_VERSION$GEMSROOT/gems/
cp -a $this_GEMSROOT/doc/$i $TMP/pkg-rubygem-$this_GEM-$this_GEM_VERSION$GEMSROOT/doc/
if [ -e $TMP/pkg-rubygem-$this_GEM-$this_GEM_VERSION$GEMSROOT/gems/$i/bin/ ]; then
mkdir -p $TMP/pkg-rubygem-$this_GEM-$this_GEM_VERSION$GEMSROOT/bin/
for b in $TMP/pkg-rubygem-$this_GEM-$this_GEM_VERSION$GEMSROOT/gems/$i/bin/* ; do
cp -a $this_GEMSROOT/bin/$(basename $b) $TMP/pkg-rubygem-$this_GEM-$this_GEM_VERSION$GEMSROOT/bin/
done
fi
package_this $TMP/pkg-rubygem-$this_GEM-$this_GEM_VERSION $INSTALL
done
}
function cleanup() {
for i in $(gem cleanup --dryrun | grep "^Dry" | cut -d\ -f6); do
removepkg /var/adm/packages/rubygem-$i-*
done
}
# commandline arguments processing
while [ "x$1" != "x" ]
do
case "$1" in
-a | --all-locals | --backup )
PACKAGE_ALL_LOCALS=--backup
shift
;;
-c | --clean-after )
CLEAN_AFTER=YES
shift
;;
-d | --duplicates )
list_duplicates
exit 0
;;
-g | --gem )
shift
GEM=$1
shift
;;
-i | --install )
INSTALL=--install
shift
;;
-n | --nodeps )
MAKE_DEPS=--ignore-dependencies
shift
;;
-o | --output )
shift
OUTPUT=$1
shift
;;
-r | --cleanup )
cleanup
exit 0
;;
-t | --tag )
shift
TAG=$1
shift
;;
-v | --version )
shift
VERSION="--version $1"
shift
;;
-h | --help )
echo -e "Usage: $0 <options>"
echo -e "Options:"
echo -e "\t-a | --backup | --all-locals"
echo -e "\t\tGenerate packages for ALL gems installed locally"
echo -e "\t-d | --duplicates"
echo -e "\t\tDisplay a list of gems installed in more than one version"
echo -e "\t\t(can be used in /etc/slackpkg/blacklist)"
echo -e "\t-r | --cleanup"
echo -e "\t\t'gem cleanup' at Slackware packaging level"
echo -e ""
echo -e "\t-g | --gem <name>"
echo -e "\t\tgem to package [no default]"
echo -e "\t-v | --version <x.x.x>"
echo -e "\t\tPackage a specific version [default: latest]"
echo -e "\t-t | --tag <tag>"
echo -e "\t\tSet a specific tag for the package's name [default: $TAG]"
echo -e "\t-n | --nodeps"
echo -e "\t\tDo not build packages of dependencies [default: package all dependencies]"
echo -e "\t-i | --install"
echo -e "\t\tInstall the package [default: no]"
echo -e "\t-o | --output <dir>"
echo -e "\t\tDirectory where the resulting package will be [default: /tmp]"
echo -e "\t-c | --clean-after"
echo -e "\t\tDelete temporary files after packaging [default: no]"
echo -e ""
echo -e "\t-h | --help"
echo -e "\t\tWhat you're reading at this very moment"
exit 0
;;
* )
GEM=$1
shift
;;
esac
done
PKG=${PKG:-$TMP/pkg-rubygem-$GEM}
if [ "x$PACKAGE_ALL_LOCALS" == "x--backup" ]; then
package_all_under $GEMSROOT
else
[ -e $PKG ] && rm -fr $PKG
mkdir -p $PKG$GEMSROOT
gem install $GEM $VERSION \
--install-dir $PKG$GEMSROOT \
--force \
$MAKE_DEPS
if [ "x$MAKE_DEPS" == "x" ]; then
package_all_under $PKG$GEMSROOT
else
package_this $PKG
fi
fi
Jump to Line
Something went wrong with that request. Please try again.