Beispiel #1
0
 def manual_sync(self, target):
     process = subprocess.Popen([
         self.command(), 'rev-parse', '--abbrev-ref',
         '--symbolic-full-name', '@{upstream}'
     ],
                                cwd=target,
                                stdout=subprocess.PIPE)
     try:
         revision = process.communicate()[0]
     except Exception as err:
         sys.stderr.write("git rev-parse failed\n")
         return 1
     revision = revision.decode('utf-8')
     revision = revision.rstrip()
     if revision == '':
         sys.stderr.write("git rev-parse failed to return revision\n")
         return 1
     run_command(self.config,
                 self.command(),
                 ['update-index', '--refresh', '-q', '--unmerged'],
                 cwd=target,
                 cmd="git update-index --refresh -q --unmerged")
     sys.stderr.write("Bar\n")
     result = run_command(self.config,
                          self.command(), ['fetch'],
                          cwd=target,
                          cmd="git fetch")
     if result != 0:
         return 1
     return run_command(self.config,
                        self.command(), ['reset', '--hard', revision],
                        cwd=target,
                        cmd="git reset --hard %s" % revision)
Beispiel #2
0
 def set_user(self, target):
     '''Set dummy user.name and user.email to prevent possible errors'''
     user = '******' % self.config['git_user']
     email = '"%s"' % self.config['git_email']
     args = ['config', 'user.name', user]
     self.output.debug("set git user info...args=%s" % ' '.join(args), 8)
     failure = run_command(self.config, self.command(), args, cmd=self.type, cwd=target)
     if failure:
         self.output.debug("set git user info...failure setting name")
         return failure
     args = ['config', 'user.email', email]
     self.output.debug("set git user info...args=%s" % ' '.join(args), 8)
     return run_command(self.config, self.command(), args, cmd=self.type,
                        cwd=target)
Beispiel #3
0
 def set_user(self, target):
     '''Set dummy user.name and user.email to prevent possible errors'''
     user = '******' % self.config['git_user']
     email = '"%s"' % self.config['git_email']
     args = ['config', 'user.name', user]
     self.output.debug("set git user info...args=%s" % ' '.join(args), 8)
     failure = run_command(self.config, self.command(), args, cmd=self.type, cwd=target)
     if failure:
         self.output.debug("set git user info...failure setting name")
         return failure
     args = ['config', 'user.email', email]
     self.output.debug("set git user info...args=%s" % ' '.join(args), 8)
     return run_command(self.config, self.command(), args, cmd=self.type,
                        cwd=target)
Beispiel #4
0
    def sync(self, base):
        '''Sync overlay.'''

        if not self.supported():
            return 1

        # rsync OPTIONS [-q] SOURCE TARGET
        args = [
            '-rlptDvz', '--progress', '--delete', '--delete-after',
            '--timeout=180', '--exclude=distfiles/*', '--exclude=local/*',
            '--exclude=packages/*'
        ]

        cfg_opts = self.config["rsync_syncopts"]
        target = path([base, self.parent.name])

        if self.config['quiet']:
            args.append('-q')
        if len(cfg_opts):
            args.extend(cfg_opts.split())
        args.append(self.src + '/')
        args.append(target)

        return self.postsync(run_command(self.config,
                                         self.command(),
                                         args,
                                         cmd=self.type),
                             cwd=target)
Beispiel #5
0
    def add(self, base):
        '''Add overlay.'''

        if not self.supported():
            return 1

        cfg_opts = self.config["git_addopts"]
        target = path([base, self.parent.name])

        # git clone [-q] SOURCE TARGET
        args = ['clone']
        if self.config['quiet']:
            args.append('-q')
        if len(cfg_opts):
            args.extend(cfg_opts.split())
        args.append(self._fix_git_source(self.src))
        args.append(target)

        if self.branch:
            args.append('-b')
            args.append(self.branch)
        success = False
        # adding cwd=base due to a new git bug in selinux due to
        # not having user_home_dir_t and portage_fetch_t permissions
        # but changing dir works around it.
        success = run_command(self.config,
                              self.command(),
                              args,
                              cmd=self.type,
                              cwd=base)
        self.output.debug("cloned git repo...success=%s" % str(success), 8)
        success = self.set_user(target)
        return self.postsync(success, cwd=target)
Beispiel #6
0
    def add(self, base):
        '''Add overlay.'''

        if not self.supported():
            return 1

        cfg_opts = self.config["darcs_addopts"]
        target = path([base, self.parent.name])

        if self.src.endswith("/"):
            src = self.src
        else:
            src = self.src + '/'

        # darcs get --partial SOURCE TARGET
        if len(cfg_opts):
            args = ['get', '--partial', cfg_opts,
                src, target]
        else:
            args = ['get', '--partial',
                src, target]

        return self.postsync(
            run_command(self.config, self.command(), args, cmd=self.type),
            cwd=target)
Beispiel #7
0
    def umount(self, repo, dest=None, sync=False):
        '''
        Unmounts an overlay from it's installation directory.

        @params repo: str of overlay name or "ALL".
        @params dest: str of optional path to unmount.
        @params sync: bool to reflect whether or not the overlay is being
        synced.
        @rtype int: reflects whether or not it was a successful unmount.
        '''
        result = 1

        selection = self._check_selection(repo)
            
        for i in selection:
            name = {'ovl': i}

            if i not in self.mountables and not sync:
                self.output.error('Overlay "%(ovl)s" cannot be mounted!'\
                                    % name)
                continue
            if dest:
                mdir = dest
            else:
                mdir = path([self.storage, i])

            if is_mounted(mdir):
                args = ['-l', mdir]
                result = run_command(self.config, 'umount', args, cmd='umount')
            else:
                self.output.warn('Overlay "%(ovl)s" is already unmounted!'\
                                    % name)

        return result
Beispiel #8
0
    def umount(self, repo, dest=None, sync=False):
        '''
        Unmounts an overlay from it's installation directory.

        @params repo: str of overlay name or "ALL".
        @params dest: str of optional path to unmount.
        @params sync: bool to reflect whether or not the overlay is being
        synced.
        @rtype int: reflects whether or not it was a successful unmount.
        '''
        result = 1

        selection = self._check_selection(repo)

        for i in selection:
            name = {'ovl': i}

            if i not in self.mountables and not sync:
                self.output.error('Overlay "%(ovl)s" cannot be mounted!'\
                                    % name)
                continue
            if dest:
                mdir = dest
            else:
                mdir = path([self.storage, i])

            if is_mounted(mdir):
                args = ['-l', mdir]
                result = run_command(self.config, 'umount', args, cmd='umount')
            else:
                self.output.warn('Overlay "%(ovl)s" is already unmounted!'\
                                    % name)

        return result
Beispiel #9
0
    def sync(self, base):
        '''Sync overlay.'''

        if not self.supported():
            return 1

        def checkout_location():
            # Append '@' iff needed
            # Keeps users of SVN <1.6.5 happy in more cases (bug #313303)
            repo_part = self.parent.name
            if self.parent.name.find('@') != -1:
                repo_part = repo_part + '@'
            return path([base, repo_part])

        cfg_opts = self.config["svn_syncopts"]
        self.target = checkout_location()

        # first check if an svn upgrade is needed.
        self.output.debug("SVN: check_upgrade() call", 4)
        self.check_upgrade(path([base, self.parent.name]))

        # svn up [-q] TARGET
        args = ['up']
        if self.config['quiet']:
            args.append('-q')
        if len(cfg_opts):
            args.append(cfg_opts)
        args.append(self.target)

        return self.postsync(
            run_command(self.config, self.command(), args, cmd=self.type),
            cwd=self.target)
Beispiel #10
0
    def add(self, base):
        '''Add overlay.'''

        if not self.supported():
            return 1

        cfg_opts = self.config["mercurial_addopts"]
        target = path([base, self.parent.name])

        src = self._fix_mercurial_source(self.src)

        # hg clone SOURCE TARGET
        if len(cfg_opts):
            args = ['clone'] + cfg_opts.split() + [src, target]
        else:
            args = ['clone', src, target]

        if self.branch:
            args.append('-r')
            args.append(self.branch)

        return self.postsync(run_command(self.config,
                                         self.command(),
                                         args,
                                         cmd=self.type),
                             cwd=target)
Beispiel #11
0
    def add(self, base):
        '''Add overlay.'''

        if not self.supported():
            return 1

        cfg_opts = self.config["git_addopts"]
        target = path([base, self.parent.name])

        # git clone [-q] SOURCE TARGET
        args = ['clone']
        if self.config['quiet']:
            args.append('-q')
        if len(cfg_opts):
            args.append(cfg_opts)
        args.append(self._fix_git_source(self.src))
        args.append(target)

        if self.branch:
            args.append('-b')
            args.append(self.branch)
        success = False
        # adding cwd=base due to a new git bug in selinux due to
        # not having user_home_dir_t and portage_fetch_t permissions
        # but changing dir works around it.
        success = run_command(self.config, self.command(), args,cmd=self.type,
                              cwd=base)
        self.output.debug("cloned git repo...success=%s" % str(success), 8)
        success = self.set_user(target)
        return self.postsync(success, cwd=target)
Beispiel #12
0
    def sync(self, base):
        '''Sync overlay.'''

        if not self.supported():
            return 1

        def checkout_location():
            # Append '@' iff needed
            # Keeps users of SVN <1.6.5 happy in more cases (bug #313303)
            repo_part = self.parent.name
            if self.parent.name.find('@') != -1:
                repo_part = repo_part + '@'
            return path([base, repo_part])

        cfg_opts = self.config["svn_syncopts"]
        self.target = checkout_location()

        # first check if an svn upgrade is needed.
        self.output.debug("SVN: check_upgrade() call", 4)
        self.check_upgrade(path([base, self.parent.name]))

        # svn up [-q] TARGET
        args = ['up']
        if self.config['quiet']:
            args.append('-q')
        if len(cfg_opts):
            args.extend(cfg_opts.split())
        args.append(self.target)

        return self.postsync(
            run_command(self.config, self.command(), args, cmd=self.type),
            cwd=self.target)
Beispiel #13
0
    def add(self, base):
        '''Add overlay.'''

        if not self.supported():
            return 1

        cfg_opts = self.config["cvs_addopts"]
        target = path([base, self.parent.name])

        # cvs [-q] co -d SOURCE SCOPE
        args = []
        if self.config['quiet']:
            args.append('-q')
        args.append('co')
        args.append('-d')
        if len(cfg_opts):
            args.extend(cfg_opts.split())
        args.append(self.parent.name)
        args.append(self.branch)

        return self.postsync(run_command(self.config,
                                         self.command(),
                                         args,
                                         cwd=base,
                                         env=dict(CVSROOT=self.src),
                                         cmd=self.type),
                             cwd=target)
Beispiel #14
0
    def sync(self, base):
        '''Sync overlay.'''

        if not self.supported():
            return 1

        target = path([base, self.parent.name])

        args = [self.backend, '-o', target, '-r', self.repository, 'sync']
        returncode = run_command(self.config, self.command(), args,
                                 cwd=target)
        if returncode:
            return returncode
        args = [self.backend, '-o', target, 'generate-tree']
        return self.postsync(
            run_command(self.config, self.command(), args, cwd=target,
                        cmd=self.type),
            cwd=target)
Beispiel #15
0
 def cleanup(self):
     '''Code to run in the event of a keyboard interrupt.
     runs svn cleanup
     '''
     self.output.warn("SVN: preparing to run cleanup()", 2)
     args = ["cleanup"]
     args.append(self.target)
     cleanup = run_command(self.config, self.command(), args,
                           cmd="svn cleanup")
     return
Beispiel #16
0
 def cleanup(self):
     '''Code to run in the event of a keyboard interrupt.
     runs svn cleanup
     '''
     self.output.warn("SVN: preparing to run cleanup()", 2)
     args = ["cleanup"]
     args.append(self.target)
     cleanup = run_command(self.config, self.command(), args,
                           cmd="svn cleanup")
     return
Beispiel #17
0
    def sync(self, base):
        '''Sync overlay.'''

        if not self.supported():
            return 1

        target = path([base, self.parent.name])

        args = [self.backend, '-o', target, '-r', self.repository, 'sync']
        returncode = run_command(self.config, self.command(), args, cwd=target)
        if returncode:
            return returncode
        args = [self.backend, '-o', target, 'generate-tree']
        return self.postsync(run_command(self.config,
                                         self.command(),
                                         args,
                                         cwd=target,
                                         cmd=self.type),
                             cwd=target)
Beispiel #18
0
    def post_fetch(self, pkg, dest_dir):
        '''
        Extracts tar archive.

        @params pkg: string location where tar archive is located.
        @params dest_dir: string of destination of extracted archive.
        @rtype bool
        '''
        # tar -v -x -f SOURCE -C TARGET
        args = ['-v', '-x', '-f', pkg, '-C', dest_dir]
        result = run_command(self.config, self.command(), args, cmd=self.type)

        return result
Beispiel #19
0
    def post_fetch(self, pkg, dest_dir):
        '''
        Extracts tar archive.

        @params pkg: string location where tar archive is located.
        @params dest_dir: string of destination of extracted archive.
        @rtype bool
        '''
        # tar -v -x -f SOURCE -C TARGET
        args = ['-v', '-x', '-f', pkg, '-C', dest_dir]
        result = run_command(self.config, self.command(), args, cmd=self.type)

        return result
Beispiel #20
0
    def update(self, base, src):
        '''
        Updates overlay src-url.

        @params base: base location where all overlays are installed.
        @params src: source URL.
        '''

        if not self.supported():
            return 1

        target = path([base, self.parent.name])

        # First echo the new repository to CVS/Root
        args = [src, '>', '/CVS/Root']
        result = run_command(self.config, 'echo', args, cmd='echo', cwd=target)

        if result == 0:
            location = src.split(':')[3]
            old_location = self.src.split(':/')[3]

            # Check if the repository location needs to be updated too.
            if not location == old_location:
                location = re.sub('/', '\/', location)
                old_location = re.sub('/', '\/', old_location)

                expression = 's/' + old_location + '/' + location + '/'

                # sed -i 's/<old_location>/<new_location>/ <target>/CVS/Repository
                args = ['-i', expression, '/CVS/Repository']

                return run_command(self.config,
                                   'sed',
                                   args,
                                   cmd='sed',
                                   cwd=target)

        return result
Beispiel #21
0
    def mount(self, repo, dest=None, install=False, ovl_type=None, pkg=None):
        '''
        Mounts an overlay to it's installation directory.

        @params repo: str of overlay name or "ALL".
        @params dest: str of optional destination dir.
        @params install: bool to reflect whether or not the overlay is being
        installed.
        @params ovl_type: str of optional overlay type.
        @params pkg: str of optional location of package to mount.
        @rtype int: reflects whether or not the overlay was mounted.
        '''
        result = 1

        selection = self._check_selection(repo)

        for i in selection:
            name = {'ovl': i}

            if i not in self.mountables and not install:
                self.output.error('Overlay "%(ovl)s" cannot be mounted!'\
                                    % name)
                continue
            if dest:
                mdir = dest
            else:
                mdir = path([self.storage, i])

            if not is_mounted(mdir):
                if install:
                    args = copy.deepcopy(MOUNT_ARGS[ovl_type])
                else:
                    args = copy.deepcopy(MOUNT_ARGS[self.mountables[i]])

                if not pkg:
                    source = self.installed[i].sources[0].src

                    if 'file://' in source:
                        pkg = source.replace('file://', '')
                    else:
                        pkg = path([self.storage, i, source.get_extension()])

                args.append(pkg)
                args.append(mdir)
                result = run_command(self.config, 'mount', args, cmd='mount')
            else:
                self.output.warn('Overlay "%(ovl)s" is already mounted!'\
                                    % name)
        return result
Beispiel #22
0
    def mount(self, repo, dest=None, install=False, ovl_type=None, pkg=None):
        '''
        Mounts an overlay to it's installation directory.

        @params repo: str of overlay name or "ALL".
        @params dest: str of optional destination dir.
        @params install: bool to reflect whether or not the overlay is being
        installed.
        @params ovl_type: str of optional overlay type.
        @params pkg: str of optional location of package to mount.
        @rtype int: reflects whether or not the overlay was mounted.
        '''
        result = 1

        selection = self._check_selection(repo)

        for i in selection:
            name = {'ovl': i}

            if i not in self.mountables and not install:
                self.output.error('Overlay "%(ovl)s" cannot be mounted!'\
                                    % name)
                continue
            if dest:
                mdir = dest
            else:
                mdir = path([self.storage, i])

            if not is_mounted(mdir):
                if install:
                    args = copy.deepcopy(MOUNT_ARGS[ovl_type])
                else:
                    args = copy.deepcopy(MOUNT_ARGS[self.mountables[i]])
                
                if not pkg:
                    source = self.installed[i].sources[0].src

                    if 'file://' in source:
                        pkg = source.replace('file://', '')
                    else:
                        pkg = path([self.storage, i, source.get_extension()])

                args.append(pkg)
                args.append(mdir)
                result = run_command(self.config, 'mount', args, cmd='mount')
            else:
                self.output.warn('Overlay "%(ovl)s" is already mounted!'\
                                    % name)
        return result
Beispiel #23
0
    def update(self, base, src):
        '''
        Updates overlay src-url.

        @params base: base location where all overlays are installed.
        @params src: source URL.
        '''

        if not self.supported():
            return 1

        target = path([base, self.parent.name])

        # First echo the new repository to CVS/Root
        args = [src, '>', '/CVS/Root']
        result = run_command(self.config, 'echo', args, cmd='echo',
                             cwd=target)

        if result == 0:
            location = src.split(':')[3]
            old_location = self.src.split(':/')[3]

            # Check if the repository location needs to be updated too.
            if not location == old_location:
                location = re.sub('/', '\/', location)
                old_location = re.sub('/', '\/', old_location)

                expression = 's/' + old_location + '/' + location + '/'

                # sed -i 's/<old_location>/<new_location>/ <target>/CVS/Repository
                args = ['-i', expression, '/CVS/Repository']

                return run_command(self.config, 'sed', args, cmd='sed',
                                   cwd=target)

        return result
Beispiel #24
0
    def update(self, base, src):
        '''
        Update overlay src-url

        @params base: base location where all overlays are installed.
        @params src:  source URL.
        '''
        self.output.debug("git.update(); starting...%s" % self.parent.name, 6)
        target = path([base, self.parent.name])

        # git remote set-url <name> <newurl> <oldurl>
        args = ['remote', 'set-url', 'origin', self._fix_git_source(src), self._fix_git_source(self.src)]

        return run_command(self.config, self.command(), args, cmd=self.type,
                           cwd=target)
Beispiel #25
0
    def update(self, base, src):
        '''
        Update overlay src-url
        
        @params base: base location where all overlays are installed.
        @params src:  source URL.
        '''
        self.output.debug("git.update(); starting...%s" % self.parent.name, 6)
        target = path([base, self.parent.name])

        # git remote set-url <name> <newurl> <oldurl>
        args = ['remote', 'set-url', 'origin', self._fix_git_source(src), self._fix_git_source(self.src)]

        return run_command(self.config, self.command(), args, cmd=self.type,
                           cwd=target)
Beispiel #26
0
 def postsync(self, failed_sync, **kwargs):
     """Runs any repo specific postsync operations
     """
     # check if the add/sync operation succeeded
     if failed_sync:
         return failed_sync
     # good to continue
     postsync_opt = self.config['%s_postsync' % self.__class__.type_key]
     if len(postsync_opt):
         # repalce "%cwd=" while it's still a string'
         _opt = postsync_opt.replace('%cwd=',
             kwargs.get('cwd', '')).split()
         command = _opt[0]
         args = _opt[1:]
         return run_command(self.config, command, args,
             cmd='%s_postsync' % self.__class__.type_key)
     return failed_sync
Beispiel #27
0
    def update(self, base, src):
        '''
        Update overlay src-url
        
        @params base: base location where all overlays are installed.
        @params src: source URL.
        '''

        self.output.debug("svn.update(); starting...%s" % self.parent.name, 6)
        target = path([base, self.parent.name])

        # svn switch --relocate <oldurl> <newurl>
        args = ['switch', '--relocate', self._fix_svn_source(self.src), self._fix_svn_source(src)]

        return self.postsync(
             run_command(self.config, self.command(), args, cmd=self.type),
             cwd=target)
Beispiel #28
0
    def update(self, base, src):
        '''
        Update overlay src-url

        @params base: base location where all overlays are installed.
        @params src: source URL.
        '''

        self.output.debug("svn.update(); starting...%s" % self.parent.name, 6)
        target = path([base, self.parent.name])

        # svn switch --relocate <oldurl> <newurl>
        args = ['switch', '--relocate', self._fix_svn_source(self.src), self._fix_svn_source(src)]

        return self.postsync(
             run_command(self.config, self.command(), args, cmd=self.type),
             cwd=target)
Beispiel #29
0
    def sync(self, base):
        '''Sync overlay.'''

        if not self.supported():
            return 1

        cfg_opts = self.config["darcs_addopts"]
        target = path([base, self.parent.name])

        # darcs pull --all SOURCE
        if len(cfg_opts):
            args = ['pull', '--all', cfg_opts, self.src]
        else:
            args = ['pull', '--all', self.src]
        return self.postsync(
            run_command(self.config, self.command(), args, cwd=target,
                        cmd=self.type),
            cwd=target)
Beispiel #30
0
 def postsync(self, failed_sync, **kwargs):
     """Runs any repo specific postsync operations
     """
     # check if the add/sync operation succeeded
     if failed_sync:
         return failed_sync
     # good to continue
     postsync_opt = self.config['%s_postsync' % self.__class__.type_key]
     if len(postsync_opt):
         # repalce "%cwd=" while it's still a string'
         _opt = postsync_opt.replace('%cwd=', kwargs.get('cwd', '')).split()
         command = _opt[0]
         args = _opt[1:]
         return run_command(self.config,
                            command,
                            args,
                            cmd='%s_postsync' % self.__class__.type_key)
     return failed_sync
Beispiel #31
0
    def sync(self, base):
        '''Sync overlay.'''

        if not self.supported():
            return 1

        cfg_opts = self.config["bzr_syncopts"]
        target = path([base, self.parent.name])

        # bzr pull --overwrite SOURCE
        if len(cfg_opts):
            args = ['pull'] + cfg_opts.split() + ['--overwrite', self.src]
        else:
            args = ['pull', '--overwrite', self.src]
        return self.postsync(
            run_command(self.config, self.command(), args, cwd=target,
                        cmd=self.type),
            cwd=target)
Beispiel #32
0
    def add(self, base):
        '''Add overlay.'''

        if not self.supported():
            return 1

        cfg_opts = self.config["bzr_addopts"]
        target = path([base, self.parent.name])

        src = self._fix_bzr_source(self.src)

        # bzr get SOURCE TARGET
        if len(cfg_opts):
            args = ['branch'] + cfg_opts.split() + [src, target]
        else:
            args = ['branch', src, target]
        return self.postsync(
            run_command(self.config, self.command(), args, cmd=self.type),
            cwd=target)
Beispiel #33
0
    def sync(self, base):
        '''Sync overlay.'''

        self.output.debug("git.sync(); starting...%s" % self.parent.name, 6)
        if not self.supported():
            return 1

        cfg_opts = self.config["git_syncopts"]
        target = path([base, self.parent.name])

        args = ['pull']
        if self.config['quiet']:
            args.append('-q')
        if len(cfg_opts):
            args.append(cfg_opts)

        return self.postsync(
            run_command(self.config, self.command(), args, cwd=target,
                        cmd=self.type),
            cwd=target)
Beispiel #34
0
    def sync(self, base):
        '''Sync overlay.'''

        if not self.supported():
            return 1

        cfg_opts = self.config["bzr_syncopts"]
        target = path([base, self.parent.name])

        # bzr pull --overwrite SOURCE
        if len(cfg_opts):
            args = ['pull'] + cfg_opts.split() + ['--overwrite', self.src]
        else:
            args = ['pull', '--overwrite', self.src]
        return self.postsync(run_command(self.config,
                                         self.command(),
                                         args,
                                         cwd=target,
                                         cmd=self.type),
                             cwd=target)
Beispiel #35
0
    def update(self, base, src):
        '''
        Updates overlay src-url.

        @params base: base location where all overlays are installed.
        @params src: source URL.
        '''

        if not self.supported():
            return 1

        target = path([base, self.parent.name])

        # bzr bind SOURCE
        args = ['bind', self._fix_bzr_source(src)]
        if self.config['quiet']:
            args.append('--quiet')
        return self.postsync(
            run_command(self.config, self.command(), args, cmd=self.type),
            cwd=target)
Beispiel #36
0
    def sync(self, base):
        '''Sync overlay.'''

        self.output.debug("git.sync(); starting...%s" % self.parent.name, 6)
        if not self.supported():
            return 1

        cfg_opts = self.config["git_syncopts"]
        target = path([base, self.parent.name])

        args = ['pull']
        if self.config['quiet']:
            args.append('-q')
        if len(cfg_opts):
            args.extend(cfg_opts.split())

        return self.postsync(
            run_command(self.config, self.command(), args, cwd=target,
                        cmd=self.type),
            cwd=target)
Beispiel #37
0
    def sync(self, base):
        '''Sync overlay.'''

        if not self.supported():
            return 1

        cfg_opts = self.config["cvs_syncopts"]
        target = path([base, self.parent.name])

        # cvs [-q] update -d
        args = []
        if self.config['quiet']:
            args.append('-q')
        args.append('update')
        args.append('-d')
        if len(cfg_opts):
            args.extend(cfg_opts.split())
        return self.postsync(
            run_command(self.config, self.command(), args, cwd=target,
                        cmd=self.type),
            cwd=target)
Beispiel #38
0
    def add(self, base):
        '''Add overlay.'''

        if not self.supported():
            return 1

        cfg_opts = self.config["bzr_addopts"]
        target = path([base, self.parent.name])

        src = self._fix_bzr_source(self.src)

        # bzr get SOURCE TARGET
        if len(cfg_opts):
            args = ['branch'] + cfg_opts.split() + [src, target]
        else:
            args = ['branch', src, target]
        return self.postsync(run_command(self.config,
                                         self.command(),
                                         args,
                                         cmd=self.type),
                             cwd=target)
Beispiel #39
0
    def update(self, base, src):
        '''
        Updates overlay src-url.

        @params base: base location where all overlays are installed.
        @params src: source URL.
        '''

        if not self.supported():
            return 1

        target = path([base, self.parent.name])

        # bzr bind SOURCE
        args = ['bind', self._fix_bzr_source(src)]
        if self.config['quiet']:
            args.append('--quiet')
        return self.postsync(run_command(self.config,
                                         self.command(),
                                         args,
                                         cmd=self.type),
                             cwd=target)
Beispiel #40
0
    def sync(self, base):
        '''Sync overlay.'''

        if not self.supported():
            return 1

        cfg_opts = self.config["cvs_syncopts"]
        target = path([base, self.parent.name])

        # cvs [-q] update -d
        args = []
        if self.config['quiet']:
            args.append('-q')
        args.append('update')
        args.append('-d')
        if len(cfg_opts):
            args.extend(cfg_opts.split())
        return self.postsync(run_command(self.config,
                                         self.command(),
                                         args,
                                         cwd=target,
                                         cmd=self.type),
                             cwd=target)
Beispiel #41
0
    def update(self, base, src):
        '''
        Updates overlay src-url.

        @params base: base location where all overlays are installed.
        @params src: source URL.
        '''

        if not self.supported():
            return 1

        target = path([base, self.parent.name])
        hgrc = ".hg/hgrc"

        old_src = re.sub('/', '\/', self._fix_mercurial_source(self.src))
        new_src = re.sub('/', '\/', self._fix_mercurial_source(src))
        expression = "s/" + old_src + "/" + new_src + "/"

        # sed -i 's/oldurl/newurl/' <target>/.hg/hgrc
        args = ['-i', expression, hgrc]

        # Run sed.
        return run_command(self.config, 'sed', args, cmd='sed', cwd=target)
Beispiel #42
0
    def update(self, base, src):
        '''
        Updates overlay src-url.

        @params base: base location where all overlays are installed.
        @params src: source URL.
        '''

        if not self.supported():
            return 1

        target = path([base, self.parent.name])
        hgrc = ".hg/hgrc"

        old_src = re.sub('/', '\/', self._fix_mercurial_source(self.src))
        new_src = re.sub('/', '\/', self._fix_mercurial_source(src))
        expression = "s/" + old_src + "/" + new_src + "/"

        # sed -i 's/oldurl/newurl/' <target>/.hg/hgrc
        args = ['-i', expression, hgrc]

        # Run sed.
        return run_command(self.config, 'sed', args, cmd='sed', cwd=target)
Beispiel #43
0
    def add(self, base):
        '''Add overlay.'''

        if not self.supported():
            return 1

        cfg_opts = self.config["mercurial_addopts"]
        target = path([base, self.parent.name])

        src = self._fix_mercurial_source(self.src)

        # hg clone SOURCE TARGET
        if len(cfg_opts):
            args = ['clone'] + cfg_opts.split() + [src, target]
        else:
            args = ['clone', src, target]

        if self.branch:
            args.append('-r')
            args.append(self.branch)

        return self.postsync(
            run_command(self.config, self.command(), args, cmd=self.type),
            cwd=target)
Beispiel #44
0
    def sync(self, base):
        '''Sync overlay.'''

        if not self.supported():
            return 1

        # rsync OPTIONS [-q] SOURCE TARGET
        args = ['-rlptDvz', '--progress', '--delete', '--delete-after',
            '--timeout=180', '--exclude=distfiles/*', '--exclude=local/*',
            '--exclude=packages/*']

        cfg_opts = self.config["rsync_syncopts"]
        target = path([base, self.parent.name])

        if self.config['quiet']:
            args.append('-q')
        if len(cfg_opts):
            args.append(cfg_opts)
        args.append(self.src + '/')
        args.append(target)

        return self.postsync(
            run_command(self.config, self.command(), args, cmd=self.type),
            cwd=target)
Beispiel #45
0
    def add(self, base):
        '''Add overlay.'''

        if not self.supported():
            return 1

        super(SvnOverlay, self).add(base)

        cfg_opts = self.config["svn_addopts"]
        self.target = path([base, self.parent.name])

        args = ['co']
        if self.config['quiet']:
            args.append('-q')
        if len(cfg_opts):
            args.extend(cfg_opts.split())

        src = self._fix_svn_source(self.src)
        args.append(src)
        args.append(self.target)

        return self.postsync(
            run_command(self.config, self.command(), args, cmd=self.type),
            cwd=self.target)
Beispiel #46
0
    def add(self, base):
        '''Add overlay.'''

        if not self.supported():
            return 1

        cfg_opts = self.config["cvs_addopts"]
        target = path([base, self.parent.name])

        # cvs [-q] co -d SOURCE SCOPE
        args = []
        if self.config['quiet']:
            args.append('-q')
        args.append('co')
        args.append('-d')
        if len(cfg_opts):
            args.extend(cfg_opts.split())
        args.append(self.parent.name)
        args.append(self.branch)

        return self.postsync(
            run_command(self.config, self.command(), args, cwd=base,
                env=dict(CVSROOT=self.src), cmd=self.type),
            cwd=target)
Beispiel #47
0
    def add(self, base):
        '''Add overlay.'''

        if not self.supported():
            return 1

        super(SvnOverlay, self).add(base)

        cfg_opts = self.config["svn_addopts"]
        self.target = path([base, self.parent.name])

        args = ['co']
        if self.config['quiet']:
            args.append('-q')
        if len(cfg_opts):
            args.append(cfg_opts)

        src = self._fix_svn_source(self.src)
        args.append(src)
        args.append(self.target)

        return self.postsync(
            run_command(self.config, self.command(), args, cmd=self.type),
            cwd=self.target)