Example #1
0
def rdepscan(package):
    
    # qlist -Ce package
    # returns list of files installed by package
    command = 'qlist'
    flags = '-Ce'
    args = [package]
    output = make_sys_call(command, flags, args)
    
    # scanelf -L -n -q -F%n#F output
    # returns list of libraries that ELF files of package depend on 
    command = 'scanelf'
    flags = '-L -n -q -F%n#F'
    args = output.split()
    output = make_sys_call(command, flags, args)
    
    # qfile -Cv output
    # returns list of packages that provide the library dependencies
    command = 'qfile'
    flags = '-Cv'
    args = output.replace('\n', ',').split(',')
    output = make_sys_call(command, flags, args)
    
    # remove duplicates and return
    pkgs = output.replace('\n', ':').split(':')
    pkgs = filter(None, pkgs)
    
    uniq = set()
    for pkg in pkgs:
        uniq.add(pkg.partition(' ')[0])
        
    return list(uniq)        
Example #2
0
def repoman(package):
    current_dir = os.getcwd()
#    print(current_dir)
    
    portdir = '/usr/portage'
    os.chdir(os.path.join(portdir, package.category, package.name))
#    print(os.getcwd())
    
    ebuild = os.path.realpath(package.name + '-' + package.version + '.ebuild')
    print(ebuild)
    
    # save ebuild in memory
    with open(ebuild, 'r') as file:
        lines = file.readlines()
        
    # mark ARCH stable for this repoman check
    arch = 'arm64'
    with open(ebuild, 'w') as file:
        for line in lines:
            if 'KEYWORDS=' in line:
                line = re.sub(r'~%s'%arch, arch, line)
            file.write(line)
    
#    count = 1
#    for line in open(ebuild):
#        if 'KEYWORDS=' in line:
#            break
#        count += 1
#    
#    command = 'sed'
#    flags = '-ie'
#    args = ['%ds/~amd64/amd64/g'%count, ebuild]
#    output = make_sys_call(command, flags, args)
#    print(output)
    
    output = make_sys_call('repoman', args=['manifest'])
#    print(output)
    
    output = make_sys_call('repoman', args=['full']);
    print(output)
    
    # check repoman's response
    rc = output.split('\n')[-2]
    qa_ok = ("If everyone were like you, I'd be out of business!" in rc)

    # restore ebuild from memory
    with open(ebuild, 'w') as file:
        for line in lines:
            file.write(line)
    
#    command = 'sed'
#    flags = '-ie'
#    args = ['%ds/amd64/~amd64/g'%count, ebuild]
#    output = make_sys_call(command, flags, args)
#    print(output)
    
    output = make_sys_call('repoman', args=['manifest'])
#    print(output)
        
    os.chdir(current_dir)
#    print(os.getcwd())    

    return qa_ok