@ -1,4 +1,4 @@
#!/data/data/com.termux/files/ usr/bin/python3
#!/usr/bin/python3
def parse_tlpdb_to_dict ( tlpdb_path ) :
def parse_tlpdb_to_dict ( tlpdb_path ) :
""" Reads given tlpdb database and creates dict with packages and their dependencies and files
""" Reads given tlpdb database and creates dict with packages and their dependencies and files
@ -15,14 +15,14 @@ def parse_tlpdb_to_dict(tlpdb_path):
# We only care about getting all the files so only check for "depend" and files
# We only care about getting all the files so only check for "depend" and files
pkg_dict [ pkg_name ] = { " depends " : [ ] , " files " : [ ] }
pkg_dict [ pkg_name ] = { " depends " : [ ] , " files " : [ ] }
for line in pkg_lines :
for line in pkg_lines :
line_descr = line . split ( " " ) [ 0 ]
line_description = line . split ( " " ) [ 0 ]
if line_descr == " " :
if line_description == " " :
pkg_dict [ pkg_name ] [ " files " ] . append ( line . split ( " " ) [ 1 ] )
pkg_dict [ pkg_name ] [ " files " ] . append ( line . split ( " " ) [ 1 ] )
elif line_descr == " depend " :
elif line_description == " depend " :
pkg_dict [ pkg_name ] [ " depends " ] . append ( line . split ( " " ) [ 1 ] )
pkg_dict [ pkg_name ] [ " depends " ] . append ( line . split ( " " ) [ 1 ] )
return pkg_dict
return pkg_dict
def get_files ( package , files_in_package , visited_pkgs , visit_collections = False ) :
def get_files_in_package ( package , files_in_package , visited_pkgs , visit_collections = False ) :
""" Prints files in package and then run itself on each dependency. Doesn ' t visit collections unless argument visit_collections=True is passed.
""" Prints files in package and then run itself on each dependency. Doesn ' t visit collections unless argument visit_collections=True is passed.
"""
"""
for f in pkg_dict [ package ] [ " files " ] :
for f in pkg_dict [ package ] [ " files " ] :
@ -35,10 +35,10 @@ def get_files(package, files_in_package, visited_pkgs, visit_collections=False):
# avoid duplicates:
# avoid duplicates:
if not dep in visited_pkgs :
if not dep in visited_pkgs :
visited_pkgs . append ( dep )
visited_pkgs . append ( dep )
files_in_package , visited_pkgs = get_files ( dep , files_in_package , visited_pkgs )
files_in_package , visited_pkgs = get_files_in_package ( dep , files_in_package , visited_pkgs )
return files_in_package , visited_pkgs
return files_in_package , visited_pkgs
def f iles( * args , * * kwargs ) :
def F iles( * args , * * kwargs ) :
""" Wrapper around function get_files. Prepends " collection- " to package unless prepend_collection=False is passed. Also uses visit_collections=False per default.
""" Wrapper around function get_files. Prepends " collection- " to package unless prepend_collection=False is passed. Also uses visit_collections=False per default.
"""
"""
prefix = " collection- "
prefix = " collection- "
@ -50,54 +50,64 @@ def files(*args, **kwargs):
bool_visit_collections = True
bool_visit_collections = True
files = [ ]
files = [ ]
for pkg in args :
for pkg in args [ 0 ] :
files + = get_files ( prefix + pkg , [ ] , [ ] , visit_collections = bool_visit_collections ) [ 0 ]
files + = get_files_in_package ( prefix + pkg , [ ] , [ ] , visit_collections = bool_visit_collections ) [ 0 ]
return files
return files
import sys
import sys
tlpdb = sys . argv [ 2 ]
tlpdb = sys . argv [ 2 ]
pkg_dict = parse_tlpdb_to_dict ( tlpdb )
pkg_dict = parse_tlpdb_to_dict ( tlpdb )
def get_conflicting_pkgs ( package ) :
if sys . argv [ 1 ] in [ " basic " , " fontsrecommended " , " games " , " luatex " , " music " , " plaingeneric " , " publishers " , " texworks " , " wintools " ] :
""" Returns list of packages that contain some files that are also found in ' package ' .
files = set ( files ( sys . argv [ 1 ] ) )
These packages should be listed as dependencies .
elif sys . argv [ 1 ] in [ " latex " , " langeuropean " , " langenglish " , " langfrench " , " langgerman " , " binextra " , " fontutils " , " langarabic " , " langgreek " , " langitalian " , " langother " , " langpolish " , " langportuguese " , " langspanish " , " metapost " ] :
"""
files = set ( files ( sys . argv [ 1 ] ) ) - set ( files ( " basic " ) )
if package in [ " basic " , " fontsrecommended " , " games " , " luatex " ,
elif sys . argv [ 1 ] == " langczechslovak " :
" music " , " plaingeneric " , " publishers " , " texworks " , " wintools " ] :
files = set ( files ( sys . argv [ 1 ] ) ) - set ( files ( " basic " , " latex " , " fontsextra " , " luatex " ) )
return [ ]
elif sys . argv [ 1 ] == " langcyrillic " :
elif package in [ " latex " , " langeuropean " , " langenglish " , " langfrench " ,
files = set ( files ( sys . argv [ 1 ] ) ) - set ( files ( " basic " , " latex " , " fontsextra " , " fontsrecommended " , " langgreek " , " latexrecommended " ) )
" langgerman " , " binextra " , " fontutils " , " langarabic " ,
elif sys . argv [ 1 ] == " formatsextra " :
" langgreek " , " langitalian " , " langother " , " langpolish " ,
files = set ( files ( sys . argv [ 1 ] ) ) - set ( files ( " basic " , " latex " , " langcyrillic " , " mathscience " , " fontsrecommended " , " plaingeneric " ) )
" langportuguese " , " langspanish " , " metapost " ] :
elif sys . argv [ 1 ] == " context " :
return [ " basic " ]
files = set ( files ( sys . argv [ 1 ] ) ) - set ( files ( " basic " , " latex " , " mathscience " , " fontsrecommended " , " metapost " , " xetex " ) )
elif package == " langczechslovak " :
elif sys . argv [ 1 ] == " langjapanese " :
return [ " basic " , " latex " , " fontsextra " , " luatex " ]
files = set ( files ( sys . argv [ 1 ] ) ) - set ( files ( " basic " , " latex " , " langcjk " , " langchinese " ) )
elif package == " langcyrillic " :
elif sys . argv [ 1 ] == " langchinese " :
return [ " basic " , " latex " , " fontsextra " , " fontsrecommended " ,
files = set ( files ( sys . argv [ 1 ] ) ) - set ( files ( " basic " , " langcjk " , " fontutils " ) )
" langgreek " , " latexrecommended " ]
elif sys . argv [ 1 ] == " bibtexextra " :
elif package == " formatsextra " :
files = set ( files ( sys . argv [ 1 ] ) ) - set ( files ( " basic " , " binextra " ) )
return [ " basic " , " latex " , " langcyrillic " , " mathscience " ,
elif sys . argv [ 1 ] == " langcjk " :
" fontsrecommended " , " plaingeneric " ]
files = set ( files ( sys . argv [ 1 ] ) ) - set ( files ( " basic " , " langkorean " , " langother " ) )
elif package == " context " :
elif sys . argv [ 1 ] == " latexrecommended " :
return [ " basic " , " latex " , " mathscience " , " fontsrecommended " ,
files = set ( files ( sys . argv [ 1 ] ) ) - set ( files ( " basic " , " fontsrecommended " , " latexextra " , " pictures " , " plaingeneric " ) )
" metapost " , " xetex " ]
elif sys . argv [ 1 ] == " mathscience " :
elif package == " langjapanese " :
files = set ( files ( sys . argv [ 1 ] ) ) - set ( files ( " basic " , " langgreek " ) )
return [ " basic " , " latex " , " langcjk " , " langchinese " ]
elif sys . argv [ 1 ] == " langkorean " :
elif package == " langchinese " :
files = set ( files ( sys . argv [ 1 ] ) ) - set ( files ( " langjapanese " , " latexrecommended " ) )
return [ " basic " , " langcjk " , " fontutils " ]
elif sys . argv [ 1 ] == " latexextra " :
elif package == " bibtexextra " :
files = set ( files ( sys . argv [ 1 ] ) ) - set ( files ( " fontsextra " ) )
return [ " basic " , " binextra " ]
elif sys . argv [ 1 ] == " humanities " :
elif package == " langcjk " :
files = set ( files ( sys . argv [ 1 ] ) ) - set ( files ( " latexextra " ) )
return [ " basic " , " langkorean " , " langother " ]
elif sys . argv [ 1 ] == " pictures " :
elif package == " latexrecommended " :
files = set ( files ( sys . argv [ 1 ] ) ) - set ( files ( " latexextra " ) )
return [ " basic " , " fontsrecommended " , " latexextra " , " pictures " , " plaingeneric " ]
elif sys . argv [ 1 ] == " fontsextra " :
elif package == " mathscience " :
files = set ( files ( sys . argv [ 1 ] ) ) - set ( files ( " plaingeneric " ) )
return [ " basic " , " langgreek " ]
elif sys . argv [ 1 ] == " pstricks " :
elif package == " langkorean " :
files = set ( files ( sys . argv [ 1 ] ) ) - set ( files ( " plaingeneric " ) )
return [ " langjapanese " , " latexrecommended " ]
elif sys . argv [ 1 ] == " xetex " :
elif package == " latexextra " :
files = set ( files ( sys . argv [ 1 ] ) ) - set ( files ( " latex " ) )
return [ " fontsextra " ]
else :
elif package == " humanities " :
raise ValueError ( sys . argv [ 1 ] + " isn ' t a known package name " )
return [ " latexextra " ]
elif package == " pictures " :
print ( " \n " . join ( [ " share/texlive/ " + line for line in list ( files ) ] ) )
return [ " latexextra " ]
elif package == " fontsextra " :
return [ " plaingeneric " ]
elif package == " pstricks " :
return [ " plaingeneric " ]
elif package == " xetex " :
return [ " latex " ]
else :
raise ValueError ( sys . argv [ 1 ] + " isn ' t a known package name " )
print ( " \n " . join ( [ " share/texlive/ " + line for line in
list ( set ( Files ( [ sys . argv [ 1 ] ] ) ) - set ( Files ( get_conflicting_pkgs ( sys . argv [ 1 ] ) ) ) ) ] ) )