Example #1
0
    def run_unpack(self):
        '''Unpack source into <source_dir>.  Source is taken from
        <source_package> which may be a zip or tar file (with various
        compression methods supported) or a git directory.  If it is a
        git directory the <source_tag> is used to determine what is
        checked out into <source_dir>.  If <unpacked_dir> or
        <unpacked_reldir> (relative to <source_dir>) are defined they
        will be used as indication that the unpacking has already been
        done.
        '''
        dldir = self.vars.get('download_dir')
        src = self.vars.get('source_package')
        if not src.startswith('/'):
            src = os.path.join(dldir, src)
        dst = self.vars.get('source_dir')
        if not (src and dst):
            raise ValueError, 'Need both a source_package (got: "%s") and a source_dir (got: "%s" for unpacking' % (src,dst)

        creates = self.vars.get('unpacked_dir')
        if not creates:
            creates = self.vars.get('unpacked_reldir')
            if creates:
                creates = os.path.join(dst, creates)
        dst,creates = os.path.split(creates)

        logging.debug('builtin unpack: src:%s dst:%s creates:%s' % (src,dst,creates))

        isgit = git_repo(src)
        if isgit:
            tag = self.vars.get('source_tag','HEAD')
            return unpack.ungit(isgit, dst, creates, tag)
        if src.endswith('.zip'):
            return unpack.unzip(src, dst, creates)
        return unpack.untar(src, dst, creates)
Example #2
0
# add the handlers to logger
logger.addHandler(ch)
logger.addHandler(fh)

#logging.basicConfig(filename=os.path.join(logdir,os.path.basename(args.logfile)))

#logging.basicConfig(level=loglevel)

s = StringIO.StringIO()
pprint.pprint(args, s)

logger.info("lanciato con---->" + s.getvalue())
logger.info("root_dir-->" + root_dir + "<--")

dev_git = util.git_repo(dest, logger=logger, dry_run=args.dry_run)

if not os.path.exists(dest):
    logger.info("MISSING destintion_dir-->" + dest + "<-- ")
    os.makedirs(dest)

    origin_branches = util.get_branches(args.origin,
                                        branch_selection=args.branches)

    dev_git.init()

    dev_git.get_remotes()
    dev_git.add_remote(args.origin,
                       name='origin',
                       fetch_branches=origin_branches)
    dev_git.add_remote(args.upstream, name='upstream')
#logging.basicConfig(level=loglevel)




s = StringIO.StringIO()
pprint.pprint(args, s)

logger.info("lanciato con---->"+s.getvalue())
logger.info("root_dir-->"+root_dir+"<--")




dev_git = util.git_repo(dest,logger = logger,dry_run=args.dry_run)

if not os.path.exists(dest):
    logger.info("MISSING destintion_dir-->"+dest+"<-- ")
    os.makedirs(dest)

    origin_branches = util.get_branches(args.origin, branch_selection=args.branches)

    dev_git.init()

    dev_git.get_remotes()
    dev_git.add_remote(args.origin, name='origin', fetch_branches=origin_branches)
    dev_git.add_remote(args.upstream, name='upstream')

    upstream_branches = util.get_branches(
        args.upstream,