specs/stx-jv.rbspec
branchstx-8.0.0
changeset 219 c96964104b1a
parent 218 327e28e1fcaf
child 236 5a4e789cdd40
--- a/specs/stx-jv.rbspec	Thu Jan 18 13:27:55 2018 +0000
+++ b/specs/stx-jv.rbspec	Tue Jan 23 09:50:40 2018 +0000
@@ -1,9 +1,10 @@
 # A helper function to download and unpack pre-built stc and librun
 # for those who are not lucky enough to have an access to sources
-def download_blob_matching(pattern, directory)
+def download_binary_component(component, directory)
   plat = nil
   blob = nil
   sha256 = nil
+  pattern = /prebuilt-#{Regexp.quote(component)}/
 
   build_url = %Q{https://swing.fit.cvut.cz/jenkins/job/stx_jv/lastStableBuild}
 
@@ -26,19 +27,34 @@
     end
   end
   if not blob then
-    error "No artifact matching given pattern found: '#{pattern}'"
+    error "No binary component \"'#{component}\" found: #{build_url}/artifact/artifacts/"
   end
-  puts "Downloading binary component #{blob.name}"
+  if sha256 then
+    info "Downloading binary component SHA265 checksum #{sha256.name}"
+    sha256.download_to(directory)
+    if File.exist? directory / "#{component}" and File.exist? directory / "#{component}.sha256" then
+      # Compare a "current" checksum and the (possibly) "new" checkum.
+      # if same, skip the download (assuming that version has been
+      # downloaded already)
+      sha256_current = File.read(directory / ".#{component}.sha256")
+      sha256_new     = File.read(directory / sha256.name)
+      if sha256_new == sha256_current then
+        return
+      end
+    end
+  end
+  info "Downloading binary component #{blob.name}"
   blob.download_to(directory)
-  if sha256 then
-    sha256.download_to(directory)
+  info "Extracting binary component #{blob.name}"
+  if File.exist? directory / component then
+    rm_rf directory / component
   end
   unzip directory / blob.name, remove: true
-  rm_f directory / sha256.name
+  if sha256 then
+    mv directory / sha256.name, directory / ".#{component}.sha256"
+  end
 end
 
-
-
 project :'stx:jv-branch-core' do
   # Core Smalltalk/X - does contain only standard libraries,
   # and development tools. Does not contain any other 'features'
@@ -49,35 +65,35 @@
   # FORKED STC and librun
   package "stx:stc", :repository => :'jv-branch:private', :branch => 'jv', revision: 'stx-8.0.0',
     :checkout => (Proc.new do | pkg |
-    # Download pre-compiled binary if user has no access to source code
-    if Rake::Stx::Configuration::Repository::find(pkg.repository) then
-          checkout pkg.repository, 'stx/stc', :branch => pkg.branch, :revision => pkg.revision
-    else
-        download_blob_matching(/prebuilt-stc/, BUILD_DIR / 'stx')
+      # Download pre-compiled binary if user has no access to source code
+      if Rake::Stx::Configuration::Repository::find(pkg.repository) then
+        checkout pkg.repository, 'stx/stc', :branch => pkg.branch, :revision => pkg.revision
+      else
+        download_binary_component('stc', BUILD_DIR / 'stx')
       end
     end),
     :update => (Proc.new do | pkg |
       if (File.exists? BUILD_DIR / 'stx' / 'stc' / '.hg' / 'hgrc') then
         update pkg.repository, 'stx/stc', :branch => pkg.branch, :revision => pkg.revision
       else
-        warn "Not updating #{pkg.name} as no HG repository found in #{BUILD_DIR / 'stx' / 'stc'}"
+        download_binary_component('stc', BUILD_DIR / 'stx')
     end
   end)
 
   package "stx:librun", :repository => :'jv-branch:private', :branch => 'jv', revision: 'stx-8.0.0',
     :checkout => (Proc.new do | pkg |
-    # Download pre-compiled binary if user has no access to source code
-    if Rake::Stx::Configuration::Repository::find(pkg.repository) then
+      # Download pre-compiled binary if user has no access to source code
+      if Rake::Stx::Configuration::Repository::find(pkg.repository) then
           checkout pkg.repository, 'stx/librun', :branch => pkg.branch, :revision => pkg.revision
-    else
-        download_blob_matching(/prebuilt-librun/, BUILD_DIR / 'stx')
+      else
+        download_binary_component('librun', BUILD_DIR / 'stx')
       end
     end),
     :update => (Proc.new do | pkg |
       if (File.exists? BUILD_DIR / 'stx' / 'librun' / '.hg' / 'hgrc') then
         update pkg.repository, 'stx/stc', :branch => pkg.branch, :revision => pkg.revision
       else
-        warn "Not updating #{pkg.name} as no HG repository found in #{BUILD_DIR / 'stx' / 'librun'}"
+        download_binary_component('librun', BUILD_DIR / 'stx')
     end
   end)