10 Do some stuff with ABS. Search, compile, install.
11 You know, everything that you need to be happy
13 def __init__(self
, put
, conf
):
16 self
.compile_cmd
= "makepkg -f "
17 self
.install_cmd
= "pacman -U "
18 self
.search_path
= "/var/abs"
21 def do_builddir(self
, bdir
=None, *ignore
):
22 # shouldn't this be plugin independent method?
24 if not os
.path
.isdir(bdir
):
25 if self
.put
.ask("No such directory, create it?"):
28 self
.conf
.build_dir
= bdir
30 self
.put("Permission denied.", "RED", True)
32 self
.conf
.build_dir
= bdir
33 self
.put("Build directory: ", "GREEN", False)
34 self
.put(self
.conf
.build_dir
)
37 def do_search(self
, pkgname
, *ignore
):
39 # TODO 2008-02-13 20:08:29
40 # Regular expression operations for searching
42 for root
, dirs
, files
in os
.walk(self
.search_path
):
47 for line
in open(os
.path
.join(root
, d
, "PKGBUILD"), "r"):
48 if line
.startswith("pkgver"):
49 name
+= " - " + line
.split("=")[1][:-1]
50 self
.put("[abs] ", "YELLOW", False)
51 self
.put(name
.ljust(32), "WHITE", False)
56 def do_compile(self
, pkgname
, *ignore
):
57 for root
, dirs
, files
in os
.walk(self
.search_path
):
60 path
= os
.path
.join(root
, d
)
61 build_path
= os
.path
.join(self
.conf
.build_dir
, d
)
62 if os
.path
.isdir(build_path
):
63 if self
.put
.ask("Directory exist. Delete it?"):
64 shutil
.rmtree(build_path
)
66 self
.put("Nothing to do.")
68 shutil
.copytree(path
, build_path
)
69 os
.system("cd %s && %s " % (build_path
, self
.conf
.compile_cmd
))
71 self
.put("PKGBUILD not found.")
73 def do_install(self
, pkgname
, *ignore
):
74 build_path
= os
.path
.join(self
.conf
.build_dir
, pkgname
)
75 if not os
.path
.isdir(build_path
):
76 self
.put("No package found. Try to compile it first.")
78 for pkgfile
in os
.listdir(build_path
):
79 if pkgfile
.endswith("pkg.tar.gz"):
80 os
.system("cd %s && %s %s" % \
81 (build_path
, self
.conf
.install_cmd
, pkgfile
))
83 self
.put("No package found. Try to compile it first.")