Truncated history
authorChristoph Dwertmann <christoph.dwertmann@nicta.com.au>
Fri, 17 May 2013 07:22:31 +0000 (17:22 +1000)
committerChristoph Dwertmann <christoph.dwertmann@nicta.com.au>
Fri, 17 May 2013 07:22:31 +0000 (17:22 +1000)
README [new file with mode: 0644]
rpm/create_rpm_from_here [new file with mode: 0755]
rpm/rvm-ruby.spec [new file with mode: 0644]

diff --git a/README b/README
new file mode 100644 (file)
index 0000000..b654394
--- /dev/null
+++ b/README
@@ -0,0 +1,22 @@
+This is a fork of <http://github.com/wayneeseguin/rvm>. I added branches `rpm` and `rpmtest`. The main branch to use is `rpm`.
+
+I do not plan to work on RVM. I simply added a `rpm` folder which contains a `rvm-ruby.spec` and a script to create the RPM from the sources.
+
+Just clone this repo, customize the rubies and gems needed as indicated below, go at the root, and launch:
+
+    ./rpm/create_rpm_from_here
+
+The `rvm-ruby.spec` file is based on <https://github.com/mdkent/rvm-rpm/blob/master/SPECS/rvm-ruby.spec>. I applied some customizations to make it compatibe with the small script i made to create the RPM. What i added is at the end of the `%install` section, beginning at
+
+    # At this point, install of RVM is finished
+    # Now install some rubies
+    (...)
+    ruby_tag=ruby-1.9.3-p0
+    rvm install $ruby_tag
+    rvm use $ruby_tag
+    gem install bundler --no-ri --no-rdoc
+    (...)
+
+There, i added instructions to build and packages some rubies and gems i want to deploy on all my servers. Up to you to modify that for your own needs.
+
+Last time i checked, it did not work on the `master` branch or RVM. It works with the `stable` branch.
diff --git a/rpm/create_rpm_from_here b/rpm/create_rpm_from_here
new file mode 100755 (executable)
index 0000000..9e62023
--- /dev/null
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+# This script will build a RPM from the files in the current directory, given that there is a rpm/file.spec
+# Its primary purpose is to be used by Jenkins
+
+set -e
+set -x
+
+specfile=`find rpm -name \*.spec |head -1`
+test -z "$specfile" && exit -1
+
+specfile=`basename $specfile`
+
+name=`grep -P '^Name:\s+' rpm/$specfile |awk '{print $2}'`
+commitdate=`git log -1 --format="%ct"`
+version=`grep -P '^Version:\s+' rpm/$specfile |awk '{print $2}'`.$commitdate
+#release=`grep -P '^Release:\s+' rpm/$specfile |awk '{print $2}'`
+
+rm -rf rpmbuild
+mkdir -p rpmbuild/{BUILD,RPMS,SOURCES/$name-$version,SPECS,SRPMS,tmp}
+cp -a rpm/$specfile rpmbuild/SPECS
+sed -i "s/^[\t ]*Version:.*\$/Version: ${version}/" rpmbuild/SPECS/$specfile
+tar --exclude-vcs --exclude='rpmbuild' --exclude='rpm' -cp * | (cd rpmbuild/SOURCES/$name-$version ; tar xp)
+
+pushd rpmbuild/SOURCES
+tar cf $name-$version.tar $name-$version  # Best not to use cpu on our small ec2 instances
+#sed -i "s/^[\t ]*Source0:.*/Source0: $name-$version.tar/g" rpmbuild/SPECS/*.spec
+#sed -i "s/^[\t ]*%setup[\t ]\+-n[\t ]\+.*/%setup -n $name-$version/g" rpmbuild/SPECS/*.spec
+popd
+
+rpmbuild --define "_topdir %(pwd)/rpmbuild" -ba rpmbuild/SPECS/$specfile
diff --git a/rpm/rvm-ruby.spec b/rpm/rvm-ruby.spec
new file mode 100644 (file)
index 0000000..68c3e02
--- /dev/null
@@ -0,0 +1,254 @@
+%global rvm_dir /usr/lib/rvm
+%global rvm_group rvm
+
+# RVM can not be sourced with default /bin/sh
+%define _buildshell /bin/bash
+
+Name: rvm-ruby
+Summary: Ruby Version Manager
+Version: 3  # Version will be appended the commit date
+Release: 1.el6_CS
+License: ASL 2.0
+URL: http://rvm.beginrescueend.com/
+Group: Applications/System
+
+Source: %{name}-%{version}.tar
+
+#BuildArch: noarch
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id_u} -n)
+
+BuildRequires: bash curl git
+BuildRequires: gcc-c++ patch chrpath readline readline-devel zlib-devel libyaml-devel libffi-devel openssl-devel
+BuildRequires: sed grep tar gzip bzip2 make file
+
+Requires(pre): shadow-utils
+# For rvm
+Requires: bash curl git
+# Basics for building ruby 1.8/1.9
+Requires: gcc-c++ patch readline readline-devel zlib-devel libyaml-devel libffi-devel openssl-devel
+# Used by the scripts
+Requires: sed grep tar gzip bzip2 make file
+
+%description
+RVM is the Ruby Version Manager (rvm). It manages Ruby interpreter environments
+and switching between them.
+
+This package is meant for use by multiple users maintaining a shared copy of
+RVM. Users added to the '%{rvm_group}' group will be able to modify all aspects
+of RVM. These users will also have their default umask modified ("g+w") to allow
+group write permission (usually resulting in a umask of "0002") in order to
+ensure correct permissions for the shared RVM content.
+
+RVM is activated for all logins by default. To disable remove
+%{_sysconfdir}/profile.d/rvm.sh and source rvm from each users shell.
+
+Rubies in this package:
+ruby-1.9.3-p0
+  bundler
+  bluepill
+  whenever
+
+ruby-1.9.2-p290
+  bundler
+  bluepill
+  whenever
+
+
+%prep
+%setup -q
+
+%build
+
+%install
+rm -rf %{buildroot}
+
+# Clean the env
+for i in `env | grep ^rvm_ | cut -d"=" -f1`; do
+  unset $i;
+done
+
+# Install everything into one directory
+rvm_ignore_rvmrc=1 \
+  rvm_user_install_flag=0 \
+  rvm_path="%{buildroot}%{rvm_dir}" \
+  rvm_bin_path="%{buildroot}%{_bindir}" \
+  rvm_man_path="%{buildroot}%{_mandir}" \
+  ./install
+
+# So members of the rvm group can write to it
+find %{buildroot}%{rvm_dir} -exec chmod ug+w {} \;
+find %{buildroot}%{rvm_dir} -type d -exec chmod g+s {} \;
+
+mkdir -p %{buildroot}%{_sysconfdir}
+
+# We use selfcontained so binaries end up in rvm/bin
+cat > %{buildroot}%{_sysconfdir}/rvmrc <<END_OF_RVMRC
+# Setup default configuration for rvm.
+# If an rvm install exists in the home directory, don't load this.'
+if [[ ! -s "\${HOME}/.rvm/scripts/rvm" ]]; then
+
+  # Only users in the rvm group need the umask modification
+  for i in \$(id -G -n); do
+    if [ \$i = "rvm" ]; then
+      umask g+w
+      break
+    fi
+  done
+
+  export rvm_user_install_flag=1
+  export rvm_path="%{rvm_dir}"
+fi
+END_OF_RVMRC
+
+mkdir -p %{buildroot}%{_sysconfdir}/profile.d
+
+cat > %{buildroot}%{_sysconfdir}/profile.d/rvm.sh <<END_OF_RVMSH
+# rvm loading hook
+#
+if [ -s "\${HOME}/.rvm/scripts/rvm" ]; then
+  source "\${HOME}/.rvm/scripts/rvm"
+elif [ -s "%{rvm_dir}/scripts/rvm" ]; then
+  source "%{rvm_dir}/scripts/rvm"
+fi
+END_OF_RVMSH
+
+chmod 755 %{buildroot}%{_sysconfdir}/profile.d/rvm.sh
+
+mv %{buildroot}%{_bindir}/rake %{buildroot}%{_bindir}/rvm-rake
+
+
+# At this point, install of RVM is finished
+# Now install some rubies
+
+# Run this in a subshell so the rvm loading does not infect our current shell.
+(
+export rvm_ignore_rvmrc=1
+export rvm_user_install_flag=0
+export rvm_path="%{buildroot}%{rvm_dir}"
+export rvm_bin_path="%{buildroot}%{_bindir}"
+export rvm_man_path="%{buildroot}%{_mandir}"
+source ${rvm_path}/scripts/rvm
+gemi='gem install --no-ri --no-rdoc'
+
+ruby_tag=ruby-1.9.3-p0
+rvm install $ruby_tag
+rvm use $ruby_tag
+$gemi bundler
+$gemi whenever
+$gemi bluepill
+
+ruby_tag=ruby-1.9.2-p290
+rvm install $ruby_tag
+rvm use $ruby_tag
+$gemi bundler
+$gemi whenever
+$gemi bluepill
+
+#ruby_tag=ruby-1.8.7-p352
+#rvm install $ruby_tag
+#rvm use $ruby_tag
+)
+
+export br=%{buildroot}
+
+# Remove sources
+rm -rf $br/usr/lib/rvm/src
+
+# Strip binaries
+#find $br -type f -print0 |xargs -0 file --no-dereference --no-pad |grep 'not stripped' |cut -f1 -d: |xargs -r strip
+
+# Strip and Fix bad paths in generated files
+# That is not optimized, but that is not supposed to be done often
+for f in `find $br -type f -print0 |xargs -0 file --no-dereference --no-pad |grep ': ELF' |cut -f1 -d:`; do
+  strip $f
+  grep "$br" $f || continue
+  line=`chrpath -l $f` || continue
+  echo $line |grep "$br" || continue
+  chrpath -r `echo $line |cut -f2 -d= |sed "s,$br,,"` $f
+done
+
+# Replace bad paths in text files
+find $br -type f \( -name \*.log -o -name \*.la \) -print0 |xargs -0 -r sed -i "s,$br,,g"
+find $br -type f -print0 |xargs -0 file --no-dereference --no-pad |grep ': .* text' |cut -f1 -d: |xargs -r sed -i "s,$br,,g"
+
+# Strip object files in ar archives from bad path strings
+for f in `find $br -type f -name \*.a`; do
+  td=`mktemp -d`
+  pushd $td
+  ar x $f
+
+  for g in `find . -type f -print0 |xargs -0 file --no-dereference --no-pad |grep ': ELF' |cut -f1 -d:`; do
+    strip $g
+    grep "$br" $g || continue
+
+    # Replace the bad path with the good one, padded by nulls
+    ruby -p -i -e '
+      $_.gsub!(/#{ENV["br"]}(.*?)\0/) do |s|
+      $1 + ( "\0" * ENV["br"].size ) + "\0"
+      end
+    ' $g
+  done
+
+  ar r $f *
+  popd
+  rm -rf $td
+done
+
+# Replace paths in libraries strings
+for f in `find $br/usr/lib/rvm/rubies -type f -print0 |xargs -0 file --no-dereference --no-pad |grep ': ELF' |cut -f1 -d:`; do
+  grep "$br" $f || continue
+
+  # Replace the bad path with the good one, padded by nulls
+  ruby -p -i -e '
+    $_.gsub!(/#{ENV["br"]}(.*?)\0/) do |s|
+    $1 + ( "\0" * ENV["br"].size ) + "\0"
+    end
+  ' $f
+done
+
+# Fix symlinks with bad path
+for f in `find $br -type l |grep "$br"`; do
+    ln -sf `readlink -f $f |sed "s,$br,,"` $f
+done
+
+
+%clean
+rm -rf %{buildroot}
+
+%pre
+getent group %{rvm_group} >/dev/null || groupadd -r %{rvm_group}
+exit 0
+
+%files
+%defattr(-,root,root)
+%config(noreplace) /etc/rvmrc
+%config(noreplace) /etc/profile.d/rvm.sh
+%attr(-,root,%{rvm_group}) %{rvm_dir}
+%{_bindir}
+%{_mandir}/man1/*
+
+%changelog
+* Fri Mar 30 2012 Alexandre Fouche - 3.xxx
+Add some rubies and gems to compile:
+- 1.9.2-p290 + bundler, bluepill, whenever
+- 1.9.3-p0 + bundler, bluepill, whenever
+
+* Thu Mar 29 2012 Alexandre Fouche - 2.xxx
+- Adapt <https://github.com/mdkent/rvm-rpm/blob/master/SPECS/rvm-ruby.spec> to make it work from RVM git source directly
+- Strip binaries, libraries, ...
+
+* Thu Mar 29 2012 Alexandre Fouche - 1.xxx
+- Adapt <https://github.com/mdkent/rvm-rpm/blob/master/SPECS/rvm-ruby.spec> to make it work from RVM git source directly
+
+* Tue Dec 13 2011 Matthew Kent <mkent@magoazul.com> - 1.10.0-2
+- New upstream release
+- Drop rvm_prefix
+- Rename rvm_user_install to rvm_user_install_flag
+- Rename rake wrapper to rvm-rake
+- Add file dependency
+
+* Thu Aug 4 2011 Matthew Kent <mkent@magoazul.com> - 1.6.32-1
+- New upstream release
+
+* Tue Apr 19 2011 Matthew Kent <mkent@magoazul.com> - 1.6.3-1
+- Initial package based off Gentoo work