author | Brock Pytlik <bpytlik@sun.com> |
Mon, 16 Aug 2010 16:48:50 -0700 | |
changeset 2026 | d1b30615bc99 |
parent 1968 | c0540b1e4f7e |
child 2790 | ad2a0669d661 |
permissions | -rw-r--r-- |
1506
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
1 |
#!/usr/bin/python |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
2 |
# |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
3 |
# CDDL HEADER START |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
4 |
# |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
5 |
# The contents of this file are subject to the terms of the |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
6 |
# Common Development and Distribution License (the "License"). |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
7 |
# You may not use this file except in compliance with the License. |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
8 |
# |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
9 |
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
10 |
# or http://www.opensolaris.org/os/licensing. |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
11 |
# See the License for the specific language governing permissions |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
12 |
# and limitations under the License. |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
13 |
# |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
14 |
# When distributing Covered Code, include this CDDL HEADER in each |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
15 |
# file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
16 |
# If applicable, add the following below this CDDL HEADER, with the |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
17 |
# fields enclosed by brackets "[]" replaced with your own identifying |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
18 |
# information: Portions Copyright [yyyy] [name of copyright owner] |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
19 |
# |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
20 |
# CDDL HEADER END |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
21 |
# |
1903
460ef45c8ebd
15939 Need a easy way to format package manifests in a consistent style
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
1715
diff
changeset
|
22 |
# |
460ef45c8ebd
15939 Need a easy way to format package manifests in a consistent style
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
1715
diff
changeset
|
23 |
# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. |
460ef45c8ebd
15939 Need a easy way to format package manifests in a consistent style
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
1715
diff
changeset
|
24 |
# |
1506
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
25 |
|
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
26 |
import testutils |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
27 |
if __name__ == "__main__": |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
28 |
testutils.setup_environment("../../../proto") |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1679
diff
changeset
|
29 |
import pkg5unittest |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1679
diff
changeset
|
30 |
|
1506
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
31 |
import errno |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
32 |
import os |
1949
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
33 |
import re |
1506
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
34 |
import shutil |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
35 |
import stat |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
36 |
import sys |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
37 |
import tempfile |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
38 |
import unittest |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
39 |
|
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1679
diff
changeset
|
40 |
class TestPkgMogrify(pkg5unittest.CliTestCase): |
1949
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
41 |
"""Tests for the pkgmogrify publication tool.""" |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
42 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
43 |
persistent_setup = True |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
44 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
45 |
pkgcontents = """\ |
1506
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
46 |
# directories |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
47 |
dir group=bin mode=0755 owner=root path=usr/X11 |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
48 |
dir group=bin mode=0755 owner=root path=usr/X11/bin |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
49 |
dir group=bin mode=0755 owner=root path=usr/X11/include |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
50 |
dir group=bin mode=0755 owner=root path=usr/X11/include/X11 |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
51 |
# dependencies |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
52 |
depend [email protected]$(BUILDID) type=require |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
53 |
depend [email protected]$(BUILDID) type=require |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
54 |
depend [email protected]$(BUILDID) type=require |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
55 |
$(i386_ONLY)depend [email protected]$(BUILDID) type=require |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
56 |
file NOHASH elfarch=i386 elfbits=32 group=bin mode=0755 \ |
1903
460ef45c8ebd
15939 Need a easy way to format package manifests in a consistent style
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
1715
diff
changeset
|
57 |
owner=root path=usr/X11/bin/xkbprint |
1679
85a836145f8f
13792 on_ips needs abort and print operations for pkgmogrify's transform directive
Mark J. Nelson <Mark.J.Nelson@Sun.COM>
parents:
1506
diff
changeset
|
58 |
file NOHASH group=bin mode=0755 owner=root path=usr/X11/bin/Xserver |
1903
460ef45c8ebd
15939 Need a easy way to format package manifests in a consistent style
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
1715
diff
changeset
|
59 |
file NOHASH group=bin mode=0755 owner=root path=usr/X11/bin/bdftopcf |
1506
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
60 |
link path=usr/X11/lib/libXdmcp.so target=./libXdmcp.so.6 |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
61 |
link path=usr/X11/lib/libXevie.so target=./libXevie.so.1 |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
62 |
link path=usr/X11/lib/libXext.so target=./libXext.so.0 |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
63 |
link path=usr/X11/lib/libXfixes.so target=./libXfixes.so.1 |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
64 |
link path=usr/X11/lib/libXi.so target=./libXi.so.5 |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
65 |
link path=usr/X11/lib/libXinerama.so target=./libXinerama.so.1 |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
66 |
link path=usr/X11/lib/libXmu.so target=./libXmu.so.4 |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
67 |
""" |
1949
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
68 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
69 |
pkgcontents2 = """\ |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
70 |
set name=pkg.fmri value=wombat/[email protected],5.11-0.101 |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
71 |
set name=bugs value=12345 value=54321 value=13524 |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
72 |
set name=justonebug value=12345 |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
73 |
file thisismyhashvalue path=usr/bin/foo mode=0777 owner=root group=bin |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
74 |
file thisismyotherhashvalue path=usr/sfw/bin/foo mode=0777 owner=root group=bin |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
75 |
file path=usr/bin/bar mode=0777 owner=root group=bin |
1950
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
76 |
depend type=require fmri=__TBD path=usr/bin/foo mode=0755 |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
77 |
file NOHASH path="'/usr/bin/quotedpath'" moo=cowssayit |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
78 |
file NOHASH path=usr/share/locale/de/foo.mo |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
79 |
file NOHASH path=usr/share/locale/fr/foo.mo locale.fr=oui |
1955
81dd10fe5255
16023 pkgsend generate should provide a way to distinguish files from hardlinks
Danek Duvall <danek.duvall@oracle.com>
parents:
1950
diff
changeset
|
80 |
set name=pkg.summary value="Doo wah diddy" |
81dd10fe5255
16023 pkgsend generate should provide a way to distinguish files from hardlinks
Danek Duvall <danek.duvall@oracle.com>
parents:
1950
diff
changeset
|
81 |
legacy pkg=SUNWwombat version=3 |
1949
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
82 |
""" |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
83 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
84 |
pkgcontents3 = """\ |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
85 |
$(i386_ONLY)file NOHASH path=kernel/drv/x86_only1 reboot-needed=true |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
86 |
$(i386_ONLY)file NOHASH path=kernel/drv/x86_only2 reboot-needed=true |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
87 |
$(sparc_ONLY)file NOHASH path=kernel/drv/sparc_only1 reboot-needed=true |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
88 |
$(sparc_ONLY)file NOHASH path=kernel/drv/sparc_only2 reboot-needed=true |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
89 |
file NOHASH path=kernel/drv/common1 reboot-needed=true |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
90 |
file NOHASH path=kernel/drv/common2 reboot-needed=true |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
91 |
""" |
1506
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
92 |
|
1949
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
93 |
# Give names to simple transforms. These transforms can use <include> |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
94 |
# by referring to the named transforms using the %()s construct. |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
95 |
transforms = { |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
96 |
"X11->Y11": "<transform file link dir -> edit path X11 Y11>", |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
97 |
"drop xkbprint": "<transform file path='.*xkbprint.*' -> drop>", |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
98 |
"X11mode": "<transform file path='usr/X11/bin/.*' -> set mode 0555>", |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
99 |
"drop mode=0755": "<transform file -> delete mode 0755> ", |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
100 |
"empty": "<transform file >", |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
101 |
"empty edit": "<transform file -> edit bar >", |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
102 |
"2include": "<include %(X11->Y11)s>\n<include %(X11mode)s>", |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
103 |
"include 9": "<include %(include 5)s>", |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
104 |
"include 5": "<include %(empty)s>", |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
105 |
"add bobcat": "<transform file -> add bobcat 1>", |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
106 |
"print ouch": '<transform file bobcat=1 -> print "ouch" >', |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
107 |
"abort on bobcat": "<transform file bobcat=1 -> abort >", |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
108 |
"exit7 on bobcat": "<transform file bobcat=1 -> exit 7>", |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
109 |
"exit6 on bobcat": "<transform file bobcat=1 -> exit 6 found a bobcat>", |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
110 |
"pkg.fmri": "<transform file path=usr/bin/foo -> print pkg attr \"%%{pkg.fmri}\" and the rest>", |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
111 |
"pkg.bugs": "<transform file path=usr/bin/foo -> print pkg attr \"%%{bugs}\" and the rest>", |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
112 |
"fmrival": "<transform set name=pkg.fmri -> print test of \"%%(value)\" ... or is it?>", |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
113 |
"fmrinoval": "<transform set name=pkg.fmri -> print test of \"%%(valuee)\" ... or is it?>", |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
114 |
"fmrisaved": "<transform set name=pkg.fmri -> print test of \"%%(valuee;notfound=noprint)\" ... or is it?>", |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
115 |
"fmriqsaved": "<transform set name=pkg.fmri -> print test of \"%%(valuee;notfound=\"got quotes\")\" ... or is it?>", |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
116 |
"fmrinotsaved": "<transform set name=pkg.fmri -> print test of \"%%(value;notfound=noprint)\" ... or is it?>", |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
117 |
"list": "<transform set name=bugs -> print test of listval \"%%(value)\">", |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
118 |
"listsep": "<transform set name=bugs -> print test of listval \"%%(value;sep=\",\")\">", |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
119 |
"listsufpresep": "<transform set name=bugs -> print test of listval \"%%(value;sep=\", \";prefix=\"bug='\";suffix=\"'\")\">", |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
120 |
"nolistsufpre": "<transform set name=justonebug -> print test of \"%%(value;prefix=\"bug='\";suffix=\"'\")\">", |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
121 |
"emitblank": "<transform set name=pkg.fmri -> emit>", |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
122 |
"emitcomment": "<transform set name=pkg.fmri -> emit # comment>", |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
123 |
"emitaction": "<transform set name=pkg.fmri -> emit depend type=incorporate fmri=%%(value)>", |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
124 |
"synthetic": "<transform file path=usr/bin/foo -> print %%(pkg.manifest.filename) %%(pkg.manifest.lineno)>", |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
125 |
"synthetic2": "<transform file path=usr/bin/foo -> print %%(action.hash) %%(action.key) %%(action.name)>", |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
126 |
"synthetic3": "<transform file -> print %%(action.hash)>", |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
127 |
"synthetic4": "<transform set -> print %%(action.hash)>", |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
128 |
"synthetic5": "<transform set -> print %%(action.hash;notfound=something)>", |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
129 |
"pkgmatch": "<transform pkg -> default $(MYATTR) false>", |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
130 |
"pkggen": "<transform pkg $(MYATTR)=false -> emit depend fmri=consolidation type=require>", |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
131 |
"recurse": "<transform file mode=0777 -> emit file path=usr/bin/bar mode=0777>", |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
132 |
"rbneeded": "<transform file reboot-needed=true -> emit set name=magic value=true>", |
1950
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
133 |
"brdefault": "<transform depend fmri=__TBD path=([^/]*)/([^/]*)/ mode=0(.)55 -> default pkg.debug.depend.path %%<1>/%%<2>>", |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
134 |
"brdefault2": "<transform depend fmri=__TBD mode=0(.)55 path=([^/]*)/([^/]*)/ -> default pkg.debug.depend.path %%<2>/%%<3>>", |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
135 |
"brdefault3": "<transform depend fmri=__TBD mode=0(.)55 path=([^/]*)/([^/]*)/ -> default pkg.debug.depend.path %%<2>/%%<4>>", |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
136 |
"brdefault3a": "<transform depend fmri=__TBD mode=0(.)55 path=([^/]*)/([^/]*)/ -> default pkg.debug.depend.path %%<2>/%%<0>>", |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
137 |
"brdefault4": "<transform file path=usr/share/locale/([^/]+).* -> default locale.%%<1> true>", |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
138 |
"brweirdquote": "<transform file moo=(.*) path='\\'.*/([^/]*)\\'' -> default refs %%<1>,%%<2>>", |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
139 |
"bradd": "<transform file path=usr/share/locale/([^/]+).* -> add locale.%%<1> true>", |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
140 |
"brset": "<transform file path=usr/share/locale/([^/]+).* -> set locale.%%<1> true>", |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
141 |
"bredit": "<transform file path=usr/share/locale/([^/]+).* -> edit path .*/([^/]*\\.mo) another/place/for/locales/%%<1>/\\\\1>", |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
142 |
"bredit2": "<transform file path=usr/share/locale/([^/]+).* -> edit path %%<1> LANG>", |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
143 |
"edit1": "<transform file path=usr/(share|lib)/locale.* -> edit path usr/(lib|share)/locale place/\\\\1/langs>", |
1955
81dd10fe5255
16023 pkgsend generate should provide a way to distinguish files from hardlinks
Danek Duvall <danek.duvall@oracle.com>
parents:
1950
diff
changeset
|
144 |
"doublequote": "<transform legacy -> default name %%{pkg.summary}>", |
1949
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
145 |
} |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
146 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
147 |
basic_defines = { |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
148 |
"i386_ONLY": "#", |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
149 |
"BUILDID": 0.126 |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
150 |
} |
1506
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
151 |
|
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
152 |
def setUp(self): |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1679
diff
changeset
|
153 |
pkg5unittest.CliTestCase.setUp(self) |
1506
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
154 |
|
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1679
diff
changeset
|
155 |
f = file(os.path.join(self.test_root, "source_file"), "wb") |
1506
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
156 |
f.write(self.pkgcontents) |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
157 |
f.close() |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
158 |
|
1949
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
159 |
f = file(os.path.join(self.test_root, "source_file2"), "wb") |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
160 |
f.write(self.pkgcontents2) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
161 |
f.close() |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
162 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
163 |
f = file(os.path.join(self.test_root, "source_file3"), "wb") |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
164 |
f.write(self.pkgcontents3) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
165 |
f.close() |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
166 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
167 |
# Map the transform names to path names |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
168 |
xformpaths = dict(( |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
169 |
(name, os.path.join(self.test_root, "transform_%s" % i)) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
170 |
for i, name in enumerate(self.transforms.iterkeys()) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
171 |
)) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
172 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
173 |
# Now that we have path names, we can use the expandos in the |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
174 |
# transform contents to embed those pathnames, and write the |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
175 |
# transform files out. |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
176 |
for name, path in xformpaths.iteritems(): |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
177 |
f = file(path, "wb") |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
178 |
self.transforms[name] %= xformpaths |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
179 |
f.write(self.transforms[name]) |
1506
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
180 |
f.close() |
1679
85a836145f8f
13792 on_ips needs abort and print operations for pkgmogrify's transform directive
Mark J. Nelson <Mark.J.Nelson@Sun.COM>
parents:
1506
diff
changeset
|
181 |
|
1949
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
182 |
self.transform_contents = self.transforms |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
183 |
self.transforms = xformpaths |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
184 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
185 |
def pkgmogrify(self, sources, defines=None, output=None, args="", exit=0): |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
186 |
if defines is None: |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
187 |
defines = self.basic_defines |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
188 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
189 |
defines = " ".join([ |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
190 |
"-D %s=%s" % (k, v) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
191 |
for k, v in defines.iteritems() |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
192 |
]) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
193 |
sources = " ".join(sources) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
194 |
if output: |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
195 |
args += " -O %s" % output |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
196 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
197 |
cmd = "%s/usr/bin/pkgmogrify %s %s %s" % ( |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
198 |
pkg5unittest.g_proto_area, defines, args, sources) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
199 |
|
1506
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
200 |
self.cmdline_run(cmd, exit=exit) |
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
201 |
|
1949
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
202 |
def __countMatches(self, regex, path=None): |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
203 |
"""Count how many lines in the output of the previously run |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
204 |
command match the regular expression 'regex'. If 'path' is |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
205 |
specified, the contents of that file are searched.""" |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
206 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
207 |
if path is not None: |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
208 |
output = file(path).read() |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
209 |
else: |
1968
c0540b1e4f7e
8722 advanced repository metadata store needed
Shawn Walker <shawn.walker@oracle.com>
parents:
1955
diff
changeset
|
210 |
output = self.output + self.errout |
1949
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
211 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
212 |
c = sum(( |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
213 |
int(bool(re.search(regex, line))) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
214 |
for line in output.splitlines() |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
215 |
)) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
216 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
217 |
return c |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
218 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
219 |
def assertMatch(self, regex, path=None, count=0): |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
220 |
"""Assert that the regular expression 'regex' matches in the |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
221 |
output of the previously run command. If 'path' is specified, |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
222 |
the contents of that file are searched. If 'count' is greater |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
223 |
than zero, then the number of lines which match must equal that |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
224 |
number.""" |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
225 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
226 |
c = self.__countMatches(regex, path) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
227 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
228 |
self.failIf(count == c == 0, |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
229 |
"No matches for '%s' found" % regex) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
230 |
if count > 0: |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
231 |
self.failUnless(c == count, |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
232 |
"%s matches for '%s' found, %s expected" % |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
233 |
(c, regex, count)) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
234 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
235 |
def assertNoMatch(self, regex, path=None): |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
236 |
"""Assert that the regular expression 'regex' is not found in |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
237 |
the output of the previously run command. If 'path' is |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
238 |
specified, the contents of that file are searched.""" |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
239 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
240 |
c = self.__countMatches(regex, path) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
241 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
242 |
self.assert_(c == 0, "Match for '%s' found unexpectedly" % regex) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
243 |
|
1506
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
244 |
def test_1(self): |
1949
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
245 |
"""Basic and nested macro substitution. Allow a macro to |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
246 |
comment out a manifest line.""" |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
247 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
248 |
source_file = os.path.join(self.test_root, "source_file") |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
249 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
250 |
sources = [ source_file ] |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
251 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
252 |
# Lines commented out by macros remain in the output. |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
253 |
self.pkgmogrify(sources) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
254 |
self.assertNoMatch("^[^#].*SUNWxorg-mesa") |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
255 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
256 |
defines = self.basic_defines.copy() |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
257 |
defines["i386_ONLY"] = " " |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
258 |
self.pkgmogrify(sources, defines=defines) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
259 |
self.assertMatch("SUNWxorg-mesa") |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
260 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
261 |
# nested macros |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
262 |
defines["BUILDID"] = "$(FOO)"; defines["FOO"] = "0.126" |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
263 |
self.pkgmogrify(sources, defines=defines) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
264 |
self.assertMatch("SUNWxorg-mesa") |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
265 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
266 |
def test_2(self): |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
267 |
"""The -O option: output goes to a file rather than stdout.""" |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
268 |
|
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1679
diff
changeset
|
269 |
source_file = os.path.join(self.test_root, "source_file") |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1679
diff
changeset
|
270 |
output_file = os.path.join(self.test_root, "output_file") |
1679
85a836145f8f
13792 on_ips needs abort and print operations for pkgmogrify's transform directive
Mark J. Nelson <Mark.J.Nelson@Sun.COM>
parents:
1506
diff
changeset
|
271 |
|
1949
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
272 |
sources = [ source_file ] |
1506
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
273 |
|
1949
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
274 |
defines = self.basic_defines.copy() |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
275 |
defines["i386_ONLY"] = " " |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
276 |
self.pkgmogrify(sources, defines=defines, output=output_file) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
277 |
self.assertMatch("[email protected]", path=output_file) |
1679
85a836145f8f
13792 on_ips needs abort and print operations for pkgmogrify's transform directive
Mark J. Nelson <Mark.J.Nelson@Sun.COM>
parents:
1506
diff
changeset
|
278 |
|
1506
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
279 |
def test_3(self): |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1679
diff
changeset
|
280 |
source_file = os.path.join(self.test_root, "source_file") |
1949
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
281 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
282 |
self.pkgmogrify([self.transforms["X11->Y11"], source_file]) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
283 |
self.assertNoMatch("X11") |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
284 |
self.assertMatch("Y11") |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
285 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
286 |
self.pkgmogrify([self.transforms["add bobcat"], source_file]) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
287 |
self.assertMatch("bobcat", count=3) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
288 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
289 |
self.pkgmogrify([self.transforms["drop mode=0755"], source_file]) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
290 |
self.assertNoMatch("^file.*mode=0755") |
1679
85a836145f8f
13792 on_ips needs abort and print operations for pkgmogrify's transform directive
Mark J. Nelson <Mark.J.Nelson@Sun.COM>
parents:
1506
diff
changeset
|
291 |
|
1506
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
292 |
def test_4(self): |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1679
diff
changeset
|
293 |
source_file = os.path.join(self.test_root, "source_file") |
1949
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
294 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
295 |
self.pkgmogrify([self.transforms["drop xkbprint"], source_file]) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
296 |
self.assertNoMatch("xkbprint") |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
297 |
# Make sure that the line really got dropped, not just changed |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
298 |
# unrecognizably. |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
299 |
self.assertMatch("^.*$", count=19) |
1679
85a836145f8f
13792 on_ips needs abort and print operations for pkgmogrify's transform directive
Mark J. Nelson <Mark.J.Nelson@Sun.COM>
parents:
1506
diff
changeset
|
300 |
|
1506
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
301 |
def test_5(self): |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1679
diff
changeset
|
302 |
source_file = os.path.join(self.test_root, "source_file") |
1949
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
303 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
304 |
# Basic attribute editing. |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
305 |
self.pkgmogrify([self.transforms["X11mode"], source_file]) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
306 |
self.assertMatch("file NOHASH group=bin mode=0555 owner=root " |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
307 |
"path=usr/X11/bin/Xserver") |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
308 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
309 |
# Ensure that modifying an attribute used as matching criteria |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
310 |
# by a later transform means that the later transform is not |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
311 |
# invoked. |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
312 |
self.pkgmogrify([self.transforms["X11->Y11"], |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
313 |
self.transforms["X11mode"], source_file]) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
314 |
self.assertMatch("file NOHASH group=bin mode=0755 owner=root " |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
315 |
"path=usr/Y11/bin/Xserver") |
1506
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
316 |
|
1949
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
317 |
# Make sure that the -I flag works, with files specified on the |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
318 |
# commandline as well as ones <include>d by others. |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
319 |
self.pkgmogrify([os.path.basename(self.transforms["2include"]), |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
320 |
source_file], args="-I %s" % self.test_root) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
321 |
self.assertMatch("file NOHASH group=bin mode=0755 owner=root " |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
322 |
"path=usr/Y11/bin/Xserver") |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
323 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
324 |
# Ensure that modifying an attribute used as matching criteria |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
325 |
# by an earlier transform doesn't prevent the earlier transform |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
326 |
# from being invoked. |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
327 |
self.pkgmogrify([self.transforms["X11mode"], |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
328 |
self.transforms["X11->Y11"], source_file]) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
329 |
self.assertMatch("file NOHASH group=bin mode=0555 owner=root " |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
330 |
"path=usr/Y11/bin/Xserver") |
1679
85a836145f8f
13792 on_ips needs abort and print operations for pkgmogrify's transform directive
Mark J. Nelson <Mark.J.Nelson@Sun.COM>
parents:
1506
diff
changeset
|
331 |
|
1506
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
332 |
def test_6(self): |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1679
diff
changeset
|
333 |
source_file = os.path.join(self.test_root, "source_file") |
1949
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
334 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
335 |
# If NOHASH is omitted from the original manifest, check that it |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
336 |
# gets added. |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
337 |
self.pkgmogrify([self.transforms["X11mode"], |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
338 |
self.transforms["X11->Y11"], source_file]) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
339 |
self.assertMatch("file NOHASH group=bin mode=0555 owner=root " |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
340 |
"path=usr/Y11/bin/bdftopcf") |
1506
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
341 |
|
9c8b3a3184be
12373 Need a programatic way of transforming manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
diff
changeset
|
342 |
def test_7(self): |
1949
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
343 |
"""Test various error conditions.""" |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
344 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
345 |
source_file = os.path.join(self.test_root, "source_file") |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
346 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
347 |
# Bad argument |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
348 |
self.pkgmogrify([], args="--froob", exit=2) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
349 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
350 |
# Bad transform |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
351 |
self.pkgmogrify([self.transforms["empty edit"], source_file], |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
352 |
exit=1) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
353 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
354 |
# file not found XXX this fails because of a bad transform |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
355 |
self.pkgmogrify([self.transforms["include 9"]], exit=1) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
356 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
357 |
# nested tranform error XXX this fails because of a bad transform |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
358 |
self.pkgmogrify([self.transforms["include 9"]], |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
359 |
args="-I %s" % self.test_root, exit=1) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
360 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
361 |
# Wombats! |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
362 |
self.pkgmogrify(["/wombat-farm"], exit=1) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
363 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
364 |
def test_8(self): |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
365 |
"""Test for graceful exit with no output on abort.""" |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
366 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
367 |
source_file = os.path.join(self.test_root, "source_file") |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
368 |
no_output = os.path.join(self.test_root, "no_output") |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
369 |
no_print = os.path.join(self.test_root, "no_print") |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
370 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
371 |
# Add an abort transform that's expected to trigger. This |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
372 |
# should cover the "exit gracefully" part of abort. |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
373 |
self.pkgmogrify([self.transforms["add bobcat"], |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
374 |
self.transforms["abort on bobcat"], source_file], |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
375 |
output=no_output, args="-P %s" % no_print) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
376 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
377 |
# Make sure neither output nor print file was created. |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
378 |
self.failIf(os.access(no_output, os.F_OK)) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
379 |
self.failIf(os.access(no_print, os.F_OK)) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
380 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
381 |
# Trigger an exit transform with a specific exit code. |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
382 |
self.pkgmogrify([self.transforms["add bobcat"], |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
383 |
self.transforms["exit7 on bobcat"], source_file], |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
384 |
output=no_output, args="-P %s" % no_print, exit=7) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
385 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
386 |
# Make sure neither output nor print file was created. |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
387 |
self.failIf(os.access(no_output, os.F_OK)) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
388 |
self.failIf(os.access(no_print, os.F_OK)) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
389 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
390 |
# Trigger an exit transform with a specific exit code and |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
391 |
# message. |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
392 |
self.pkgmogrify([self.transforms["add bobcat"], |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
393 |
self.transforms["exit6 on bobcat"], source_file], |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
394 |
output=no_output, args="-P %s" % no_print, exit=6) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
395 |
self.assertMatch("found a bobcat") |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
396 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
397 |
def test_9(self): |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
398 |
"""Test for print output to specified file.""" |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
399 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
400 |
source_file = os.path.join(self.test_root, "source_file") |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
401 |
output_file = os.path.join(self.test_root, "output_file") |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
402 |
print_file = os.path.join(self.test_root, "print_file") |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
403 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
404 |
# Generate output for each file action, and count resulting |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
405 |
# lines in print file to be sure it matches our expectations. |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
406 |
defines = self.basic_defines.copy() |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
407 |
defines["i386_ONLY"] = " " |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
408 |
self.pkgmogrify([self.transforms["add bobcat"], |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
409 |
self.transforms["print ouch"], source_file], |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
410 |
defines=defines, output=output_file, |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
411 |
args="-P %s" % print_file) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
412 |
self.assertMatch("ouch", path=print_file, count=3) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
413 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
414 |
def test_10(self): |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
415 |
"""Test to make sure we can handle leading macros, preserve comments""" |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
416 |
|
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1679
diff
changeset
|
417 |
source_file = os.path.join(self.test_root, "source_file") |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1679
diff
changeset
|
418 |
output_file = os.path.join(self.test_root, "output_file") |
1679
85a836145f8f
13792 on_ips needs abort and print operations for pkgmogrify's transform directive
Mark J. Nelson <Mark.J.Nelson@Sun.COM>
parents:
1506
diff
changeset
|
419 |
|
1949
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
420 |
self.pkgmogrify([source_file], output=output_file, defines={}) |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1968
diff
changeset
|
421 |
self.cmdline_run("diff %s %s" % (source_file, output_file), |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1968
diff
changeset
|
422 |
coverage=False) |
1949
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
423 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
424 |
def test_11(self): |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
425 |
"""Test the generation of new actions.""" |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
426 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
427 |
source_file = os.path.join(self.test_root, "source_file2") |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
428 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
429 |
# The emit operation can emit a blank line ... |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
430 |
self.pkgmogrify([self.transforms["emitblank"], source_file]) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
431 |
self.assertMatch("^$") |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
432 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
433 |
# ... or a comment ... |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
434 |
self.pkgmogrify([self.transforms["emitcomment"], source_file]) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
435 |
self.assertMatch("^# comment$") |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
436 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
437 |
# ... or an action ... |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
438 |
self.pkgmogrify([self.transforms["emitaction"], source_file]) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
439 |
self.assertMatch("^depend fmri=wombat/[email protected],5.11-0.101 type=incorporate") |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
440 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
441 |
# Recursive transforms shouldn't blow up. |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
442 |
self.pkgmogrify([self.transforms["recurse"], source_file], |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
443 |
exit=1) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
444 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
445 |
# Emitted actions shouldn't be duplicated, modulo a macro |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
446 |
# prefix. |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
447 |
source_file = os.path.join(self.test_root, "source_file3") |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
448 |
defines = self.basic_defines.copy() |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
449 |
del defines["i386_ONLY"] |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
450 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
451 |
self.pkgmogrify([self.transforms["rbneeded"], source_file], |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
452 |
defines=defines) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
453 |
self.assertMatch("name=magic", count=3) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
454 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
455 |
def test_12(self): |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
456 |
"""Test the use of action attributes.""" |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
457 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
458 |
source_file = os.path.join(self.test_root, "source_file2") |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
459 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
460 |
expect = "^test of \"%s\" ... or is it\?$" |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
461 |
fmri = "wombat/[email protected],5.11-0.101" |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
462 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
463 |
# Simple %() replacement |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
464 |
self.pkgmogrify([self.transforms["fmrival"], source_file]) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
465 |
self.assertMatch(expect % fmri) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
466 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
467 |
# We should exit with an error and exit code 1 when the %() |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
468 |
# replacement fails because of a missing attribute. |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
469 |
self.pkgmogrify([self.transforms["fmrinoval"], source_file], |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
470 |
exit=1) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
471 |
self.assertMatch("'valuee' not found") |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
472 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
473 |
# When the attribute is missing but a notfound token is present, |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
474 |
# we should see that value show up. |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
475 |
self.pkgmogrify([self.transforms["fmrisaved"], source_file]) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
476 |
self.assertMatch(expect % "noprint") |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
477 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
478 |
# If the notfound value has quotes, the quoted value should show |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
479 |
# up, and the quotes dropped. |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
480 |
self.pkgmogrify([self.transforms["fmriqsaved"], source_file]) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
481 |
self.assertMatch(expect % '"got quotes"') |
1679
85a836145f8f
13792 on_ips needs abort and print operations for pkgmogrify's transform directive
Mark J. Nelson <Mark.J.Nelson@Sun.COM>
parents:
1506
diff
changeset
|
482 |
|
1949
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
483 |
# When a notfound value is present, but the original attribute |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
484 |
# is also present, the notfound value should be ignored. |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
485 |
self.pkgmogrify([self.transforms["fmrinotsaved"], source_file]) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
486 |
self.assertMatch(expect % fmri) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
487 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
488 |
# Basic list-valued attribute |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
489 |
self.pkgmogrify([self.transforms["list"], source_file]) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
490 |
self.assertMatch("^test of listval \"12345 54321 13524\"$") |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
491 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
492 |
# List-valued attribute with a separator |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
493 |
self.pkgmogrify([self.transforms["listsep"], source_file]) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
494 |
self.assertMatch("^test of listval \"12345,54321,13524\"$") |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
495 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
496 |
# List-valued attribute with a prefix, suffix, and separator |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
497 |
self.pkgmogrify([self.transforms["listsufpresep"], source_file]) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
498 |
self.assertMatch("^test of listval \"bug='12345', bug='54321', " |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
499 |
"bug='13524'\"$") |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
500 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
501 |
# Singly-valued attribute with a prefix and suffix |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
502 |
self.pkgmogrify([self.transforms["nolistsufpre"], source_file]) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
503 |
self.assertMatch("^test of \"bug='12345'\"$") |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
504 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
505 |
# Synthetic attributes |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
506 |
self.pkgmogrify([self.transforms["synthetic"], source_file]) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
507 |
self.assertMatch("^%s 4$" % source_file) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
508 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
509 |
# Synthetic attributes |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
510 |
self.pkgmogrify([self.transforms["synthetic2"], source_file]) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
511 |
self.assertMatch("^thisismyhashvalue usr/bin/foo file$") |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
512 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
513 |
# The "action.hash" attribute shouldn't cause a problem when a |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
514 |
# file action doesn't specify the hash in the manifest. |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
515 |
self.pkgmogrify([self.transforms["synthetic3"], source_file]) |
1679
85a836145f8f
13792 on_ips needs abort and print operations for pkgmogrify's transform directive
Mark J. Nelson <Mark.J.Nelson@Sun.COM>
parents:
1506
diff
changeset
|
516 |
|
1949
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
517 |
# The "action.hash" attribute shouldn't explode when an action |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
518 |
# which doesn't have one tries to use it. |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
519 |
self.pkgmogrify([self.transforms["synthetic4"], source_file], |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
520 |
exit=1) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
521 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
522 |
# The "action.hash" attribute can have a "notfound" value. |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
523 |
self.pkgmogrify([self.transforms["synthetic5"], source_file]) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
524 |
self.assertMatch("^something$") |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
525 |
|
1955
81dd10fe5255
16023 pkgsend generate should provide a way to distinguish files from hardlinks
Danek Duvall <danek.duvall@oracle.com>
parents:
1950
diff
changeset
|
526 |
self.pkgmogrify([self.transforms["doublequote"], source_file]) |
81dd10fe5255
16023 pkgsend generate should provide a way to distinguish files from hardlinks
Danek Duvall <danek.duvall@oracle.com>
parents:
1950
diff
changeset
|
527 |
self.assertNoMatch("^legacy .*'\"") |
81dd10fe5255
16023 pkgsend generate should provide a way to distinguish files from hardlinks
Danek Duvall <danek.duvall@oracle.com>
parents:
1950
diff
changeset
|
528 |
|
1949
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
529 |
def test_13(self): |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
530 |
"""Test the use of package attributes.""" |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
531 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
532 |
source_file = os.path.join(self.test_root, "source_file2") |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
533 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
534 |
# Simple valued |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
535 |
self.pkgmogrify([self.transforms["pkg.fmri"], source_file]) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
536 |
self.assertMatch('^pkg attr "wombat/[email protected],5.11-0.101" and ' |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
537 |
'the rest$') |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
538 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
539 |
# List valued |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
540 |
self.pkgmogrify([self.transforms["pkg.bugs"], source_file]) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
541 |
self.assertMatch('^pkg attr "12345 54321 13524" and the rest$') |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
542 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
543 |
defines = self.basic_defines.copy() |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
544 |
defines["MYATTR"] = "pkg.obsolete" |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
545 |
# Match on package attributes, and generate temporary ones |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
546 |
self.pkgmogrify([self.transforms["pkgmatch"], |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
547 |
self.transforms["pkggen"], source_file], defines=defines) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
548 |
self.assertMatch("^depend fmri=consolidation type=require$") |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
549 |
|
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
550 |
# If we don't match, don't generate |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
551 |
defines["MYATTR"] = "bugs" |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
552 |
self.pkgmogrify([self.transforms["pkgmatch"], |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
553 |
self.transforms["pkggen"], source_file], defines=defines) |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
554 |
self.assertNoMatch("^depend fmri=consolidation type=require$") |
ed836bef8b90
14052 pkgmogrify: extended output capabilities could simplify complex publication makefiles
Danek Duvall <danek.duvall@oracle.com>
parents:
1903
diff
changeset
|
555 |
|
1950
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
556 |
def test_14(self): |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
557 |
"""Test the use of backreferences to the matching portion of the |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
558 |
transform.""" |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
559 |
|
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
560 |
source_file = os.path.join(self.test_root, "source_file2") |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
561 |
|
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
562 |
# Basic test of backreferences, using the default operation. |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
563 |
self.pkgmogrify([self.transforms["brdefault"], source_file]) |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
564 |
self.assertMatch("pkg.debug.depend.path=usr/bin($| )") |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
565 |
|
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
566 |
# Same operation, but reorder the match criteria (and the |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
567 |
# references to match) to show that the reference numbers are |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
568 |
# based on the literal order of the match criteria, rather than |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
569 |
# some internal storage mechanism. |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
570 |
self.pkgmogrify([self.transforms["brdefault2"], source_file]) |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
571 |
self.assertMatch("pkg.debug.depend.path=usr/bin($| )") |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
572 |
|
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
573 |
# A reference to a group that doesn't exist should die |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
574 |
# gracefully. |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
575 |
self.pkgmogrify([self.transforms["brdefault3"], source_file], |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
576 |
exit=1) |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
577 |
|
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
578 |
# A reference to group 0 should die gracefully. |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
579 |
self.pkgmogrify([self.transforms["brdefault3a"], source_file], |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
580 |
exit=1) |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
581 |
|
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
582 |
# A backreference may very well be used as part of an attribute |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
583 |
# name. Make sure that the "default" operation takes the fully |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
584 |
# substituted attribute name into account. |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
585 |
self.pkgmogrify([self.transforms["brdefault4"], source_file]) |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
586 |
self.assertMatch("locale.de=true") |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
587 |
self.assertMatch("locale.fr=oui") |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
588 |
|
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
589 |
# Quoting in a match attribute may not agree with the quoting |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
590 |
# that actions use, confusing the mechanism we use to ensure |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
591 |
# backreference numbers refer to the right groups. Make sure |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
592 |
# we don't tip over, but show that we didn't get the backrefs |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
593 |
# right. The right solution for this is probably to have a |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
594 |
# mode for fromstr() that returns a list rather than a dict. |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
595 |
self.pkgmogrify([self.transforms["brweirdquote"], source_file]) |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
596 |
# XXX # self.assertMatch("refs=cowssayit,quotedpath") |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
597 |
|
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
598 |
# A "set" operation with a backreference works. |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
599 |
self.pkgmogrify([self.transforms["brset"], source_file]) |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
600 |
self.assertMatch("locale.de=true") |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
601 |
self.assertMatch("locale.fr=true") |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
602 |
|
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
603 |
# An "add" operation with a backreference works. |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
604 |
self.pkgmogrify([self.transforms["bradd"], source_file]) |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
605 |
self.assertMatch("locale.de=true", count=1) |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
606 |
self.assertMatch("locale.fr=oui", count=1) |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
607 |
self.assertMatch("locale.fr=true", count=1) |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
608 |
|
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
609 |
# This is the "normal" kind of backreferencing, only available |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
610 |
# for the "edit" operation, where a \1 in the replacement string |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
611 |
# refers to a group in the regex string, all on the operation |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
612 |
# side of the transform. |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
613 |
self.pkgmogrify([self.transforms["edit1"], source_file]) |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
614 |
self.assertMatch("path=place/share/langs/de/foo.mo") |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
615 |
|
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
616 |
# An "edit" operation with a backreference in the replacement |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
617 |
# value works. This one also uses the \1-style backreference. |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
618 |
self.pkgmogrify([self.transforms["bredit"], source_file]) |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
619 |
self.assertMatch("path=another/place/for/locales/de/foo.mo") |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
620 |
|
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
621 |
# An "edit" operation with a backreference in the matching |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
622 |
# expression works. |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
623 |
self.pkgmogrify([self.transforms["bredit2"], source_file]) |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
624 |
self.assertMatch("path=usr/share/locale/LANG/foo.mo") |
79501d918477
16156 pkgmogrify should allow backreferences in operation to match criteria
Danek Duvall <danek.duvall@oracle.com>
parents:
1949
diff
changeset
|
625 |
|
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1679
diff
changeset
|
626 |
if __name__ == "__main__": |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1679
diff
changeset
|
627 |
unittest.main() |