Пример #1
0
    def _prepare_pristine_tar(self):
        """
        Prepare the upstream source for pristine tar import.

        This checks if the upstream source is actually a tarball
        and creates a symlink from I{archive}
        to I{<pkg>_<version>.orig.tar.<ext>} so pristine-tar will
        see the correct basename.
        """
        if os.path.isdir(self._source.path):
            return

        ext = os.path.splitext(self._source.path)[1]
        if ext in ['.tgz', '.tbz2', '.tlz', '.txz' ]:
            ext = ".%s" % ext[2:]

        if not self.component:
            link = "../%s_%s.orig.tar%s" % (self.name, self.version, ext)
        else:
            link = "../%s_%s.orig-%s.tar%s" % ( self.name, self.version, self.component, ext)

        if os.path.basename(self._source.path) != os.path.basename(link):
            try:
                if not is_link_target(self._source.path, link):
                    os.symlink(os.path.abspath(self._source.path), link)
                    self._linked = True
            except OSError as err:
                    raise GbpError("Cannot symlink '%s' to '%s': %s" % (self._source.path, link, err[1]))
            self._pristine_orig = link
        else:
            self._pristine_orig = self._source.path
Пример #2
0
def maybe_link(orig, link):
    """
    Create a symlink named link pointing to orig if
    that is not the case already.
    """
    if is_link_target(orig, link):
        return False

    if os.path.exists(link):
        backup = "%s.%d" % (link, time.time())
        gbp.log.info("%s already exists, moving to %s" % (link, backup))
        shutil.move(link, backup)
    os.symlink(os.path.abspath(orig), link)
    return True
Пример #3
0
def prepare_pristine_tar(archive, pkg, version):
    """
    Prepare the upstream source for pristine tar import.

    This checks if the upstream source is actually a tarball
    and creates a symlink from I{archive}
    to I{<pkg>_<version>.orig.tar.<ext>} so pristine-tar will
    see the correct basename.

    @param archive: the upstream source's name
    @type archive: C{str}
    @param pkg: the source package's name
    @type pkg: C{str}
    @param version: the upstream version number
    @type version: C{str}
    @rtype: C{str}
    """
    linked = False
    if os.path.isdir(archive):
        return None

    ext = os.path.splitext(archive)[1]
    if ext in ['.tgz', '.tbz2', '.tlz', '.txz']:
        ext = ".%s" % ext[2:]

    link = "../%s_%s.orig.tar%s" % (pkg, version, ext)

    if os.path.basename(archive) != os.path.basename(link):
        try:
            if not is_link_target(archive, link):
                if os.path.exists(link):
                    backup = "%s.%d" % (link, time.time())
                    gbp.log.info("%s already exists, moving to %s" %
                                 (link, backup))
                    shutil.move(link, backup)
                os.symlink(os.path.abspath(archive), link)
                linked = True
        except OSError as err:
            raise GbpError("Cannot symlink '%s' to '%s': %s" %
                           (archive, link, err[1]))
        return (link, linked)
    else:
        return (archive, linked)
Пример #4
0
def prepare_pristine_tar(archive, pkg, version):
    """
    Prepare the upstream source for pristine tar import.

    This checks if the upstream source is actually a tarball
    and creates a symlink from I{archive}
    to I{<pkg>_<version>.orig.tar.<ext>} so pristine-tar will
    see the correct basename.

    @param archive: the upstream source's name
    @type archive: C{str}
    @param pkg: the source package's name
    @type pkg: C{str}
    @param version: the upstream version number
    @type version: C{str}
    @rtype: C{str}
    """
    linked = False
    if os.path.isdir(archive):
        return None, None

    ext = os.path.splitext(archive)[1]
    if ext in ['.tgz', '.tbz2', '.tlz', '.txz']:
        ext = ".%s" % ext[2:]

    link = "../%s_%s.orig.tar%s" % (pkg, version, ext)

    if os.path.basename(archive) != os.path.basename(link):
        try:
            if not is_link_target(archive, link):
                if os.path.exists(link):
                    backup = "%s.%d" % (link, time.time())
                    gbp.log.info("%s already exists, moving to %s" % (link, backup))
                    shutil.move(link, backup)
                os.symlink(os.path.abspath(archive), link)
                linked = True
        except OSError as err:
                raise GbpError("Cannot symlink '%s' to '%s': %s" % (archive, link, err[1]))
        return (link, linked)
    else:
        return (archive, linked)
Пример #5
0
def symlink_orig(archive, pkg, version):
    """
    Create a symlink from I{archive} ti I{<pkg>_<version>.orig.tar.<ext>} so
    pristine-tar will see the correct basename.

    @return: archive path to be used by pristine tar
    @rtype: C{str}
    """
    if os.path.isdir(archive):
        return None
    ext = os.path.splitext(archive)[1]
    if ext in ['.tgz', '.tbz2', '.tlz', '.txz' ]:
        ext = ".%s" % ext[2:]

    link = "../%s_%s.orig.tar%s" % (pkg, version, ext)
    if os.path.basename(archive) != os.path.basename(link):
        try:
            if not is_link_target(archive, link):
                os.symlink(os.path.abspath(archive), link)
        except OSError as err:
                raise GbpError("Cannot symlink '%s' to '%s': %s" % (archive, link, err[1]))
        return link
    else:
        return archive