summaryrefslogtreecommitdiff
path: root/test/pacman/tests/hook-target-list.py
blob: 6dd6c4d817822a92d7f75b3639afa59029b106f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
self.description = "Hook with NeedsTargets"

self.add_hook("hook",
        """
        [Trigger]
        Type = Package
        Operation = Install
        Target = foo

        # duplicate trigger to check that duplicate targets are removed
        [Trigger]
        Type = Package
        Operation = Install
        Target = foo

        [Trigger]
        Type = File
        Operation = Install
        # matches files in 'file/' but not 'file/' itself
        Target = file/?*

        [Action]
        When = PreTransaction
        Exec = bin/sh -c 'while read -r tgt; do printf "%s\\n" "$tgt"; done > var/log/hook-output'
        NeedsTargets
        """);

p1 = pmpkg("foo")
p1.files = ["file/foo"]
self.addpkg(p1)

p2 = pmpkg("bar")
p2.files = ["file/bar"]
self.addpkg(p2)

self.args = "-U %s %s" % (p1.filename(), p2.filename())

self.addrule("PACMAN_RETCODE=0")
self.addrule("PKG_EXIST=foo")
self.addrule("FILE_CONTENTS=var/log/hook-output|file/bar\nfile/foo\nfoo\n")