def checkout(self, pkg, builder, cmd_group): ret = 0 if self.scm == 'gitmodule': cwd = os.getcwd() os.chdir(self.root_dir) ret += self.exec_cmd(pkg, "git submodule update --init --recursive %s" % self.path, 'checkout', chdir=False) os.chdir(cwd) elif self.scm == 'git': ret = 0 if self.url is not None: self.dump_msg(self, 'checkout') if not os.path.exists(self.abs_path): cmd = "git clone %s %s" % (self.url, self.abs_path) if os.system(cmd) != 0: return -1 cwd = os.getcwd() os.chdir(self.abs_path) # We may get an exception if the version is not specified, just # ignore it if self.version is not None: ret += os.system("git fetch") ret += os.system("git checkout %s" % (self.version)) cmd = 'git log -n 1 --format=format:%H'.split() output = subprocess.check_output(cmd) if output.decode('utf-8') != self.version: ret += os.system("git pull") os.chdir(cwd) step = self.steps.get('checkout') if step is not None: name = '%s:%s:checkout' % (pkg, self.name) cmd_group.inc_enqueued() cmd = plptools_builder.Builder_command( name=name, cmd=step.command, path=self.abs_path, env=self.get_env_for_command(pkg)) cmd.set_callback(callback=cmd_group.dec_enqueued, command=cmd) builder.enqueue(cmd=cmd) else: self.dump_error(pkg, 'Unknown SCM: %s' % self.scm) return -1 return ret
def checkout(self, pkg, builder, cmd_group): ret = 0 if self.url is not None: self.dumpMsg(self, 'checkout') if not os.path.exists(self.abs_path): cmd = "git clone %s %s" % (self.url, self.abs_path) if os.system(cmd) != 0: return -1 cwd = os.getcwd() os.chdir(self.abs_path) # We may get an exception if the version is not specified, just # ignore it if self.version is not None: try: ret += os.system("git fetch") ret += os.system("git checkout %s" % (self.version)) cmd = 'git log -n 1 --format=format:%H'.split() output = subprocess.check_output(cmd) if output.decode('utf-8') != self.version: os.system("git pull") except Exception: pass os.chdir(cwd) step = self.steps.get('checkout') if step is not None: name = '%s:%s:checkout' % (pkg, self.name) cmd_group.inc_enqueued() cmd = plptools_builder.Builder_command( name=name, cmd=step.command, path=self.abs_path, env=self.get_env_for_command(pkg)) cmd.set_callback(callback=cmd_group.dec_enqueued, command=cmd) builder.enqueue(cmd=cmd) return ret
def enqueue_steps(self, builder, pkg, cmd_group, configs, steps): self.builder = builder # First create a proxy job with nothing to execute so that other modules # which depends on it can wait for the completion of all module jobs # This job will inherit the job dependencies and will trigger module # jobs when it is ready self.nb_pending_configs = 0 deps = [] for dep in self.deps: # A module must be built for each package, thus module commands are registered # in the builder with both package and module names to differentiate them # And depend on the right module dep_job = builder.get_command('%s:%s:last' % (pkg, dep.name)) if dep_job != None: deps.append(dep_job) cmd_group.inc_enqueued() module_job = plptools_builder.Builder_command(name='%s:%s' % (pkg, self.name), deps=deps) module_job.set_callback(callback=cmd_group.dec_enqueued, command=module_job) builder.enqueue(cmd=module_job) configs_last_cmd = [] job_configs = [] for configId in range(0, len(configs)): config = configs[configId] if not self.is_active_config(config): continue config_last_cmd = None # Extract the items from the config on which the module is sentitive to check # if we should consider it as already processed job_config = config.get_name_from_items(self.parameters) if job_config in job_configs: continue job_configs.append(job_config) self.nb_pending_configs += 1 # The first step always depend on the module job, to get triggered when all module deps are finished prev_step = module_job for i in range(0, len(steps)): step = steps[i] if self.steps.get(step) == None: continue # Then each step depends on the previous one to execute them sequentially # Only the last step has a callback to update the module else: name = '%s:%s:%s' % (pkg, self.name, step) if len(self.parameters) != 0: name += ' (%s)' % (config.name) cmd_group.inc_enqueued() prev_step = plptools_builder.Builder_command( name=name, cmd=self.steps.get(step).command, path=self.abs_path, env=self.get_env_for_command(pkg, config), deps=[prev_step]) prev_step.set_callback(callback=cmd_group.dec_enqueued, command=prev_step) builder.enqueue(cmd=prev_step) config_last_cmd = prev_step if config_last_cmd != None: configs_last_cmd.append(config_last_cmd) cmd_group.inc_enqueued() module_job = plptools_builder.Builder_command(name='%s:%s:last' % (pkg, self.name), deps=configs_last_cmd) module_job.set_callback(callback=cmd_group.dec_enqueued, command=module_job) builder.enqueue(cmd=module_job)