Add emacs and vim editing settings to the bottom of *.py files.
[scons.git] / test / packaging / rpm / tagging.py
1 #!/usr/bin/env python
2 #
3 # __COPYRIGHT__
4 #
5 # Permission is hereby granted, free of charge, to any person obtaining
6 # a copy of this software and associated documentation files (the
7 # "Software"), to deal in the Software without restriction, including
8 # without limitation the rights to use, copy, modify, merge, publish,
9 # distribute, sublicense, and/or sell copies of the Software, and to
10 # permit persons to whom the Software is furnished to do so, subject to
11 # the following conditions:
12 #
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
15 #
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
17 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 #
24
25 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
26
27 """
28 Test the ability to add file tags
29 """
30
31 import os
32
33 import TestSCons
34
35 machine = TestSCons.machine
36 _python_ = TestSCons._python_
37
38 test = TestSCons.TestSCons()
39
40 scons = test.program
41
42 rpm = test.Environment().WhereIs('rpm')
43
44 if not rpm:
45     test.skip_test('rpm not found, skipping test\n')
46
47 rpm_build_root = test.workpath('rpm_build_root')
48
49 #
50 # Test adding an attr tag to the built program.
51 #
52 test.subdir('src')
53
54 test.write( [ 'src', 'main.c' ], r"""
55 int main( int argc, char* argv[] )
56 {
57 return 0;
58 }
59 """)
60
61 test.write('SConstruct', """
62 import os
63
64 env = Environment(tools=['default', 'packaging'])
65
66 env.Prepend(RPM = 'TAR_OPTIONS=--wildcards ')
67 env.Append(RPMFLAGS = r' --buildroot %(rpm_build_root)s')
68
69 install_dir= os.path.join( ARGUMENTS.get('prefix', '/'), 'bin/' )
70 prog_install = env.Install( install_dir , Program( 'src/main.c' ) )
71 env.Tag( prog_install, UNIX_ATTR = '(0755, root, users)' )
72 env.Alias( 'install', prog_install )
73
74 env.Package( NAME           = 'foo',
75              VERSION        = '1.2.3',
76              PACKAGETYPE    = 'rpm',
77              LICENSE        = 'gpl',
78              SUMMARY        = 'balalalalal',
79              PACKAGEVERSION = 0,
80              X_RPM_GROUP    = 'Applicatio/fu',
81              X_RPM_INSTALL  = r'%(_python_)s %(scons)s --install-sandbox="$RPM_BUILD_ROOT" "$RPM_BUILD_ROOT"',
82              DESCRIPTION    = 'this should be really really long',
83              source         = [ prog_install ],
84              SOURCE_URL     = 'http://foo.org/foo-1.2.3.tar.gz'
85           )
86 """ % locals())
87
88 test.run(arguments='', stderr = None)
89
90 src_rpm = 'foo-1.2.3-0.src.rpm'
91 machine_rpm = 'foo-1.2.3-0.%s.rpm' % machine
92
93 test.must_exist( machine_rpm )
94 test.must_exist( src_rpm )
95 test.fail_test( not os.popen('rpm -qpl %s' % machine_rpm).read()=='/bin/main\n')
96 test.fail_test( not os.popen('rpm -qpl %s' % src_rpm).read()=='foo-1.2.3.spec\nfoo-1.2.3.tar.gz\n')
97
98 expect = '(0755, root, users) /bin/main'
99 test.must_contain_all_lines(test.read('foo-1.2.3.spec'), [expect])
100
101 test.pass_test()
102
103 # Local Variables:
104 # tab-width:4
105 # indent-tabs-mode:nil
106 # End:
107 # vim: set expandtab tabstop=4 shiftwidth=4: