Changeset 4342


Ignore:
Timestamp:
Apr 19, 2017, 6:05:54 PM (2 years ago)
Author:
mabarracus
Message:

Update lliurex-version to lliurex-detect 1.4

Location:
lliurex-base-files/trunk/fuentes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • lliurex-base-files/trunk/fuentes/debian/changelog

    r3803 r4342  
     1lliurex-base-files (16.06.13) xenial; urgency=medium
     2
     3  * Update lliurex-version to lliurex-detect 1.4
     4
     5 -- M.Angel Juan <m.angel.juan@gmail.com>  Wed, 19 Apr 2017 18:05:22 +0200
     6
    17lliurex-base-files (16.06.12) xenial; urgency=medium
    28
  • lliurex-base-files/trunk/fuentes/install/usr/bin/lliurex-version

    r3803 r4342  
    115115    except Exception as e1:
    116116        try:
    117             with open('/uusr/share/lliurex-cdd/version','r') as cdd_num_file:
     117            with open('/usr/share/lliurex-cdd/version','r') as cdd_num_file:
    118118                return cdd_num_file.readline().strip()
    119119        except Exception as e2:
     
    202202#def detect_user():
    203203
     204def check_mirror():
     205    #
     206    # Run checks against mirror
     207    #
     208    mirror_location='/net/mirror/llx16'
     209    #dict = check keys & recurse into values
     210    #list = check items
     211    #tuple = check items(files or regexp) ; syntax=('type','value') where type = 'regexp' or something else to exact match
     212    #string = check items
     213
     214    need_structure={'pool':[{'main':{'l/lliurex-version-timestamp':('regexp','lliurex-version-timestamp_.*\.deb$')}},'universe','multiverse','preschool','restricted'],
     215                    'dists':['xenial','xenial-security','xenial-updates'],
     216                    'lists':[('regexp','.*xenial.*_amd64_Packages$'),('regexp','.*xenial.*_i386_Packages$')]}
     217
     218    return os.path.isdir(mirror_location) and check_structure(mirror_location,need_structure)
     219
     220def check_structure(path_from,child=''):
     221    DBG=False
     222    dbg=lambda x: DBG and sys.stdout.write(x+'\n')
     223    typeparam=type(child)
     224    if typeparam == type(dict()):
     225        for item in child:
     226            new_path=path_from+'/'+item
     227            if not check_structure(path_from,item):
     228                return False
     229            if not check_structure(new_path,child[item]):
     230                return False
     231    elif typeparam == type(list()):
     232        for item in child:
     233            if not check_structure(path_from,item):
     234                return False
     235    elif typeparam == type(tuple()):
     236        mode,value=child
     237        if mode=='regexp':
     238            reg=re.compile(value)
     239            for f in os.listdir(path_from):
     240                path_check=path_from+'/'+f
     241                dbg('checking file ' + path_check)
     242                if os.path.isfile(path_check):
     243                    if reg.match(f):
     244                        return True
     245            return False
     246        else:
     247            path_check=path_from+'/'+value
     248            dbg('checking file ' + path_check)
     249            return os.path.isfile(path_check)
     250    elif typeparam == type(str()):
     251        path_check=path_from+'/'+child
     252        dbg('checking dir ' + path_check)
     253        if not os.path.isdir(path_check):
     254            return False
     255    return True
     256
    204257def store_result(results='',namevar='',action='store'):
    205258    global eval_mode
     
    306359                else:
    307360                    sys.exit(1)
     361            elif exit_return_code_mode.upper() == 'MIRROR':
     362                if result['MIRROR']=='True':
     363                    sys.exit(0)
     364                else:
     365                    sys.exit(1)
    308366            else:
    309367                if result[exit_return_code_mode.upper()]=='yes':
     
    330388parser = argparse.ArgumentParser(description='Get information about running environment')
    331389parser.add_argument('-a','--all',metavar='',action='store_const',help='Get all information',const=True)
     390parser.add_argument('-m','--mirror',metavar='',action='store_const',help='Check mirror available',const=True)
    332391parser.add_argument('-e','--eval',metavar='',action='store_const',help='Show all information to evaluate in bash variables',const=True)
    333392parser.add_argument('-s','--session',metavar='',action='store_const',help='Get current session type',const=True)
    334393parser.add_argument('-f','--flavour',metavar='',action='store_const',help='Get the flavour of current system',const=True)
    335394parser.add_argument('-u','--usertype',metavar='username',nargs='?',const='',help='Get the usertype from current user or from passed username')
    336 code_types=['live','ltsp','fat','semi','thin','desktop','server','client','infantil','pime','music','local','ldap','promoted']
    337 parser.add_argument('-x','--with-return-code',metavar='[live|ltsp|fat|semi|thin|desktop|server|client|infantil|pime|music|local|ldap|promoted]',nargs=1,choices=code_types,help='Execute mode testing value passed')
     395code_types=['live','ltsp','fat','semi','thin','desktop','server','client','infantil','pime','music','local','ldap','promoted','mirror']
     396parser.add_argument('-x','--with-return-code',metavar='[live|ltsp|fat|semi|thin|desktop|server|client|infantil|pime|music|local|ldap|promoted|mirror]',nargs=1,choices=code_types,help='Execute mode testing value passed')
    338397# lliurex-version options
    339398parser.add_argument('-n','--number',metavar='',action='store_const',const=True,help='Get the cdd number version')
     
    380439    if args_all or args.usertype != None:
    381440        store_result(detect_user(args.usertype),'USERTYPE')
     441    if args_all or args.mirror != None:
     442        store_result(str(check_mirror()),'MIRROR')
    382443
    383444#lliurex version options
Note: See TracChangeset for help on using the changeset viewer.