Skip to content

Commit 6ff599d

Browse files
committed
Add install_git and refactor to support it. Pass package name, git url, git ref, and build commands.
1 parent 1985fb8 commit 6ff599d

File tree

2 files changed

+43
-12
lines changed

2 files changed

+43
-12
lines changed

bin/ruby-build

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
RUBY_BUILD_VERSION="20110906.1"
3+
RUBY_BUILD_VERSION="20110912.1"
44

55
set -E
66
exec 3<&2 # preserve original stderr at fd 3
@@ -35,36 +35,58 @@ build_failed() {
3535
}
3636

3737
install_package() {
38-
local cwd="$(pwd)"
38+
install_package_using "tarball" 1 $*
39+
}
40+
41+
install_git() {
42+
install_package_using "git" 2 $*
43+
}
44+
45+
install_package_using() {
46+
local package_type="$1"
47+
local package_type_nargs="$2"
48+
local package_name="$3"
49+
shift 3
50+
51+
pushd "$TEMP_PATH"
52+
"fetch_${package_type}" "$package_name" $*
53+
shift $(($package_type_nargs))
54+
make_package "$package_name" $*
55+
popd
56+
57+
echo "Installed ${package_name} to ${PREFIX_PATH}" >&2
58+
}
59+
60+
make_package() {
3961
local package_name="$1"
40-
local package_url="$2"
41-
shift 2
62+
shift
4263

43-
cd "$TEMP_PATH"
44-
download_package "$package_name" "$package_url"
45-
extract_package "$package_name"
46-
cd "$package_name"
64+
pushd "$package_name"
4765
build_package "$package_name" $*
4866
after_install_package "$package_name"
4967
fix_directory_permissions
50-
cd "$cwd"
68+
popd
5169

5270
echo "Installed ${package_name} to ${PREFIX_PATH}" >&2
5371
}
5472

55-
download_package() {
73+
fetch_tarball() {
5674
local package_name="$1"
5775
local package_url="$2"
5876

5977
echo "Downloading ${package_url}..." >&2
6078
{ curl "$package_url" > "${package_name}.tar.gz"
79+
tar xzvf "${package_name}.tar.gz"
6180
} >&4 2>&1
6281
}
6382

64-
extract_package() {
83+
fetch_git() {
6584
local package_name="$1"
85+
local git_url="$2"
86+
local git_ref="$3"
6687

67-
{ tar xzvf "${package_name}.tar.gz"
88+
echo "Cloning ${git_url}..." >&2
89+
{ git clone --depth 1 --branch "$git_ref" "$git_url" "${package_name}"
6890
} >&4 2>&1
6991
}
7092

@@ -94,6 +116,11 @@ build_package_standard() {
94116
} >&4 2>&1
95117
}
96118

119+
build_package_autoconf() {
120+
{ autoconf
121+
} >&4 2>&1
122+
}
123+
97124
build_package_ruby() {
98125
local package_name="$1"
99126

share/ruby-build/1.9.3-dev

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
use_gcc42_on_lion
2+
install_package "yaml-0.1.4" "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz"
3+
install_git "ruby-1.9.3-dev" "https://github.com/ruby/ruby.git" "ruby_1_9_3" autoconf standard
4+
install_package "rubygems-1.8.10" "http://production.cf.rubygems.org/rubygems/rubygems-1.8.10.tgz" ruby

0 commit comments

Comments
 (0)