Пример #1
0
    def create_new_links(self, project, pkgname, oldspeclist):
        filelist = self.api.get_filelist_for_package(pkgname=pkgname,
                                                     project=project,
                                                     extension='spec')
        removedspecs = set(oldspeclist) - set(filelist)
        for spec in removedspecs:
            # Deleting all the packages that no longer have a .spec file
            url = self.api.makeurl(['source', project, spec[:-5]])
            print("Deleting package %s from project %s" % (spec[:-5], project))
            try:
                http_DELETE(url)
            except HTTPError as err:
                if err.code == 404:
                    # the package link was not yet created, which was likely a mistake from earlier
                    pass
                else:
                    # If the package was there bug could not be delete, raise the error
                    raise

            # Remove package from Rings in case 2nd specfile was removed
            if self.api.ring_packages.get(spec[:-5]):
                delete_package(self.api.apiurl,
                               self.api.ring_packages.get(spec[:-5]),
                               spec[:-5],
                               force=True,
                               msg="Cleanup package in Rings")

        if len(filelist) > 1:
            # There is more than one .spec file in the package; link package containers as needed
            origmeta = source_file_load(self.api.apiurl, project, pkgname,
                                        '_meta')
            for specfile in filelist:
                package = specfile[:
                                   -5]  # stripping .spec off the filename gives the packagename
                if package == pkgname:
                    # This is the original package and does not need to be linked to itself
                    continue
                # Check if the target package already exists, if it does not, we get a HTTP error 404 to catch
                if not self.api.item_exists(project, package):
                    print("Creating new package %s linked to %s" %
                          (package, pkgname))
                    # new package does not exist. Let's link it with new metadata
                    newmeta = re.sub(r'(<package.*name=.){}'.format(pkgname),
                                     r'\1{}'.format(package), origmeta)
                    newmeta = re.sub(r'<devel.*>',
                                     r'<devel package="{}"/>'.format(pkgname),
                                     newmeta)
                    newmeta = re.sub(r'<bcntsynctag>.*</bcntsynctag>', r'',
                                     newmeta)
                    newmeta = re.sub(
                        r'</package>',
                        r'<bcntsynctag>{}</bcntsynctag></package>'.format(
                            pkgname), newmeta)
                    source_file_save(self.api.apiurl, project, package,
                                     '_meta', newmeta)
                    link = "<link package=\"{}\" cicount=\"copy\" />".format(
                        pkgname)
                    source_file_save(self.api.apiurl, project, package,
                                     '_link', link)
        return True
Пример #2
0
    def create_new_links(self, project, pkgname, oldspeclist):
        filelist = self.api.get_filelist_for_package(pkgname=pkgname, project=project, extension='spec')
        removedspecs = set(oldspeclist) - set(filelist)
        for spec in removedspecs:
            # Deleting all the packages that no longer have a .spec file
            url = self.api.makeurl(['source', project, spec[:-5]])
            print("Deleting package %s from project %s" % (spec[:-5], project))
            try:
                http_DELETE(url)
            except HTTPError as err:
                if err.code == 404:
                    # the package link was not yet created, which was likely a mistake from earlier
                    pass
                else:
                    # If the package was there bug could not be delete, raise the error
                    raise

            # Remove package from Rings in case 2nd specfile was removed
            if self.api.ring_packages.get(spec[:-5]):
                delete_package(self.api.apiurl, self.api.ring_packages.get(spec[:-5]), spec[:-5], force=True, msg="Cleanup package in Rings")

        if len(filelist) > 1:
            # There is more than one .spec file in the package; link package containers as needed
            origmeta = source_file_load(self.api.apiurl, project, pkgname, '_meta')
            for specfile in filelist:
                package = specfile[:-5]  # stripping .spec off the filename gives the packagename
                if package == pkgname:
                    # This is the original package and does not need to be linked to itself
                    continue
                # Check if the target package already exists, if it does not, we get a HTTP error 404 to catch
                if not self.api.item_exists(project, package):
                    print("Creating new package %s linked to %s" % (package, pkgname))
                    # new package does not exist. Let's link it with new metadata
                    newmeta = re.sub(r'(<package.*name=.){}'.format(pkgname),
                                     r'\1{}'.format(package),
                                     origmeta)
                    newmeta = re.sub(r'<devel.*>',
                                     r'<devel package="{}"/>'.format(pkgname),
                                     newmeta)
                    newmeta = re.sub(r'<bcntsynctag>.*</bcntsynctag>',
                                     r'',
                                     newmeta)
                    newmeta = re.sub(r'</package>',
                                     r'<bcntsynctag>{}</bcntsynctag></package>'.format(pkgname),
                                     newmeta)
                    source_file_save(self.api.apiurl, project, package, '_meta', newmeta)
                    link = "<link package=\"{}\" cicount=\"copy\" />".format(pkgname)
                    source_file_save(self.api.apiurl, project, package, '_link', link)
        return True
Пример #3
0
 def create_new_links(self, project, pkgname, oldspeclist):
     filelist = self.api.get_filelist_for_package(pkgname=pkgname, project=project, extension='spec')
     removedspecs = set(oldspeclist) - set(filelist)
     for spec in removedspecs:
         # Deleting all the packages that no longer have a .spec file
         url = self.api.makeurl(['source', project, spec[:-5]])
         print "Deleting package %s from project %s" % (spec[:-5], project)
         try:
             http_DELETE(url)
         except urllib2.HTTPError, err:
             if err.code == 404:
                 # the package link was not yet created, which was likely a mistake from earlier
                 pass
             else:
                 # If the package was there bug could not be delete, raise the error
                 raise
Пример #4
0
 def create_new_links(self, project, pkgname, oldspeclist):
     filelist = self.api.get_filelist_for_package(pkgname=pkgname, project=project, extension='spec')
     removedspecs = set(oldspeclist) - set(filelist)
     for spec in removedspecs:
         # Deleting all the packages that no longer have a .spec file
         url = self.api.makeurl(['source', project, spec[:-5]])
         print "Deleting package %s from project %s" % (spec[:-5], project)
         try:
             http_DELETE(url)
         except urllib2.HTTPError, err:
             if err.code == 404:
                 # the package link was not yet created, which was likely a mistake from earlier
                 pass
             else:
                 # If the package was there bug could not be delete, raise the error
                 raise
Пример #5
0
    def remove_link_if_shadow_devel(self, request):
        """If the request is a shadow_devel (the reference is to a request
        that is a link from the product to Factory), remove the link
        to transform it as a normal request.

        """
        if request.is_shadow_devel:
            url = makeurl(self.apiurl, ('source', request.shadow_src_project, request.src_package))
            if self.readonly:
                print 'DRY RUN: DELETE %s' % url
            else:
                http_DELETE(url)
            for sub_prj, sub_pkg in self.staging.get_sub_packages(request.src_package,
                                                                  request.shadow_src_project):
                url = makeurl(self.apiurl, ('source', sub_prj, sub_pkg))
                if self.readonly:
                    print 'DRY RUN: DELETE %s' % url
                else:
                    http_DELETE(url)
Пример #6
0
    def remove_link_if_shadow_devel(self, request):
        """If the request is a shadow_devel (the reference is to a request
        that is a link from the product to Factory), remove the link
        to transform it as a normal request.

        """
        if request.is_shadow_devel:
            url = makeurl(self.apiurl, ('source', request.shadow_src_project, request.src_package))
            if self.readonly:
                print 'DRY RUN: DELETE %s' % url
            else:
                http_DELETE(url)
            for sub_prj, sub_pkg in self.staging.get_sub_packages(request.src_package,
                                                                  request.shadow_src_project):
                url = makeurl(self.apiurl, ('source', sub_prj, sub_pkg))
                if self.readonly:
                    print 'DRY RUN: DELETE %s' % url
                else:
                    http_DELETE(url)
Пример #7
0
 def delete(self, comment_id):
     """Remove a comment object.
     :param comment_id: Id of the comment object.
     """
     url = makeurl(self.apiurl, ['comment', comment_id])
     return http_DELETE(url)
Пример #8
0
 def delete(self, comment_id):
     """Remove a comment object.
     :param comment_id: Id of the comment object.
     """
     url = makeurl(self.apiurl, ['comment', comment_id])
     return http_DELETE(url)
Пример #9
0
def attribute_value_delete(apiurl, project, name, namespace='OSRT', package=None):
    http_DELETE(makeurl(
        apiurl, list(filter(None, ['source', project, package, '_attribute', namespace + ':' + name]))))