From 701ab02619b06ba650d7d50bc745afd562a7860f Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Wed, 30 Mar 2016 13:57:10 -0700 Subject: [PATCH] Copying same file shouldn't crash (#1269213) When using the template install command copying the same file to itself shouldn't crash. Just log the error and continue. Also copy the s390 configuration files for use with livemedia-creator Resolves: rhbz#1269213 --- .../99-generic/live/config_files/s390/generic.ins | 5 +++++ .../99-generic/live/config_files/s390/generic.prm | 1 + .../99-generic/live/config_files/s390/genericdvd.prm | 1 + .../99-generic/live/config_files/s390/redhat.exec | 9 +++++++++ src/pylorax/ltmpl.py | 11 +++++++++-- 5 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 share/templates.d/99-generic/live/config_files/s390/generic.ins create mode 100644 share/templates.d/99-generic/live/config_files/s390/generic.prm create mode 100644 share/templates.d/99-generic/live/config_files/s390/genericdvd.prm create mode 100644 share/templates.d/99-generic/live/config_files/s390/redhat.exec diff --git a/share/templates.d/99-generic/live/config_files/s390/generic.ins b/share/templates.d/99-generic/live/config_files/s390/generic.ins new file mode 100644 index 00000000..756d2ff4 --- /dev/null +++ b/share/templates.d/99-generic/live/config_files/s390/generic.ins @@ -0,0 +1,5 @@ +* minimal lpar ins file +images/kernel.img 0x00000000 +images/initrd.img @INITRD_LOAD_ADDRESS@ +images/genericdvd.prm 0x00010480 +images/initrd.addrsize 0x00010408 diff --git a/share/templates.d/99-generic/live/config_files/s390/generic.prm b/share/templates.d/99-generic/live/config_files/s390/generic.prm new file mode 100644 index 00000000..e1dc3977 --- /dev/null +++ b/share/templates.d/99-generic/live/config_files/s390/generic.prm @@ -0,0 +1 @@ +ro ramdisk_size=40000 cio_ignore=all,!condev diff --git a/share/templates.d/99-generic/live/config_files/s390/genericdvd.prm b/share/templates.d/99-generic/live/config_files/s390/genericdvd.prm new file mode 100644 index 00000000..b5d27316 --- /dev/null +++ b/share/templates.d/99-generic/live/config_files/s390/genericdvd.prm @@ -0,0 +1 @@ +ro ramdisk_size=40000 cio_ignore=all,!condev rd.cmdline=ask diff --git a/share/templates.d/99-generic/live/config_files/s390/redhat.exec b/share/templates.d/99-generic/live/config_files/s390/redhat.exec new file mode 100644 index 00000000..f1e5931a --- /dev/null +++ b/share/templates.d/99-generic/live/config_files/s390/redhat.exec @@ -0,0 +1,9 @@ +/* */ +'CL RDR' +'PURGE RDR ALL' +'SPOOL PUNCH * RDR' +'PUNCH KERNEL IMG A (NOH' +'PUNCH GENERIC PRM A (NOH' +'PUNCH INITRD IMG A (NOH' +'CH RDR ALL KEEP NOHOLD' +'I 00C' diff --git a/src/pylorax/ltmpl.py b/src/pylorax/ltmpl.py index 42f5435b..87fb6f52 100644 --- a/src/pylorax/ltmpl.py +++ b/src/pylorax/ltmpl.py @@ -26,6 +26,7 @@ logger = logging.getLogger("pylorax.ltmpl") import os, re, glob, shlex, fnmatch from os.path import basename, isdir from subprocess import CalledProcessError +import shutil from pylorax.sysutils import joinpaths, cpfile, mvfile, replace, remove from pylorax.dnfhelper import LoraxDownloadCallback, LoraxRpmCallback @@ -269,7 +270,10 @@ class LoraxTemplateRunner(object): install /usr/share/myconfig/grub.conf.in /boot/grub.conf ''' for src in rglob(self._in(srcglob), fatal=True): - cpfile(src, self._out(dest)) + try: + cpfile(src, self._out(dest)) + except shutil.Error as e: + logger.error(e) def installimg(self, *args): ''' @@ -424,7 +428,10 @@ class LoraxTemplateRunner(object): If DEST doesn't exist, SRC will be copied to a file with that name, if the path leading to it exists. ''' - cpfile(self._out(src), self._out(dest)) + try: + cpfile(self._out(src), self._out(dest)) + except shutil.Error as e: + logger.error(e) def move(self, src, dest): '''