Faculty of Information Technology
Software Engineering Group

Ticket #110: stx-8.0.0-user-build_fix_1_of_1_rev_c96964104b1a_Issue__110__download_new__binary___stx_stc__and__stx_librun__when_doing__rake_update_.patch

File stx-8.0.0-user-build_fix_1_of_1_rev_c96964104b1a_Issue__110__download_new__binary___stx_stc__and__stx_librun__when_doing__rake_update_.patch, 4.9 KB (added by Jan Vrany, 22 months ago)
  • specs/stx-jv.rbspec

    # 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  
    11# A helper function to download and unpack pre-built stc and librun
    22# for those who are not lucky enough to have an access to sources
    3 def download_blob_matching(pattern, directory)
     3def download_binary_component(component, directory)
    44  plat = nil
    55  blob = nil
    66  sha256 = nil
     7  pattern = /prebuilt-#{Regexp.quote(component)}/
    78
    89  build_url = %Q{https://swing.fit.cvut.cz/jenkins/job/stx_jv/lastStableBuild}
    910
     
    2627    end
    2728  end
    2829  if not blob then
    29     error "No artifact matching given pattern found: '#{pattern}'"
     30    error "No binary component \"'#{component}\" found: #{build_url}/artifact/artifacts/"
    3031  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}"
    3247  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
    3551  end
    3652  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
    3856end
    3957
    40 
    41 
    4258project :'stx:jv-branch-core' do
    4359  # Core Smalltalk/X - does contain only standard libraries,
    4460  # and development tools. Does not contain any other 'features'
     
    4965  # FORKED STC and librun
    5066  package "stx:stc", :repository => :'jv-branch:private', :branch => 'jv', revision: 'stx-8.0.0',
    5167    :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')
    5773      end
    5874    end),
    5975    :update => (Proc.new do | pkg |
    6076      if (File.exists? BUILD_DIR / 'stx' / 'stc' / '.hg' / 'hgrc') then
    6177        update pkg.repository, 'stx/stc', :branch => pkg.branch, :revision => pkg.revision
    6278      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')
    6480    end
    6581  end)
    6682
    6783  package "stx:librun", :repository => :'jv-branch:private', :branch => 'jv', revision: 'stx-8.0.0',
    6884    :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
    7187          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')
    7490      end
    7591    end),
    7692    :update => (Proc.new do | pkg |
    7793      if (File.exists? BUILD_DIR / 'stx' / 'librun' / '.hg' / 'hgrc') then
    7894        update pkg.repository, 'stx/stc', :branch => pkg.branch, :revision => pkg.revision
    7995      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')
    8197    end
    8298  end)
    8399