Last active
September 12, 2016 15:10
-
-
Save crhan/6800d9887aca1a5cf4b9 to your computer and use it in GitHub Desktop.
rbenv.spec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Gem | |
class << self | |
## | |
# Returns full path of previous but one directory of dir in path | |
# E.g. for '/usr/share/ruby', 'ruby', it returns '/usr' | |
def previous_but_one_dir_to(path, dir) | |
split_path = path.split(File::SEPARATOR) | |
File.join(split_path.take_while { |one_dir| one_dir !~ /^#{dir}$/ }[0..-2]) | |
end | |
private :previous_but_one_dir_to | |
## | |
# Tries to detect, if arguments and environment variables suggest that | |
# 'gem install' is executed from rpmbuild. | |
def rpmbuild? | |
(ARGV.include?('--install-dir') || ARGV.include?('-i')) && ENV['RPM_PACKAGE_NAME'] | |
end | |
private :rpmbuild? | |
## | |
# Default gems locations allowed on FHS system (/usr, /usr/share). | |
# The locations are derived from directories specified during build | |
# configuration. | |
def default_locations | |
@default_locations ||= { | |
:system => previous_but_one_dir_to(ConfigMap[:vendordir], ConfigMap[:RUBY_INSTALL_NAME]), | |
:local => previous_but_one_dir_to(ConfigMap[:sitedir], ConfigMap[:RUBY_INSTALL_NAME]) | |
} | |
end | |
## | |
# For each location provides set of directories for binaries (:bin_dir) | |
# platform independent (:gem_dir) and dependent (:ext_dir) files. | |
def default_dirs | |
@libdir ||= case RUBY_PLATFORM | |
when 'java' | |
ConfigMap[:datadir] | |
else | |
ConfigMap[:libdir] | |
end | |
@default_dirs ||= Hash[default_locations.collect do |destination, path| | |
[destination, { | |
:bin_dir => File.join(path, ConfigMap[:bindir].split(File::SEPARATOR).last), | |
:gem_dir => File.join(path, ConfigMap[:datadir].split(File::SEPARATOR).last, 'gems'), | |
:ext_dir => File.join(path, @libdir.split(File::SEPARATOR).last, 'gems') | |
}] | |
end] | |
end | |
## | |
# Remove methods we are going to override. This avoids "method redefined;" | |
# warnings otherwise issued by Ruby. | |
remove_method :default_dir if method_defined? :default_dir | |
remove_method :default_path if method_defined? :default_path | |
remove_method :default_bindir if method_defined? :default_bindir | |
remove_method :default_ext_dir_for if method_defined? :default_ext_dir_for | |
## | |
# RubyGems default overrides. | |
def default_dir | |
if Process.uid == 0 | |
Gem.default_dirs[:local][:gem_dir] | |
else | |
Gem.user_dir | |
end | |
end | |
def default_path | |
path = default_dirs.collect {|location, paths| paths[:gem_dir]} | |
path.unshift Gem.user_dir if File.exist? Gem.user_home | |
end | |
def default_bindir | |
if Process.uid == 0 | |
Gem.default_dirs[:local][:bin_dir] | |
else | |
File.join [Dir.home, 'bin'] | |
end | |
end | |
def default_ext_dir_for base_dir | |
dir = if rpmbuild? | |
build_dir = base_dir.chomp Gem.default_dirs[:system][:gem_dir] | |
if build_dir != base_dir | |
File.join build_dir, Gem.default_dirs[:system][:ext_dir] | |
end | |
else | |
dirs = Gem.default_dirs.detect {|location, paths| paths[:gem_dir] == base_dir} | |
dirs && dirs.last[:ext_dir] | |
end | |
dir && File.join(dir, RbConfig::CONFIG['RUBY_INSTALL_NAME']) | |
end | |
# This method should be available since RubyGems 2.2 until RubyGems 3.0. | |
# https://github.com/rubygems/rubygems/issues/749 | |
if method_defined? :install_extension_in_lib | |
remove_method :install_extension_in_lib | |
def install_extension_in_lib | |
false | |
end | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%define _major 2 | |
%define _minor 1 | |
%define _patch 4 | |
%define VERSION %{_major}.%{_minor}.%{_patch} | |
%define ruby_lib_version %{_major}.%{_minor} | |
Name: rbenv-ruby21 | |
Version: %{VERSION} | |
Release: 1%{?dist} | |
Summary: A dynamic, open source programming language with a focus on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write. | |
Group: Development/Language | |
License: (Ruby or BSD) and Public Domain | |
URL: https://www.ruby-lang.org/en/ | |
Source0: ruby-%{version}.tar.gz | |
Source1: operating_system.rb | |
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) | |
BuildRequires: rbenv-devel | |
BuildRequires: libyaml-devel openssl-devel libffi-devel readline-devel ncurses-devel gdbm-devel glibc-devel tcl-devel | |
BuildRequires: db4-devel byacc | |
Requires: rbenv | |
%description | |
A dynamic, open source programming language with a focus on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write. | |
%prep | |
%setup -q -n ruby-%{version} | |
%build | |
%define _prefix %{rbenv_root}/versions/%{version} | |
%configure \ | |
--with-ruby-pc='ruby.pc' \ | |
--enable-shared \ | |
--disable-rpath \ | |
--mandir=%{_prefix}/share/man \ | |
--disable-install-doc \ | |
--disable-install-rdoc \ | |
--disable-install-capi \ | |
--enable-load-relative \ | |
--with-ruby-version='minor' \ | |
make %{?_smp_mflags} COPY="cp -p" Q= | |
%install | |
rm -rf $RPM_BUILD_ROOT | |
make install DESTDIR=%{buildroot} | |
mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/ld.so.conf.d/ | |
cat > $RPM_BUILD_ROOT/%{_sysconfdir}/ld.so.conf.d/%{name}.conf <<EOF | |
%{_libdir} | |
EOF | |
%define rubygems_default_dir %{_libdir}/ruby/%{ruby_lib_version}/rubygems/defaults | |
mkdir -p %{buildroot}/%{rubygems_default_dir} | |
cp %{SOURCE1} %{buildroot}/%{rubygems_default_dir}/operating_system.rb | |
%post -p /sbin/ldconfig | |
%postun -p /sbin/ldconfig | |
%clean | |
rm -rf $RPM_BUILD_ROOT | |
%files | |
%defattr(-,root,root,-) | |
%{_prefix} | |
%{_sysconfdir}/ld.so.conf.d/%{name}.conf | |
%doc README | |
%lang(ja) %doc README.ja | |
%doc ChangeLog | |
%doc doc/ChangeLog-* | |
%changelog | |
* Sat Jan 10 2015 ruohan.chen<[email protected]> - 2.1.4 | |
- initial import |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%define _major 2 | |
%define _minor 2 | |
%define _patch 0 | |
%define VERSION %{_major}.%{_minor}.%{_patch} | |
%define ruby_lib_version %{_major}.%{_minor} | |
Name: rbenv-ruby22 | |
Version: %{VERSION} | |
Release: 1%{?dist} | |
Summary: A dynamic, open source programming language with a focus on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write. | |
Group: Development/Language | |
License: (Ruby or BSD) and Public Domain | |
URL: https://www.ruby-lang.org/en/ | |
Source0: ruby-%{version}.tar.gz | |
Source1: operating_system.rb | |
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) | |
BuildRequires: rbenv-devel | |
BuildRequires: libyaml-devel openssl-devel libffi-devel readline-devel ncurses-devel gdbm-devel glibc-devel tcl-devel | |
BuildRequires: db4-devel byacc | |
Requires: rbenv | |
%description | |
A dynamic, open source programming language with a focus on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write. | |
%prep | |
%setup -q -n ruby-%{version} | |
%build | |
%define _prefix %{rbenv_root}/versions/%{version} | |
%configure \ | |
--with-ruby-pc='ruby.pc' \ | |
--enable-shared \ | |
--disable-rpath \ | |
--mandir=%{_prefix}/share/man \ | |
--disable-install-doc \ | |
--disable-install-rdoc \ | |
--disable-install-capi \ | |
--enable-load-relative \ | |
--with-ruby-version='%{ruby_lib_version}' \ | |
make %{?_smp_mflags} COPY="cp -p" Q= | |
%install | |
rm -rf $RPM_BUILD_ROOT | |
make install DESTDIR=%{buildroot} | |
mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/ld.so.conf.d/ | |
cat > $RPM_BUILD_ROOT/%{_sysconfdir}/ld.so.conf.d/%{name}.conf <<EOF | |
%{_libdir} | |
EOF | |
%define rubygems_default_dir %{_libdir}/ruby/%{ruby_lib_version}/rubygems/defaults | |
mkdir -p %{buildroot}/%{rubygems_default_dir} | |
cp %{SOURCE1} %{buildroot}/%{rubygems_default_dir}/operating_system.rb | |
%post -p /sbin/ldconfig | |
%postun -p /sbin/ldconfig | |
%clean | |
rm -rf $RPM_BUILD_ROOT | |
%files | |
%defattr(-,root,root,-) | |
%{_prefix} | |
%{_sysconfdir}/ld.so.conf.d/%{name}.conf | |
%doc README.md | |
%lang(ja) %doc README.ja.md | |
%doc ChangeLog | |
%doc doc/ChangeLog-* | |
%changelog | |
* Sat Jan 11 2015 ruohan.chen<[email protected]> - 2.2.0 | |
- initial import |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%define _prefix /opt | |
Name: rbenv | |
Version: 0.4.0 | |
Release: 1%{?dist} | |
Summary: rbenv is a tool for simple Ruby version management. | |
Group: System/Applications | |
License: MIT | |
URL: https://github.com/sstephenson/rbenv | |
Source0: rbenv-0.4.0.tar.gz | |
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) | |
BuildArch: noarch | |
%description | |
Use rbenv to pick a Ruby version for your application and guarantee that your | |
development environment matches production. Put rbenv to work with Bundler | |
for painless Ruby upgrades and bulletproof deployments. | |
%package devel | |
Summary: Macros and development tools for packagin rbenv ruby versions | |
Group: System/Applications | |
License: MIT | |
Requires: %{name} = %{version}-%{release} | |
BuildArch: noarch | |
%description devel | |
Macros and development tools for packagin rbenv ruby versions | |
%prep | |
%setup -q | |
%build | |
: | |
%install | |
rm -rf $RPM_BUILD_ROOT | |
%define rbenv_root %{_prefix}/rbenv | |
mkdir -p $RPM_BUILD_ROOT/%{rbenv_root} | |
cp -r * $RPM_BUILD_ROOT/%{rbenv_root} | |
install -d -m0777 $RPM_BUILD_ROOT/%{rbenv_root}/shims | |
mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/profile.d/ | |
cat > $RPM_BUILD_ROOT/%{_sysconfdir}/profile.d/rbenv.sh <<EOF | |
# rbenv setup | |
export RBENV_ROOT=%{rbenv_root} | |
export PATH="%{rbenv_root}/bin:%{rbenv_root}/shims:$PATH" | |
eval "\$(rbenv init -)" | |
EOF | |
mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/rpm | |
cat > $RPM_BUILD_ROOT/%{_sysconfdir}/rpm/macros.rbenv <<EOF | |
%%rbenv_root %{rbenv_root} | |
EOF | |
%clean | |
rm -rf $RPM_BUILD_ROOT | |
%files | |
%defattr(-,root,root,-) | |
%{_prefix} | |
%doc README.md LICENSE | |
%attr(0777,root,root) %dir %{rbenv_root}/shims | |
%attr(0755,root,root) %{_sysconfdir}/profile.d/rbenv.sh | |
%files devel | |
%{_sysconfdir}/rpm/macros.rbenv | |
%changelog | |
* Sat Jan 11 2015 ruohan.chen<[email protected]> - 0.4.0 | |
- initial import |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment