def get_files(self, package): files = pisi.files.Files() files_xml = os.path.join(self.package_path(package), ctx.const.files_xml) files.read(files_xml) return files
def build_packages(self): """Build each package defined in PSPEC file. After this process there will be .pisi files hanging around, AS INTENDED ;)""" self.fetch_component() # bug 856 # Operations and filters for package files self.file_actions() if ctx.get_option('create_static'): obj = self.generate_static_package_object() if obj: self.spec.packages.append(obj) if ctx.config.values.build.generatedebug: obj = self.generate_debug_package_object() if obj: self.spec.packages.append(obj) self.new_packages = [] self.old_packages = [] for package in self.spec.packages: # removing "farce" in specfile.py:SpecFile.override_tags # this block of code came here... SpecFile should never # ever ruin the generated PSPEC file. If build process # needs this, we should do it in here... (bug: #3773) if not package.summary: package.summary = self.spec.source.summary if not package.description: # TODO: remove this if statement with the part in # specfile.py:SpecFile if not self.spec.source.description: self.spec.dirtyWorkAround() package.description = self.spec.source.description if not package.partOf: package.partOf = self.spec.source.partOf if not package.license: package.license = self.spec.source.license if not package.icon: package.icon = self.spec.source.icon old_package_name = None # store additional files c = os.getcwd() os.chdir(self.specdir) install_dir = self.pkg_dir() + ctx.const.install_dir_suffix for afile in package.additionalFiles: src = os.path.join(ctx.const.files_dir, afile.filename) dest = os.path.join( install_dir + os.path.dirname(afile.target), os.path.basename(afile.target)) pisi.util.copy_file(src, dest) if afile.permission: # mode is octal! os.chmod(dest, int(afile.permission, 8)) if afile.owner: try: os.chown(dest, pwd.getpwnam(afile.owner)[2], -1) except KeyError: ctx.ui.warning( _("No user named '%s' found on the system") % afile.owner) if afile.group: try: os.chown(dest, -1, grp.getgrnam(afile.group)[2]) except KeyError: ctx.ui.warning( _("No group named '%s' found on the system") % afile.group) os.chdir(c) ctx.ui.action(_("** Building package %s") % package.name) ctx.ui.info(_("Generating %s,") % ctx.const.files_xml) self.gen_files_xml(package) ctx.ui.info(_("Generating %s,") % ctx.const.metadata_xml) self.gen_metadata_xml(package) abandoned_files = self.get_abandoned_files() if ctx.get_option('debug'): if abandoned_files: # Fail ctx.ui.error( _('There are abandoned files under the install dir (%s):' ) % (install_dir)) for f in abandoned_files: ctx.ui.info(' - %s' % (f)) raise AbandonedFilesException # build number if ctx.config.options.ignore_build_no or not ctx.config.values.build.buildno: build_no = old_build_no = None ctx.ui.warning( _('Build number is not available. For repo builds you must enable buildno in pisi.conf.' )) else: build_no, old_build_no = self.calc_build_no(package.name) self.metadata.package.build = build_no self.metadata.write( pisi.util.join_path(self.pkg_dir(), ctx.const.metadata_xml)) self.check_versioning( "%s-%s" % (self.spec.getSourceVersion(), self.spec.getSourceRelease())) # Calculate new and oldpackage names for buildfarm name = pisi.util.package_name(package.name, self.spec.getSourceVersion(), self.spec.getSourceRelease(), self.metadata.package.build) outdir = ctx.get_option('output_dir') if outdir: name = pisi.util.join_path(outdir, name) self.new_packages.append(name) ctx.ui.info(_("Creating PiSi package %s.") % name) pkg = pisi.package.Package(name, 'w') # add comar files to package os.chdir(self.specdir) for pcomar in package.providesComar: fname = pisi.util.join_path(ctx.const.comar_dir, pcomar.script) pkg.add_to_package(fname) # add xmls and files os.chdir(self.pkg_dir()) pkg.add_to_package(ctx.const.metadata_xml) pkg.add_to_package(ctx.const.files_xml) # Now it is time to add files to the packages using newly # created files.xml files = pisi.files.Files() files.read(ctx.const.files_xml) # Sort the files in-place according to their path for an ordered # tarfile layout which dramatically improves the compression performance # of lzma. files.list.sort(key=lambda x: x.path) if ctx.get_option('package_format') == "1.0": for finfo in files.list: orgname = arcname = pisi.util.join_path( "install", finfo.path) if package.debug_package: orgname = pisi.util.join_path("debug", finfo.path) pkg.add_to_package(orgname, arcname) pkg.close() else: # default package format is 1.1, so make it fallback. ctx.build_leftover = pisi.util.join_path( self.pkg_dir(), ctx.const.install_tar_lzma) tar = archive.ArchiveTar(ctx.const.install_tar_lzma, "tarlzma") for finfo in files.list: orgname = arcname = pisi.util.join_path( "install", finfo.path) if package.debug_package: orgname = pisi.util.join_path("debug", finfo.path) tar.add_to_archive(orgname, arcname.lstrip("install")) tar.close() pkg.add_to_package(ctx.const.install_tar_lzma) pkg.close() os.unlink(ctx.const.install_tar_lzma) ctx.build_leftover = None os.chdir(c) self.set_state("buildpackages") ctx.ui.info(_("Done.")) # Show the files those are not collected from the install dir if ctx.get_option('debug'): if not abandoned_files: ctx.ui.info( _('All of the files under the install dir (%s) has been collected by package(s)' ) % (install_dir)) if ctx.config.values.general.autoclean is True: ctx.ui.info(_("Cleaning Build Directory...")) pisi.util.clean_dir(self.pkg_dir()) else: ctx.ui.info(_("Keeping Build Directory")) # reset environment variables after build. this one is for # buildfarm actually. buildfarm re-inits pisi for each build # and left environment variables go directly into initial dict # making actionsapi.variables.exportFlags() useless... os.environ.clear() os.environ.update(ctx.config.environ) return self.new_packages, self.old_packages
def build_packages(self): """Build each package defined in PSPEC file. After this process there will be .pisi files hanging around, AS INTENDED ;)""" self.fetch_component() # bug 856 # Strip install directory before building .pisi packages. self.strip_install_dir() if ctx.get_option('create_static'): obj = self.generate_static_package_object() if obj: self.spec.packages.append(obj) if ctx.config.values.build.generatedebug: obj = self.generate_debug_package_object() if obj: self.spec.packages.append(obj) self.new_packages = [] self.old_packages = [] for package in self.spec.packages: # removing "farce" in specfile.py:SpecFile.override_tags # this block of code came here... SpecFile should never # ever ruin the generated PSPEC file. If build process # needs this, we should do it in here... (bug: #3773) if not package.summary: package.summary = self.spec.source.summary if not package.description: # TODO: remove this if statement with the part in # specfile.py:SpecFile if not self.spec.source.description: self.spec.dirtyWorkAround() package.description = self.spec.source.description if not package.partOf: package.partOf = self.spec.source.partOf if not package.license: package.license = self.spec.source.license if not package.icon: package.icon = self.spec.source.icon old_package_name = None # store additional files c = os.getcwd() os.chdir(self.specdir) install_dir = self.pkg_dir() + ctx.const.install_dir_suffix for afile in package.additionalFiles: src = os.path.join(ctx.const.files_dir, afile.filename) dest = os.path.join(install_dir + os.path.dirname(afile.target), os.path.basename(afile.target)) pisi.util.copy_file(src, dest) if afile.permission: # mode is octal! os.chmod(dest, int(afile.permission, 8)) if afile.owner: try: os.chown(dest, pwd.getpwnam(afile.owner)[2], -1) except KeyError: ctx.ui.warning(_("No user named '%s' found on the system") % afile.owner) if afile.group: try: os.chown(dest, -1, grp.getgrnam(afile.group)[2]) except KeyError: ctx.ui.warning(_("No group named '%s' found on the system") % afile.group) os.chdir(c) ctx.ui.action(_("** Building package %s") % package.name); ctx.ui.info(_("Generating %s,") % ctx.const.files_xml) self.gen_files_xml(package) ctx.ui.info(_("Generating %s,") % ctx.const.metadata_xml) self.gen_metadata_xml(package) # build number if ctx.config.options.ignore_build_no or not ctx.config.values.build.buildno: build_no = old_build_no = None ctx.ui.warning(_('Build number is not available. For repo builds you must enable buildno in pisi.conf.')) else: build_no, old_build_no = self.calc_build_no(package.name) self.metadata.package.build = build_no self.metadata.write(pisi.util.join_path(self.pkg_dir(), ctx.const.metadata_xml)) # Calculate new and oldpackage names for buildfarm name = pisi.util.package_name(package.name, self.spec.getSourceVersion(), self.spec.getSourceRelease(), self.metadata.package.build) outdir = ctx.get_option('output_dir') if outdir: name = pisi.util.join_path(outdir, name) self.new_packages.append(name) ctx.ui.info(_("Creating PiSi package %s.") % name) pkg = pisi.package.Package(name, 'w') # add comar files to package os.chdir(self.specdir) for pcomar in package.providesComar: fname = pisi.util.join_path(ctx.const.comar_dir, pcomar.script) pkg.add_to_package(fname) # add xmls and files os.chdir(self.pkg_dir()) pkg.add_to_package(ctx.const.metadata_xml) pkg.add_to_package(ctx.const.files_xml) # Now it is time to add files to the packages using newly # created files.xml files = pisi.files.Files() files.read(ctx.const.files_xml) if ctx.get_option('package_format') == "1.0": for finfo in files.list: orgname = arcname = pisi.util.join_path("install", finfo.path) if package.debug_package: orgname = pisi.util.join_path("debug", finfo.path) pkg.add_to_package(orgname, arcname) pkg.close() else: # default package format is 1.1, so make it fallback. ctx.build_leftover = pisi.util.join_path(self.pkg_dir(), ctx.const.install_tar_lzma) tar = archive.ArchiveTar(ctx.const.install_tar_lzma, "tarlzma") for finfo in files.list: orgname = arcname = pisi.util.join_path("install", finfo.path) if package.debug_package: orgname = pisi.util.join_path("debug", finfo.path) tar.add_to_archive(orgname, arcname.lstrip("install")) tar.close() pkg.add_to_package(ctx.const.install_tar_lzma) pkg.close() os.unlink(ctx.const.install_tar_lzma) ctx.build_leftover = None os.chdir(c) self.set_state("buildpackages") ctx.ui.info(_("Done.")) #show the files those are not collected from the install dir if ctx.get_option('debug'): abandoned_files = self.get_abandoned_files() if abandoned_files: ctx.ui.warning(_('Abandoned files under the install dir (%s):') % (install_dir)) for f in abandoned_files: ctx.ui.info(' - %s' % (f)) else: ctx.ui.warning(_('All of the files under the install dir (%s) has been collected by package(s)') % (install_dir)) if ctx.config.values.general.autoclean is True: ctx.ui.info(_("Cleaning Build Directory...")) pisi.util.clean_dir(self.pkg_dir()) else: ctx.ui.info(_("Keeping Build Directory")) # reset environment variables after build. this one is for # buildfarm actually. buildfarm re-inits pisi for each build # and left environment variables go directly into initial dict # making actionsapi.variables.exportFlags() useless... os.environ = {} os.environ = copy.deepcopy(ctx.config.environ) return self.new_packages, self.old_packages
def files(self, pkg): pkg = str(pkg) pkginfo = self.d[pkg] files = pisi.files.Files() files.read(self.files_name(pkg,pkginfo.version,pkginfo.release)) return files