Example #1
0
def dohtml(*sourceFiles):
    '''inserts the files in the list of files into /usr/share/doc/PACKAGE/html'''

    ''' example call: pisitools.dohtml("doc/doxygen/html/*")'''
    destionationDirectory = join_path(get.installDIR(), 'usr/share/doc', get.srcNAME(), 'html')

    if not can_access_directory(destionationDirectory):
        makedirs(destionationDirectory)

    allowed_extensions = ['.png', '.gif', '.html', '.htm', '.jpg', '.css', '.js']
    disallowed_directories = ['CVS']

    for sourceFile in sourceFiles:
        sourceFileGlob = glob.glob(sourceFile)
        if len(sourceFileGlob) == 0:
            raise FileError(_("No file matched pattern \"%s\"") % sourceFile)

        for source in sourceFileGlob:
            if os.path.isfile(source) and os.path.splitext(source)[1] in allowed_extensions:
                system('install -m0644 "%s" %s' % (source, destionationDirectory))
            if os.path.isdir(source) and os.path.basename(source) not in disallowed_directories:
                eraser = os.path.split(source)[0]
                for root, dirs, files in os.walk(source):
                    newRoot = remove_prefix(eraser, root)
                    for sourcename in files:
                        if os.path.splitext(sourcename)[1] in allowed_extensions:
                            makedirs(join_path(destionationDirectory, newRoot))
                            system('install -m0644 %s %s' % (join_path(root, sourcename), join_path(destionationDirectory, newRoot, sourcename)))
Example #2
0
    def generate_static_package_object(self):
        ar_files = []
        for root, dirs, files in os.walk(self.pkg_install_dir()):
            for f in files:
                if f.endswith(ctx.const.ar_file_suffix) and util.is_ar_file(util.join_path(root, f)):
                    ar_files.append(util.join_path(root, f))

        if not len(ar_files):
            return None

        static_package_obj = pisi.specfile.Package()
        static_package_obj.name = self.spec.source.name + ctx.const.static_name_suffix
        # FIXME: find a better way to deal with the summary and description constants.
        static_package_obj.summary['en'] = u'Ar files for %s' % (self.spec.source.name)
        static_package_obj.description['en'] = u'Ar files for %s' % (self.spec.source.name)
        static_package_obj.partOf = self.spec.source.partOf
        for f in ar_files:
            static_package_obj.files.append(pisi.specfile.Path(path = f[len(self.pkg_install_dir()):], fileType = "library"))

        # append all generated packages to dependencies
        for p in self.spec.packages:
            static_package_obj.packageDependencies.append(
                pisi.dependency.Dependency(package = p.name))

        return static_package_obj
Example #3
0
    def gen_metadata_xml(self, package):
        """Generate the metadata.xml file for build source.

        metadata.xml is composed of the information from specfile plus
        some additional information."""
        metadata = MetaData()
        metadata.from_spec(self.spec.source, package)

        metadata.package.distribution = ctx.config.values.general.distribution
        metadata.package.distributionRelease = ctx.config.values.general.distribution_release
        metadata.package.architecture = "Any"
        
        size, d = 0, self.pkg_install_dir()

        for path in package.files:
             size += util.dir_size(util.join_path(d, path.path))

        metadata.package.installedSize = size

        # build no
        if ctx.config.options.ignore_build_no:
            metadata.package.build = None  # means, build no information n/a
            ctx.ui.warning(_('Build number is not available due to --ignore-build'))
        elif (not ctx.config.values.build.buildno):
            metadata.package.build = None
            ctx.ui.warning(_('Build number is not available. For repo builds you must enable buildno in pisi.conf.'))
        else:
            metadata.package.build = self.calc_build_no(metadata.package.name)

        metadata_xml_path = util.join_path(self.pkg_dir(), ctx.const.metadata_xml)
        metadata.write(metadata_xml_path)
        self.metadata = metadata
Example #4
0
def dohtml(*sourceFiles):
    '''inserts the files in the list of files into /usr/share/doc/PACKAGE/html'''
    ''' example call: pisitools.dohtml("doc/doxygen/html/*")'''
    destionationDirectory = join_path(get.installDIR(), 'usr/share/doc',
                                      get.srcTAG(), 'html')

    if not can_access_directory(destionationDirectory):
        makedirs(destionationDirectory)

    allowed_extensions = [
        '.png', '.gif', '.html', '.htm', '.jpg', '.css', '.js'
    ]
    disallowed_directories = ['CVS']

    for sourceFile in sourceFiles:
        for source in glob.glob(sourceFile):
            if os.path.isfile(source) and os.path.splitext(
                    source)[1] in allowed_extensions:
                system('install -m0644 "%s" %s' %
                       (source, destionationDirectory))
            if os.path.isdir(source) and os.path.basename(
                    source) not in disallowed_directories:
                for root, dirs, files in os.walk(source):
                    for source in files:
                        if os.path.splitext(source)[1] in allowed_extensions:
                            makedirs(destionationDirectory)
                            system('install -m0644 %s %s' % (join_path(
                                root, source), destionationDirectory))
Example #5
0
    def get_abandoned_files(self):
        # return the files those are not collected from the install dir

        install_dir = self.pkg_install_dir()
        abandoned_files = []
        all_paths_in_packages = []

        for package in self.spec.packages:
            for path in package.files:
                path = util.join_path(install_dir, path.path)
                all_paths_in_packages.append(path)

        def is_included(path1, path2):
            "Return True if path2 includes path1"
            return path1 == path2 or fnmatch.fnmatch(path1, path2) or fnmatch.fnmatch(path1, util.join_path(path2, "*"))

        for root, dirs, files in os.walk(install_dir):
            if not dirs and not files:
                for _path in all_paths_in_packages:
                    if is_included(root, _path):
                        break
                else:
                    abandoned_files.append(root)

            for file_ in files:
                fpath = util.join_path(root, file_)
                for _path in all_paths_in_packages:
                    if is_included(fpath, _path):
                        break

                else:
                    abandoned_files.append(fpath)

        len_install_dir = len(install_dir)
        return map(lambda x: x[len_install_dir:], abandoned_files)
Example #6
0
 def fetch_additionalFiles(self):
     for pkg in self.spec.packages + [self.spec.source]:
         for afile in pkg.additionalFiles:
             file_name = os.path.basename(afile.filename)
             dir_name = os.path.dirname(afile.filename)
             afileuri = util.join_path(self.specdiruri, ctx.const.files_dir, dir_name, file_name)
             self.download(afileuri, util.join_path(self.destdir, ctx.const.files_dir, dir_name))
Example #7
0
def dohtml(*sourceFiles, **kw):
    '''inserts the files in the list of files into /usr/share/doc/PACKAGE/html'''

    ''' example call: pisitools.dohtml("doc/doxygen/html/*")'''
    destDir = kw.get("destDir", get.srcNAME())
    destionationDirectory = join_path(get.installDIR(), get.docDIR(), destDir, 'html')

    if not can_access_directory(destionationDirectory):
        makedirs(destionationDirectory)

    allowed_extensions = ['.png', '.gif', '.html', '.htm', '.jpg', '.css', '.js']
    disallowed_directories = ['CVS', '.git', '.svn', '.hg']

    for sourceFile in sourceFiles:
        sourceFileGlob = glob.glob(sourceFile)
        if len(sourceFileGlob) == 0:
            raise FileError(_("No file matched pattern \"%s\"") % sourceFile)

        for source in sourceFileGlob:
            if os.path.isfile(source) and os.path.splitext(source)[1] in allowed_extensions:
                system('install -m0644 "%s" %s' % (source, destionationDirectory))
            if os.path.isdir(source) and os.path.basename(source) not in disallowed_directories:
                eraser = os.path.split(source)[0]
                for root, dirs, files in os.walk(source):
                    newRoot = remove_prefix(eraser, root)
                    for sourcename in files:
                        if os.path.splitext(sourcename)[1] in allowed_extensions:
                            makedirs(join_path(destionationDirectory, newRoot))
                            system('install -m0644 %s %s' % (join_path(root, sourcename), join_path(destionationDirectory, newRoot, sourcename)))
Example #8
0
def dohtml(*sourceFiles, **kw):
    """inserts the files in the list of files into /usr/share/doc/PACKAGE/html"""

    """ example call: pisitools.dohtml("doc/doxygen/html/*")"""
    destDir = kw.get("destDir", get.srcNAME())
    destionationDirectory = join_path(get.installDIR(), get.docDIR(), destDir, "html")

    if not can_access_directory(destionationDirectory):
        makedirs(destionationDirectory)

    allowed_extensions = [".png", ".gif", ".html", ".htm", ".jpg", ".css", ".js"]
    disallowed_directories = ["CVS", ".git", ".svn", ".hg"]

    for sourceFile in sourceFiles:
        sourceFileGlob = glob.glob(sourceFile)
        if len(sourceFileGlob) == 0:
            raise FileError(_('No file matched pattern "%s"') % sourceFile)

        for source in sourceFileGlob:
            if os.path.isfile(source) and os.path.splitext(source)[1] in allowed_extensions:
                system('install -m0644 "%s" %s' % (source, destionationDirectory))
            if os.path.isdir(source) and os.path.basename(source) not in disallowed_directories:
                eraser = os.path.split(source)[0]
                for root, dirs, files in os.walk(source):
                    newRoot = remove_prefix(eraser, root)
                    for sourcename in files:
                        if os.path.splitext(sourcename)[1] in allowed_extensions:
                            makedirs(join_path(destionationDirectory, newRoot))
                            system(
                                "install -m0644 %s %s"
                                % (join_path(root, sourcename), join_path(destionationDirectory, newRoot, sourcename))
                            )
Example #9
0
def doman(*sourceFiles):
    """inserts the man pages in the list of files into /usr/share/man/"""

    """example call: pisitools.doman("man.1", "pardus.*")"""
    manDIR = join_path(get.installDIR(), get.manDIR())
    if not can_access_directory(manDIR):
        makedirs(manDIR)

    for sourceFile in sourceFiles:
        sourceFileGlob = glob.glob(sourceFile)
        if len(sourceFileGlob) == 0:
            raise FileError(_('No file matched pattern "%s"') % sourceFile)

        for source in sourceFileGlob:
            compressed = source.endswith("gz") and source
            if compressed:
                source = source[:-3]
            try:
                pageName, pageDirectory = source[: source.rindex(".")], source[source.rindex(".") + 1 :]
            except ValueError:
                error(_("ActionsAPI [doman]: Wrong man page file: %s") % (source))

            manPDIR = join_path(manDIR, "/man%s" % pageDirectory)
            makedirs(manPDIR)
            if not compressed:
                system("install -m0644 %s %s" % (source, manPDIR))
            else:
                uncompress(compressed, targetDir=manPDIR)
Example #10
0
def doman(*sourceFiles):
    '''inserts the man pages in the list of files into /usr/share/man/'''
    '''example call: pisitools.doman("man.1", "pardus.*")'''
    manDIR = join_path(get.installDIR(), get.manDIR())
    if not can_access_directory(manDIR):
        makedirs(manDIR)

    for sourceFile in sourceFiles:
        sourceFileGlob = glob.glob(sourceFile)
        if len(sourceFileGlob) == 0:
            raise FileError(_("No file matched pattern \"%s\"") % sourceFile)

        for source in sourceFileGlob:
            compressed = source.endswith("gz") and source
            if compressed:
                source = source[:-3]
            try:
                pageName, pageDirectory = source[:source.rindex('.')], \
                                          source[source.rindex('.')+1:]
            except ValueError:
                error(
                    _('ActionsAPI [doman]: Wrong man page file: %s') %
                    (source))

            manPDIR = join_path(manDIR, '/man%s' % pageDirectory)
            makedirs(manPDIR)
            if not compressed:
                system('install -m0644 %s %s' % (source, manPDIR))
            else:
                uncompress(compressed, targetDir=manPDIR)
Example #11
0
def dolib_a(sourceFile, destinationDirectory='/usr/lib'):
    '''insert the static library into /usr/lib with permission 0644'''
    '''example call: pisitools.dolib_a("staticlib/libvga.a")'''
    sourceFile = join_path(os.getcwd(), sourceFile)
    destinationDirectory = join_path(get.installDIR(), destinationDirectory)

    lib_insinto(sourceFile, destinationDirectory, 644)
Example #12
0
def resurrect_package(package_fn):
    """Resurrect the package in the PiSi databases"""

    metadata_xml = util.join_path(ctx.config.lib_dir(), package_fn, ctx.const.metadata_xml)
    if not exists(metadata_xml):
        return

    metadata = MetaData()
    metadata.read(metadata_xml)

    errs = metadata.has_errors()
    if errs:
        util.Checks.print_errors(errs)
        raise Error, _("MetaData format wrong")

    files_xml = util.join_path(ctx.config.lib_dir(), package_fn, ctx.const.files_xml)
    if not exists(files_xml):
        return

    files = Files()
    files.read(files_xml)

    if files.has_errors():
        raise Error, _("Invalid %s") % ctx.const.files_xml

    virtual_install(metadata, files)
Example #13
0
    def fetch_component(self):
        if self.spec.source.partOf:
            return

        diruri = util.parenturi(self.specuri.get_uri())
        parentdir = util.parenturi(diruri)
        url = util.join_path(parentdir, 'component.xml')
        progress = ctx.ui.Progress
        if pisi.uri.URI(url).is_remote_file():
            try:
                pisi.fetcher.fetch_url(url, self.pkg_work_dir(), progress)
            except pisi.fetcher.FetchError:
                ctx.ui.warning(_("Cannot find component.xml in remote "
                                 "directory, Source is now part of "
                                 "unknown component"))
                self.spec.source.partOf = 'unknown'
                return
            path = util.join_path(self.pkg_work_dir(), 'component.xml')
        else:
            if not os.path.exists(url):
                ctx.ui.warning(_("Cannot find component.xml in upper "
                                 "directory, Source is now part of "
                                 "unknown component"))
                self.spec.source.partOf = 'unknown'
                return
            path = url
        comp = component.CompatComponent()
        comp.read(path)
        self.spec.source.partOf = comp.name
Example #14
0
 def fetch_comarfiles(self):
     for package in self.spec.packages:
         for pcomar in package.providesComar:
             comaruri = util.join_path(self.specdiruri,
                             ctx.const.comar_dir, pcomar.script)
             self.download(comaruri, util.join_path(self.destdir,
                                                    ctx.const.comar_dir))
Example #15
0
def _dodoc(*source_files, **kw):
    '''copy doc files to /usr/share/doc/src_name recursively'''

    dest = util.join_path(get.docDIR(), kw.get('dest_dir', get.srcNAME()))
    destination = util.join_path(get.installDIR(), dest)

    if not os.access(destination, os.F_OK):
        os.makedirs(destination)

    for source_file in source_files:
        sources = glob(source_file)
        if not sources:
            raise DoJavadocError(_('No any file/directory matched '
                                   'to regex expression "%s".' % source_file))

        for source in sources:
            if os.path.isfile(source):
                try:
                    copy(source, destination)
                except IOError:
                    raise DoJavadocError(_('DoJavadoc failed.'))
            elif os.path.isdir(source):
                target = util.join_path(destination, source.split("/")[-1])
                try:
                    copytree(source, target)
                except IOError:
                    raise DoJavadocError(_('DoJavadoc failed.'))
Example #16
0
def configure_pending():
    # start with pending packages
    # configure them in reverse topological order of dependency
    A = ctx.installdb.list_pending()
    order = generate_pending_order(A)
    try:
        import pisi.comariface as comariface
        for x in order:
            if ctx.installdb.is_installed(x):
                pkginfo = A[x]
                pkgname = util.package_name(x, pkginfo.version,
                                        pkginfo.release,
                                        False,
                                        False)
                pkg_path = util.join_path(ctx.config.lib_dir(),
                                          'package', pkgname)
                m = MetaData()
                metadata_path = util.join_path(pkg_path, ctx.const.metadata_xml)
                m.read(metadata_path)
                # FIXME: we need a full package info here!
                pkginfo.name = x
                ctx.ui.notify(pisi.ui.configuring, package = pkginfo, files = None)
                pisi.comariface.post_install(
                    pkginfo.name,
                    m.package.providesComar,
                    util.join_path(pkg_path, ctx.const.comar_dir),
                    util.join_path(pkg_path, ctx.const.metadata_xml),
                    util.join_path(pkg_path, ctx.const.files_xml),
                )
                ctx.ui.notify(pisi.ui.configured, package = pkginfo, files = None)
            ctx.installdb.clear_pending(x)
    except ImportError:
        raise Error(_("comar package is not fully installed"))
Example #17
0
def dolib_so(sourceFile, destinationDirectory='/usr/lib'):
    '''insert the static library into /usr/lib with permission 0755'''
    '''example call: pisitools.dolib_so("pppd/plugins/minconn.so")'''
    sourceFile = join_path(os.getcwd(), sourceFile)
    destinationDirectory = join_path(get.installDIR(), destinationDirectory)

    lib_insinto(sourceFile, destinationDirectory, 755)
Example #18
0
    def gen_metadata_xml(self, package, build_no=None):
        """Generate the metadata.xml file for build source.

        metadata.xml is composed of the information from specfile plus
        some additional information."""
        metadata = MetaData()
        metadata.from_spec(self.spec.source, package)

        metadata.package.distribution = ctx.config.values.general.distribution
        metadata.package.distributionRelease = ctx.config.values.general.distribution_release
        metadata.package.architecture = "Any"
        metadata.package.packageFormat = ctx.get_option('package_format')

        size = long(0)
        if package.debug_package:
            d = self.pkg_debug_dir()
        else:
            d = self.pkg_install_dir()

        for path in package.files:
            for p in glob.glob(util.join_path(d, path.path)):
                size += util.dir_size(p)

        metadata.package.installedSize = size

        metadata.package.build = build_no

        metadata_xml_path = util.join_path(self.pkg_dir(),
                                           ctx.const.metadata_xml)
        metadata.write(metadata_xml_path)
        self.metadata = metadata
def resurrect_package(package_fn):
    """Resurrect the package in the PiSi databases"""

    from os.path import exists

    metadata_xml = util.join_path(ctx.config.lib_dir(), package_fn, ctx.const.metadata_xml)
    if not exists(metadata_xml):
       raise Error, _("Metadata XML '%s' cannot be found") % metadata_xml

    metadata = MetaData()
    metadata.read(metadata_xml)

    errs = metadata.errors()
    if errs:   
       util.Checks.print_errors(errs)
       raise Error, _("MetaData format wrong (%s)") % package_fn
    
    ctx.ui.info(_('* Adding \'%s\' to db... ') % (metadata.package.name), noln=True)
    
    files_xml = util.join_path(ctx.config.lib_dir(), package_fn, ctx.const.files_xml)
    if not exists(files_xml):
       raise Error, _("Files XML '%s' cannot be found") % files_xml

    files = Files()
    files.read(files_xml)

    if files.errors():
       raise Error, _("Invalid %s") % ctx.const.files_xml

    import pisi.atomicoperations
    pisi.atomicoperations.virtual_install(metadata, files)
    ctx.ui.info(_('OK.'))
Example #20
0
    def generate_static_package_object(self):
        ar_files = []
        for root, dirs, files in os.walk(self.pkg_install_dir()):
            for f in files:
                if f.endswith(ctx.const.ar_file_suffix) and util.is_ar_file(
                        util.join_path(root, f)):
                    ar_files.append(util.join_path(root, f))

        if not len(ar_files):
            return None

        static_package_obj = pisi.specfile.Package()
        static_package_obj.name = self.spec.source.name + ctx.const.static_name_suffix
        # FIXME: find a better way to deal with the summary and description constants.
        static_package_obj.summary['en'] = u'Ar files for %s' % (
            self.spec.source.name)
        static_package_obj.description['en'] = u'Ar files for %s' % (
            self.spec.source.name)
        static_package_obj.partOf = self.spec.source.partOf
        for f in ar_files:
            static_package_obj.files.append(
                pisi.specfile.Path(path=f[len(self.pkg_install_dir()):],
                                   fileType="library"))

        # append all generated packages to dependencies
        for p in self.spec.packages:
            static_package_obj.packageDependencies.append(
                pisi.dependency.Dependency(package=p.name))

        return static_package_obj
Example #21
0
    def pkg_src_dir(self):
        """Returns the real path of WorkDir for an unpacked archive."""

        dirname = self.actionGlobals.get("WorkDir")
        if dirname:
            return util.join_path(self.pkg_work_dir(), dirname)

        dirname = self.spec.source.name + "-" + self.spec.getSourceVersion()
        src_dir = util.join_path(self.pkg_work_dir(), dirname)

        if not os.path.exists(src_dir):
            archive = self.spec.source.archive[0]

            # For binary types, WorkDir is usually "."
            if archive.type == "binary":
                return self.pkg_work_dir()

            basename = os.path.basename(archive.uri)
            dirname = os.path.splitext(basename)[0]
            src_dir = util.join_path(self.pkg_work_dir(), dirname)

            while not os.path.exists(src_dir):
                src_dir, ext = os.path.splitext(src_dir)
                if not ext:
                    break

        return src_dir
Example #22
0
def create_delta_packages(old_packages, new_package):
    if new_package in old_packages:
        ctx.ui.warning(_("New package '%s' exists in the list of old "
                         "packages. Skipping it...") % new_package)
        while new_package in old_packages:
            old_packages.remove(new_package)

    new_pkg_name = os.path.splitext(os.path.basename(new_package))[0]
    new_pkg_path = util.join_path(ctx.config.tmp_dir(), new_pkg_name)

    new_pkg = pisi.package.Package(new_package, tmp_dir=new_pkg_path)
    new_pkg.read()

    # Unpack new package to temp
    new_pkg.extract_pisi_files(new_pkg_path)
    new_pkg.extract_dir("comar", new_pkg_path)

    install_dir = util.join_path(new_pkg_path, "install")
    util.clean_dir(install_dir)
    os.mkdir(install_dir)
    new_pkg.extract_install(install_dir)

    delta_packages = create_delta_packages_from_obj(old_packages,
                                                    new_pkg,
                                                    new_pkg_path)

    # Remove temp dir
    util.clean_dir(new_pkg_path)

    # Return delta package names
    return delta_packages
Example #23
0
    def gen_metadata_xml(self, package, build_no=None):
        """Generate the metadata.xml file for build source.

        metadata.xml is composed of the information from specfile plus
        some additional information."""
        metadata = MetaData()
        metadata.from_spec(self.spec.source, package)

        metadata.package.distribution = ctx.config.values.general.distribution
        metadata.package.distributionRelease = ctx.config.values.general.distribution_release
        metadata.package.architecture = "Any"
        metadata.package.packageFormat = ctx.get_option('package_format')
        
        size = 0
        if package.debug_package:
            d = self.pkg_debug_dir()
        else:
            d = self.pkg_install_dir()

        for path in package.files:
            for p in glob.glob(util.join_path(d, path.path)):
                size += util.dir_size(p)

        metadata.package.installedSize = size

        metadata.package.build = build_no

        metadata_xml_path = util.join_path(self.pkg_dir(), ctx.const.metadata_xml)
        metadata.write(metadata_xml_path)
        self.metadata = metadata
Example #24
0
    def pkg_src_dir(self):
        """Returns the real path of WorkDir for an unpacked archive."""

        dirname = self.actionGlobals.get("WorkDir")
        if dirname:
            return util.join_path(self.pkg_work_dir(), dirname)

        dirname = self.spec.source.name + "-" + self.spec.getSourceVersion()
        src_dir = util.join_path(self.pkg_work_dir(), dirname)

        if not os.path.exists(src_dir):
            archive = self.spec.source.archive[0]

            # For binary types, WorkDir is usually "."
            if archive.type == "binary":
                return self.pkg_work_dir()

            basename = os.path.basename(archive.uri)
            dirname = os.path.splitext(basename)[0]
            src_dir = util.join_path(self.pkg_work_dir(), dirname)

            while not os.path.exists(src_dir):
                src_dir, ext = os.path.splitext(src_dir)
                if not ext:
                    break

        return src_dir
Example #25
0
    def fetch_component(self):
        if self.spec.source.partOf:
            return

        diruri = util.parenturi(self.specuri.get_uri())
        parentdir = util.parenturi(diruri)
        url = util.join_path(parentdir, 'component.xml')
        progress = ctx.ui.Progress
        if pisi.uri.URI(url).is_remote_file():
            try:
                pisi.fetcher.fetch_url(url, self.pkg_work_dir(), progress)
            except pisi.fetcher.FetchError:
                ctx.ui.warning(
                    _("Cannot find component.xml in remote "
                      "directory, Source is now part of "
                      "unknown component"))
                self.spec.source.partOf = 'unknown'
                return
            path = util.join_path(self.pkg_work_dir(), 'component.xml')
        else:
            if not os.path.exists(url):
                ctx.ui.warning(
                    _("Cannot find component.xml in upper "
                      "directory, Source is now part of "
                      "unknown component"))
                self.spec.source.partOf = 'unknown'
                return
            path = url
        comp = component.CompatComponent()
        comp.read(path)
        self.spec.source.partOf = comp.name
Example #26
0
def dobin(sourceFile, destinationDirectory='/usr/bin'):
    '''insert a executable file into /bin or /usr/bin'''
    ''' example call: pisitools.dobin("bin/xloadimage", "/bin", "xload") '''
    ctx.ui.debug(
        "%s -> %s" %
        (join_path(get.installDIR(), destinationDirectory), sourceFile))
    executable_insinto(join_path(get.installDIR(), destinationDirectory),
                       sourceFile)
Example #27
0
 def fetch_comarfiles(self):
     for package in self.spec.packages:
         for pcomar in package.providesComar:
             comaruri = util.join_path(self.specdiruri, ctx.const.comar_dir,
                                       pcomar.script)
             self.download(
                 comaruri, util.join_path(self.specdir,
                                          ctx.const.comar_dir))
Example #28
0
def dolib_so(sourceFile, destinationDirectory="/usr/lib"):
    """insert the dynamic library into /usr/lib with permission 0755"""

    """example call: pisitools.dolib_so("pppd/plugins/minconn.so")"""
    sourceFile = join_path(os.getcwd(), sourceFile)
    destinationDirectory = join_path(get.installDIR(), destinationDirectory)

    lib_insinto(sourceFile, destinationDirectory, 0755)
Example #29
0
def dodoc(*sourceFiles):
    '''inserts the files in the list of files into /usr/share/doc/PACKAGE'''
    ctx.ui.debug("%s -> %s" %
                 (str(sourceFiles),
                  join_path(get.installDIR(), '/usr/share/doc', get.srcTAG())))
    readable_insinto(
        join_path(get.installDIR(), '/usr/share/doc', get.srcTAG()),
        *sourceFiles)
Example #30
0
 def fetch_patches(self):
     for patch in self.spec.source.patches:
         dir_name = os.path.dirname(patch.filename)
         patchuri = util.join_path(self.specdiruri, ctx.const.files_dir,
                                   patch.filename)
         self.download(
             patchuri,
             util.join_path(self.specdir, ctx.const.files_dir, dir_name))
Example #31
0
def dolib(sourceFile, destinationDirectory='/usr/lib'):
    '''insert the library into /usr/lib'''
    '''example call: pisitools.dolib_a("libz.a")'''
    '''example call: pisitools.dolib_a("libz.so")'''
    sourceFile = join_path(os.getcwd(), sourceFile)
    destinationDirectory = join_path(get.installDIR(), destinationDirectory)

    lib_insinto(sourceFile, destinationDirectory, 755)
Example #32
0
def dolib_so(sourceFile, destinationDirectory = '/usr/lib'):
    '''insert the static library into /usr/lib with permission 0755'''

    '''example call: pisitools.dolib_so("pppd/plugins/minconn.so")'''
    sourceFile = join_path(os.getcwd(), sourceFile)
    destinationDirectory = join_path(get.installDIR(), destinationDirectory)

    lib_insinto(sourceFile, destinationDirectory, 755)
Example #33
0
    def patch_exists(self):
        """check existence of patch files declared in PSPEC"""

        files_dir = os.path.abspath(util.join_path(self.pspecDir, ctx.const.files_dir))
        for patch in self.spec.source.patches:
            patchFile = util.join_path(files_dir, patch.filename)
            if not os.access(patchFile, os.F_OK):
                raise Error(_("Patch file is missing: %s\n") % patch.filename)
Example #34
0
def dolib_a(sourceFile, destinationDirectory = '/usr/lib'):
    '''insert the static library into /usr/lib with permission 0644'''

    '''example call: pisitools.dolib_a("staticlib/libvga.a")'''
    sourceFile = join_path(os.getcwd(), sourceFile)
    destinationDirectory = join_path(get.installDIR(), destinationDirectory)

    lib_insinto(sourceFile, destinationDirectory, 644)
Example #35
0
    def gen_files_xml(self, package):
        """Generates files.xml using the path definitions in specfile and
        the files produced by the build system."""

        if package.debug_package:
            install_dir = self.pkg_debug_dir()
        else:
            install_dir = self.pkg_install_dir()

        # FIXME: We need to expand globs before trying to calculate hashes
        # Not on the fly like now.

        # we'll exclude collisions in get_file_hashes. Having a
        # collisions list is not wrong, we must just handle it :).
        collisions = check_path_collision(package, self.spec.packages)
        # FIXME: material collisions after expanding globs could be
        # reported as errors

        # Use a dict to avoid duplicate entries in files.xml.
        d = {}

        def add_path(path):
            # add the files under material path
            for fpath, fhash in util.get_file_hashes(path, collisions, install_dir):
                if ctx.get_option('create_static') \
                    and fpath.endswith(ctx.const.ar_file_suffix) \
                    and not package.name.endswith(ctx.const.static_name_suffix) \
                    and util.is_ar_file(fpath):
                    # if this is an ar file, and this package is not a static package,
                    # don't include this file into the package.
                    continue
                frpath = util.removepathprefix(install_dir, fpath)  # relative path
                ftype, permanent = get_file_type(frpath, package.files)
                fsize = long(util.dir_size(fpath))
                if not os.path.islink(fpath):
                    st = os.stat(fpath)
                else:
                    st = os.lstat(fpath)

                d[frpath] = pisi.files.FileInfo(path=frpath, type=ftype, permanent=permanent,
                                     size=fsize, hash=fhash, uid=str(st.st_uid), gid=str(st.st_gid),
                                     mode=oct(stat.S_IMODE(st.st_mode)))

                if stat.S_IMODE(st.st_mode) & stat.S_ISUID:
                    ctx.ui.warning(_("/%s has suid bit set") % frpath)

        for pinfo in package.files:
            wildcard_path = util.join_path(install_dir, pinfo.path)
            for path in glob.glob(wildcard_path):
                add_path(path)

        files = pisi.files.Files()
        for fileinfo in d.itervalues():
            files.append(fileinfo)

        files_xml_path = util.join_path(self.pkg_dir(), ctx.const.files_xml)
        files.write(files_xml_path)
        self.files = files
Example #36
0
def postInstall(fromVersion, fromRelease, toVersion, toRelease):
    for executable in executables:
        try:
            os.system('update-alternatives --install %s %s %s 2' %
                      (join_path(bin_dir, executable), executable,
                       join_path(jvm_dir, 'bin', executable)))
            os.system('update-alternatives --auto %s' % executable)
        except:
            pass
Example #37
0
 def fetch_patches(self):
     for patch in self.spec.source.patches:
         dir_name = os.path.dirname(patch.filename)
         patchuri = util.join_path(self.specdiruri,
                                   ctx.const.files_dir,
                                   patch.filename)
         self.download(patchuri, util.join_path(self.destdir,
                                                ctx.const.files_dir,
                                                dir_name))
Example #38
0
    def patch_exists(self):
        """check existence of patch files declared in PSPEC"""

        files_dir = os.path.abspath(
            util.join_path(self.specdir, ctx.const.files_dir))
        for patch in self.spec.source.patches:
            patchFile = util.join_path(files_dir, patch.filename)
            if not os.access(patchFile, os.F_OK):
                raise Error(_("Patch file is missing: %s\n") % patch.filename)
Example #39
0
def dolib(sourceFile, destinationDirectory = '/usr/lib'):
    '''insert the library into /usr/lib'''

    '''example call: pisitools.dolib_a("libz.a")'''
    '''example call: pisitools.dolib_a("libz.so")'''
    sourceFile = join_path(os.getcwd(), sourceFile)
    destinationDirectory = join_path(get.installDIR(), destinationDirectory)

    lib_insinto(sourceFile, destinationDirectory, 755)
Example #40
0
def dosym(sourceFile, destinationFile):
    '''creates soft link between sourceFile and destinationFile'''
    ''' example call: pisitools.dosym("/usr/bin/bash", "/bin/bash")'''
    makedirs(join_path(get.installDIR(), os.path.dirname(destinationFile)))

    try:
        os.symlink(sourceFile, join_path(get.installDIR(), destinationFile))
    except OSError:
        error(_('ActionsAPI [dosym]: File exists: %s') % (sourceFile))
Example #41
0
def dolib(sourceFile, destinationDirectory="/usr/lib"):
    """insert the library into /usr/lib"""

    """example call: pisitools.dolib("libz.a")"""
    """example call: pisitools.dolib("libz.so")"""
    sourceFile = join_path(os.getcwd(), sourceFile)
    destinationDirectory = join_path(get.installDIR(), destinationDirectory)

    lib_insinto(sourceFile, destinationDirectory, 0755)
Example #42
0
def install(parameters = ''):
    installdir = join_path(get.installDIR(), get_rubygemdir())
    bindir = join_path(get.installDIR(), "/usr/bin")
    source = "%s-%s" %(get.srcNAME()[8:], get.srcVERSION())
    sourcedir = join_path(get.workDIR(), source)

    if system("gem install -E --local --install-dir %s  --bindir %s --force %s" % (installdir, bindir, sourcedir)):
        raise InstallError, _('Install failed.')

    remove_cachedir()
Example #43
0
def insinto(destinationDirectory, sourceFile,  destinationFile = '', sym = True):
    '''insert a sourceFile into destinationDirectory as a destinationFile with same uid/guid/permissions'''
    makedirs(join_path(get.installDIR(), destinationDirectory))

    if not destinationFile:
        for filePath in glob.glob(sourceFile):
            if can_access_file(filePath):
                copy(filePath, join_path(get.installDIR(), join_path(destinationDirectory, os.path.basename(filePath))), sym)
    else:
        copy(sourceFile, join_path(get.installDIR(), join_path(destinationDirectory, destinationFile)), sym)
Example #44
0
def dosym(sourceFile, destinationFile):
    '''creates soft link between sourceFile and destinationFile'''

    ''' example call: pisitools.dosym("/usr/bin/bash", "/bin/bash")'''
    makedirs(join_path(get.installDIR(), os.path.dirname(destinationFile)))

    try:
        os.symlink(sourceFile, join_path(get.installDIR() ,destinationFile))
    except OSError:
        error(_('ActionsAPI [dosym]: File exists: %s') % (sourceFile))
Example #45
0
    def check_patches(self):
        """check existence of patch files and their sizes."""

        files_dir = os.path.abspath(util.join_path(self.specdir, ctx.const.files_dir))
        for patch in self.spec.source.patches:
            patchFile = util.join_path(files_dir, patch.filename)
            if not os.access(patchFile, os.F_OK):
                raise Error(_("Patch file is missing: %s\n") % patch.filename)
            if os.stat(patchFile).st_size == 0:
                ctx.ui.warning(_("Patch file is empty: %s") % patch.filename)
Example #46
0
 def fetch_additionalFiles(self):
     for pkg in self.spec.packages + [self.spec.source]:
         for afile in pkg.additionalFiles:
             file_name = os.path.basename(afile.filename)
             dir_name = os.path.dirname(afile.filename)
             afileuri = util.join_path(self.specdiruri, ctx.const.files_dir,
                                       dir_name, file_name)
             self.download(
                 afileuri,
                 util.join_path(self.specdir, ctx.const.files_dir,
                                dir_name))
Example #47
0
def install():
    pisitools.dodir("/usr/share/themes/Arc")
    pisitools.dodir("/usr/share/themes/Arc-Solid")
    pisitools.dodir("/usr/share/themes/Arc-Dark")
    pisitools.dodir("/usr/share/themes/Arc-Dark-Solid")

    for sub_theme in ["gtk-2.0", "gtk-3.0", "metacity-1", "xfwm4", "cinnamon", "gnome-shell", "unity"]:
        pisitools.insinto("/usr/share/themes/Arc", join_path(ARC_DIR, sub_theme))
        pisitools.insinto("/usr/share/themes/Arc-Solid", join_path(ARC_SOLID_DIR, sub_theme))
        pisitools.insinto("/usr/share/themes/Arc-Dark", join_path(ARC_DARK_DIR, sub_theme))
        pisitools.insinto("/usr/share/themes/Arc-Dark-Solid", join_path(ARC_DARK_SOLID_DIR, sub_theme))
Example #48
0
    def check_patches(self):
        """check existence of patch files and their sizes."""

        files_dir = os.path.abspath(
            util.join_path(self.specdir, ctx.const.files_dir))
        for patch in self.spec.source.patches:
            patchFile = util.join_path(files_dir, patch.filename)
            if not os.access(patchFile, os.F_OK):
                raise Error(_("Patch file is missing: %s\n") % patch.filename)
            if os.stat(patchFile).st_size == 0:
                ctx.ui.warning(_('Patch file is empty: %s') % patch.filename)
Example #49
0
    def gen_files_xml(self, package):
        """Generates files.xml using the path definitions in specfile and
        the files produced by the build system."""
        files = Files()

        if package.debug_package:
            install_dir = self.pkg_debug_dir()
        else:
            install_dir = self.pkg_install_dir()

        # FIXME: We need to expand globs before trying to calculate hashes
        # Not on the fly like now.

        # we'll exclude collisions in get_file_hashes. Having a
        # collisions list is not wrong, we must just handle it :).
        collisions = check_path_collision(package, self.spec.packages)
        # FIXME: material collisions after expanding globs could be
        # reported as errors

        d = {}

        def add_path(path):
            # add the files under material path
            for fpath, fhash in util.get_file_hashes(path, collisions,
                                                     install_dir):
                if ctx.get_option('create_static') \
                    and fpath.endswith(ctx.const.ar_file_suffix) \
                    and not package.name.endswith(ctx.const.static_name_suffix) \
                    and util.is_ar_file(fpath):
                    # if this is an ar file, and this package is not a static package,
                    # don't include this file into the package.
                    continue
                frpath = util.removepathprefix(install_dir,
                                               fpath)  # relative path
                ftype, permanent = get_file_type(frpath, package.files,
                                                 install_dir)
                fsize = long(util.dir_size(fpath))
                d[frpath] = FileInfo(path=frpath,
                                     type=ftype,
                                     permanent=permanent,
                                     size=fsize,
                                     hash=fhash)

        for pinfo in package.files:
            wildcard_path = util.join_path(install_dir, pinfo.path)
            for path in glob.glob(wildcard_path):
                add_path(path)

        for (p, fileinfo) in d.iteritems():
            files.append(fileinfo)

        files_xml_path = util.join_path(self.pkg_dir(), ctx.const.files_xml)
        files.write(files_xml_path)
        self.files = files
Example #50
0
    def apply_patches(self):
        files_dir = os.path.abspath(util.join_path(self.pspecDir, ctx.const.files_dir))

        for patch in self.spec.source.patches:
            patchFile = util.join_path(files_dir, patch.filename)
            if patch.compressionType:
                patchFile = util.uncompress(
                    patchFile, compressType=patch.compressionType, targetDir=ctx.config.tmp_dir()
                )

            ctx.ui.action(_("* Applying patch: %s") % patch.filename)
            util.do_patch(self.srcDir, patchFile, level=patch.level, target=patch.target)
Example #51
0
def rename(sourceFile, destinationFile):
    ''' renames sourceFile as destinationFile'''

    ''' example call: pisitools.rename("/usr/bin/bash", "bash.old") '''
    ''' the result of the previous example would be "/usr/bin/bash.old" '''

    baseDir = os.path.dirname(sourceFile)

    try:
        os.rename(join_path(get.installDIR(), sourceFile), join_path(get.installDIR(), baseDir, destinationFile))
    except OSError:
        error(_('ActionsAPI [rename]: No such file or directory: %s') % (sourceFile))
Example #52
0
def install(parameters=''):
    installdir = join_path(get.installDIR(), get_rubygemdir())
    bindir = join_path(get.installDIR(), "/usr/bin")
    source = "%s-%s" % (get.srcNAME()[8:], get.srcVERSION())
    sourcedir = join_path(get.workDIR(), source)

    if system(
            "gem install -E --local --install-dir %s  --bindir %s --force %s" %
        (installdir, bindir, sourcedir)):
        raise InstallError, _('Install failed.')

    remove_cachedir()
Example #53
0
def rename(sourceFile, destinationFile):
    """ renames sourceFile as destinationFile"""

    """ example call: pisitools.rename("/usr/bin/bash", "bash.old") """
    """ the result of the previous example would be "/usr/bin/bash.old" """

    baseDir = os.path.dirname(sourceFile)

    try:
        os.rename(join_path(get.installDIR(), sourceFile), join_path(get.installDIR(), baseDir, destinationFile))
    except OSError, e:
        error(_("ActionsAPI [rename]: %s: %s") % (e, sourceFile))
Example #54
0
def rename(sourceFile, destinationFile):
    ''' renames sourceFile as destinationFile'''
    ''' example call: pisitools.rename("/usr/bin/bash", "bash.old") '''
    ''' the result of the previous example would be "/usr/bin/bash.old" '''

    baseDir = os.path.dirname(sourceFile)

    try:
        os.rename(join_path(get.installDIR(), sourceFile),
                  join_path(get.installDIR(), baseDir, destinationFile))
    except OSError, e:
        error(_('ActionsAPI [rename]: %s: %s') % (e, sourceFile))
Example #55
0
def insinto(destinationDirectory, sourceFile,  destinationFile = '', sym = True):
    '''insert a sourceFile into destinationDirectory as a destinationFile with same uid/guid/permissions'''
    makedirs(join_path(get.installDIR(), destinationDirectory))

    if not destinationFile:
        sourceFileGlob = glob.glob(sourceFile)
        if len(sourceFileGlob) == 0:
            raise FileError(_("No file matched pattern \"%s\".") % sourceFile)

        for filePath in sourceFileGlob:
            if can_access_file(filePath):
                copy(filePath, join_path(get.installDIR(), join_path(destinationDirectory, os.path.basename(filePath))), sym)
    else:
        copy(sourceFile, join_path(get.installDIR(), join_path(destinationDirectory, destinationFile)), sym)
Example #56
0
def installLib(src='*.jar', dest='/usr/share/java'):
    '''install compilation output that is mix of the utility classes as
    in jars or meta/data files to specified locations.

    src:    Source file pattern to be installed
    dest:   Destination dir where the source files to be installed
    '''

    classpath = []

    destination = util.join_path(get.installDIR(), dest)
    sources = glob(src)

    # If no source matched, then no need to create destination dir
    if not sources:
        raise InstallError(_('No any file/directory matched '
                             'to regex expression "%s".' % src))

    if not os.access(destination, os.F_OK):
        os.makedirs(destination)

    for source in sources:
        if os.path.isfile(source):
            try:
                copy(source, destination)
            except IOError:
                raise InstallError(_('Installing file "%s" '
                                     'failed.' % source))
            if source.endswith('.jar'):
                classpath.append(util.join_path('/',
                                                dest,
                                                source.split('/')[-1]))
        elif os.path.isdir(source):
            target = util.join_path(destination, source.split('/')[-1])
            try:
                copytree(source, target)
            except IOError:
                raise InstallError(_('Installing directory "%s" '
                                     'failed.' % source))
            for root, dirs, files in os.walk(target):
                for f in files:
                    if f.endswith('.jar'):
                        # Exclude sandbox dir from jar path
                        jar = util.remove_prefix(get.installDIR(),
                                                 util.join_path(root, f))
                        classpath.append(jar)

    if classpath:
        _generate_classpath_file(classpath)
Example #57
0
def configure_pending():
    # start with pending packages
    # configure them in reverse topological order of dependency
    A = ctx.installdb.list_pending()
    G_f = pgraph.PGraph(ctx.packagedb,
                        pisi.itembyrepodb.installed)  # construct G_f
    for x in A.keys():
        G_f.add_package(x)
    B = A
    while len(B) > 0:
        Bp = set()
        for x in B.keys():
            pkg = ctx.packagedb.get_package(x, pisi.itembyrepodb.installed)
            for dep in pkg.runtimeDependencies():
                if dep.package in G_f.vertices():
                    G_f.add_dep(x, dep)
        B = Bp
    if ctx.get_option('debug'):
        G_f.write_graphviz(sys.stdout)
    order = G_f.topological_sort()
    order.reverse()
    try:
        import pisi.comariface as comariface
        for x in order:
            if ctx.installdb.is_installed(x):
                pkginfo = A[x]
                pkgname = util.package_name(x, pkginfo.version,
                                            pkginfo.release, False, False)
                pkg_path = util.join_path(ctx.config.lib_dir(), 'package',
                                          pkgname)
                m = MetaData()
                metadata_path = util.join_path(pkg_path,
                                               ctx.const.metadata_xml)
                m.read(metadata_path)
                # FIXME: we need a full package info here!
                pkginfo.name = x
                ctx.ui.notify(pisi.ui.configuring, package=pkginfo, files=None)
                pisi.comariface.post_install(
                    pkginfo.name,
                    m.package.providesComar,
                    util.join_path(pkg_path, ctx.const.comar_dir),
                    util.join_path(pkg_path, ctx.const.metadata_xml),
                    util.join_path(pkg_path, ctx.const.files_xml),
                )
                ctx.ui.notify(pisi.ui.configured, package=pkginfo, files=None)
            ctx.installdb.clear_pending(x)
    except ImportError:
        raise Error(_("comar package is not fully installed"))
Example #58
0
def copy(source, destination, sym=True):
    '''recursively copy a "source" file or directory to "destination"'''
    for filePath in glob.glob(source):
        if isFile(filePath) and not isLink(filePath):
            try:
                shutil.copy(filePath, destination)
            except IOError:
                error(
                    _('ActionsAPI [copy]: Permission denied: %s to %s') %
                    (filePath, destination))
        elif isLink(filePath) and sym:
            if isDirectory(destination):
                os.symlink(os.readlink(filePath),
                           join_path(destination, os.path.basename(filePath)))
            else:
                if isFile(destination):
                    os.remove(destination)
                os.symlink(os.readlink(filePath), destination)
        elif isLink(filePath) and not sym:
            if isDirectory(filePath):
                copytree(filePath, destination)
            else:
                shutil.copy(filePath, destination)
        elif isDirectory(filePath):
            copytree(filePath, destination, sym)
        else:
            error(_('ActionsAPI [copy]: File %s does not exist.') % filePath)
Example #59
0
def getPackages(pspecList):
    packages = []
    for pspec in pspecList:
        specFile = SpecFile(join_path(pspec, "pspec.xml"))
        for p in specFile.packages:
            packages += [p.name]
    return packages