forked from zy-sunshine/magicinstaller2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SConstruct-mi
120 lines (102 loc) · 4.11 KB
/
SConstruct-mi
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# -*- python -*-
Import('*')
import os
import glob
use_cp_mode = mi_config.use_copy_install_mode
##### Construct the root.src.tar.gz
## and something to fix(like copy install mode files fix)
class miSrcMaker(PkgMaker.StepMaker):
target_list = ['bindir/root.src.tar.gz']
ROOT = '$tmpdir/root.src'
steps = ['init_dir',
'install_src_step1',
'install_src_pyext',
'install_configfiles',
'install_tranlatefiles',
'install_post',
'install_fix',
'mkmisrc',
]
def init_dir(self):
cmds = ['rm -rf $ROOT',
'mkdir -p $ROOT']
return [], cmds
def install_src_step1(self):
inst_file = ['bindir/root.src.step1.tar.gz']
cmds = [self.get_extract_cmd('bindir/root.src.step1.tar.gz', self.ROOT)]
return inst_file, cmds
def install_src_pyext(self):
# Install python extention module for MI, the package have been packed
# in the develop mode.
inst_file = ['bindir/root.src.pyext.tar.gz']
cmds = [self.get_extract_cmd('bindir/root.src.pyext.tar.gz', self.ROOT)]
return inst_file, cmds
def install_configfiles(self):
configfiles = [('src/mi/mipublic.py',
'$ROOT/$pythondir/site-packages/'),
('src/mi/magic.autopart.xml',
'$ROOT/usr/share/MagicInstaller/')]
slist = []
cmds = []
for src, dest in configfiles:
slist.append(src)
cmds.extend(['mkdir -p %s' % dest,
'cp -a %s %s' % (src, dest)])
return slist, cmds
def install_tranlatefiles(self):
slist = []
cmds = []
for lang in mi_config.all_linguas:
inst_file = 'src/mi/po/%s.mo' % lang
dest_file = '$ROOT/usr/share/locale/%s/LC_MESSAGES/${textdomain}.mo' % lang
slist.append(inst_file)
cmds.extend(['mkdir -p %s' % os.path.dirname(dest_file),
'cp -a %s %s' % (inst_file, dest_file)])
return slist, cmds
def install_post(self):
env = self.env
post_script = '$specdir/post_install.sh'
if os.path.exists(env.subst(post_script)):
cmds = ['mkdir -pv $ROOT/root && cp %s $ROOT/root' % post_script,
'chmod 700 $ROOT/root/post_install.sh']
return [post_script], cmds
else:
return [], []
def install_fix(self):
slist = []
cmds = []
if use_cp_mode:
inst_file = 'src/mi/UIxml/takeactions.xml.cpinstmode'
dest_file = '$ROOT$root_datadir/UIxml/takeactions.xml'
slist.append(inst_file)
cmds.extend['mkdir -p %s' % os.path.dirname(dest_file),
'cp -a %s %s' % (inst_file, dest_file)]
return slist, cmds
def mkmisrc(self):
#cmds = ['tar c -C $ROOT . | gzip -9 > $TARGET']
cmds = ['tar czvf $TARGET -C $ROOT .']
return [], cmds
misrc = miSrcMaker(env)
misrc.make()
if mi_config.develmode:
# Pack src/mi and src/etc into root.src.step1.tar.gz
env.Command('bindir/root.src.step1.tar.gz', [env.Alias('root_src'), env.Alias('root.src.etc')],
#['tar c -C $destdir . | gzip -9 > $TARGET'])
['tar czf $TARGET -C $destdir .'])
# There will compile the src/pyext (python modules for magicinstaller)
# Do it at develmode ,because we won't compile the python modules
# every time (especially at dist mode).
env.Command('bindir/root.src.pyext.tar.gz', env.Alias('root.pyext'),
#['tar c -C $pyextdir . | gzip -9 > $TARGET'])
['tar czf $TARGET -C $pyextdir .'])
### Hotfix file
# Handle with hotfix file
hotfix_path = mi_config.hotfixfiles_dir
if glob.glob(hotfix_path + '/*'):
Default(env.Command('%s.hotfix' % mi_config.mkisofn(1),
DirValue(hotfix_path),
['(cd $SOURCE && find . -print | cpio -o -H newc | gzip -9) > $TARGET']))
else:
Delete('%s.hotfix' % mi_config.mkisofn(1))
### SConscript
SConscript('src/SConscript')