2013-07-31 16:57:29 +02:00
|
|
|
from base import Task
|
|
|
|
from common import phases
|
|
|
|
import os
|
2013-08-10 19:01:54 +02:00
|
|
|
from common.tasks.packages import ImagePackages
|
|
|
|
from common.tasks.host import CheckPackages
|
2013-08-12 16:06:08 +02:00
|
|
|
from common.tasks.filesystem import MountVolume
|
2013-07-31 16:57:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
class AddUserPackages(Task):
|
|
|
|
description = 'Adding user defined packages to the image packages'
|
|
|
|
phase = phases.preparation
|
|
|
|
after = [ImagePackages]
|
|
|
|
before = [CheckPackages]
|
|
|
|
|
|
|
|
def run(self, info):
|
|
|
|
if 'repo' not in info.manifest.plugins['user_packages']:
|
|
|
|
return
|
|
|
|
for pkg in info.manifest.plugins['user_packages']['repo']:
|
|
|
|
info.img_packages[0].add(pkg)
|
|
|
|
|
2013-08-10 19:01:54 +02:00
|
|
|
|
2013-07-31 16:57:29 +02:00
|
|
|
class AddLocalUserPackages(Task):
|
2013-08-10 19:01:54 +02:00
|
|
|
description = 'Adding user local packages to the image packages'
|
|
|
|
phase = phases.system_modification
|
|
|
|
after = [MountVolume]
|
2013-07-31 16:57:29 +02:00
|
|
|
|
2013-08-10 19:01:54 +02:00
|
|
|
def run(self, info):
|
|
|
|
if 'local' not in info.manifest.plugins['user_packages']:
|
|
|
|
return
|
2013-07-31 16:57:29 +02:00
|
|
|
|
2013-08-10 19:01:54 +02:00
|
|
|
import stat
|
|
|
|
rwxr_xr_x = (stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR |
|
|
|
|
stat.S_IRGRP | stat.S_IXGRP |
|
|
|
|
stat.S_IROTH | stat.S_IXOTH)
|
2013-07-31 16:57:29 +02:00
|
|
|
|
2013-08-10 19:01:54 +02:00
|
|
|
from shutil import copy
|
|
|
|
from common.tools import log_check_call
|
2013-07-31 16:57:29 +02:00
|
|
|
|
|
|
|
for pkg in info.manifest.plugins['user_packages']['local']:
|
2013-08-10 19:01:54 +02:00
|
|
|
script_src = os.path.normpath(pkg)
|
|
|
|
script_dst = os.path.join(info.root, 'tmp/'+os.path.basename(script_src))
|
|
|
|
copy(script_src, script_dst)
|
|
|
|
os.chmod(script_dst, rwxr_xr_x)
|
2013-07-31 16:57:29 +02:00
|
|
|
|
2013-08-10 19:01:54 +02:00
|
|
|
log_check_call(['/usr/sbin/chroot', info.root, 'dpkg', '-i', '/tmp/'+os.path.basename(script_src)])
|