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 import pkgmanagers
37 from micng.utils.rpmmisc import *
38 from micng.utils.misc import *
39 from BaseImageCreator import ImageCreator
42 class FsImageCreator(ImageCreator):
43 def __init__(self, ks, name):
44 """Initialize a LoopImageCreator instance.
46 This method takes the same arguments as ImageCreator.__init__()
48 ImageCreator.__init__(self, ks, name)
53 def _stage_final_image(self):
57 def package(self, destdir = "."):
58 self._stage_final_image()
60 destdir = os.path.abspath(os.path.expanduser(destdir))
61 if self._recording_pkgs:
62 self._save_recording_pkgs(destdir)
64 print "Copying %s to %s, please be patient to wait (it is slow if they are on different file systems/partitons/disks)" \
65 % (self._instroot, destdir + "/" + self.name)
67 copycmd = find_binary_path("cp")
68 args = [ copycmd, "-af", self._instroot, destdir + "/" + self.name ]
71 ignores = ["/dev/fd", "/dev/stdin", "/dev/stdout", "/dev/stderr", "/etc/mtab"]
72 for exclude in ignores:
73 if os.path.exists(destdir + "/" + self.name + exclude):
74 os.unlink(destdir + "/" + self.name + exclude)
76 self.outimage.append(destdir + "/" + self.name)