本文整理汇总了Python中mic.utils.fs_related.makedirs函数的典型用法代码示例。如果您正苦于以下问题:Python makedirs函数的具体用法?Python makedirs怎么用?Python makedirs使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了makedirs函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: package
def package(self, destdir = "."):
"""Prepares the created image for final delivery.
In its simplest form, this method merely copies the install root to the
supplied destination directory; other subclasses may choose to package
the image by e.g. creating a bootable ISO containing the image and
bootloader configuration.
destdir -- the directory into which the final image should be moved;
this defaults to the current directory.
"""
self._stage_final_image()
if not os.path.exists(destdir):
fs.makedirs(destdir)
if self._img_compression_method:
if not self._img_name:
raise CreatorError("Image name not set.")
rc = None
img_location = os.path.join(self._outdir,self._img_name)
if self._img_compression_method == "bz2":
bzip2 = fs.find_binary_path('bzip2')
msger.info("Compressing %s with bzip2. Please wait..." \
% img_location)
rc = runner.show([bzip2, "-f", img_location])
if rc:
raise CreatorError("Failed to compress image %s with %s." \
% (img_location, self._img_compression_method))
for bootimg in glob.glob(os.path.dirname(img_location) + \
"/*-boot.bin"):
msger.info("Compressing %s with bzip2. Please wait..." \
% bootimg)
rc = runner.show([bzip2, "-f", bootimg])
if rc:
raise CreatorError("Failed to compress image %s with "
"%s." \
% (bootimg,
self._img_compression_method))
if self._recording_pkgs:
self._save_recording_pkgs(destdir)
# For image formats with two or multiple image files, it will be
# better to put them under a directory
if self.image_format in ("raw", "vmdk", "vdi", "nand", "mrstnand"):
destdir = os.path.join(destdir, "%s-%s" \
% (self.name, self.image_format))
msger.debug("creating destination dir: %s" % destdir)
fs.makedirs(destdir)
# Ensure all data is flushed to _outdir
runner.quiet('sync')
for f in os.listdir(self._outdir):
shutil.move(os.path.join(self._outdir, f),
os.path.join(destdir, f))
self.outimage.append(os.path.join(destdir, f))
self.do_genchecksum(os.path.join(destdir, f))
开发者ID:csdb,项目名称:mic,代码行数:60,代码来源:baseimager.py
示例2: __write_initrd_conf
def __write_initrd_conf(self, path):
content = ""
if not os.path.exists(os.path.dirname(path)):
fs_related.makedirs(os.path.dirname(path))
f = open(path, "w")
content += 'LIVEOS="yes"\n'
content += 'PROBE="no"\n'
content += 'MODULES+="squashfs ext3 ext2 vfat msdos "\n'
content += 'MODULES+="sr_mod sd_mod ide-cd cdrom "\n'
for module in self.__modules:
if module == "=usb":
content += 'MODULES+="ehci_hcd uhci_hcd ohci_hcd "\n'
content += 'MODULES+="usb_storage usbhid "\n'
elif module == "=firewire":
content += 'MODULES+="firewire-sbp2 firewire-ohci "\n'
content += 'MODULES+="sbp2 ohci1394 ieee1394 "\n'
elif module == "=mmc":
content += 'MODULES+="mmc_block sdhci sdhci-pci "\n'
elif module == "=pcmcia":
content += 'MODULES+="pata_pcmcia "\n'
else:
content += 'MODULES+="' + module + ' "\n'
f.write(content)
f.close()
开发者ID:nataliakoval,项目名称:mic,代码行数:26,代码来源:livecd.py
示例3: savefs_before_chroot
def savefs_before_chroot(chrootdir, saveto = None):
""" backup chrootdir to another directory before chrooting in """
if configmgr.chroot['saveto']:
savefs = True
saveto = configmgr.chroot['saveto']
wrnmsg = "Can't save chroot fs for dir %s exists" % saveto
if saveto == chrootdir:
savefs = False
wrnmsg = "Dir %s is being used to chroot" % saveto
elif os.path.exists(saveto):
if msger.ask("Dir %s already exists, cleanup and continue?" %
saveto):
shutil.rmtree(saveto, ignore_errors = True)
savefs = True
else:
savefs = False
if savefs:
msger.info("Saving image to directory %s" % saveto)
fs_related.makedirs(os.path.dirname(os.path.abspath(saveto)))
runner.quiet("cp -af %s %s" % (chrootdir, saveto))
devs = ['dev/fd',
'dev/stdin',
'dev/stdout',
'dev/stderr',
'etc/mtab']
ignlst = [os.path.join(saveto, x) for x in devs]
map(os.unlink, filter(os.path.exists, ignlst))
else:
msger.warning(wrnmsg)
开发者ID:01org,项目名称:mic,代码行数:30,代码来源:chroot.py
示例4: _stage_final_image
def _stage_final_image(self):
try:
fs_related.makedirs(self.__ensure_isodir() + "/LiveOS")
minimal_size = self._resparse()
if not self.skip_minimize:
fs_related.create_image_minimizer(self.__isodir + \
"/LiveOS/osmin.img",
self._image,
minimal_size)
if self.skip_compression:
shutil.move(self._image, self.__isodir + "/LiveOS/ext3fs.img")
else:
fs_related.makedirs(os.path.join(
os.path.dirname(self._image),
"LiveOS"))
shutil.move(self._image,
os.path.join(os.path.dirname(self._image),
"LiveOS", "ext3fs.img"))
fs_related.mksquashfs(os.path.dirname(self._image),
self.__isodir + "/LiveOS/squashfs.img")
self.__create_iso(self.__isodir)
if self.pack_to:
isoimg = os.path.join(self._outdir, self.name + ".iso")
packimg = os.path.join(self._outdir, self.pack_to)
misc.packing(packimg, isoimg)
os.unlink(isoimg)
finally:
shutil.rmtree(self.__isodir, ignore_errors = True)
self.__isodir = None
开发者ID:nataliakoval,项目名称:mic,代码行数:35,代码来源:livecd.py
示例5: _configure_syslinux_bootloader
def _configure_syslinux_bootloader(self, isodir):
"""configure the boot loader"""
fs_related.makedirs(isodir + "/isolinux")
menu = self.__find_syslinux_menu()
self.__copy_syslinux_files(isodir, menu,
self.__find_syslinux_mboot())
background = ""
if self.__copy_syslinux_background(isodir + "/isolinux/splash.jpg"):
background = "menu background splash.jpg"
cfg = self.__get_basic_syslinux_config(menu = menu,
background = background,
name = self.name,
timeout = self._timeout * 10,
distroname = self.distro_name)
cfg += self.__get_image_stanzas(isodir)
cfg += self.__get_memtest_stanza(isodir)
cfg += self.__get_local_stanza(isodir)
cfg += self._get_isolinux_stanzas(isodir)
cfgf = open(isodir + "/isolinux/isolinux.cfg", "w")
cfgf.write(cfg)
cfgf.close()
开发者ID:nataliakoval,项目名称:mic,代码行数:27,代码来源:livecd.py
示例6: package
def package(self, destdir="."):
"""Prepares the created image for final delivery.
In its simplest form, this method merely copies the install root to the
supplied destination directory; other subclasses may choose to package
the image by e.g. creating a bootable ISO containing the image and
bootloader configuration.
destdir -- the directory into which the final image should be moved;
this defaults to the current directory.
"""
self._stage_final_image()
if not os.path.exists(destdir):
fs.makedirs(destdir)
if self._recording_pkgs:
self._save_recording_pkgs(destdir)
# For image formats with two or multiple image files, it will be
# better to put them under a directory
if self.image_format in ("raw", "vmdk", "vdi", "nand", "mrstnand"):
destdir = os.path.join(destdir, "%s-%s" % (self.name, self.image_format))
msger.debug("creating destination dir: %s" % destdir)
fs.makedirs(destdir)
# Ensure all data is flushed to _outdir
runner.quiet("sync")
misc.check_space_pre_cp(self._outdir, destdir)
for f in os.listdir(self._outdir):
shutil.move(os.path.join(self._outdir, f), os.path.join(destdir, f))
self.outimage.append(os.path.join(destdir, f))
self.do_genchecksum(os.path.join(destdir, f))
开发者ID:JussiPakkanen,项目名称:mic,代码行数:35,代码来源:baseimager.py
示例7: _configure_efi_bootloader
def _configure_efi_bootloader(self, isodir):
"""Set up the configuration for an EFI bootloader"""
fs_related.makedirs(isodir + "/EFI/boot")
if not self.__copy_efi_files(isodir):
shutil.rmtree(isodir + "/EFI")
return
for f in os.listdir(isodir + "/isolinux"):
os.link("%s/isolinux/%s" %(isodir, f),
"%s/EFI/boot/%s" %(isodir, f))
cfg = self.__get_basic_efi_config(name = self.name,
timeout = self._timeout)
cfg += self.__get_efi_image_stanzas(isodir, self.name)
cfgf = open(isodir + "/EFI/boot/grub.conf", "w")
cfgf.write(cfg)
cfgf.close()
# first gen mactel machines get the bootloader name wrong apparently
if rpmmisc.getBaseArch() == "i386":
os.link(isodir + "/EFI/boot/grub.efi",
isodir + "/EFI/boot/boot.efi")
os.link(isodir + "/EFI/boot/grub.conf",
isodir + "/EFI/boot/boot.conf")
# for most things, we want them named boot$efiarch
efiarch = {"i386": "ia32", "x86_64": "x64"}
efiname = efiarch[rpmmisc.getBaseArch()]
os.rename(isodir + "/EFI/boot/grub.efi",
isodir + "/EFI/boot/boot%s.efi" %(efiname,))
os.link(isodir + "/EFI/boot/grub.conf",
isodir + "/EFI/boot/boot%s.conf" %(efiname,))
开发者ID:nataliakoval,项目名称:mic,代码行数:35,代码来源:livecd.py
示例8: _do_chroot_tar
def _do_chroot_tar(cls, target, cmd=[]):
mountfp_xml = os.path.splitext(target)[0] + '.xml'
if not os.path.exists(mountfp_xml):
raise errors.CreatorError("No mount point file found for this tar "
"image, please check %s" % mountfp_xml)
import tarfile
tar = tarfile.open(target, 'r')
tmpdir = misc.mkdtemp()
tar.extractall(path=tmpdir)
tar.close()
mntdir = misc.mkdtemp()
loops = []
for (mp, label, name, size, fstype) in load_mountpoints(mountfp_xml):
if fstype in ("ext2", "ext3", "ext4"):
myDiskMount = fs_related.ExtDiskMount
elif fstype == "btrfs":
myDiskMount = fs_related.BtrfsDiskMount
elif fstype in ("vfat", "msdos"):
myDiskMount = fs_related.VfatDiskMount
else:
raise errors.CreatorError("Cannot support fstype: %s" % fstype)
name = os.path.join(tmpdir, name)
size = size * 1024L * 1024L
loop = myDiskMount(fs_related.SparseLoopbackDisk(name, size),
os.path.join(mntdir, mp.lstrip('/')),
fstype, size, label)
try:
msger.verbose("Mount %s to %s" % (mp, mntdir + mp))
fs_related.makedirs(os.path.join(mntdir, mp.lstrip('/')))
loop.mount()
except:
loop.cleanup()
for lp in reversed(loops):
chroot.cleanup_after_chroot("img", lp, None, mntdir)
shutil.rmtree(tmpdir, ignore_errors=True)
raise
loops.append(loop)
try:
if len(cmd) != 0:
cmdline = "/usr/bin/env HOME=/root " + ' '.join(cmd)
else:
cmdline = "/usr/bin/env HOME=/root /bin/bash"
chroot.chroot(mntdir, None, cmdline)
except:
raise errors.CreatorError("Failed to chroot to %s." % target)
finally:
for loop in reversed(loops):
chroot.cleanup_after_chroot("img", loop, None, mntdir)
shutil.rmtree(tmpdir, ignore_errors=True)
开发者ID:nataliakoval,项目名称:mic,代码行数:59,代码来源:loop_plugin.py
示例9: setup_qemu_emulator
def setup_qemu_emulator(rootdir, arch):
# mount binfmt_misc if it doesn't exist
if not os.path.exists("/proc/sys/fs/binfmt_misc"):
modprobecmd = find_binary_path("modprobe")
runner.show([modprobecmd, "binfmt_misc"])
if not os.path.exists("/proc/sys/fs/binfmt_misc/register"):
mountcmd = find_binary_path("mount")
runner.show([mountcmd, "-t", "binfmt_misc", "none", "/proc/sys/fs/binfmt_misc"])
# qemu_emulator is a special case, we can't use find_binary_path
# qemu emulator should be a statically-linked executable file
if arch == "aarch64":
node = "/proc/sys/fs/binfmt_misc/aarch64"
if os.path.exists("/usr/bin/qemu-arm64") and is_statically_linked("/usr/bin/qemu-arm64"):
arm_binary = "qemu-arm64"
elif os.path.exists("/usr/bin/qemu-aarch64") and is_statically_linked("/usr/bin/qemu-aarch64"):
arm_binary = "qemu-aarch64"
elif os.path.exists("/usr/bin/qemu-arm64-static"):
arm_binary = "qemu-arm64-static"
elif os.path.exists("/usr/bin/qemu-aarch64-static"):
arm_binary = "qemu-aarch64-static"
else:
raise CreatorError("Please install a statically-linked %s" % arm_binary)
else:
node = "/proc/sys/fs/binfmt_misc/arm"
arm_binary = "qemu-arm"
if not os.path.exists("/usr/bin/qemu-arm") or not is_statically_linked("/usr/bin/qemu-arm"):
arm_binary = "qemu-arm-static"
if not os.path.exists("/usr/bin/%s" % arm_binary):
raise CreatorError("Please install a statically-linked %s" % arm_binary)
qemu_emulator = "/usr/bin/%s" % arm_binary
if not os.path.exists(rootdir + "/usr/bin"):
makedirs(rootdir + "/usr/bin")
shutil.copy(qemu_emulator, rootdir + qemu_emulator)
# disable selinux, selinux will block qemu emulator to run
if os.path.exists("/usr/sbin/setenforce"):
msger.info('Try to disable selinux')
runner.show(["/usr/sbin/setenforce", "0"])
# unregister it if it has been registered and is a dynamically-linked executable
if os.path.exists(node):
qemu_unregister_string = "-1\n"
with open(node, "w") as fd:
fd.write(qemu_unregister_string)
# register qemu emulator for interpreting other arch executable file
if not os.path.exists(node):
if arch == "aarch64":
qemu_arm_string = ":aarch64:M::\\x7fELF\\x02\\x01\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x02\\x00\\xb7:\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xfe\\xff\\xff:%s:\n" % qemu_emulator
else:
qemu_arm_string = ":arm:M::\\x7fELF\\x01\\x01\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x02\\x00\\x28\\x00:\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xfa\\xff\\xff\\xff:%s:\n" % qemu_emulator
with open("/proc/sys/fs/binfmt_misc/register", "w") as fd:
fd.write(qemu_arm_string)
return qemu_emulator
开发者ID:nataliakoval,项目名称:mic,代码行数:58,代码来源:misc.py
示例10: __create_repo_file
def __create_repo_file(self, repo, repodir):
fs.makedirs(self.path(repodir))
f = open(self.path(repodir + "/" + repo.name + ".repo"), "w")
self.__create_repo_section(repo, "base", f)
if repo.debuginfo:
self.__create_repo_section(repo, "debuginfo", f)
if repo.source:
self.__create_repo_section(repo, "source", f)
f.close()
开发者ID:csdb,项目名称:mic,代码行数:9,代码来源:__init__.py
示例11: __save_repo_keys
def __save_repo_keys(self, repodata):
if not repodata:
return None
gpgkeydir = "/etc/pki/rpm-gpg"
fs.makedirs(self._instroot + gpgkeydir)
for repo in repodata:
if repo["repokey"]:
repokey = gpgkeydir + "/RPM-GPG-KEY-%s" % repo["name"]
shutil.copy(repo["repokey"], self._instroot + repokey)
开发者ID:JussiPakkanen,项目名称:mic,代码行数:10,代码来源:baseimager.py
示例12: setup_qemu_emulator
def setup_qemu_emulator(rootdir, arch):
# mount binfmt_misc if it doesn't exist
if not os.path.exists("/proc/sys/fs/binfmt_misc"):
modprobecmd = find_binary_path("modprobe")
runner.show([modprobecmd, "binfmt_misc"])
if not os.path.exists("/proc/sys/fs/binfmt_misc/register"):
mountcmd = find_binary_path("mount")
runner.show([mountcmd, "-t", "binfmt_misc", "none", "/proc/sys/fs/binfmt_misc"])
# qemu_emulator is a special case, we can't use find_binary_path
# qemu emulator should be a statically-linked executable file
qemu_emulator = "/usr/bin/qemu-arm"
if not os.path.exists(qemu_emulator) or not is_statically_linked(qemu_emulator):
qemu_emulator = "/usr/bin/qemu-arm-static"
if not os.path.exists(qemu_emulator):
raise CreatorError("Please install a statically-linked qemu-arm")
# qemu emulator version check
armv7_list = [arch for arch in rpmmisc.archPolicies.keys() if arch.startswith('armv7')]
if arch in armv7_list: # need qemu (>=0.13.0)
qemuout = runner.outs([qemu_emulator, "-h"])
m = re.search("version\s*([.\d]+)", qemuout)
if m:
qemu_version = m.group(1)
if qemu_version < "0.13":
raise CreatorError("Requires %s version >=0.13 for %s" % (qemu_emulator, arch))
else:
msger.warning("Can't get version info of %s, please make sure it's higher than 0.13.0" % qemu_emulator)
if not os.path.exists(rootdir + "/usr/bin"):
makedirs(rootdir + "/usr/bin")
shutil.copy(qemu_emulator, rootdir + "/usr/bin/qemu-arm-static")
qemu_emulator = "/usr/bin/qemu-arm-static"
# disable selinux, selinux will block qemu emulator to run
if os.path.exists("/usr/sbin/setenforce"):
msger.info('Try to disable selinux')
runner.show(["/usr/sbin/setenforce", "0"])
# unregister it if it has been registered and is a dynamically-linked executable
node = "/proc/sys/fs/binfmt_misc/arm"
if os.path.exists(node):
qemu_unregister_string = "-1\n"
fd = open("/proc/sys/fs/binfmt_misc/arm", "w")
fd.write(qemu_unregister_string)
fd.close()
# register qemu emulator for interpreting other arch executable file
if not os.path.exists(node):
qemu_arm_string = ":arm:M::\\x7fELF\\x01\\x01\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x02\\x00\\x28\\x00:\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xfa\\xff\\xff\\xff:%s:\n" % qemu_emulator
fd = open("/proc/sys/fs/binfmt_misc/register", "w")
fd.write(qemu_arm_string)
fd.close()
return qemu_emulator
开发者ID:Javoe,项目名称:splicer_poky,代码行数:55,代码来源:misc.py
示例13: get_cachedir
def get_cachedir(self, cachedir=None):
if self.cachedir:
return self.cachedir
self.__ensure_builddir()
if cachedir:
self.cachedir = cachedir
else:
self.cachedir = self.__builddir + "/mic-cache"
fs.makedirs(self.cachedir)
return self.cachedir
开发者ID:JussiPakkanen,项目名称:mic,代码行数:11,代码来源:baseimager.py
示例14: _mount_instroot
def _mount_instroot(self, base_on=None):
if base_on and os.path.isfile(base_on):
self.__imgdir = os.path.dirname(base_on)
imgname = os.path.basename(base_on)
self._base_on(base_on)
self._set_image_size(misc.get_file_size(self._image))
# here, self._instloops must be []
self._instloops.append({
"mountpoint": "/",
"label": self.name,
"name": imgname,
"size": self.__image_size or 4096L,
"fstype": self.__fstype or "ext3",
"extopts": None,
"loop": None
})
self._check_imgdir()
for loop in self._instloops:
fstype = loop['fstype']
mp = os.path.join(self._instroot, loop['mountpoint'].lstrip('/'))
size = loop['size'] * 1024L * 1024L
imgname = loop['name']
if fstype in ("ext2", "ext3", "ext4"):
MyDiskMount = fs.ExtDiskMount
elif fstype == "btrfs":
MyDiskMount = fs.BtrfsDiskMount
elif fstype in ("vfat", "msdos"):
MyDiskMount = fs.VfatDiskMount
else:
msger.error('Cannot support fstype: %s' % fstype)
loop['loop'] = MyDiskMount(fs.SparseLoopbackDisk(
os.path.join(self.__imgdir, imgname),
size),
mp,
fstype,
self._blocksize,
loop['label'])
if fstype in ("ext2", "ext3", "ext4"):
loop['loop'].extopts = loop['extopts']
try:
msger.verbose('Mounting image "%s" on "%s"' % (imgname, mp))
fs.makedirs(mp)
loop['loop'].mount()
except MountError, e:
raise
开发者ID:117111302,项目名称:poky,代码行数:53,代码来源:loop.py
示例15: apply
def apply(self, ksnet):
fs.makedirs(self.path("/etc/sysconfig/network-scripts"))
useipv6 = False
nodns = False
hostname = None
gateway = None
nameservers = None
for network in ksnet.network:
if not network.device:
raise errors.KsError("No --device specified with "
"network kickstart command")
if (network.onboot and network.bootProto.lower() != "dhcp" and
not (network.ip and network.netmask)):
raise errors.KsError("No IP address and/or netmask "
"specified with static "
"configuration for '%s'" %
network.device)
self.write_ifcfg(network)
self.write_wepkey(network)
if network.ipv6:
useipv6 = True
if network.nodns:
nodns = True
if network.hostname:
hostname = network.hostname
if network.gateway:
gateway = network.gateway
if network.nameserver:
nameservers = network.nameserver.split(",")
self.write_sysconfig(useipv6, hostname, gateway)
self.write_hosts(hostname)
self.write_resolv(nodns, nameservers)
开发者ID:csdb,项目名称:mic,代码行数:40,代码来源:__init__.py
示例16: _stage_final_image
def _stage_final_image(self):
try:
isodir = self._get_isodir()
fs_related.makedirs(isodir + "/LiveOS")
minimal_size = self._resparse()
if not self.skip_minimize:
fs_related.create_image_minimizer(isodir + "/LiveOS/osmin.img",
self._image,
minimal_size)
if self.skip_compression:
shutil.move(self._image,
isodir + "/LiveOS/ext3fs.img")
else:
fs_related.makedirs(os.path.join(
os.path.dirname(self._image),
"LiveOS"))
shutil.move(self._image,
os.path.join(os.path.dirname(self._image),
"LiveOS", "ext3fs.img"))
fs_related.mksquashfs(os.path.dirname(self._image),
isodir + "/LiveOS/squashfs.img")
self._create_usbimg(isodir)
if self.pack_to:
self.image_files.update({'image_files': self.pack_to})
usbimg = os.path.join(self._outdir, self.name + ".usbimg")
packimg = os.path.join(self._outdir, self.pack_to)
packing(packimg, usbimg)
os.unlink(usbimg)
else:
self.image_files.update({'image_files': self.name + ".usbimg"})
finally:
shutil.rmtree(isodir, ignore_errors = True)
self._set_isodir(None)
开发者ID:01org,项目名称:mic,代码行数:39,代码来源:liveusb.py
示例17: mount
def mount(self, base_on = None, cachedir = None):
"""Setup the target filesystem in preparation for an install.
This function sets up the filesystem which the ImageCreator will
install into and configure. The ImageCreator class merely creates an
install root directory, bind mounts some system directories (e.g. /dev)
and writes out /etc/fstab. Other subclasses may also e.g. create a
sparse file, format it and loopback mount it to the install root.
base_on -- a previous install on which to base this install; defaults
to None, causing a new image to be created
cachedir -- a directory in which to store the Yum cache; defaults to
None, causing a new cache to be created; by setting this
to another directory, the same cache can be reused across
multiple installs.
"""
self.__ensure_builddir()
fs.makedirs(self._instroot)
fs.makedirs(self._outdir)
self._mount_instroot(base_on)
for d in ("/dev/pts",
"/etc",
"/boot",
"/var/log",
"/sys",
"/proc",
"/usr/bin"):
fs.makedirs(self._instroot + d)
if self.target_arch and self.target_arch.startswith("arm"):
self.qemu_emulator = misc.setup_qemu_emulator(self._instroot,
self.target_arch)
self.get_cachedir(cachedir)
# bind mount system directories into _instroot
for (f, dest) in [("/sys", None),
("/proc", None),
("/proc/sys/fs/binfmt_misc", None),
("/dev/pts", None)]:
self.__bindmounts.append(fs.BindChrootMount(f, self._instroot, dest))
self._do_bindmounts()
self.__create_minimal_dev()
if os.path.exists(self._instroot + "/etc/mtab"):
os.unlink(self._instroot + "/etc/mtab")
os.symlink("../proc/mounts", self._instroot + "/etc/mtab")
self.__write_fstab()
# get size of available space in 'instroot' fs
self._root_fs_avail = misc.get_filesystem_avail(self._instroot)
开发者ID:sanyaade-embedded-systems,项目名称:mic,代码行数:59,代码来源:baseimager.py
示例18: _stage_final_image
def _stage_final_image(self):
try:
isodir = self._get_isodir()
fs_related.makedirs(isodir + "/LiveOS")
minimal_size = self._resparse()
if not self.skip_minimize:
fs_related.create_image_minimizer(isodir + "/LiveOS/osmin.img", self._image, minimal_size)
if self.skip_compression:
shutil.move(self._image, isodir + "/LiveOS/ext3fs.img")
else:
fs_related.makedirs(os.path.join(os.path.dirname(self._image), "LiveOS"))
shutil.move(self._image, os.path.join(os.path.dirname(self._image), "LiveOS", "ext3fs.img"))
fs_related.mksquashfs(os.path.dirname(self._image), isodir + "/LiveOS/squashfs.img")
self._create_usbimg(isodir)
finally:
shutil.rmtree(isodir, ignore_errors=True)
self._set_isodir(None)
开发者ID:saukko,项目名称:mic,代码行数:22,代码来源:liveusb.py
示例19: safecopy
def safecopy(src, dst, symlinks=False, ignore_ptns=()):
if os.path.isdir(src):
if os.path.isdir(dst):
dst = os.path.join(dst, os.path.basename(src))
if os.path.exists(dst):
shutil.rmtree(dst, ignore_errors=True)
src = src.rstrip('/')
# check common prefix to ignore copying itself
if dst.startswith(src + '/'):
ignore_ptns = list(ignore_ptns) + [ os.path.basename(src) ]
ignores = shutil.ignore_patterns(*ignore_ptns)
try:
shutil.copytree(src, dst, symlinks, ignores)
except (OSError, IOError):
shutil.rmtree(dst, ignore_errors=True)
raise
else:
if not os.path.isdir(dst):
makedirs(os.path.dirname(dst))
shutil.copy2(src, dst)
开发者ID:01org,项目名称:mic,代码行数:23,代码来源:rt_util.py
示例20: open
with open(_path(binpth), 'w') as wf:
wf.write(mic_cont)
def safecopy(src, dst, symlinks=False, ignore_ptns=[]):
if os.path.isdir(src):
if os.path.isdir(dst):
dst = os.path.join(dst, os.path.basename(src))
if os.path.exists(dst):
shutil.rmtree(dst, ignore_errors=True)
src = src.rstrip('/')
# check common prefix to ignore copying itself
if dst.startswith(src + '/'):
ignore_ptns += os.path.basename(src)
try:
ignores = shutil.ignore_patterns(*ignore_ptns)
shutil.copytree(src, dst, symlinks, ignores)
except OSError, IOError:
shutil.rmtree(dst, ignore_errors=True)
raise
else:
try:
if not os.path.isdir(dst):
makedirs(os.path.dirname(dst))
shutil.copy2(src, dst)
except:
raise
开发者ID:sanyaade-mobiledev,项目名称:mic,代码行数:30,代码来源:rt_util.py
注:本文中的mic.utils.fs_related.makedirs函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论