Esempio n. 1
0
def git_clone(*params, **kwargs):
    '''Clone or update a local git repository'''
    if not 'subdir' in kwargs:
        raise BuiltinError("you must give subdir parameter.")
    subdir = kwargs['subdir']
    clone_dir = joinpath(src_cache, fullname)
    shelltools.makedirs(clone_dir)
    current_dir = pwd()
    cd(clone_dir)
    if isdir(subdir):
        if not isempty(subdir):
            cd(subdir)
            notify("updating %s" % subdir)
            notify("running git pull %s" % " ".join(params))
            if not shelltools.system("git pull", sandbox=False):
                raise BuiltinError("git pull failed")
            copy_to_build_dir(joinpath(clone_dir, subdir))
            cd(current_dir)
            return True
    notify("cloning into %s" % pwd())
    notify("running git clone %s" % " ".join(params))
    if not shelltools.system("git clone "+" ".join(params), sandbox=False):
        raise BuiltinError("git clone failed")
    copy_to_build_dir(joinpath(clone_dir, subdir))
    cd(current_dir)
    return True
Esempio n. 2
0
def git_clone(*params, **kwargs):
    '''Clone or update a local git repository'''
    if not 'subdir' in kwargs:
        raise BuiltinError("you must give subdir parameter.")
    subdir = kwargs['subdir']
    clone_dir = joinpath(src_cache, fullname)
    shelltools.makedirs(clone_dir)
    current_dir = pwd()
    cd(clone_dir)
    if isdir(subdir):
        if not isempty(subdir):
            cd(subdir)
            notify("updating %s" % subdir)
            notify("running git pull %s" % " ".join(params))
            if not shelltools.system("git pull", sandbox=False):
                raise BuiltinError("git pull failed")
            copy_to_build_dir(joinpath(clone_dir, subdir))
            cd(current_dir)
            return True
    notify("cloning into %s" % pwd())
    notify("running git clone %s" % " ".join(params))
    if not shelltools.system("git clone " + " ".join(params), sandbox=False):
        raise BuiltinError("git clone failed")
    copy_to_build_dir(joinpath(clone_dir, subdir))
    cd(current_dir)
    return True
Esempio n. 3
0
def desktop_database_update(*args):
    parameters = "-q"
    if args:
        parameters = " ".join(args)

    notify("updating desktop database...")
    if not shelltools.system("update-desktop-database %s" % parameters, sandbox=False):
        write(out.color("\tFAILED", "red"))
Esempio n. 4
0
 def sync(self):
     if self.git_repo():
         os.chdir(self.repo_path)
         if lpms.getopt("--reset"):
             out.warn("forcing git to overwrite local files")
             shelltools.system("%s reset --hard HEAD" % self.git_binary, sandbox=False)
             shelltools.system("%s clean -f -d" % self.git_binary, sandbox=False)
         shelltools.system("%s pull -f -u origin" % self.git_binary, sandbox=False)
     else:
         os.chdir(os.path.dirname(self.repo_path))
         shelltools.system("%s clone %s %s" % (self.git_binary, self.remote, self.repo), sandbox=False)
Esempio n. 5
0
def gnome2_icon_cache_update(*args, **kwargs):
    parameters = "-q -t -f"
    target = "/usr/share/icons/hicolor"

    if args:
        parameters = " ".join(args)

    if kwargs:
        if "target" in kwargs:
            target = kwargs["target"]

    out.notify("updating GTK+ icon cache...")
    if not shelltools.system("gtk-update-icon-cache %s %s" % (parameters, target), sandbox=False):
        out.write(out.color("\n\tFAILED\n", "red"))
Esempio n. 6
0
def system(*args, **kwargs):
    result = shelltools.system(" ".join(args), stage=current_stage, \
            sandbox=False if current_stage in cst.sandbox_exception_stages else None)
    if isinstance(result, bool): return result

    if len(result) == 2:
        if result[1]:
            logfile =  "%s/build.log" % dirname(dirname(build_dir))
            if isfile(logfile):
                shelltools.remove_file(logfile)
            echo(result[1],logfile)
            out.normal("for detalied output, view %s" % logfile)
        return result[0]
    return result
Esempio n. 7
0
 def sync(self):
     if self.git_repo():
         os.chdir(self.repo_path)
         if lpms.getopt("--reset"):
             out.warn("forcing git to overwrite local files")
             shelltools.system("%s reset --hard HEAD" % self.git_binary,
                               sandbox=False)
             shelltools.system("%s clean -f -d" % self.git_binary,
                               sandbox=False)
         shelltools.system("%s pull -f -u origin" % self.git_binary,
                           sandbox=False)
     else:
         os.chdir(os.path.dirname(self.repo_path))
         shelltools.system("%s clone %s %s" %
                           (self.git_binary, self.remote, self.repo),
                           sandbox=False)
Esempio n. 8
0
 def fetch(command, download_plan, location):
     #current = os.getcwd()
     if location is not None:
         os.chdir(location)
     else:
         os.chdir(config.src_cache)
     for url in download_plan:
         localfile = os.path.basename(url)
         partfile  = localfile+".part"
         output = shelltools.system(command+" "+partfile+" "+url, show=True, sandbox=False)
         if not output:
             out.error(url+" cannot be downloaded")
             return False
         else:
             shelltools.move(partfile, localfile)
     #os.chdir(current)
     return True
Esempio n. 9
0
def update_info_index(info_path, dir_path="/usr/share/info/dir", delete=False):
    '''Updates GNU Info file index'''
    if os.access(info_path, os.R_OK):
        if not os.access("/usr/bin/install-info", os.X_OK):
            out.error("/usr/bin/install-info seems broken. please check sys-apps/texinfo")
            return False
        if delete:
            command = "/usr/bin/install-info --delete %s %s" % (info_path, dir_path)
        else:
            command = "/usr/bin/install-info %s %s" % (info_path, dir_path)
        if not shelltools.system(command, sandbox=False):
            out.error("%s not updated. info file: %s" % (dir_path, info_path))
            return False
    else:
        out.error("%s not found" % info_path)
        return False
    return True
Esempio n. 10
0
def update_info_index(info_path, dir_path="/usr/share/info/dir", delete=False):
    '''Updates GNU Info file index'''
    if os.access(info_path, os.R_OK):
        if not os.access("/usr/bin/install-info", os.X_OK):
            out.error(
                "/usr/bin/install-info seems broken. please check sys-apps/texinfo"
            )
            return False
        if delete:
            command = "/usr/bin/install-info --delete %s %s" % (info_path,
                                                                dir_path)
        else:
            command = "/usr/bin/install-info %s %s" % (info_path, dir_path)
        if not shelltools.system(command, sandbox=False):
            out.error("%s not updated. info file: %s" % (dir_path, info_path))
            return False
    else:
        out.error("%s not found" % info_path)
        return False
    return True
Esempio n. 11
0
 def fetch(command, download_plan, location):
     #current = os.getcwd()
     if location is not None:
         os.chdir(location)
     else:
         os.chdir(config.src_cache)
     for url in download_plan:
         localfile = os.path.basename(url)
         partfile = localfile + ".part"
         output = shelltools.system(command + " " + partfile + " " +
                                    url,
                                    show=True,
                                    sandbox=False)
         if not output:
             out.error(url + " cannot be downloaded")
             return False
         else:
             shelltools.move(partfile, localfile)
     #os.chdir(current)
     return True
Esempio n. 12
0
 def create_node(params):
     return shelltools.system("mknod "+params, show=False)
Esempio n. 13
0
def apply_patch(patches, level, reverse):
    for patch in patches:
        out.notify("applying patch %s" % out.color(basename(patch), "green"))
        ret = shelltools.system("patch --remove-empty-files --no-backup-if-mismatch %s -p%d -i \"%s\"" % 
                (reverse, level, patch), show=False)
        if not ret: return False
Esempio n. 14
0
def update_mime_database(*args):
    out.notify("updating mime database...")
    if not shelltools.system("update-mime-database /usr/share/mime", sandbox=False):
        warn("update-mime-database failed.")
Esempio n. 15
0
def xdg_icon_resource(theme="hicolor"):
    notify("updating xdg icon resource for %s theme" % theme)
    if not shelltools.system("xdg-icon-resource forceupdate --theme %s" % theme, sandbox=False):
        warn("xdg-icon-resource failed.")