1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from iniparse import INIConfig
import logging
import paramiko
import getopt
import sys
import os
def usage():
print """
rpmbuild-remote : Build an RPM on a remote system
rpmbuild-remote [options]... <files>...
--help Print this message
-c, --config <config> Configuration file to use for the build.
Default: ~/.rpmbuild-remote
-s, --system <system> The remote machine to use (defined in config
file)
-u, --user <username> The username on the remote system
Default: current user
-h, --host <host> The hostname/IP of the remote system
-p, --port <port> The port to use on the remote system
Default: 21
-d, --dest <dest> Directory to place resulting files
Default: ~/rpmbuild-remote/
-m, --mock <target> Use mock (only applies to SRPM files)
Default: None
files The list of files can contain either SRPM
files or a list starting with a spec file and
followed by sources for the package.
"""
def main(argv):
try:
opts, args = getopts.getopts(argv, "c:s:u:h:p:d:m:", ['config=', 'system=', 'user=', 'host=', 'port=', 'dest=', 'mock='])
except getopt.GetoptError, err:
print str(err)
usage()
sys.exit(1)
log = logging.getLogger('rpmbuild-remote')
home = os.path.expanduser('~')
config = os.path.join(home, '.rpmbuild-remote')
system = ''
user = os.getlogin()
host = ''
port = 21
dest = os.path.join(home, 'rpmbuild-remote')
mock = ''
jobs = []
for opt, val in opts:
if opt in ['c', 'config']:
config = val
elif opt in ['s', 'system']:
system = val
elif opt in ['u', 'user']:
user = val
elif opt in ['h', 'host']:
host = val
elif opt in ['p', 'port']:
port = val
elif opt in ['d', 'dest']:
dest = val
elif opt in ['m', 'mock']:
mock = val
elif opt in ['help']:
usage()
sys.exit(0)
for arg in args:
ext = arg.split('.')[-1]
if ext == 'srpm':
jobs.append([arg])
continue
if ext == 'spec':
jobs.append([arg])
continue
if ext not in ['gz', 'tgz', 'bz2', 'patch']:
log.warning("Uncommon source extension. Please double check files.")
if not jobs:
log.error("Source file given without spec file.")
sys.exit(1)
jobs[-1].append(arg)
if __name__ == '__main__':
main(sys.argv[1:])
|