• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#/bin/bash
2set -ex
3
4if [ -z $1 ] ; then
5  echo "Gem file needed!" && exit 1;
6fi
7
8GEM=$1
9GEM_FILENAME=$(basename -- "$GEM")
10GEM_NAME="${GEM_FILENAME%.gem}"
11
12# Extract all files onto a temporary directory
13TMPDIR=$(mktemp -d -t gem-XXXXXXXXXX)
14gem unpack $GEM --target=$TMPDIR
15gem spec $GEM --ruby > ${TMPDIR}/${GEM_NAME}/${GEM_NAME}.gemspec
16
17# Run patchelf to all so files to strip out unnecessary libcrypt.so.2 dependency
18find $TMPDIR/${GEM_NAME} -name "*.so" \
19    -printf '%p\n' \
20    -exec patchelf --remove-needed libcrypt.so.2 {} \;
21
22# Rebuild the gem again with modified so files
23pushd $TMPDIR/${GEM_NAME}
24gem build ${GEM_NAME}.gemspec
25popd
26
27# Keep the new result
28mv $TMPDIR/${GEM_NAME}/${GEM_NAME}.gem $GEM
29
30rm -rf $TMPDIR
31