1 #!/usr/bin/python3 2 3 import os, subprocess 4 import cfg 5 6 def opkgcl(opkg_args): 7 cmd = "{} -o {} {}".format(cfg.opkgcl, cfg.offline_root, opkg_args) 8 #print(cmd) 9 return subprocess.getstatusoutput(cmd) 10 11 def install(pkg_name, flags=""): 12 return opkgcl("{} install {}".format(flags, pkg_name))[0] 13 14 def remove(pkg_name, flags=""): 15 return opkgcl("{} remove {}".format(flags, pkg_name))[0] 16 17 def update(): 18 return opkgcl("update")[0] 19 20 def upgrade(): 21 return opkgcl("upgrade")[0] 22 23 def files(pkg_name): 24 output = opkgcl("files {}".format(pkg_name))[1] 25 return output.split("\n")[1:] 26 27 28 def is_installed(pkg_name, version=None): 29 out = opkgcl("list_installed {}".format(pkg_name))[1] 30 if len(out) == 0 or out.split()[0] != pkg_name: 31 return False 32 if version and out.split()[2] != version: 33 return False 34 if not os.path.exists("{}/usr/lib/opkg/info/{}.control"\ 35 .format(cfg.offline_root, pkg_name)): 36 return False 37 return True 38 39 40 if __name__ == '__main__': 41 import sys 42 (status, output) = opkgcl(" ".join(sys.argv[1:])) 43 print(output) 44 exit(status)
This page was automatically generated by LXR 0.3.1. • OpenWrt