diff options
-rw-r--r-- | g_common/g_common.py | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/g_common/g_common.py b/g_common/g_common.py index c671b5c..17742bc 100644 --- a/g_common/g_common.py +++ b/g_common/g_common.py @@ -18,7 +18,11 @@ def read_config(conf_file,defaults={}): conf=defaults.copy() for line in conffile: if len(line): - conf[line[:line.find("=")]]=line[line.find("=")+1:] + value=line[line.find("=")+1:] + if value[-1]=='\n': + value=value[:-1] + conf[line[:line.find("=")]]=value + return conf #returns dict of key=value config file @@ -44,11 +48,15 @@ def action_sync(repo_location,driver,remote_uri): if remote_uri is None: remote_uri=repo_conf['uri'] - #todo write repo.cfg + if os.path.exists(repo_location): + try: + os.makedirs(os.path.join(repo_location,settings.MYDIR)) + except: + pass cfg_file=open(os.path.join(repo_location,settings.MYDIR,"repo.cfg"),"w") - cfg_file.write('driver='+driver) - cfg_file.write('uri='+remote_uri) + cfg_file.write('driver='+driver+'\n') + cfg_file.write('uri='+remote_uri+'\n') cfg_file.close() return verbose_system(driver_conf['exec']+" "+repo_location+" sync "+remote_uri) @@ -82,8 +90,8 @@ def generate_tree(repo_location): ebuild_file=settings.COMMON_EBUILD_FILE #get from settings - packages_list_pipe=subprocess.Popen(fixme,shell=True,stdout=subprocess.PIPE) - os.waitpid(process.pid,0) + packages_list_pipe=subprocess.Popen(driver_conf['exec']+' '+repo_location+' list-packages',shell=True,stdout=subprocess.PIPE) + os.waitpid(packages_list_pipe.pid,0) for line in packages_list_pipe.stdout: category=line[:line.find("/")] package=line[line.find("/")+1:line.find(" ")] @@ -91,7 +99,7 @@ def generate_tree(repo_location): ebuild_dir=os.path.join(repo_location,category,package) if not os.path.exists(ebuild_dir): os.makedirs(ebuild_dir) - os.symlink(ebuild_file,os.path.join(ebuild_dir,package.ebuild_vars['pn']+'-'+package.ebuild_vars['pv']+'.ebuild')) + os.symlink(ebuild_file,os.path.join(ebuild_dir,package+'-'+version+'.ebuild')) #list package details, in PMS's format def action_package(repo_location,package_name): @@ -125,7 +133,7 @@ def main(): if len(arguments)>2: driver=arguments[2] if len(arguments)>3: - remote_repo=arguments[2] + remote_repo=arguments[3] action_sync(repo_location,driver,remote_repo) elif action=='list-categories': list_categories(repo_location) |