Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
ruby-build
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ruby-build
Commits
d36e88c5
Commit
d36e88c5
authored
Mar 25, 2014
by
Mislav Marohnić
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'no-resume-download'
parents
556db9ab
1bcd249f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
71 additions
and
22 deletions
+71
-22
bin/ruby-build
+13
-7
test/cache.bats
+3
-3
test/checksum.bats
+48
-5
test/mirror.bats
+7
-7
No files found.
bin/ruby-build
View file @
d36e88c5
...
@@ -227,7 +227,7 @@ http_head_curl() {
...
@@ -227,7 +227,7 @@ http_head_curl() {
}
}
http_get_curl
()
{
http_get_curl
()
{
curl
-
C
-
-o
"
${
2
:-
-
}
"
-q
sSLf
"
$1
"
curl
-
q
-o
"
${
2
:-
-
}
"
-
sSLf
"
$1
"
}
}
http_head_wget
()
{
http_head_wget
()
{
...
@@ -235,7 +235,7 @@ http_head_wget() {
...
@@ -235,7 +235,7 @@ http_head_wget() {
}
}
http_get_wget
()
{
http_get_wget
()
{
wget
-nv
-
c
-
O
"
${
2
:-
-
}
"
"
$1
"
wget
-nv
-O
"
${
2
:-
-
}
"
"
$1
"
}
}
fetch_tarball
()
{
fetch_tarball
()
{
...
@@ -261,7 +261,7 @@ fetch_tarball() {
...
@@ -261,7 +261,7 @@ fetch_tarball() {
tar_args
=
"
${
tar_args
/z/j
}
"
tar_args
=
"
${
tar_args
/z/j
}
"
fi
fi
if
!
symlink_tarball_from_cache
"
$package_filename
"
"
$checksum
"
;
then
if
!
reuse_existing_tarball
"
$package_filename
"
"
$checksum
"
;
then
echo
"Downloading
${
package_filename
}
..."
>
&2
echo
"Downloading
${
package_filename
}
..."
>
&2
http head
"
$mirror_url
"
&&
http head
"
$mirror_url
"
&&
download_tarball
"
$mirror_url
"
"
$package_filename
"
"
$checksum
"
||
download_tarball
"
$mirror_url
"
"
$package_filename
"
"
$checksum
"
||
...
@@ -278,13 +278,19 @@ fetch_tarball() {
...
@@ -278,13 +278,19 @@ fetch_tarball() {
}
>
&4 2>&1
}
>
&4 2>&1
}
}
symlink_tarball_from_cache
()
{
reuse_existing_tarball
()
{
[
-n
"
$RUBY_BUILD_CACHE_PATH
"
]
||
return
1
local
package_filename
=
"
$1
"
local
package_filename
=
"
$1
"
local
cached_package_filename
=
"
${
RUBY_BUILD_CACHE_PATH
}
/
$package_filename
"
local
checksum
=
"
$2
"
local
checksum
=
"
$2
"
# Reuse existing file in build location
if
[
-e
"
$package_filename
"
]
&&
verify_checksum
"
$package_filename
"
"
$checksum
"
;
then
return
0
fi
# Reuse previously downloaded file in cache location
[
-n
"
$RUBY_BUILD_CACHE_PATH
"
]
||
return
1
local
cached_package_filename
=
"
${
RUBY_BUILD_CACHE_PATH
}
/
$package_filename
"
[
-e
"
$cached_package_filename
"
]
||
return
1
[
-e
"
$cached_package_filename
"
]
||
return
1
verify_checksum
"
$cached_package_filename
"
"
$checksum
"
>
&4 2>&1
||
return
1
verify_checksum
"
$cached_package_filename
"
"
$checksum
"
>
&4 2>&1
||
return
1
ln
-s
"
$cached_package_filename
"
"
$package_filename
"
>
&4 2>&1
||
return
1
ln
-s
"
$cached_package_filename
"
"
$package_filename
"
>
&4 2>&1
||
return
1
...
...
test/cache.bats
View file @
d36e88c5
...
@@ -11,7 +11,7 @@ setup() {
...
@@ -11,7 +11,7 @@ setup() {
@test "packages are saved to download cache" {
@test "packages are saved to download cache" {
stub md5 true
stub md5 true
stub curl "-
C - -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${6##*/} \$4
"
stub curl "-
q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3
"
install_fixture definitions/without-checksum
install_fixture definitions/without-checksum
[ "$status" -eq 0 ]
[ "$status" -eq 0 ]
...
@@ -59,7 +59,7 @@ setup() {
...
@@ -59,7 +59,7 @@ setup() {
stub md5 true "echo invalid" "echo $checksum"
stub md5 true "echo invalid" "echo $checksum"
stub curl "-*I* : true" \
stub curl "-*I* : true" \
"-
C - -o * -*S* http://?*/$checksum : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$4
"
"-
q -o * -*S* http://?*/$checksum : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3
"
touch "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz"
touch "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz"
...
@@ -76,7 +76,7 @@ setup() {
...
@@ -76,7 +76,7 @@ setup() {
@test "nonexistent cache directory is ignored" {
@test "nonexistent cache directory is ignored" {
stub md5 true
stub md5 true
stub curl "-
C - -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${6##*/} \$4
"
stub curl "-
q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3
"
export RUBY_BUILD_CACHE_PATH="${TMP}/nonexistent"
export RUBY_BUILD_CACHE_PATH="${TMP}/nonexistent"
...
...
test/checksum.bats
View file @
d36e88c5
...
@@ -7,7 +7,7 @@ export RUBY_BUILD_CACHE_PATH=
...
@@ -7,7 +7,7 @@ export RUBY_BUILD_CACHE_PATH=
@test "package URL without checksum" {
@test "package URL without checksum" {
stub md5 true
stub md5 true
stub curl "-
C - -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${6##*/} \$4
"
stub curl "-
q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3
"
install_fixture definitions/without-checksum
install_fixture definitions/without-checksum
[ "$status" -eq 0 ]
[ "$status" -eq 0 ]
...
@@ -20,7 +20,7 @@ export RUBY_BUILD_CACHE_PATH=
...
@@ -20,7 +20,7 @@ export RUBY_BUILD_CACHE_PATH=
@test "package URL with valid checksum" {
@test "package URL with valid checksum" {
stub md5 true "echo 83e6d7725e20166024a1eb74cde80677"
stub md5 true "echo 83e6d7725e20166024a1eb74cde80677"
stub curl "-
C - -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${6##*/} \$4
"
stub curl "-
q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3
"
install_fixture definitions/with-checksum
install_fixture definitions/with-checksum
[ "$status" -eq 0 ]
[ "$status" -eq 0 ]
...
@@ -33,7 +33,7 @@ export RUBY_BUILD_CACHE_PATH=
...
@@ -33,7 +33,7 @@ export RUBY_BUILD_CACHE_PATH=
@test "package URL with invalid checksum" {
@test "package URL with invalid checksum" {
stub md5 true "echo 83e6d7725e20166024a1eb74cde80677"
stub md5 true "echo 83e6d7725e20166024a1eb74cde80677"
stub curl "-
C - -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${6##*/} \$4
"
stub curl "-
q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3
"
install_fixture definitions/with-invalid-checksum
install_fixture definitions/with-invalid-checksum
[ "$status" -eq 1 ]
[ "$status" -eq 1 ]
...
@@ -46,7 +46,7 @@ export RUBY_BUILD_CACHE_PATH=
...
@@ -46,7 +46,7 @@ export RUBY_BUILD_CACHE_PATH=
@test "package URL with checksum but no MD5 support" {
@test "package URL with checksum but no MD5 support" {
stub md5 false
stub md5 false
stub curl "-
C - -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${6##*/} \$4
"
stub curl "-
q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3
"
install_fixture definitions/with-checksum
install_fixture definitions/with-checksum
[ "$status" -eq 0 ]
[ "$status" -eq 0 ]
...
@@ -59,7 +59,7 @@ export RUBY_BUILD_CACHE_PATH=
...
@@ -59,7 +59,7 @@ export RUBY_BUILD_CACHE_PATH=
@test "package with invalid checksum" {
@test "package with invalid checksum" {
stub md5 true "echo invalid"
stub md5 true "echo invalid"
stub curl "-
C - -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${6##*/} \$4
"
stub curl "-
q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3
"
install_fixture definitions/with-checksum
install_fixture definitions/with-checksum
[ "$status" -eq 1 ]
[ "$status" -eq 1 ]
...
@@ -68,3 +68,46 @@ export RUBY_BUILD_CACHE_PATH=
...
@@ -68,3 +68,46 @@ export RUBY_BUILD_CACHE_PATH=
unstub curl
unstub curl
unstub md5
unstub md5
}
}
@test "existing tarball in build location is reused" {
stub md5 true "echo 83e6d7725e20166024a1eb74cde80677"
stub curl false
stub wget false
export -n RUBY_BUILD_CACHE_PATH
export RUBY_BUILD_BUILD_PATH="${TMP}/build"
mkdir -p "$RUBY_BUILD_BUILD_PATH"
ln -s "${FIXTURE_ROOT}/package-1.0.0.tar.gz" "$RUBY_BUILD_BUILD_PATH"
run_inline_definition <<DEF
install_package "package-1.0.0" "http://example.com/packages/package-1.0.0.tar.gz#83e6d7725e20166024a1eb74cde80677" copy
DEF
assert_success
[ -x "${INSTALL_ROOT}/bin/package" ]
unstub md5
}
@test "existing tarball in build location is discarded if not matching checksum" {
stub md5 true \
"echo invalid" \
"echo 83e6d7725e20166024a1eb74cde80677"
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
export -n RUBY_BUILD_CACHE_PATH
export RUBY_BUILD_BUILD_PATH="${TMP}/build"
mkdir -p "$RUBY_BUILD_BUILD_PATH"
touch "${RUBY_BUILD_BUILD_PATH}/package-1.0.0.tar.gz"
run_inline_definition <<DEF
install_package "package-1.0.0" "http://example.com/packages/package-1.0.0.tar.gz#83e6d7725e20166024a1eb74cde80677" copy
DEF
assert_success
[ -x "${INSTALL_ROOT}/bin/package" ]
unstub md5
}
test/mirror.bats
View file @
d36e88c5
...
@@ -8,7 +8,7 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com
...
@@ -8,7 +8,7 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com
@test "package URL without checksum bypasses mirror" {
@test "package URL without checksum bypasses mirror" {
stub md5 true
stub md5 true
stub curl "-
C - -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${6##*/} \$4
"
stub curl "-
q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3
"
install_fixture definitions/without-checksum
install_fixture definitions/without-checksum
echo "$output" >&2
echo "$output" >&2
...
@@ -22,7 +22,7 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com
...
@@ -22,7 +22,7 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com
@test "package URL with checksum but no MD5 support bypasses mirror" {
@test "package URL with checksum but no MD5 support bypasses mirror" {
stub md5 false
stub md5 false
stub curl "-
C - -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${6##*/} \$4
"
stub curl "-
q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3
"
install_fixture definitions/with-checksum
install_fixture definitions/with-checksum
[ "$status" -eq 0 ]
[ "$status" -eq 0 ]
...
@@ -39,7 +39,7 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com
...
@@ -39,7 +39,7 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com
stub md5 true "echo $checksum"
stub md5 true "echo $checksum"
stub curl "-*I* $mirror_url : true" \
stub curl "-*I* $mirror_url : true" \
"-
C - -o * -*S* $mirror_url : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$4
"
"-
q -o * -*S* $mirror_url : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3
"
install_fixture definitions/with-checksum
install_fixture definitions/with-checksum
[ "$status" -eq 0 ]
[ "$status" -eq 0 ]
...
@@ -56,7 +56,7 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com
...
@@ -56,7 +56,7 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com
stub md5 true "echo $checksum"
stub md5 true "echo $checksum"
stub curl "-*I* $mirror_url : false" \
stub curl "-*I* $mirror_url : false" \
"-
C - -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${6##*/} \$4
"
"-
q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3
"
install_fixture definitions/with-checksum
install_fixture definitions/with-checksum
[ "$status" -eq 0 ]
[ "$status" -eq 0 ]
...
@@ -73,8 +73,8 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com
...
@@ -73,8 +73,8 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com
stub md5 true "echo invalid" "echo $checksum"
stub md5 true "echo invalid" "echo $checksum"
stub curl "-*I* $mirror_url : true" \
stub curl "-*I* $mirror_url : true" \
"-
C - -o * -*S* $mirror_url : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$4
" \
"-
q -o * -*S* $mirror_url : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3
" \
"-
C - -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${6##*/} \$4
"
"-
q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3
"
install_fixture definitions/with-checksum
install_fixture definitions/with-checksum
echo "$output" >&2
echo "$output" >&2
...
@@ -92,7 +92,7 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com
...
@@ -92,7 +92,7 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com
stub md5 true "echo $checksum"
stub md5 true "echo $checksum"
stub curl "-*I* : true" \
stub curl "-*I* : true" \
"-
C - -o * -*S* http://?*/$checksum : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$4
" \
"-
q -o * -*S* http://?*/$checksum : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3
" \
install_fixture definitions/with-checksum
install_fixture definitions/with-checksum
[ "$status" -eq 0 ]
[ "$status" -eq 0 ]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment