jenkins/release.rb
# Attempts to fix an out-of-date `*.metadata.json` file produced by an
# an older version of Omnibus. The data contained in this file is very
# important in publishing activities.
Attempts to fix an out-of-date `*.metadata.json` file produced by an
an older version of Omnibus. The data contained in this file is very
important in publishing activities.
Attempts to fix an out - of - date ` * . metadata . json ` file produced by an an older version of Omnibus . The data contained in this file is very important in publishing activities .
def fix_metadata(package_local_path)
    package = Omnibus::Package.new(package_local_path)
    old_metadata = JSON.parse(File.read(package.metadata.path), symbolize_names: true)
    new_metadata = old_metadata.dup
    unless new_metadata[:name]
      match = package.name.match(/^(?<project_name>[a-z].*)(_|-)\d\.\d\.\d/)
      new_metadata[:name] = match[:project_name]
    end
    match = new_metadata[:name].match(/^(?<project_basename>.*)-windows$/)
    new_metadata[:name] = match[:project_basename] if match
    if new_metadata[:platform] == 'el'
      new_metadata[:md5]    = package.md5
      new_metadata[:sha1]   = package.sha1
      new_metadata[:sha256] = package.sha256
      new_metadata[:sha512] = package.sha512
    end
    new_metadata[:sha256] = package.sha256 unless new_metadata[:sha256]
    new_metadata[:sha512] = package.sha512 unless new_metadata[:sha512]
    if new_metadata != old_metadata
      metadata = if Omnibus.const_defined?('Metadata')
        Omnibus::Metadata.new(package, new_metadata)
      else
        Omnibus::Package::Metadata.new(package, new_metadata)
      end
      puts "\nMetadata has changed...updating '#{metadata.path}'"
      metadata.save
    end
  end
def fix_metadata ( package_local_path ) package = Omnibus :: Package . new ( package_local_path ) old_metadata = JSON . parse ( File . read ( package . metadata . path ) , symbolize_names : true ) new_metadata = old_metadata . dup unless new_metadata [ :name ] match = package . name . match ( / ^(?<project_name>[a-z].*)(_|-) \d \. \d \. \d / ) new_metadata [ :name ] = match [ :project_name ] end match = new_metadata [ :name ] . match ( / ^(?<project_basename>.*)-windows$ / ) new_metadata [ :name ] = match [ :project_basename ] if match if new_metadata [ :platform ] == 'el' new_metadata [ :md5 ] = package . md5 new_metadata [ :sha1 ] = package . sha1 new_metadata [ :sha256 ] = package . sha256 new_metadata [ :sha512 ] = package . sha512 end new_metadata [ :sha256 ] = package . sha256 unless new_metadata [ :sha256 ] new_metadata [ :sha512 ] = package . sha512 unless new_metadata [ :sha512 ] if new_metadata != old_metadata metadata = if Omnibus . const_defined? ( 'Metadata' ) Omnibus :: Metadata . new ( package , new_metadata ) else Omnibus :: Package :: Metadata . new ( package , new_metadata ) end puts "\nMetadata has changed...updating '#{metadata.path}'" metadata . save end end
Attempts to fix an out-of-date `*.metadata.json` file produced by an
an older version of Omnibus.
Attempts to fix an out - of - date ` * . metadata . json ` file produced by an an older version of Omnibus .
# OLD Omnibus does not include a project name!!!! O_o # Historically we name our Windows-specific project definitions # PROJECT_NAME-windows. We want to publish this project under # PROJECT_NAME though. Luckily we are moving to a place where the # Windows-specific project definition will just become part of the # regular *nix project definition. Until then we need to modify the # the artifact's associated `*.metadata.json` file as the Omnibus # publisher uses this metadata when publishing to Artifactory. # In pre-4.0 Omnibus packages are signed outside of the Omnibus # build process which means Omnibus's generated checksums are wrong. # As we use the Omnibus-generated metadata when publishing to # Artifactory checksum mismatches are OK until Omnibus 4.0 is in # general use. # OLD Omnibus does not generate all checksum types # If the metadata has changed write the file
package_local_path