director/lib/director/jobs/update_release.rb
def create_package(package_meta)
        name, version = package_meta["name"], package_meta["version"]

        package_attrs = {
          :release => @release_model,
          :name => name,
          :sha1 => package_meta["sha1"],
          :fingerprint => package_meta["fingerprint"],
          :version => version
        }

        if @rebase
          new_version = next_package_version(name, version)
          if new_version != version
            transition = "#{version} -> #{new_version}"
            logger.info("Package `#{name}' rebased: #{transition}")
            package_attrs[:version] = new_version
            version = new_version
            @package_rebase_mapping[name] = transition
          end
        end

        package = Models::Package.new(package_attrs)
        package.dependency_set = package_meta["dependencies"]

        existing_blob = package_meta["blobstore_id"]
        desc = "package `#{name}/#{version}'"

        if existing_blob
          logger.info("Creating #{desc} from existing blob #{existing_blob}")
          package.blobstore_id = BlobUtil.copy_blob(existing_blob)
        else
          logger.info("Creating #{desc} from provided bits")

          package_tgz = File.join(@tmp_release_dir, "packages", "#{name}.tgz")
          result = Bosh::Exec.sh("tar -tzf #{package_tgz} 2>&1", :on_error => :return)
          if result.failed?
            logger.error("Extracting #{desc} archive failed, " +
                         "tar returned #{result.exit_status}, " +
                         "output: #{result.output}")
            raise PackageInvalidArchive, "Extracting #{desc} archive failed. Check task debug log for details."
          end

          package.blobstore_id = BlobUtil.create_blob(package_tgz)
        end

        package.save
      end
# Creates package in DB according to given metadata
# @param [Hash] package_meta Package metadata
# @return [void]
Creates package in DB according to given metadata
Creates package in DB according to given metadata
def create_package(package_meta)
        name, version = package_meta["name"], package_meta["version"]
        package_attrs = {
          :release => @release_model,
          :name => name,
          :sha1 => package_meta["sha1"],
          :fingerprint => package_meta["fingerprint"],
          :version => version
        }
        if @rebase
          new_version = next_package_version(name, version)
          if new_version != version
            transition = "#{version} -> #{new_version}"
            logger.info("Package `#{name}' rebased: #{transition}")
            package_attrs[:version] = new_version
            version = new_version
            @package_rebase_mapping[name] = transition
          end
        end
        package = Models::Package.new(package_attrs)
        package.dependency_set = package_meta["dependencies"]
        existing_blob = package_meta["blobstore_id"]
        desc = "package `#{name}/#{version}'"
        if existing_blob
          logger.info("Creating #{desc} from existing blob #{existing_blob}")
          package.blobstore_id = BlobUtil.copy_blob(existing_blob)
        else
          logger.info("Creating #{desc} from provided bits")
          package_tgz = File.join(@tmp_release_dir, "packages", "#{name}.tgz")
          result = Bosh::Exec.sh("tar -tzf #{package_tgz} 2>&1", :on_error => :return)
          if result.failed?
            logger.error("Extracting #{desc} archive failed, " +
                         "tar returned #{result.exit_status}, " +
                         "output: #{result.output}")
            raise PackageInvalidArchive, "Extracting #{desc} archive failed. Check task debug log for details."
          end
          package.blobstore_id = BlobUtil.create_blob(package_tgz)
        end
        package.save
      end
def create_package ( package_meta ) name , version = package_meta [ "name" ] , package_meta [ "version" ] package_attrs = { :release => @release_model , :name => name , :sha1 => package_meta [ "sha1" ] , :fingerprint => package_meta [ "fingerprint" ] , :version => version } if @rebase new_version = next_package_version ( name , version ) if new_version != version transition = "#{version} -> #{new_version}" logger . info ( "Package `#{name}' rebased: #{transition}" ) package_attrs [ :version ] = new_version version = new_version @package_rebase_mapping [ name ] = transition end end package = Models :: Package . new ( package_attrs ) package . dependency_set = package_meta [ "dependencies" ] existing_blob = package_meta [ "blobstore_id" ] desc = "package `#{name}/#{version}'" if existing_blob logger . info ( "Creating #{desc} from existing blob #{existing_blob}" ) package . blobstore_id = BlobUtil . copy_blob ( existing_blob ) else logger . info ( "Creating #{desc} from provided bits" ) package_tgz = File . join ( @tmp_release_dir , "packages" , "#{name}.tgz" ) result = Bosh :: Exec . sh ( "tar -tzf #{package_tgz} 2>&1" , :on_error => :return ) if result . failed? logger . error ( "Extracting #{desc} archive failed, " + "tar returned #{result.exit_status}, " + "output: #{result.output}" ) raise PackageInvalidArchive , "Extracting #{desc} archive failed. Check task debug log for details." end package . blobstore_id = BlobUtil . create_blob ( package_tgz ) end package . save end
Creates package in DB according to given metadata
Creates package in DB according to given metadata
None
void
package_meta
package_meta Package metadata
package_meta Package metadata