updates
This commit is contained in:
parent
ac7251b722
commit
451d4b4c79
@ -1,370 +0,0 @@
|
|||||||
# Based on local.py (c) 2012, Michael DeHaan <michael.dehaan@gmail.com>
|
|
||||||
# Based on chroot.py (c) 2013, Maykel Moya <mmoya@speedyrails.com>
|
|
||||||
# (c) 2013, Michael Scherer <misc@zarb.org>
|
|
||||||
# (c) 2015, Toshio Kuratomi <tkuratomi@ansible.com>
|
|
||||||
# (c) 2017 Ansible Project
|
|
||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
||||||
|
|
||||||
from __future__ import (absolute_import, division, print_function)
|
|
||||||
import sys
|
|
||||||
import time
|
|
||||||
|
|
||||||
__metaclass__ = type
|
|
||||||
|
|
||||||
DOCUMENTATION = """
|
|
||||||
author: Jesse Pretorius <jesse@odyssey4.me>
|
|
||||||
connection: community.libvirt.libvirt_qemu
|
|
||||||
short_description: Run tasks on libvirt/qemu virtual machines
|
|
||||||
description:
|
|
||||||
- Run commands or put/fetch files to libvirt/qemu virtual machines using the qemu agent API.
|
|
||||||
notes:
|
|
||||||
- Currently DOES NOT work with selinux set to enforcing in the VM.
|
|
||||||
- Requires the qemu-agent installed in the VM.
|
|
||||||
- Requires access to the qemu-ga commands guest-exec, guest-exec-status, guest-file-close, guest-file-open, guest-file-read, guest-file-write.
|
|
||||||
version_added: "2.10"
|
|
||||||
options:
|
|
||||||
remote_addr:
|
|
||||||
description: Virtual machine name
|
|
||||||
default: inventory_hostname
|
|
||||||
vars:
|
|
||||||
- name: ansible_host
|
|
||||||
executable:
|
|
||||||
description: Shell to use for execution inside container
|
|
||||||
default: /bin/sh
|
|
||||||
vars:
|
|
||||||
- name: ansible_executable
|
|
||||||
virt_uri:
|
|
||||||
description: libvirt URI to connect to to access the virtual machine
|
|
||||||
default: qemu:///system
|
|
||||||
vars:
|
|
||||||
- name: ansible_libvirt_uri
|
|
||||||
timeout:
|
|
||||||
description: timeout for libvirt to connect to access the virtual machine
|
|
||||||
required: false
|
|
||||||
type: int
|
|
||||||
default: 10
|
|
||||||
"""
|
|
||||||
|
|
||||||
import base64
|
|
||||||
import json
|
|
||||||
import libvirt
|
|
||||||
import libvirt_qemu
|
|
||||||
import shlex
|
|
||||||
import traceback
|
|
||||||
|
|
||||||
from ansible import constants as C
|
|
||||||
from ansible.errors import AnsibleError, AnsibleConnectionFailure, AnsibleFileNotFound
|
|
||||||
from ansible.module_utils._text import to_bytes, to_native, to_text
|
|
||||||
from ansible.plugins.connection import ConnectionBase, BUFSIZE
|
|
||||||
from ansible.plugins.shell.powershell import _parse_clixml
|
|
||||||
from ansible.utils.display import Display
|
|
||||||
from ansible.plugins.callback.minimal import CallbackModule
|
|
||||||
from functools import partial
|
|
||||||
from os.path import exists, getsize
|
|
||||||
|
|
||||||
display = Display()
|
|
||||||
|
|
||||||
iMAX_WAIT = 10 # sec.
|
|
||||||
|
|
||||||
REQUIRED_CAPABILITIES = [
|
|
||||||
{'enabled': True, 'name': 'guest-exec', 'success-response': True},
|
|
||||||
{'enabled': True, 'name': 'guest-exec-status', 'success-response': True},
|
|
||||||
{'enabled': True, 'name': 'guest-file-close', 'success-response': True},
|
|
||||||
{'enabled': True, 'name': 'guest-file-open', 'success-response': True},
|
|
||||||
{'enabled': True, 'name': 'guest-file-read', 'success-response': True},
|
|
||||||
{'enabled': True, 'name': 'guest-file-write', 'success-response': True}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
class Connection(ConnectionBase):
|
|
||||||
''' Local libvirt qemu based connections '''
|
|
||||||
|
|
||||||
transport = 'community.libvirt.libvirt_qemu'
|
|
||||||
# TODO(odyssey4me):
|
|
||||||
# Figure out why pipelining does not work and fix it
|
|
||||||
has_pipelining = False
|
|
||||||
has_tty = False
|
|
||||||
|
|
||||||
def __init__(self, play_context, new_stdin, *args, **kwargs):
|
|
||||||
super(Connection, self).__init__(play_context, new_stdin, *args, **kwargs)
|
|
||||||
|
|
||||||
self._host = self._play_context.remote_addr
|
|
||||||
|
|
||||||
# Windows operates differently from a POSIX connection/shell plugin,
|
|
||||||
# we need to set various properties to ensure SSH on Windows continues
|
|
||||||
# to work
|
|
||||||
if getattr(self._shell, "_IS_WINDOWS", False):
|
|
||||||
self.has_native_async = True
|
|
||||||
self.always_pipeline_modules = True
|
|
||||||
self.module_implementation_preferences = ('.ps1', '.exe', '')
|
|
||||||
self.allow_executable = False
|
|
||||||
self._timeout = sgelf.get_option('timeout', 10)
|
|
||||||
|
|
||||||
def _connect(self):
|
|
||||||
''' connect to the virtual machine; nothing to do here '''
|
|
||||||
super(Connection, self)._connect()
|
|
||||||
if not self._connected:
|
|
||||||
|
|
||||||
self._virt_uri = self.get_option('virt_uri')
|
|
||||||
|
|
||||||
self._display.vvv(u"CONNECT TO {0}".format(self._virt_uri), host=self._host)
|
|
||||||
try:
|
|
||||||
self.conn = libvirt.open(self._virt_uri)
|
|
||||||
except libvirt.libvirtError as err:
|
|
||||||
self._display.vv(u"ERROR: libvirtError CONNECT TO {0}\n{1}".format(self._virt_uri, to_native(err)), host=self._host)
|
|
||||||
self._connected = False
|
|
||||||
raise AnsibleConnectionFailure(to_native(err))
|
|
||||||
|
|
||||||
self._display.vvv(u"FIND DOMAIN {0}".format(self._host), host=self._host)
|
|
||||||
try:
|
|
||||||
self.domain = self.conn.lookupByName(self._host)
|
|
||||||
except libvirt.libvirtError as err:
|
|
||||||
raise AnsibleConnectionFailure(to_native(err))
|
|
||||||
|
|
||||||
request_cap = json.dumps({'execute': 'guest-info'})
|
|
||||||
response_cap = json.loads(libvirt_qemu.qemuAgentCommand(self.domain, request_cap, 5, 0))
|
|
||||||
self.capabilities = response_cap['return']['supported_commands']
|
|
||||||
self._display.vvvvv(u"GUEST CAPABILITIES: {0}".format(self.capabilities), host=self._host)
|
|
||||||
missing_caps = []
|
|
||||||
for cap in REQUIRED_CAPABILITIES:
|
|
||||||
if cap not in self.capabilities:
|
|
||||||
missing_caps.append(cap['name'])
|
|
||||||
if len(missing_caps) > 0:
|
|
||||||
self._display.vvv(u"REQUIRED CAPABILITIES MISSING: {0}".format(missing_caps), host=self._host)
|
|
||||||
raise AnsibleConnectionFailure('Domain does not have required capabilities')
|
|
||||||
|
|
||||||
display.vvv(u"ESTABLISH {0} CONNECTION".format(self.transport), host=self._host)
|
|
||||||
self._connected = True
|
|
||||||
|
|
||||||
def exec_command(self, cmd, in_data=None, sudoable=True, timeout=None):
|
|
||||||
""" execute a command on the virtual machine host """
|
|
||||||
super(Connection, self).exec_command(cmd, in_data=in_data, sudoable=sudoable)
|
|
||||||
|
|
||||||
self._display.vvv(u"EXEC {0}".format(cmd), host=self._host)
|
|
||||||
if timeout is None:
|
|
||||||
timeout = self._timeout
|
|
||||||
|
|
||||||
cmd_args_list = shlex.split(to_native(cmd, errors='surrogate_or_strict'))
|
|
||||||
|
|
||||||
if getattr(self._shell, "_IS_WINDOWS", False):
|
|
||||||
# Become method 'runas' is done in the wrapper that is executed,
|
|
||||||
# need to disable sudoable so the bare_run is not waiting for a
|
|
||||||
# prompt that will not occur
|
|
||||||
sudoable = False
|
|
||||||
|
|
||||||
# Generate powershell commands
|
|
||||||
cmd_args_list = self._shell._encode_script(cmd, as_list=True, strict_mode=False, preserve_rc=False)
|
|
||||||
|
|
||||||
# TODO(odyssey4me):
|
|
||||||
# Implement buffering much like the other connection plugins
|
|
||||||
# Implement 'env' for the environment settings
|
|
||||||
# Implement 'input-data' for whatever it might be useful for
|
|
||||||
request_exec = {
|
|
||||||
'execute': 'guest-exec',
|
|
||||||
'arguments': {
|
|
||||||
'path': cmd_args_list[0],
|
|
||||||
'capture-output': True,
|
|
||||||
'arg': cmd_args_list[1:]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
request_exec_json = json.dumps(request_exec)
|
|
||||||
|
|
||||||
display.vvv("GA send: {0}".format(request_exec_json), host=self._host)
|
|
||||||
# sys.stderr.write("GA send: {0}\n".format(request_exec_json))
|
|
||||||
command_start = time.clock_gettime(time.CLOCK_MONOTONIC)
|
|
||||||
# TODO(odyssey4me):
|
|
||||||
# Add timeout parameter
|
|
||||||
flags = 0
|
|
||||||
try:
|
|
||||||
result_exec = json.loads(libvirt_qemu.qemuAgentCommand(self.domain, request_exec_json, timeout, flags))
|
|
||||||
except libvirt.libvirtError as err:
|
|
||||||
self._display.vv(u"ERROR: libvirtError EXEC TO {0}\n{1}".format(self._virt_uri, to_native(err)), host=self._host)
|
|
||||||
sys.stderr.write(u"ERROR: libvirtError EXEC TO {0}\n{1}\n".format(self._virt_uri, to_native(err)))
|
|
||||||
self._connected = False
|
|
||||||
raise AnsibleConnectionFailure(to_native(err))
|
|
||||||
|
|
||||||
display.vvv(u"GA return: {0}".format(result_exec), host=self._host)
|
|
||||||
|
|
||||||
request_status = {
|
|
||||||
'execute': 'guest-exec-status',
|
|
||||||
'arguments': {
|
|
||||||
'pid': result_exec['return']['pid']
|
|
||||||
}
|
|
||||||
}
|
|
||||||
request_status_json = json.dumps(request_status)
|
|
||||||
|
|
||||||
display.vvv(u"GA send: {0}".format(request_status_json), host=self._host)
|
|
||||||
|
|
||||||
# TODO(odyssey4me):
|
|
||||||
# Work out a better way to wait until the command has exited
|
|
||||||
max_time = iMAX_WAIT + time.clock_gettime(time.CLOCK_MONOTONIC)
|
|
||||||
result_status = {
|
|
||||||
'return': dict(exited=False),
|
|
||||||
}
|
|
||||||
while not result_status['return']['exited']:
|
|
||||||
# Wait for 5% of the time already elapsed
|
|
||||||
sleep_time = (time.clock_gettime(time.CLOCK_MONOTONIC) - command_start) * (5 / 100)
|
|
||||||
if sleep_time < 0.0002:
|
|
||||||
sleep_time = 0.0002
|
|
||||||
elif sleep_time > 1:
|
|
||||||
sleep_time = 1
|
|
||||||
time.sleep(sleep_time)
|
|
||||||
result_status = json.loads(libvirt_qemu.qemuAgentCommand(self.domain, request_status_json, 5, 0))
|
|
||||||
if time.clock_gettime(time.CLOCK_MONOTONIC) > max_time:
|
|
||||||
err = 'timeout'
|
|
||||||
self._display.vv(u"ERROR: libvirtError EXEC TO {0}\n{1}".format(self._virt_uri, to_native(err)), host=self._host)
|
|
||||||
sys.stderr.write(u"ERROR: libvirtError EXEC TO {0}\n{1}\n".format(self._virt_uri, to_native(err)))
|
|
||||||
self._connected = False
|
|
||||||
raise AnsibleConnectionFailure(to_native(err))
|
|
||||||
|
|
||||||
display.vvv(u"GA return: {0}".format(result_status), host=self._host)
|
|
||||||
|
|
||||||
while not result_status['return']['exited']:
|
|
||||||
result_status = json.loads(libvirt_qemu.qemuAgentCommand(self.domain, request_status_json, 5, 0))
|
|
||||||
|
|
||||||
display.vvv(u"GA return: {0}".format(result_status), host=self._host)
|
|
||||||
|
|
||||||
if result_status['return'].get('out-data'):
|
|
||||||
stdout = base64.b64decode(result_status['return']['out-data'])
|
|
||||||
else:
|
|
||||||
stdout = b''
|
|
||||||
|
|
||||||
if result_status['return'].get('err-data'):
|
|
||||||
stderr = base64.b64decode(result_status['return']['err-data'])
|
|
||||||
else:
|
|
||||||
stderr = b''
|
|
||||||
|
|
||||||
# Decode xml from windows
|
|
||||||
if getattr(self._shell, "_IS_WINDOWS", False) and stdout.startswith(b"#< CLIXML"):
|
|
||||||
stdout = _parse_clixml(stdout)
|
|
||||||
|
|
||||||
display.vvv(u"GA stdout: {0}".format(to_text(stdout)), host=self._host)
|
|
||||||
display.vvv(u"GA stderr: {0}".format(to_text(stderr)), host=self._host)
|
|
||||||
|
|
||||||
return result_status['return']['exitcode'], stdout, stderr
|
|
||||||
|
|
||||||
def put_file(self, in_path, out_path):
|
|
||||||
''' transfer a file from local to domain '''
|
|
||||||
super(Connection, self).put_file(in_path, out_path)
|
|
||||||
display.vvv("PUT %s TO %s" % (in_path, out_path), host=self._host)
|
|
||||||
|
|
||||||
if not exists(to_bytes(in_path, errors='surrogate_or_strict')):
|
|
||||||
raise AnsibleFileNotFound(
|
|
||||||
"file or module does not exist: %s" % in_path)
|
|
||||||
|
|
||||||
request_handle = {
|
|
||||||
'execute': 'guest-file-open',
|
|
||||||
'arguments': {
|
|
||||||
'path': out_path,
|
|
||||||
'mode': 'wb+'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
request_handle_json = json.dumps(request_handle)
|
|
||||||
|
|
||||||
display.vvv(u"GA send: {0}".format(request_handle_json), host=self._host)
|
|
||||||
|
|
||||||
result_handle = json.loads(libvirt_qemu.qemuAgentCommand(self.domain, request_handle_json, 5, 0))
|
|
||||||
|
|
||||||
display.vvv(u"GA return: {0}".format(result_handle), host=self._host)
|
|
||||||
|
|
||||||
# TODO(odyssey4me):
|
|
||||||
# Handle exception for file/path IOError
|
|
||||||
with open(to_bytes(in_path, errors='surrogate_or_strict'), 'rb') as in_file:
|
|
||||||
for chunk in iter(partial(in_file.read, BUFSIZE), b''):
|
|
||||||
try:
|
|
||||||
request_write = {
|
|
||||||
'execute': 'guest-file-write',
|
|
||||||
'arguments': {
|
|
||||||
'handle': result_handle['return'],
|
|
||||||
'buf-b64': base64.b64encode(chunk).decode()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
request_write_json = json.dumps(request_write)
|
|
||||||
|
|
||||||
display.vvvvv(u"GA send: {0}".format(request_write_json), host=self._host)
|
|
||||||
|
|
||||||
result_write = json.loads(libvirt_qemu.qemuAgentCommand(self.domain, request_write_json, 5, 0))
|
|
||||||
|
|
||||||
display.vvvvv(u"GA return: {0}".format(result_write), host=self._host)
|
|
||||||
|
|
||||||
except Exception:
|
|
||||||
traceback.print_exc()
|
|
||||||
raise AnsibleError("failed to transfer file %s to %s" % (in_path, out_path))
|
|
||||||
|
|
||||||
request_close = {
|
|
||||||
'execute': 'guest-file-close',
|
|
||||||
'arguments': {
|
|
||||||
'handle': result_handle['return']
|
|
||||||
}
|
|
||||||
}
|
|
||||||
request_close_json = json.dumps(request_close)
|
|
||||||
|
|
||||||
display.vvv(u"GA send: {0}".format(request_close_json), host=self._host)
|
|
||||||
|
|
||||||
result_close = json.loads(libvirt_qemu.qemuAgentCommand(self.domain, request_close_json, 5, 0))
|
|
||||||
|
|
||||||
display.vvv(u"GA return: {0}".format(result_close), host=self._host)
|
|
||||||
|
|
||||||
def fetch_file(self, in_path, out_path):
|
|
||||||
''' fetch a file from domain to local '''
|
|
||||||
super(Connection, self).fetch_file(in_path, out_path)
|
|
||||||
display.vvv("FETCH %s TO %s" % (in_path, out_path), host=self._host)
|
|
||||||
|
|
||||||
request_handle = {
|
|
||||||
'execute': 'guest-file-open',
|
|
||||||
'arguments': {
|
|
||||||
'path': in_path,
|
|
||||||
'mode': 'r'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
request_handle_json = json.dumps(request_handle)
|
|
||||||
|
|
||||||
display.vvv(u"GA send: {0}".format(request_handle_json), host=self._host)
|
|
||||||
|
|
||||||
result_handle = json.loads(libvirt_qemu.qemuAgentCommand(self.domain, request_handle_json, 5, 0))
|
|
||||||
|
|
||||||
display.vvv(u"GA return: {0}".format(result_handle), host=self._host)
|
|
||||||
|
|
||||||
request_read = {
|
|
||||||
'execute': 'guest-file-read',
|
|
||||||
'arguments': {
|
|
||||||
'handle': result_handle['return'],
|
|
||||||
'count': BUFSIZE
|
|
||||||
}
|
|
||||||
}
|
|
||||||
request_read_json = json.dumps(request_read)
|
|
||||||
|
|
||||||
display.vvv(u"GA send: {0}".format(request_read_json), host=self._host)
|
|
||||||
|
|
||||||
with open(to_bytes(out_path, errors='surrogate_or_strict'), 'wb+') as out_file:
|
|
||||||
try:
|
|
||||||
result_read = json.loads(libvirt_qemu.qemuAgentCommand(self.domain, request_read_json, 5, 0))
|
|
||||||
display.vvvvv(u"GA return: {0}".format(result_read), host=self._host)
|
|
||||||
out_file.write(base64.b64decode(result_read['return']['buf-b64']))
|
|
||||||
while not result_read['return']['eof']:
|
|
||||||
result_read = json.loads(libvirt_qemu.qemuAgentCommand(self.domain, request_read_json, 5, 0))
|
|
||||||
display.vvvvv(u"GA return: {0}".format(result_read), host=self._host)
|
|
||||||
out_file.write(base64.b64decode(result_read['return']['buf-b64']))
|
|
||||||
|
|
||||||
except Exception:
|
|
||||||
traceback.print_exc()
|
|
||||||
raise AnsibleError("failed to transfer file %s to %s" % (in_path, out_path))
|
|
||||||
|
|
||||||
request_close = {
|
|
||||||
'execute': 'guest-file-close',
|
|
||||||
'arguments': {
|
|
||||||
'handle': result_handle['return']
|
|
||||||
}
|
|
||||||
}
|
|
||||||
request_close_json = json.dumps(request_close)
|
|
||||||
|
|
||||||
display.vvv(u"GA send: {0}".format(request_close_json), host=self._host)
|
|
||||||
|
|
||||||
result_close = json.loads(libvirt_qemu.qemuAgentCommand(self.domain, request_close_json, 5, 0))
|
|
||||||
|
|
||||||
display.vvv(u"GA return: {0}".format(result_close), host=self._host)
|
|
||||||
|
|
||||||
def close(self):
|
|
||||||
''' terminate the connection; nothing to do here '''
|
|
||||||
super(Connection, self).close()
|
|
||||||
self._connected = False
|
|
@ -1,279 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
# -*- mode: sh; tab-width: 8; encoding: utf-8-unix -*-
|
|
||||||
|
|
||||||
prog=`basename $0 .bash`
|
|
||||||
PREFIX=/usr/local
|
|
||||||
ROLE=toxcore
|
|
||||||
|
|
||||||
PKG=dracut
|
|
||||||
VER=050
|
|
||||||
DIR=${PKG}-$VER
|
|
||||||
URL=distfiles.gentoo.org/distfiles/$DIR.tar.xz
|
|
||||||
URI="https://www.kernel.org/pub/linux/utils/boot/${VER}/${DIR}.tar.xz"
|
|
||||||
|
|
||||||
cd $PREFIX/src || exit 2
|
|
||||||
WD=$PWD
|
|
||||||
|
|
||||||
if [ -d /etc/apt -a $USER = root ] ; then
|
|
||||||
# old_debian_requires asciidoc libkmod-dev libkmod-dev xsltproc
|
|
||||||
which xsltproc 2>/dev/null || apt-get install xsltproc || exit 2
|
|
||||||
which asciidoc 2>/dev/null || apt-get install asciidoc || exit 2
|
|
||||||
elif [ -d /etc/portage -a $USER = root ] ; then
|
|
||||||
which cpio >/dev/null || emerge -fp app-arch/cpio || exit 2
|
|
||||||
[ -f /usr/lib64/libkmod.so ] || emerge -fp '>=sys-apps/kmod-23[tools]' || exit 2
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -f $DIR/dracut-initramfs-restore ] ; then
|
|
||||||
if [ -e $PREFIX/net/Http/$URL ] ; then
|
|
||||||
ip route|grep -q ^default || { echo "DEBUG: $0 not connected" ; exit 0 ; }
|
|
||||||
wget -xc -P $PREFIX/net/Http https://$URL
|
|
||||||
fi
|
|
||||||
tar xvfJ $PREFIX/net/Http/$URL
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd $DIR || exit 3
|
|
||||||
|
|
||||||
true || \
|
|
||||||
grep -q ^prefix=$PREFIX configure || \
|
|
||||||
sed -e 's/^KMOD_LIBS.*/KMOD_LIBS ?= -lkmod/' \
|
|
||||||
-e 's@^ exit 1@# exit 1@' \
|
|
||||||
-e "s@^prefix=/usr$@prefix=$PREFIX@" -i configure
|
|
||||||
|
|
||||||
|
|
||||||
src_configure() {
|
|
||||||
local PV=$VER
|
|
||||||
|
|
||||||
# tc-export CC PKG_CONFIG
|
|
||||||
sed -e "s@^prefix=/usr\$@prefix=$PREFIX@" -i configure
|
|
||||||
./configure \
|
|
||||||
--disable-documentation \
|
|
||||||
--prefix="${PREFIX}" \
|
|
||||||
--sysconfdir="${PREFIX}/etc" \
|
|
||||||
|| return 1
|
|
||||||
# --bashcompletiondir="$(get_bashcompdir)"
|
|
||||||
# --systemdsystemunitdir="$(systemd_get_systemunitdir)"
|
|
||||||
|
|
||||||
if [ ! -f dracut-version.sh ] ; then
|
|
||||||
# Source tarball from github doesn't include this file
|
|
||||||
echo "DRACUT_VERSION=${PV}" > dracut-version.sh
|
|
||||||
fi
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ "$#" -eq 0 ] ; then
|
|
||||||
if [ ! -f dracut-initramfs-restore.sh.dst ] ; then
|
|
||||||
false && \
|
|
||||||
if [ -d /usr/local/patches/$ROLE/usr/local/src/$DIR/files ] ; then
|
|
||||||
find /usr/local/patches/$ROLE/usr/local/src/$DIR/files -type f -name \*.patch | \
|
|
||||||
while read file ; do
|
|
||||||
root=`echo $file | sed -e 's/.patch//' -e "s@$PREFIX/patches/$ROLE/usr/local/src/$DIR/@@"`
|
|
||||||
[ -f $root.dst ] && continue
|
|
||||||
patch -b -z.dst $root < $file
|
|
||||||
done || exit 5
|
|
||||||
fi
|
|
||||||
|
|
||||||
# patches
|
|
||||||
if [ -d /usr/local/patches/$ROLE/usr/local/src/$DIR/ ] ; then
|
|
||||||
find /usr/local/patches/$ROLE/usr/local/src/$DIR/ -type f -name \*.diff | \
|
|
||||||
while read file ; do
|
|
||||||
root=$( echo $file | sed -e 's/.diff//' \
|
|
||||||
-e "s@$PREFIX/patches/$ROLE/usr/local/src/$DIR/@@" )
|
|
||||||
[ -f $root.dst ] && continue
|
|
||||||
patch -b -z.dst $root < $file
|
|
||||||
done || exit 5
|
|
||||||
fi
|
|
||||||
|
|
||||||
find * -type f -name \*sh -exec grep -q /usr/lib/dracut {} \; -print | \
|
|
||||||
while read file ; do
|
|
||||||
[ -f $file.dst ] || cp -p $file $file.dst
|
|
||||||
sed -e "s@/usr/lib/dracut@$PREFIX/lib/dracut@" $file
|
|
||||||
chmod 755 $file
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
[ -f Makefile.inc ] || \
|
|
||||||
src_configure || exit 6
|
|
||||||
grep -q systemdsystemunitdir Makefile.inc || \
|
|
||||||
cat >> Makefile.inc << EOF
|
|
||||||
systemdsystemunitdir ?= /usr/local/lib/systemd
|
|
||||||
EOF
|
|
||||||
grep -v =$ dracut-version.sh && sed -e "s/=/=$VER/" dracut-version.sh
|
|
||||||
|
|
||||||
[ -x install/dracut-install ] || make >> make.log 2>&1 || exit 7
|
|
||||||
[ -x $PREFIX/lib/dracut/dracut-install -a \
|
|
||||||
$PREFIX/lib/dracut/dracut-install -nt install/dracut-install ] || \
|
|
||||||
make install >> install.log 2>&1 || exit 8
|
|
||||||
|
|
||||||
elif [ "$1" = 'test' ] ; then
|
|
||||||
$PREFIX/bin/$PKG --help || exit 30
|
|
||||||
# Has tests
|
|
||||||
|
|
||||||
elif [ "$1" = 'refresh' ] ; then # 6*
|
|
||||||
cd $WD/$DIR || exit 6
|
|
||||||
find * -name \*.dst | while read file ; do
|
|
||||||
base=`echo $file |sed -e 's/.dst//'`
|
|
||||||
[ -f $base.diff -a $base.diff -nt $base ] && continue
|
|
||||||
diff -c -C 5 $file $base>$base.diff
|
|
||||||
done
|
|
||||||
find * -name \*.diff | tar cf - -T - | \
|
|
||||||
tar xfBv - -C ../../patches/gpgkey/usr/local/src/dracut-050/
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
|
|
||||||
cp -p install/dracut-install $PREFIX/bin
|
|
||||||
|
|
||||||
rm -f -- "lsinitrd.1.xml"
|
|
||||||
asciidoc -d manpage -b docbook -o "lsinitrd.1.xml" lsinitrd.1.asc
|
|
||||||
rm -f -- "lsinitrd.1"
|
|
||||||
xsltproc -o "lsinitrd.1" -nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl lsinitrd.1.xml
|
|
||||||
rm -f -- "dracut.conf.5.xml"
|
|
||||||
asciidoc -d manpage -b docbook -o "dracut.conf.5.xml" dracut.conf.5.asc
|
|
||||||
rm -f -- "dracut.conf.5"
|
|
||||||
xsltproc -o "dracut.conf.5" -nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl dracut.conf.5.xml
|
|
||||||
rm -f -- "dracut.cmdline.7.xml"
|
|
||||||
asciidoc -d manpage -b docbook -o "dracut.cmdline.7.xml" dracut.cmdline.7.asc
|
|
||||||
rm -f -- "dracut.cmdline.7"
|
|
||||||
xsltproc -o "dracut.cmdline.7" -nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl dracut.cmdline.7.xml
|
|
||||||
rm -f -- "dracut.bootup.7.xml"
|
|
||||||
asciidoc -d manpage -b docbook -o "dracut.bootup.7.xml" dracut.bootup.7.asc
|
|
||||||
rm -f -- "dracut.bootup.7"
|
|
||||||
xsltproc -o "dracut.bootup.7" -nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl dracut.bootup.7.xml
|
|
||||||
rm -f -- "dracut.modules.7.xml"
|
|
||||||
asciidoc -d manpage -b docbook -o "dracut.modules.7.xml" dracut.modules.7.asc
|
|
||||||
rm -f -- "dracut.modules.7"
|
|
||||||
xsltproc -o "dracut.modules.7" -nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl dracut.modules.7.xml
|
|
||||||
rm -f -- "dracut.8.xml"
|
|
||||||
asciidoc -d manpage -b docbook -o "dracut.8.xml" dracut.8.asc
|
|
||||||
rm -f -- "dracut.8"
|
|
||||||
xsltproc -o "dracut.8" -nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl dracut.8.xml
|
|
||||||
rm -f -- "dracut-catimages.8.xml"
|
|
||||||
asciidoc -d manpage -b docbook -o "dracut-catimages.8.xml" dracut-catimages.8.asc
|
|
||||||
rm -f -- "dracut-catimages.8"
|
|
||||||
xsltproc -o "dracut-catimages.8" -nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl dracut-catimages.8.xml
|
|
||||||
rm -f -- "mkinitrd.8.xml"
|
|
||||||
asciidoc -d manpage -b docbook -o "mkinitrd.8.xml" mkinitrd.8.asc
|
|
||||||
rm -f -- "mkinitrd.8"
|
|
||||||
xsltproc -o "mkinitrd.8" -nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl mkinitrd.8.xml
|
|
||||||
rm -f -- "mkinitrd-suse.8.xml"
|
|
||||||
asciidoc -d manpage -b docbook -o "mkinitrd-suse.8.xml" mkinitrd-suse.8.asc
|
|
||||||
rm -f -- "mkinitrd-suse.8"
|
|
||||||
xsltproc -o "mkinitrd-suse.8" -nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl mkinitrd-suse.8.xml
|
|
||||||
rm -f -- "modules.d/98dracut-systemd/dracut-cmdline.service.8.xml"
|
|
||||||
asciidoc -d manpage -b docbook -o "modules.d/98dracut-systemd/dracut-cmdline.service.8.xml" modules.d/98dracut-systemd/dracut-cmdline.service.8.asc
|
|
||||||
rm -f -- "modules.d/98dracut-systemd/dracut-cmdline.service.8"
|
|
||||||
xsltproc -o "modules.d/98dracut-systemd/dracut-cmdline.service.8" -nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl modules.d/98dracut-systemd/dracut-cmdline.service.8.xml
|
|
||||||
rm -f -- "modules.d/98dracut-systemd/dracut-initqueue.service.8.xml"
|
|
||||||
asciidoc -d manpage -b docbook -o "modules.d/98dracut-systemd/dracut-initqueue.service.8.xml" modules.d/98dracut-systemd/dracut-initqueue.service.8.asc
|
|
||||||
rm -f -- "modules.d/98dracut-systemd/dracut-initqueue.service.8"
|
|
||||||
xsltproc -o "modules.d/98dracut-systemd/dracut-initqueue.service.8" -nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl modules.d/98dracut-systemd/dracut-initqueue.service.8.xml
|
|
||||||
rm -f -- "modules.d/98dracut-systemd/dracut-mount.service.8.xml"
|
|
||||||
asciidoc -d manpage -b docbook -o "modules.d/98dracut-systemd/dracut-mount.service.8.xml" modules.d/98dracut-systemd/dracut-mount.service.8.asc
|
|
||||||
rm -f -- "modules.d/98dracut-systemd/dracut-mount.service.8"
|
|
||||||
xsltproc -o "modules.d/98dracut-systemd/dracut-mount.service.8" -nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl modules.d/98dracut-systemd/dracut-mount.service.8.xml
|
|
||||||
rm -f -- "modules.d/98dracut-systemd/dracut-shutdown.service.8.xml"
|
|
||||||
asciidoc -d manpage -b docbook -o "modules.d/98dracut-systemd/dracut-shutdown.service.8.xml" modules.d/98dracut-systemd/dracut-shutdown.service.8.asc
|
|
||||||
rm -f -- "modules.d/98dracut-systemd/dracut-shutdown.service.8"
|
|
||||||
xsltproc -o "modules.d/98dracut-systemd/dracut-shutdown.service.8" -nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl modules.d/98dracut-systemd/dracut-shutdown.service.8.xml
|
|
||||||
rm -f -- "modules.d/98dracut-systemd/dracut-pre-mount.service.8.xml"
|
|
||||||
asciidoc -d manpage -b docbook -o "modules.d/98dracut-systemd/dracut-pre-mount.service.8.xml" modules.d/98dracut-systemd/dracut-pre-mount.service.8.asc
|
|
||||||
rm -f -- "modules.d/98dracut-systemd/dracut-pre-mount.service.8"
|
|
||||||
xsltproc -o "modules.d/98dracut-systemd/dracut-pre-mount.service.8" -nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl modules.d/98dracut-systemd/dracut-pre-mount.service.8.xml
|
|
||||||
rm -f -- "modules.d/98dracut-systemd/dracut-pre-pivot.service.8.xml"
|
|
||||||
asciidoc -d manpage -b docbook -o "modules.d/98dracut-systemd/dracut-pre-pivot.service.8.xml" modules.d/98dracut-systemd/dracut-pre-pivot.service.8.asc
|
|
||||||
rm -f -- "modules.d/98dracut-systemd/dracut-pre-pivot.service.8"
|
|
||||||
xsltproc -o "modules.d/98dracut-systemd/dracut-pre-pivot.service.8" -nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl modules.d/98dracut-systemd/dracut-pre-pivot.service.8.xml
|
|
||||||
rm -f -- "modules.d/98dracut-systemd/dracut-pre-trigger.service.8.xml"
|
|
||||||
asciidoc -d manpage -b docbook -o "modules.d/98dracut-systemd/dracut-pre-trigger.service.8.xml" modules.d/98dracut-systemd/dracut-pre-trigger.service.8.asc
|
|
||||||
rm -f -- "modules.d/98dracut-systemd/dracut-pre-trigger.service.8"
|
|
||||||
xsltproc -o "modules.d/98dracut-systemd/dracut-pre-trigger.service.8" -nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl modules.d/98dracut-systemd/dracut-pre-trigger.service.8.xml
|
|
||||||
rm -f -- "modules.d/98dracut-systemd/dracut-pre-udev.service.8.xml"
|
|
||||||
asciidoc -d manpage -b docbook -o "modules.d/98dracut-systemd/dracut-pre-udev.service.8.xml" modules.d/98dracut-systemd/dracut-pre-udev.service.8.asc
|
|
||||||
rm -f -- "modules.d/98dracut-systemd/dracut-pre-udev.service.8"
|
|
||||||
xsltproc -o "modules.d/98dracut-systemd/dracut-pre-udev.service.8" -nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl modules.d/98dracut-systemd/dracut-pre-udev.service.8.xml
|
|
||||||
rm -f -- dracut.xml
|
|
||||||
asciidoc -a numbered -d book -b docbook -o dracut.xml dracut.asc
|
|
||||||
rm -f -- dracut.html
|
|
||||||
xsltproc -o dracut.html --xinclude -nonet \
|
|
||||||
--stringparam custom.css.source dracut.css \
|
|
||||||
--stringparam generate.css.header 1 \
|
|
||||||
http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl dracut.xml
|
|
||||||
rm -f -- dracut.xml
|
|
||||||
|
|
||||||
[ -d /usr/lib/dracut ] || mkdir -p /usr/lib/dracut
|
|
||||||
mkdir -p /usr/lib/dracut/modules.d
|
|
||||||
mkdir -p /usr/share/man/man1 /usr/share/man/man5 /usr/share/man/man7 /usr/share/man/man8
|
|
||||||
install -m 0755 dracut.sh /usr/bin/dracut
|
|
||||||
install -m 0755 dracut-catimages.sh /usr/bin/dracut-catimages
|
|
||||||
install -m 0755 mkinitrd-dracut.sh /usr/bin/mkinitrd
|
|
||||||
install -m 0755 lsinitrd.sh /usr/bin/lsinitrd
|
|
||||||
install -m 0644 dracut.conf /usr/etc/dracut.conf
|
|
||||||
mkdir -p /usr/etc/dracut.conf.d
|
|
||||||
mkdir -p /usr/lib/dracut/dracut.conf.d
|
|
||||||
install -m 0755 dracut-init.sh /usr/lib/dracut/dracut-init.sh
|
|
||||||
install -m 0755 dracut-functions.sh /usr/lib/dracut/dracut-functions.sh
|
|
||||||
install -m 0755 dracut-version.sh /usr/lib/dracut/dracut-version.sh
|
|
||||||
ln -fs dracut-functions.sh /usr/lib/dracut/dracut-functions
|
|
||||||
install -m 0755 dracut-logger.sh /usr/lib/dracut/dracut-logger.sh
|
|
||||||
install -m 0755 dracut-initramfs-restore.sh /usr/lib/dracut/dracut-initramfs-restore
|
|
||||||
cp -arx modules.d /usr/lib/dracut
|
|
||||||
for i in lsinitrd.1; do install -m 0644 $i /usr/share/man/man1/${i##*/}; done
|
|
||||||
for i in dracut.conf.5; do install -m 0644 $i /usr/share/man/man5/${i##*/}; done
|
|
||||||
for i in dracut.cmdline.7 dracut.bootup.7 dracut.modules.7; do install -m 0644 $i /usr/share/man/man7/${i##*/}; done
|
|
||||||
for i in dracut.8 dracut-catimages.8 mkinitrd.8 mkinitrd-suse.8 modules.d/98dracut-systemd/dracut-cmdline.service.8 modules.d/98dracut-systemd/dracut-initqueue.service.8 modules.d/98dracut-systemd/dracut-mount.service.8 modules.d/98dracut-systemd/dracut-shutdown.service.8 modules.d/98dracut-systemd/dracut-pre-mount.service.8 modules.d/98dracut-systemd/dracut-pre-pivot.service.8 modules.d/98dracut-systemd/dracut-pre-trigger.service.8 modules.d/98dracut-systemd/dracut-pre-udev.service.8; do install -m 0644 $i /usr/share/man/man8/${i##*/}; done
|
|
||||||
ln -fs dracut.cmdline.7 /usr/share/man/man7/dracut.kernel.7
|
|
||||||
if [ -n "" ]; then \
|
|
||||||
mkdir -p ; \
|
|
||||||
ln -srf /usr/lib/dracut/modules.d/98dracut-systemd/dracut-shutdown.service /dracut-shutdown.service; \
|
|
||||||
mkdir -p /sysinit.target.wants; \
|
|
||||||
ln -s ../dracut-shutdown.service \
|
|
||||||
/sysinit.target.wants/dracut-shutdown.service; \
|
|
||||||
mkdir -p /initrd.target.wants; \
|
|
||||||
for i in \
|
|
||||||
dracut-cmdline.service \
|
|
||||||
dracut-initqueue.service \
|
|
||||||
dracut-mount.service \
|
|
||||||
dracut-pre-mount.service \
|
|
||||||
dracut-pre-pivot.service \
|
|
||||||
dracut-pre-trigger.service \
|
|
||||||
dracut-pre-udev.service \
|
|
||||||
; do \
|
|
||||||
ln -srf /usr/lib/dracut/modules.d/98dracut-systemd/$i ; \
|
|
||||||
ln -s ../$i \
|
|
||||||
/initrd.target.wants/$i; \
|
|
||||||
done \
|
|
||||||
fi
|
|
||||||
if [ -f install/dracut-install ]; then \
|
|
||||||
install -m 0755 install/dracut-install /usr/lib/dracut/dracut-install; \
|
|
||||||
fi
|
|
||||||
if [ -f skipcpio/skipcpio ]; then \
|
|
||||||
install -m 0755 skipcpio/skipcpio /usr/lib/dracut/skipcpio; \
|
|
||||||
fi
|
|
||||||
mkdir -p /usr/lib/kernel/install.d
|
|
||||||
install -m 0755 50-dracut.install /usr/lib/kernel/install.d/50-dracut.install
|
|
||||||
install -m 0755 51-dracut-rescue.install /usr/lib/kernel/install.d/51-dracut-rescue.install
|
|
||||||
mkdir -p /usr/share/bash-completion/completions
|
|
||||||
install -m 0644 dracut-bash-completion.sh /usr/share/bash-completion/completions/dracut
|
|
||||||
install -m 0644 lsinitrd-bash-completion.sh /usr/share/bash-completion/completions/lsinitrd
|
|
||||||
mkdir -p /usr/share/pkgconfig
|
|
||||||
install -m 0644 dracut.pc /usr/share/pkgconfig/dracut.pc
|
|
||||||
rm dracut.8.xml dracut.cmdline.7.xml modules.d/98dracut-systemd/dracut-mount.service.8.xml dracut.bootup.7.xml modules.d/98dracut-systemd/dracut-pre-mount.service.8.xml modules.d/98dracut-systemd/dracut-initqueue.service.8.xml mkinitrd.8.xml modules.d/98dracut-systemd/dracut-pre-pivot.service.8.xml dracut.modules.7.xml dracut.conf.5.xml lsinitrd.1.xml modules.d/98dracut-systemd/dracut-cmdline.service.8.xml dracut-catimages.8.xml modules.d/98dracut-systemd/dracut-pre-udev.service.8.xml modules.d/98dracut-systemd/dracut-pre-trigger.service.8.xml mkinitrd-suse.8.xml modules.d/98dracut-systemd/dracut-shutdown.service.8.xml
|
|
||||||
ROLE=text
|
|
||||||
ROLE=text
|
|
||||||
ROLE=text
|
|
||||||
ROLE=text
|
|
||||||
ROLE=text
|
|
||||||
ROLE=text
|
|
||||||
ROLE=text
|
|
||||||
ROLE=text
|
|
||||||
ROLE=text
|
|
||||||
ROLE=testing
|
|
||||||
ROLE=pydev
|
|
||||||
ROLE=logging
|
|
||||||
ROLE=gpgkey
|
|
||||||
ROLE=harden
|
|
||||||
ROLE=privacy
|
|
||||||
ROLE=hostvms
|
|
||||||
ROLE=pentest
|
|
||||||
ROLE=update
|
|
@ -1 +0,0 @@
|
|||||||
root@pentoo.152064:1703733868
|
|
Loading…
Reference in New Issue
Block a user