# HG changeset patch
# User Jan Vrany <jan.vrany@fit.cvut.cz>
# Date 1516701040 0
# Tue Jan 23 09:50:40 2018 +0000
# Branch stx-8.0.0
# Node ID c96964104b1a870c31247f0836cf76f1b30d50e0
# Parent 327e28e1fcaf11e132e1297653eed6573b54ef34
Issue #110: download new (binary) `stx:stc` and `stx:librun` when doing `rake update`
To save some network traffic, the `download_binary_component()` first download
SHA256 hash of the archive and compares it with previous hash (if any). If they
differ, it downloads the component. If not it does nothing, assuming the most
recent version has already been downloaded.
diff -r 327e28e1fcaf -r c96964104b1a specs/stx-jv.rbspec
a
|
b
|
|
1 | 1 | # A helper function to download and unpack pre-built stc and librun |
2 | 2 | # for those who are not lucky enough to have an access to sources |
3 | | def download_blob_matching(pattern, directory) |
| 3 | def download_binary_component(component, directory) |
4 | 4 | plat = nil |
5 | 5 | blob = nil |
6 | 6 | sha256 = nil |
| 7 | pattern = /prebuilt-#{Regexp.quote(component)}/ |
7 | 8 | |
8 | 9 | build_url = %Q{https://swing.fit.cvut.cz/jenkins/job/stx_jv/lastStableBuild} |
9 | 10 | |
… |
… |
|
26 | 27 | end |
27 | 28 | end |
28 | 29 | if not blob then |
29 | | error "No artifact matching given pattern found: '#{pattern}'" |
| 30 | error "No binary component \"'#{component}\" found: #{build_url}/artifact/artifacts/" |
30 | 31 | end |
31 | | puts "Downloading binary component #{blob.name}" |
| 32 | if sha256 then |
| 33 | info "Downloading binary component SHA265 checksum #{sha256.name}" |
| 34 | sha256.download_to(directory) |
| 35 | if File.exist? directory / "#{component}" and File.exist? directory / "#{component}.sha256" then |
| 36 | # Compare a "current" checksum and the (possibly) "new" checkum. |
| 37 | # if same, skip the download (assuming that version has been |
| 38 | # downloaded already) |
| 39 | sha256_current = File.read(directory / ".#{component}.sha256") |
| 40 | sha256_new = File.read(directory / sha256.name) |
| 41 | if sha256_new == sha256_current then |
| 42 | return |
| 43 | end |
| 44 | end |
| 45 | end |
| 46 | info "Downloading binary component #{blob.name}" |
32 | 47 | blob.download_to(directory) |
33 | | if sha256 then |
34 | | sha256.download_to(directory) |
| 48 | info "Extracting binary component #{blob.name}" |
| 49 | if File.exist? directory / component then |
| 50 | rm_rf directory / component |
35 | 51 | end |
36 | 52 | unzip directory / blob.name, remove: true |
37 | | rm_f directory / sha256.name |
| 53 | if sha256 then |
| 54 | mv directory / sha256.name, directory / ".#{component}.sha256" |
| 55 | end |
38 | 56 | end |
39 | 57 | |
40 | | |
41 | | |
42 | 58 | project :'stx:jv-branch-core' do |
43 | 59 | # Core Smalltalk/X - does contain only standard libraries, |
44 | 60 | # and development tools. Does not contain any other 'features' |
… |
… |
|
49 | 65 | # FORKED STC and librun |
50 | 66 | package "stx:stc", :repository => :'jv-branch:private', :branch => 'jv', revision: 'stx-8.0.0', |
51 | 67 | :checkout => (Proc.new do | pkg | |
52 | | # Download pre-compiled binary if user has no access to source code |
53 | | if Rake::Stx::Configuration::Repository::find(pkg.repository) then |
54 | | checkout pkg.repository, 'stx/stc', :branch => pkg.branch, :revision => pkg.revision |
55 | | else |
56 | | download_blob_matching(/prebuilt-stc/, BUILD_DIR / 'stx') |
| 68 | # Download pre-compiled binary if user has no access to source code |
| 69 | if Rake::Stx::Configuration::Repository::find(pkg.repository) then |
| 70 | checkout pkg.repository, 'stx/stc', :branch => pkg.branch, :revision => pkg.revision |
| 71 | else |
| 72 | download_binary_component('stc', BUILD_DIR / 'stx') |
57 | 73 | end |
58 | 74 | end), |
59 | 75 | :update => (Proc.new do | pkg | |
60 | 76 | if (File.exists? BUILD_DIR / 'stx' / 'stc' / '.hg' / 'hgrc') then |
61 | 77 | update pkg.repository, 'stx/stc', :branch => pkg.branch, :revision => pkg.revision |
62 | 78 | else |
63 | | warn "Not updating #{pkg.name} as no HG repository found in #{BUILD_DIR / 'stx' / 'stc'}" |
| 79 | download_binary_component('stc', BUILD_DIR / 'stx') |
64 | 80 | end |
65 | 81 | end) |
66 | 82 | |
67 | 83 | package "stx:librun", :repository => :'jv-branch:private', :branch => 'jv', revision: 'stx-8.0.0', |
68 | 84 | :checkout => (Proc.new do | pkg | |
69 | | # Download pre-compiled binary if user has no access to source code |
70 | | if Rake::Stx::Configuration::Repository::find(pkg.repository) then |
| 85 | # Download pre-compiled binary if user has no access to source code |
| 86 | if Rake::Stx::Configuration::Repository::find(pkg.repository) then |
71 | 87 | checkout pkg.repository, 'stx/librun', :branch => pkg.branch, :revision => pkg.revision |
72 | | else |
73 | | download_blob_matching(/prebuilt-librun/, BUILD_DIR / 'stx') |
| 88 | else |
| 89 | download_binary_component('librun', BUILD_DIR / 'stx') |
74 | 90 | end |
75 | 91 | end), |
76 | 92 | :update => (Proc.new do | pkg | |
77 | 93 | if (File.exists? BUILD_DIR / 'stx' / 'librun' / '.hg' / 'hgrc') then |
78 | 94 | update pkg.repository, 'stx/stc', :branch => pkg.branch, :revision => pkg.revision |
79 | 95 | else |
80 | | warn "Not updating #{pkg.name} as no HG repository found in #{BUILD_DIR / 'stx' / 'librun'}" |
| 96 | download_binary_component('librun', BUILD_DIR / 'stx') |
81 | 97 | end |
82 | 98 | end) |
83 | 99 | |