+++ /dev/null
-=begin
-
- LocalBuildJob.rb
-
-Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
-
-Contact:
-Taejun Ha <taejun.ha@samsung.com>
-Jiil Hyoun <jiil.hyoun@samsung.com>
-Donghyuk Yang <donghyuk.yang@samsung.com>
-DongHee Yang <donghee.yang@samsung.com>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Contributors:
-- S-Core Co., Ltd
-=end
-
-$LOAD_PATH.unshift File.dirname(__FILE__)
-$LOAD_PATH.unshift File.dirname(File.dirname(__FILE__))+"/common"
-require "BuildJob.rb"
-require "utils.rb"
-
-class LocalBuildJob < BuildJob
- attr_accessor :id, :status, :pkginfo, :pkgsvr_client, :thread, :log, :rev_fail_list, :rev_success_list, :source_path
-
- # initialize
- def initialize (local_path, os, pkgsvr_url, options, server, parent, outstream, resolve )
- super(server.jobmgr.get_new_job_id(), server)
- @rev_fail_list = []
- @rev_success_list = []
- @parent = parent
- @local_path = local_path
- @os = os
- @host_os = Utils::HOST_OS
- @pkgserver_url = pkgsvr_url
- @options = options
- @resolve = resolve
- @outstream = outstream
-
- @status = "JUST_CREATED"
- @sub_jobs = []
- @job_root = "#{@server.path}/jobs/#{@id}"
- @source_path = @local_path
- @pkginfo = nil
- @pkgsvr_client = nil
- @job_working_dir=@job_root+"/works"
-
- @thread = nil
-
- # mkdir
- FileUtils.rm_rf "#{@server.path}/jobs/#{@id}"
- FileUtils.mkdir_p "#{@server.path}/jobs/#{@id}"
-
- # create logger
- @log = JobLog.new( self, "#{@server.path}/jobs/#{@id}/log", outstream )
- end
-
-
- def terminate()
-
- # report error
- if @status == "ERROR" then
- @log.error( "Job is stopped by ERROR", Log::LV_USER)
- @server.cleaner.clean_afterwards(@id)
- else
- # if succeeded, clean up
- @server.cleaner.clean(@id)
- end
-
- # clean up builder directory if exist?
- if Builder.exist? "JB#{@id}" then
- Builder.remove("JB#{@id}")
- end
-
- # send mail
- if ( @server.send_mail.eql? "YES" ) and ( not @pkginfo.nil? ) and ( not @pkginfo.packages.nil? ) then
- mail_list = []
- contents = []
- contents.push " "
- contents.push "%-30s| %10s | %10s" % ["package name", "version", "os"]
- contents.push "---------------------------------------------------------------"
- for pkg in @pkginfo.packages
- if not pkg.os.eql? @os then next end
- mail_list = mail_list | Mail.parse_email( pkg.maintainer )
- contents.push("%-30s| %10s | %10s" % [ pkg.package_name, pkg.version, pkg.os] )
- end
-
- if @status == "ERROR" then
- subject = "[DIBS] Build fail"
- contents.push " "
- contents.push "check log file"
- contents.push "* Log : #{@server.job_log_url}/#{@id}/log"
- else
- subject = "[DIBS] Build success"
- end
- Mail.send_mail(mail_list, subject, contents.join("\n"))
- end
-
- # close logger
- @log.close
-
- # send END signal , if connectionn is valid
- if @status != "ERROR" and not @outstream.nil? then
- BuildCommServer.send_end(@outstream)
- end
-
- # close outstream
- if not @outstream.nil? then
- BuildCommServer.disconnect( @outstream )
- end
- end
-
-
- # verify
- def pre_verify
- @log.info( "Verifying job input...", Log::LV_USER)
-
- # check pkginfo.manifest
- if not File.exist? "#{@source_path}/package/pkginfo.manifest"
- @log.error( "#{@source_path}/package/pkginfo.manifest does not exist", Log::LV_USER)
- @status = "ERROR"
- return false
- end
-
- # set pkginfo
- begin
- @pkginfo = PackageManifest.new("#{@source_path}/package/pkginfo.manifest")
- rescue => e
- @log.error( e.message, Log::LV_USER)
- @status = "ERROR"
- return false
- end
-
- # set up pkgsvr_client
- @pkgsvr_client = Client.new(@pkgserver_url, @job_working_dir, @log)
-
- return true
- end
-
-end