2 # creator.py : ImageCreator and LoopImageCreator base classes
4 # Copyright 2007, Red Hat Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; version 2 of the License.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU Library General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
33 from micng.utils.errors import *
34 from micng.utils.fs_related import *
35 from micng.utils import kickstart
36 from micng.utils.rpmmisc import *
37 from micng.utils.misc import *
38 from baseimager import BaseImageCreator
41 class FsImageCreator(BaseImageCreator):
42 def __init__(self, cfgmgr = None, pkgmgr = None):
43 BaseImageCreator.__init__(self, cfgmgr, pkgmgr)
47 def _stage_final_image(self):
51 def package(self, destdir = "."):
52 self._stage_final_image()
54 if not os.path.exists(destdir):
56 destdir = os.path.abspath(os.path.expanduser(destdir))
57 if self._recording_pkgs:
58 self._save_recording_pkgs(destdir)
60 logging.info("Copying %s to %s, please be patient to wait" % (self._instroot, destdir + "/" + self.name))
62 copycmd = find_binary_path("cp")
63 args = [ copycmd, "-af", self._instroot, destdir + "/" + self.name ]
66 ignores = ["/dev/fd", "/dev/stdin", "/dev/stdout", "/dev/stderr", "/etc/mtab"]
67 for exclude in ignores:
68 if os.path.exists(destdir + "/" + self.name + exclude):
69 os.unlink(destdir + "/" + self.name + exclude)
71 self.outimage.append(destdir + "/" + self.name)