# Generate incorporation pkg incorp_pkg_name = "pkg://%s/%s@%s" % \ (args.publisher, INCORP_NAME, incorp_version) dep_pkg_name = "%s@%s" % (AI_PKG_NAME, ai_pkg_version) # Generate the manifest manifest = ('set name=pkg.fmri value=%(incorppkg)s\n' 'depend type=incorporate fmri=%(depname)s' % {'incorppkg': incorp_pkg_name, 'depname': dep_pkg_name}) print "\nManifest contents:\n%s" % manifest print "\nPublishing %s" % incorp_pkg_name cmd = [PKGSEND, "-s", args.repo, "publish"] pkgsend = Popen(cmd, stdin=Popen.PIPE, stdout=Popen.PIPE, stderr=Popen.PIPE) stdout, stderr = pkgsend.communicate(manifest) if stderr.strip() or pkgsend.returncode: pkgsend.stdout = stdout pkgsend.stderr = stderr raise CalledProcessError(pkgsend.returncode, cmd, popen=pkgsend) else: print stdout.strip() # Refresh the repository cmd = [PKGREPO, "-s", args.repo, "refresh"] run(cmd) print "Finished at " + time.asctime()
def create_repository(self): """ class method to create the repository """ self.logger.info("Creating repository") # Create the repository (as needed) if it's a local path (no scheme) # or file:/// scheme. scheme = urlparse.urlsplit(self.pkg_repo).scheme if scheme in ("file", ""): # Try to create the repo (it may already exist) cmd = [cli.PKGREPO, "create", self.pkg_repo] repo = run(cmd, check_result=Popen.ANY) if repo.returncode == 0: # New repo was created. Add the publisher and make it default cmd = [ cli.PKGREPO, "-s", self.pkg_repo, "add-publisher", self.publisher ] run(cmd) cmd = [ cli.PKGREPO, "-s", self.pkg_repo, "set", "publisher/prefix=%s" % self.publisher ] run(cmd) # Generate a manifest file cmd = [cli.PKGSEND, "generate", self.pkg_img_path] generate = run(cmd) manifest = [generate.stdout] manifest.append('license lic_OTN license=lic_OTN must-accept=true\n') manifest.append('set name=pkg.summary ' 'value="Automated Installation boot image"\n') manifest.append("set name=org.opensolaris.consolidation " "value=install\n") manifest.append('set name=info.classification ' 'value="org.opensolaris.category.2008:' 'System/Administration and Configuration"\n') arch = platform.processor() manifest.append("set name=variant.arch value=%s\n" % arch) manifest.append("set name=%s value=%s variant.arch=%s\n" % (self.SVC_NAME_ATTR, self.service_name, arch)) manifest.append("set name=pkg.fmri value=%s\n" % self.pkg_name) manifest.append("depend fmri=pkg:/system/core-os type=exclude\n") manifest = "".join(manifest) self.logger.info("Publishing %s", self.pkg_name) cmd = [ cli.PKGSEND, "-s", self.pkg_repo, "publish", "-d", self.pkg_img_path, "-d", self.tmp_dir ] pkgsend = Popen(cmd, stdin=Popen.PIPE, stdout=Popen.PIPE, stderr=Popen.PIPE) stdout, stderr = pkgsend.communicate(manifest) if stderr.strip() or pkgsend.returncode: pkgsend.stdout = stdout pkgsend.stderr = stderr raise CalledProcessError(pkgsend.returncode, cmd, popen=pkgsend) else: self.logger.info(stdout.strip())