diff options
author | Andrew Gregory <andrew.gregory.8@gmail.com> | 2015-10-17 02:28:30 +0200 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2015-10-18 02:59:24 +0200 |
commit | b76409609c051e236a849746db79bd438e353b60 (patch) | |
tree | b478973be0331bec655ac59fd25fd336e7d9a6e8 /test/pacman/pmtest.py | |
parent | 4ceb1c5bf91dea2453d9b888138c40e4f97d408d (diff) | |
download | pacman-b76409609c051e236a849746db79bd438e353b60.tar.gz pacman-b76409609c051e236a849746db79bd438e353b60.tar.xz |
pactest: add hook/script support
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'test/pacman/pmtest.py')
-rw-r--r-- | test/pacman/pmtest.py | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/test/pacman/pmtest.py b/test/pacman/pmtest.py index 7774a7bf..a1081cc6 100644 --- a/test/pacman/pmtest.py +++ b/test/pacman/pmtest.py @@ -179,10 +179,14 @@ class pmtest(object): # Filesystem vprint(" Populating file system") for f in self.filesystem: - vprint("\t%s" % f) - path = util.mkfile(self.root, f, f) - if os.path.isfile(path): - os.utime(path, (355, 355)) + if type(f) is pmfile.pmfile: + vprint("\t%s" % f.path) + f.mkfile(self.root); + else: + vprint("\t%s" % f) + path = util.mkfile(self.root, f, f) + if os.path.isfile(path): + os.utime(path, (355, 355)) for pkg in self.db["local"].pkgs: vprint("\tinstalling %s" % pkg.fullname()) pkg.install_package(self.root) @@ -193,10 +197,21 @@ class pmtest(object): # Done. vprint(" Taking a snapshot of the file system") for filename in self.snapshots_needed(): - f = pmfile.PacmanFile(self.root, filename) + f = pmfile.snapshot(self.root, filename) self.files.append(f) vprint("\t%s" % f.name) + def add_hook(self, name, content): + if not name.endswith(".hook"): + name = name + ".hook" + path = os.path.join("etc/pacman.d/hooks/", name) + self.filesystem.append(pmfile.pmfile(path, content)) + + def add_script(self, name, content): + if not content.startswith("#!"): + content = "#!/bin/sh\n" + content + path = os.path.join("bin/", name) + self.filesystem.append(pmfile.pmfile(path, content, mode=0o755)) def snapshots_needed(self): files = set() |