[PATCH] Bug fix: Use a temp directory under /var to avoid permission
by Aline Manera
The user may have the Kimchi source code in any directory and using it
as a base to do the tests may cause permission errors while open ISO
files or creating guest disks.
To avoid those errors use a temp directory under /var which already has
the right permissions to all users.
Signed-off-by: Aline Manera <alinefm(a)linux.vnet.ibm.com>
---
tests/test_model.py | 40 ++++++++++++++++++++--------------------
1 file changed, 20 insertions(+), 20 deletions(-)
diff --git a/tests/test_model.py b/tests/test_model.py
index 602ca6e..3828342 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -48,13 +48,13 @@ invalid_repository_urls = ['www.fedora.org', # missing protocol
'http://www.fedora', # invalid domain name
'file:///home/foobar'] # invalid path
-ISO_PATH = '/tmp/kimchi-model-iso/'
-UBUNTU_ISO = ISO_PATH + 'ubuntu14.04.iso'
+TMP_DIR = '/var/lib/kimchi/tests/'
+UBUNTU_ISO = TMP_DIR + 'ubuntu14.04.iso'
def setUpModule():
- if not os.path.exists(ISO_PATH):
- os.makedirs(ISO_PATH)
+ if not os.path.exists(TMP_DIR):
+ os.makedirs(TMP_DIR)
iso_gen.construct_fake_iso(UBUNTU_ISO, True, '14.04', 'ubuntu')
@@ -68,7 +68,7 @@ def setUpModule():
def tearDownModule():
- shutil.rmtree(ISO_PATH)
+ shutil.rmtree(TMP_DIR)
class ModelTests(unittest.TestCase):
@@ -382,7 +382,7 @@ class ModelTests(unittest.TestCase):
@unittest.skipUnless(utils.running_as_root(), 'Must be run as root')
def test_vm_disk(self):
- disk_path = '/tmp/existent2.iso'
+ disk_path = os.path.join(TMP_DIR, 'existent2.iso')
open(disk_path, 'w').close()
modern_disk_bus = get_template_default('modern', 'disk_bus')
@@ -403,7 +403,7 @@ class ModelTests(unittest.TestCase):
inst = model.Model(objstore_loc=self.tmp_store)
with RollbackContext() as rollback:
- path = os.path.join(os.getcwd(), 'kimchi-images')
+ path = os.path.join(TMP_DIR, 'kimchi-images')
pool = 'test-pool'
vol = 'test-volume.img'
vol_path = "%s/%s" % (path, vol)
@@ -468,7 +468,7 @@ class ModelTests(unittest.TestCase):
self.assertRaises(
InvalidParameter, inst.vmstorages_create, vm_name, disk_args)
- old_distro_iso = ISO_PATH + 'rhel4_8.iso'
+ old_distro_iso = TMP_DIR + 'rhel4_8.iso'
iso_gen.construct_fake_iso(old_distro_iso, True, '4.8', 'rhel')
vm_name = 'kimchi-ide-bus-vm'
@@ -508,8 +508,8 @@ class ModelTests(unittest.TestCase):
self.assertEquals(1, prev_count)
# dummy .iso files
- iso_path = '/tmp/existent.iso'
- iso_path2 = '/tmp/existent2.iso'
+ iso_path = os.path.join(TMP_DIR, 'existent.iso')
+ iso_path2 = os.path.join(TMP_DIR, 'existent2.iso')
open(iso_path, 'w').close()
rollback.prependDefer(os.remove, iso_path)
open(iso_path2, 'w').close()
@@ -996,20 +996,20 @@ class ModelTests(unittest.TestCase):
inst = model.Model(None,
objstore_loc=self.tmp_store)
with RollbackContext() as rollback:
- path = '/tmp/kimchi-images/tmpdir'
- if not os.path.exists(path):
- os.makedirs(path)
- iso_gen.construct_fake_iso('/tmp/kimchi-images/tmpdir/'
- 'ubuntu12.04.iso', True,
- '12.04', 'ubuntu')
- iso_gen.construct_fake_iso('/tmp/kimchi-images/sles10.iso',
- True, '10', 'sles')
+ deep_path = os.path.join(TMP_DIR, 'deep-scan')
+ subdir_path = os.path.join(deep_path, 'isos')
+ if not os.path.exists(subdir_path):
+ os.makedirs(subdir_path)
+ ubuntu_iso = os.path.join(deep_path, 'ubuntu12.04.iso')
+ sles_iso = os.path.join(subdir_path, 'sles10.iso')
+ iso_gen.construct_fake_iso(ubuntu_iso, True, '12.04', 'ubuntu')
+ iso_gen.construct_fake_iso(sles_iso, True, '10', 'sles')
args = {'name': 'kimchi-scanning-pool',
- 'path': '/tmp/kimchi-images',
+ 'path': deep_path,
'type': 'kimchi-iso'}
inst.storagepools_create(args)
- rollback.prependDefer(shutil.rmtree, '/tmp/kimchi-images')
+ rollback.prependDefer(shutil.rmtree, deep_path)
rollback.prependDefer(shutil.rmtree, args['path'])
rollback.prependDefer(inst.storagepool_deactivate, args['name'])
--
2.1.0
9 years, 6 months
[PATCH] Bug fix: Detach host device prior to attach to guest
by Aline Manera
According to libvirt documentation, the device must be detached from host to
avoid problems in the host system.
In my tests, the host crashed after attaching a FC HBA as PCI passthrough
device to a guest using Kimchi. A host reboot was needed to recover the system.
For reference:
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/5/...
Signed-off-by: Aline Manera <alinefm(a)linux.vnet.ibm.com>
---
src/kimchi/i18n.py | 1 +
src/kimchi/model/vmhostdevs.py | 21 ++++++++++++++++++---
2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/src/kimchi/i18n.py b/src/kimchi/i18n.py
index 00a6c7c..d2ffa34 100644
--- a/src/kimchi/i18n.py
+++ b/src/kimchi/i18n.py
@@ -126,6 +126,7 @@ messages = {
"For Intel CPU, add intel_iommu=on to your Kernel parameter in /boot/grub2/grub.conf. "
"For AMD CPU, add iommu=pt iommu=1."),
"KCHVMHDEV0004E": _('"name" should be a device name string'),
+ "KCHVMHDEV0005E": _('The device %(name)s is probably in use by the host. Unable to attach it to the guest.'),
"KCHVMIF0001E": _("Interface %(iface)s does not exist in virtual machine %(name)s"),
"KCHVMIF0002E": _("Network %(network)s specified for virtual machine %(name)s does not exist"),
diff --git a/src/kimchi/model/vmhostdevs.py b/src/kimchi/model/vmhostdevs.py
index 946b1f6..ea75fce 100644
--- a/src/kimchi/model/vmhostdevs.py
+++ b/src/kimchi/model/vmhostdevs.py
@@ -25,6 +25,7 @@ from lxml import etree, objectify
from lxml.builder import E
from kimchi.exception import InvalidOperation, InvalidParameter, NotFoundError
+from kimchi.exception import OperationFailed
from kimchi.model.config import CapabilitiesModel
from kimchi.model.host import DeviceModel, DevicesModel
from kimchi.model.utils import get_vm_config_flag
@@ -122,9 +123,23 @@ class VMHostDevsModel(object):
dev_name = params['name']
self._passthrough_device_validate(dev_name)
dev_info = DeviceModel(conn=self.conn).lookup(dev_name)
- attach_device = getattr(
- self, '_attach_%s_device' % dev_info['device_type'])
- return attach_device(vmid, dev_info)
+
+ with RollbackContext() as rollback:
+ try:
+ dev = self.conn.get().nodeDeviceLookupByName(dev_name)
+ dev.dettach()
+ except Exception:
+ raise OperationFailed('KCHVMHDEV0005E', {'name': dev_name})
+ else:
+ rollback.prependDefer(dev.reAttach)
+
+ attach_device = getattr(
+ self, '_attach_%s_device' % dev_info['device_type'])
+
+ info = attach_device(vmid, dev_info)
+ rollback.commitAll()
+
+ return info
def _get_pci_device_xml(self, dev_info):
if 'detach_driver' not in dev_info:
--
2.1.0
9 years, 6 months
[PATCH] Gtihub #660 - Fixing .repo file with no repos handling
by Daniel Henrique Barboza
yumparser module will not add a {None: None} dict to the
repositories listing when reading a .repo file which has
no repositories declarations.
Signed-off-by: Daniel Henrique Barboza <dhbarboza82(a)gmail.com>
---
src/kimchi/yumparser.py | 5 +++--
tests/test_yumparser.py | 24 ++++++++++++++++++++++++
2 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/src/kimchi/yumparser.py b/src/kimchi/yumparser.py
index ce6ba9d..ac4ee02 100644
--- a/src/kimchi/yumparser.py
+++ b/src/kimchi/yumparser.py
@@ -109,8 +109,9 @@ def _get_repos_from_file(repo_file):
value = value.strip()
current_repo.set_attribute(key, value)
- # add the last repo from file
- repos_from_file[current_repo_id] = current_repo
+ # add the last repo from file.
+ if current_repo is not None:
+ repos_from_file[current_repo_id] = current_repo
return repos_from_file
diff --git a/tests/test_yumparser.py b/tests/test_yumparser.py
index 8645a65..d17e647 100644
--- a/tests/test_yumparser.py
+++ b/tests/test_yumparser.py
@@ -22,6 +22,7 @@ import tempfile
import unittest
from kimchi.model import model
+from kimchi.rollbackcontext import RollbackContext
from kimchi.yumparser import delete_repo_from_file, get_repo_files
from kimchi.yumparser import get_yum_repositories, write_repo_to_file
from kimchi.yumparser import YumRepoObject
@@ -45,6 +46,21 @@ def _create_fake_repos(repo_file_name):
return repos
+def _create_empty_repo_file():
+ data = """
+#
+# This is a repository file with no repositories at all
+# No repositories must be added after reading this file.
+#
+ """
+ _, tmp_file_name = tempfile.mkstemp(suffix='.repo',
+ dir='/etc/yum.repos.d')
+ with open(tmp_file_name, 'w') as f:
+ f.writelines(data)
+
+ return tmp_file_name
+
+
def _create_fake_repos_file():
_, tmp_file_name = tempfile.mkstemp(suffix='.repo',
dir='/etc/yum.repos.d')
@@ -79,6 +95,14 @@ class YumParserTests(unittest.TestCase):
repo_objects = get_yum_repositories()
self.assertGreaterEqual(len(repo_objects), len(repo_files))
+ def test_empty_repo_file(self):
+ with RollbackContext() as rollback:
+ repos = get_yum_repositories()
+ tmp_file_name = _create_empty_repo_file()
+ rollback.prependDefer(os.remove, tmp_file_name)
+ repos_after = get_yum_repositories()
+ self.assertEqual(len(repos_after), len(repos))
+
def test_update_repo_attributes(self):
repos = get_yum_repositories()
fake_repo_2 = repos['fake-repo-2']
--
2.1.0
9 years, 6 months
[PATCH] Support ISO detection of xorriso ISOs
by Ramon Medeiros
ISOs were created by genisoimage, so the paths were lowercase, when
readed in iso9660 format. Debian 8 ppc64el started to use xorriso, which
uses uppercase paths.
Signed-off-by: Ramon Medeiros <ramonn(a)linux.vnet.ibm.com>
---
src/kimchi/isoinfo.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/kimchi/isoinfo.py b/src/kimchi/isoinfo.py
index fd1f8f7..6fb0f38 100644
--- a/src/kimchi/isoinfo.py
+++ b/src/kimchi/isoinfo.py
@@ -308,7 +308,7 @@ lang=en#!/wiki/W51a7ffcf4dfd_4b40_9d82_446ebc23c550/page/PowerLinux\
if dir_parent == 1:
# read the dir name using the namelen
dir_name = path_table_data[i: i+dir_namelen].rstrip()
- if dir_name == 'ppc':
+ if dir_name.lower() == 'ppc':
# stop searching, dir was found
break
# Need to consider the optional padding field as well
@@ -378,7 +378,7 @@ lang=en#!/wiki/W51a7ffcf4dfd_4b40_9d82_446ebc23c550/page/PowerLinux\
static_rec_size + file_name_len].rstrip()
# The second bit of the file_flags indicate if this record
# is a directory.
- if filename == BOOT_FILE_NAME and (file_flags & 2) != 1:
+ if BOOT_FILE_NAME in filename.lower() and (file_flags & 2) != 1:
self.bootable = True
return
--
2.1.0
9 years, 6 months
[PATCH] Github #657 - fixing yum check-update parsing
by Daniel Henrique Barboza
Enhancing the parsing of yum check-update command in the
yumparser module.
A new unit test was included to simulate the error condition.
Signed-off-by: Daniel Henrique Barboza <dhbarboza82(a)gmail.com>
---
src/kimchi/yumparser.py | 44 +++++++++++++++++++++++++++++++++-----------
tests/test_yumparser.py | 27 +++++++++++++++++++++++++++
2 files changed, 60 insertions(+), 11 deletions(-)
diff --git a/src/kimchi/yumparser.py b/src/kimchi/yumparser.py
index ce6ba9d..7612bbc 100644
--- a/src/kimchi/yumparser.py
+++ b/src/kimchi/yumparser.py
@@ -216,6 +216,27 @@ class YumUpdatePackageObject(object):
self.ui_from_repo = repo
+def _include_line_checkupdate_output(line):
+ tokens = line.split()
+
+ if len(tokens) != 3:
+ return False
+
+ if '.' not in tokens[0]:
+ return False
+
+ return True
+
+
+def _filter_lines_checkupdate_output(output):
+ if output is None:
+ return []
+
+ out = [l for l in output.split('\n')
+ if _include_line_checkupdate_output(l)]
+ return out
+
+
def _get_yum_checkupdate_output():
cmd = ['yum', 'check-update', '-d0']
yum_update_cmd = subprocess.Popen(cmd,
@@ -225,23 +246,24 @@ def _get_yum_checkupdate_output():
if error != '':
return None
- return out.split()
+ return out
-def get_yum_packages_list_update():
- yum_checkupdate_output = _get_yum_checkupdate_output()
- if yum_checkupdate_output is None:
- return None
+def get_yum_packages_list_update(checkupdate_output=None):
+ if checkupdate_output is None:
+ checkupdate_output = _get_yum_checkupdate_output()
+
+ filtered_output = _filter_lines_checkupdate_output(checkupdate_output)
packages = []
- index = 0
- while index < len(yum_checkupdate_output):
- name_arch = yum_checkupdate_output[index]
- index += 1
- version = yum_checkupdate_output[index]
+ for line in filtered_output:
+ line = line.split()
+ index = 0
+ name_arch = line[index]
index += 1
- repo = yum_checkupdate_output[index]
+ version = line[index]
index += 1
+ repo = line[index]
name, arch = name_arch.rsplit('.', 1)
packages.append(YumUpdatePackageObject(name, arch, version, repo))
diff --git a/tests/test_yumparser.py b/tests/test_yumparser.py
index 8645a65..4ec84ae 100644
--- a/tests/test_yumparser.py
+++ b/tests/test_yumparser.py
@@ -23,6 +23,7 @@ import unittest
from kimchi.model import model
from kimchi.yumparser import delete_repo_from_file, get_repo_files
+from kimchi.yumparser import get_yum_packages_list_update
from kimchi.yumparser import get_yum_repositories, write_repo_to_file
from kimchi.yumparser import YumRepoObject
@@ -60,6 +61,22 @@ def _create_fake_repos_file():
return tmp_file_name
+def _generate_yumcheckupdate_output():
+ output = """
+Repository 'REPOSITORY1' is missing name in configuration, using id
+Repository 'REPOSITORY1-OPTIONAL' is missing name in configuration, using id
+
+PACKAGE1.noarch 20150611.-gg-FAKE1 REPOSITORY1
+PACKAGE2.x86_64 20150611.-no-FAKE2 REPOSITORY2
+PACKAGE3.dot.dot.i386 20150611.-re-FAKE3 REPOSITORY3
+
+Obsoleting Packages
+OBSOLETE4.dot.dot.i386 20150611.FAKE4 REPOSITORY4
+OBSOLETE5.dot.dot.fakearch 20150611.FAKE5 REPOSITORY5
+ """
+ return output
+
+
@unittest.skipIf(not _is_yum_distro(), 'Skipping: YUM exclusive test')
def setUpModule():
global TEMP_REPO_FILE
@@ -109,3 +126,13 @@ class YumParserTests(unittest.TestCase):
repos = get_yum_repositories()
repos_id = repos.keys()
self.assertNotIn('fake-repo-3', repos_id)
+
+ def test_yum_checkupdate_parsing(self):
+ output = _generate_yumcheckupdate_output()
+ packages = get_yum_packages_list_update(output)
+ self.assertEqual(len(packages), 5)
+ self.assertEqual(packages[0].ui_from_repo, 'REPOSITORY1')
+ self.assertEqual(packages[1].version, '20150611.-no-FAKE2')
+ self.assertEqual(packages[2].name, 'PACKAGE3.dot.dot')
+ self.assertEqual(packages[3].arch, 'i386')
+ self.assertEqual(packages[4].arch, 'fakearch')
--
2.1.0
9 years, 6 months
[PATCH V2] Bug fix: Allow user creates multiple templates
by Aline Manera
V1 - V2:
- Enclose the guest creation code with the lock
Aline Manera (1):
Bug fix: Allow user creates multiple templates
src/kimchi/kvmusertests.py | 40 ++++++++++++++++++++++------------------
1 file changed, 22 insertions(+), 18 deletions(-)
--
2.1.0
9 years, 6 months
[PATCH 0/3 v4] Removing Yum API from Kimchi
by Daniel Henrique Barboza
v4:
- simplified the code of YumRepoObj class
x3:
- skipping yumparser tests in Ubuntu
- make check-local fixes
The use of Yum API is causing a memory leak each time the
Host tab is loaded. This can be verified by seeing the use
of memory in $top.
To remove the Yum API, a new module named 'yumparser' was created
to manipulate Yum repositories directly from the filesystem and to
return the software update list by parsing $yum check-update command.
A new unit test file was created to verify the proper
behavior of the yumparser module.
Daniel Henrique Barboza (3):
Adding yumparser module
Unit tests for the yumparser module
Changing repositories and swupdate to use yumparser module
src/kimchi/repositories.py | 65 ++++--------
src/kimchi/swupdate.py | 16 ++-
src/kimchi/yumparser.py | 248 +++++++++++++++++++++++++++++++++++++++++++++
tests/test_yumparser.py | 111 ++++++++++++++++++++
4 files changed, 385 insertions(+), 55 deletions(-)
create mode 100644 src/kimchi/yumparser.py
create mode 100644 tests/test_yumparser.py
--
2.1.0
9 years, 6 months
[PATCH] Fix bug #647: Properly set qxl as video model for Fedora 22
by Aline Manera
Signed-off-by: Aline Manera <alinefm(a)linux.vnet.ibm.com>
---
src/kimchi/osinfo.py | 6 ++++++
src/kimchi/vmtemplate.py | 8 ++++++++
2 files changed, 14 insertions(+)
diff --git a/src/kimchi/osinfo.py b/src/kimchi/osinfo.py
index 35aa594..78eb828 100644
--- a/src/kimchi/osinfo.py
+++ b/src/kimchi/osinfo.py
@@ -68,6 +68,9 @@ template_specs = {'x86': {'old': dict(disk_bus='ide',
memory=1280)}}
+custom_specs = {'fedora': {'22': dict(video_model='qxl')}}
+
+
modern_version_bases = {'x86': {'debian': '6.0', 'ubuntu': '7.10',
'opensuse': '10.3', 'centos': '5.3',
'rhel': '6.0', 'fedora': '16', 'gentoo': '0',
@@ -199,6 +202,9 @@ def lookup(distro, version):
params['os_distro'] = params['os_version'] = "unknown"
params.update(template_specs[arch]['old'])
+ # Get custom specifications
+ params.update(custom_specs.get(distro, {}).get(version, {}))
+
if distro in icon_available_distros:
params['icon'] = 'images/icon-%s.png' % distro
else:
diff --git a/src/kimchi/vmtemplate.py b/src/kimchi/vmtemplate.py
index 4143839..79e04ed 100644
--- a/src/kimchi/vmtemplate.py
+++ b/src/kimchi/vmtemplate.py
@@ -259,6 +259,12 @@ class VMTemplate(object):
<input type='tablet' bus='%(kbd_bus)s'> </input>
"""
+ video = """
+ <video>
+ <model type='%(video_model)s'/>
+ </video>
+ """
+
input_output = ""
if 'mouse_bus' in self.info.keys():
input_output += mouse % self.info
@@ -268,6 +274,8 @@ class VMTemplate(object):
input_output += tablet % self.info
if 'sound_model' in self.info.keys():
input_output += sound % self.info
+ if 'video_model' in self.info.keys():
+ input_output += video % self.info
return input_output
def _get_cpu_xml(self):
--
2.1.0
9 years, 6 months
[PATCH 0/6 - V2][Memory HotPlug] Implements backend of memory device hotplug
by Rodrigo Trujillo
V2
- Fix erros in tests and add a test to slots number
- Fix other minor issues with Libvirt < 1.2.14
V1
This patchset implements the backend part of memory hotplug functionality,
including:
- new feature test to check if libvirt supports memory devices
- changes the way that memory is assigned or updated in the guest xml:
* memory is now set in a basic NUMA node
- includes maxMemory element in the XML:
* which is equal the total memory of the host
* sets memory device slots. The total number of slots are equal the
maxMemory minus the memory assigned (1 slot == 1 GB )
- creates a new VM device, the memory device:
* by default, a memory device will have 1GB
* user can add the memory device with machine running or offline
- memory devices are selected according to its position in the xml (the slot)
0, 1, 2, etc
URL:
- http://localhost:8010/vms/<VM>/memdevices
- http://localhost:8010/vms/<VM>/memdevices/<MEM-DEV>
Rodrigo Trujillo (6):
[Memory HotPlug] Feature test to check support to memory devices
[Memory HotPlug] Add maxMemory and numa configuration to guest xml
[Memory HotPlug] Memory device control and model classes
[Memory HotPlug] Add parameters checking and documentation to memory
device API
[Memory HotPlug] Fix VM offline memory update and fix slots assignment
[Memory HotPlug] Fix test and adds slot test
docs/API.md | 16 +++++++
src/kimchi/API.json | 14 +++++-
src/kimchi/control/vm/memdevices.py | 47 +++++++++++++++++++
src/kimchi/i18n.py | 5 ++
src/kimchi/mockmodel.py | 7 +++
src/kimchi/model/config.py | 3 ++
src/kimchi/model/featuretests.py | 43 +++++++++++++++++
src/kimchi/model/vmmemdevices.py | 94 +++++++++++++++++++++++++++++++++++++
src/kimchi/model/vms.py | 85 ++++++++++++++++++++++++++++-----
src/kimchi/vmtemplate.py | 40 ++++++++++++----
tests/test_model.py | 2 +-
tests/test_rest.py | 4 +-
tests/test_vmtemplate.py | 5 +-
13 files changed, 338 insertions(+), 27 deletions(-)
create mode 100644 src/kimchi/control/vm/memdevices.py
create mode 100644 src/kimchi/model/vmmemdevices.py
--
2.1.0
9 years, 6 months
[PATCH v2] Fix make install for systemd systems
by Ramon Medeiros
Make install now will install firewalld and systemctl service. Also,
it will create base file structure to run kimchi (what was being created
at rpm spec).
Changes:
v2:
Use macros to determine systemd directory
Do not use root permissions on make install script (like rebooting systemctl)
---
Makefile.am | 50 +++++++++++++++++++++++++++----------------
configure.ac | 9 ++++++++
contrib/kimchi.spec.fedora.in | 16 --------------
contrib/kimchi.spec.suse.in | 18 ----------------
4 files changed, 41 insertions(+), 52 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 91a0fa2..46b0b5b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -115,27 +115,41 @@ ChangeLog:
fi
install-data-local:
- @if test -d /usr/lib/systemd/system/ ; then \
- $(INSTALL_DATA) contrib/kimchid.service.fedora /usr/lib/systemd/system/kimchid.service; \
- systemctl daemon-reload; \
- elif test -d /etc/systemd/system; then \
- $(INSTALL_DATA) contrib/kimchid.service.fedora /etc/systemd/system/kimchid.service; \
- systemctl daemon-reload; \
- else \
- $(INSTALL_DATA) contrib/kimchid.sysvinit /etc/init.d/kimchid; \
- chmod +x /etc/init.d/kimchid; \
- fi
+ @if test -d $(systemdsystemunitdir) ; then \
+ mkdir -p $(DESTDIR)/$(systemdsystemunitdir); \
+ $(INSTALL_DATA) contrib/kimchid.service.fedora $(DESTDIR)/$(systemdsystemunitdir)/kimchid.service; \
+ else \
+ mkdir -p $(DESTDIR)/etc/init.d/ \
+ $(INSTALL_DATA) contrib/kimchid.sysvinit $(DESTDIR)/etc/init.d/kimchid; \
+ chmod +x $(DESTDIR)/etc/init.d/kimchid; \
+ fi; \
+ if test -d /usr/lib/firewalld/services/; then \
+ mkdir -p $(DESTDIR)/usr/lib/firewalld/services/; \
+ $(INSTALL_DATA) src/firewalld.xml $(DESTDIR)/usr/lib/firewalld/services/kimchid.xml; \
+ fi; \
+ mkdir -p $(DESTDIR)/var/lib/kimchi/{debugreports,screenshots,vnc-tokens,isos}
+ touch $(DESTDIR)/var/lib/kimchi/objectstore
+ mkdir -p $(DESTDIR)/var/log/kimchi/
+ touch $(DESTDIR)/var/log/kimchi/kimchi-access.log
+ touch $(DESTDIR)/var/log/kimchi/kimchi-error.log
+ mkdir -p $(DESTDIR)/etc/kimchi/
+ touch $(DESTDIR)/etc/nginx/conf.d/kimchi.conf
uninstall-local:
- @if test -f /usr/lib/systemd/system/kimchid.service; then \
- $(RM) /usr/lib/systemd/system/kimchid.service; \
- systemctl daemon-reload; \
- elif test -f /etc/systemd/system/kimchid.service; then \
- $(RM) /etc/systemd/system/kimchid.service; \
+ @if test -f $(systemdsystemunitdir)/kimchid.service; then \
+ $(RM) $(DESTDIR)/$(systemdsystemunitdir)/kimchid.service; \
elif test -f /etc/init.d/kimchid; then \
- $(RM) /etc/init.d/kimchid; \
- fi
-
+ $(RM) $(DESTDIR)/etc/init.d/kimchid; \
+ $(RM) $(DESTDIR)/etc/init/kimchi.conf; \
+ fi; \
+ if test -d /usr/lib/firewalld/services/; then \
+ $(RM) $(DESTDIR)/usr/lib/firewalld/services/kimchid.xml; \
+ fi; \
+ $(RM) -rf $(DESTDIR)/var/lib/kimchi
+ $(RM) -rf $(DESTDIR)/var/log/kimchi
+ $(RM) -rf $(DESTDIR)/etc/kimchi
+ $(RM) $(DESTDIR)/etc/nginx/conf.d/kimchi.conf
+
VERSION:
@if test -d .git; then \
git describe --abbrev=0 > $@; \
diff --git a/configure.ac b/configure.ac
index f5091b8..0261b5f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -64,6 +64,15 @@ else
AC_SUBST([ENABLE_SAMPLE], [False])
fi
+# check for systemd
+PKG_PROG_PKG_CONFIG
+AC_ARG_WITH([systemdsystemunitdir],
+ AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]),
+ [], [with_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)])
+if test "x$with_systemdsystemunitdir" != xno; then
+ AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
+fi
+
AC_ARG_WITH(
[spice-html5],
[AS_HELP_STRING([--with-spice-html5],
diff --git a/contrib/kimchi.spec.fedora.in b/contrib/kimchi.spec.fedora.in
index 30f8417..dc5533a 100644
--- a/contrib/kimchi.spec.fedora.in
+++ b/contrib/kimchi.spec.fedora.in
@@ -85,22 +85,6 @@ make DESTDIR=%{buildroot} install
%if 0%{?with_systemd}
-# create /var/lib/kimchi structure
-mkdir -p %{buildroot}/%{_sharedstatedir}/kimchi/{debugreports,screenshots,vnc-tokens,isos}
-touch %{buildroot}/%{_sharedstatedir}/kimchi/objectstore
-
-# create /var/log/kimchi structure
-mkdir -p %{buildroot}/%{_localstatedir}/log/kimchi/
-touch %{buildroot}/%{_localstatedir}/log/kimchi/kimchi-access.log
-touch %{buildroot}/%{_localstatedir}/log/kimchi/kimchi-error.log
-
-# create /etc/kimchi structure
-mkdir -p %{buildroot}/%{_sysconfdir}/kimchi/
-touch %{buildroot}/%{_sysconfdir}/nginx/conf.d/kimchi.conf
-
-# Install the systemd scripts
-install -Dm 0644 contrib/kimchid.service.fedora %{buildroot}%{_unitdir}/kimchid.service
-install -Dm 0640 src/firewalld.xml %{buildroot}%{_prefix}/lib/firewalld/services/kimchid.xml
%endif
%if 0%{?rhel} == 6
diff --git a/contrib/kimchi.spec.suse.in b/contrib/kimchi.spec.suse.in
index bf85661..5681a60 100644
--- a/contrib/kimchi.spec.suse.in
+++ b/contrib/kimchi.spec.suse.in
@@ -54,24 +54,6 @@ make
rm -rf %{buildroot}
make DESTDIR=%{buildroot} install
-# create /var/lib/kimchi structure
-mkdir -p %{buildroot}/%{_var}/lib/kimchi/{debugreports,screenshots,vnc-tokens,isos}
-touch %{buildroot}/%{_var}/lib/kimchi/objectstore
-
-# create /var/log/kimchi structure
-mkdir -p %{buildroot}/%{_localstatedir}/log/kimchi/
-touch %{buildroot}/%{_localstatedir}/log/kimchi/kimchi-access.log
-touch %{buildroot}/%{_localstatedir}/log/kimchi/kimchi-error.log
-
-# create /etc/kimchi structure
-mkdir -p %{buildroot}/%{_sysconfdir}/kimchi/
-
-# create nginx configuration
-touch %{buildroot}/%{_sysconfdir}/nginx/conf.d/kimchi.conf
-
-# Install the SysV init scripts
-install -Dm 0755 contrib/kimchid.sysvinit %{buildroot}%{_initrddir}/kimchid
-
%post
chkconfig kimchid on
--
2.1.0
9 years, 6 months