I applied to be able to do commits to livecd-tools and gitlivecd
by Bruno Wolff III
I am mostly interested in working with enabling lzma changes right now, but
might have some interest in other things as time goes by. I am also interested
in getting an updated build in rawhide now to start testing early in the
F14 development process. By having commit access to livecd-creator, I can
do the actual work with making that happen if others agree it's OK to do.
13 years, 10 months
Re: [Fedora-livecd-list] livecd-creator proposal for compression option
by Jasper Hartline
On Thu, Jun 10, 2010 at 9:51 PM, Bruno Wolff III <bruno(a)wolff.to> wrote:
>> Introducing the option to compress without kernel support is a big
>> mistake I believe
>> especially when the only gain is for people who are using slower,
>> non-multiple core processors
>
> Why do you think only those people benefit. I would expect in many cases
> accessing the data is limited by disk I/O bandwidth and in that case lots
> of people could benefit.
I am not sure of the current benchmarks of disk I/O related data
which depicts any significant advantage over mksquashfs using zlib or
mksquashfs using lzma.
Do you have some benchmarks you can throw our way?
>> where they gain speed in creation of the ISO, but are not likely to be playing
>> those same games from that CD on that computer anyways, because gamers
>> don't use first generation pentiums
>> running at 1GHz.
>>
>> I think you are just jumping the gun and we need to focus on larger
>> problems related to livecd-tools than satisfying a small niche of
>> gamers by making 10% extra space and a handful of extra games
>
> You are free to focus on what is important to you. I plan to focus at
> least some of my resources on what is important to me.
400 MB is an insignificant gain in space saving to livecd-creator
target images, and you fail to
provide the actual uncompressed original sizes and final size using
mksquashfs w/ lzma.
This is insignificant and cannot be readily applied to any single scenario.
Just so you understand what I am getting at, a target ISO of 60MB
of a custom LiveCD I built, only shrank 10MB to 50MB using mksquashfs w/ lzma.
This is using the most minimal set of packages one could.
Where are you getting 400MB from? Because, that is not what I revealed
in my testing.
60 to 50MB is more than 10%, so you are saying the larger it gets the
worse space savings you get..
that is totally outrageous that you believe this is beneficial but not
something like adding 924K syslinux to the base DVD which benefits
many many people when they want to build a LiveCD with just the base
DVD as a repository source. Interesting that we are so enveloped in
ourselves we only see importance in what is as you said
> You are free to focus on what is important to you. I plan to focus at
> least some of my resources on what is important to me.
Try that more. 400MB is worse than 50 to 60MB, at more than 10%.
mksquashfs w/lzma makes the gain worse, when the targets get larger.
> It will in fact allow a few more well known games to be included in the
> games spin. That is mostly a marketting tool, bur being able to show off
> some more games is nice. It also effects people who want to run live usb
> images and want to limit the amount of space they use.
The amount of space is already limited, it;s already a SquashFS with
no more than 10% savings.
>> Maybe someone will disagree or perhaps some gamers will comment on
>> your post instead.
>
> It's really not a gamer issue. It is an enhancement in to the capabilities
> of live images, in that people will have the option to save additional
> space if they want. Probably lzma will be best to enable by default, but
> that will require most testing to see.
I think you're wasting your time trying this because it will be a
while before SquashFS w/ lzma is introduced
upstream for general use, and possibly longer before Fedora enables it
or puts it into stock.
Have fun.
13 years, 10 months
livecd-creator proposal for compression option
by Jasper Hartline
James Heather j.heather at surrey.ac.uk
Fri Jun 11 08:35:11 UTC 2010 wrote:
>I haven't followed the thread of (1), but it's a separate issue as to
>whether syslinux is worth the extra space, even if it's small. In any
>case, custom builds are always free to include or not include syslinux.
This show your complete lack of understanding first of all to the
situation which you decided to comment
was becoming whatever and something else which I don't care about.
Some attempt to sound
professional in an English-major sort of way.
First of all, syslinux is an absolute requirement, if you try to build
a LiveCD without syslinux
in the source repository it will fail, guaranteed. Please do not
comment on this issue which you know nothing about.
I have seen other posts of yours where you state syslinux might be in
the initrd.. which it is not.
syslinux hold the ISOLINUX bootloader, which makes the freaking LiveCD boot.
>If you don't like what's on the base DVD, build your own--that's the
>whole point of this list.
What I don't like is the requirement on syslinux, because it also
requires any time I build a liveCD
which could be 50MB or 50 million megabytes, I would need a networked
repository or local mirror of an Everything tree.
It is much simpler to be able to do testing of any given medium or
smaller size package set on livecd-creator
using the base DVD ISO, not an Everything tree, especially not one
that is on a remote server, as most of
the repositories are. By this you and Bruno now are both suggesting
one who wants to use livecd-creator
must have either network or a syned mirror locally, which is a bunch
of chicken scratch, keep it to yourself.
Have fun and hopefully you can let this clown code patch parade
actually do something useful with LiveCD tools before it becomes in a
state of limbo between useless features
and broken clown patches where the whole thing need to be rewritten.
This is not how you develop software.
13 years, 10 months
livecd-creator proposal for compression option
by Bruno Wolff III
As part of trying to get the LMZA for Live Images feature
(https://fedoraproject.org/wiki/Features/LZMA_for_Live_Images)
done, I plan on producing a patch soon that provides an option to
livecd-creator to specify a compression type.
The plan is:
Add a new option, --compression_type=string, where string is a compression
type recognized and normally passed to mksquashfs.
Make a default compression type config, that will initially be 'zlib', but
will allow for an easy change to 'lzma', when we are ready.
Make a config that knows the default compression ('zlib') for mksquashfs.
If this string matches the requested compression type, then no compression
option will be passed to mksquashfs. This allows 'zlib' to be used with
older versions of mksquashfs that don't allow for specifying the compressor.
Document at least the 'zlib' and 'lzma' compression types. (And maybe 'lzo'
if that ends up being usable at some point.) Note that 'lzma' needs kernel
support to be able to mount the file system or to use it in live images.
If anyone has suggestions for this plan, making changes now will be less
work than after I have some patches ready.
Thanks.
13 years, 10 months
imgcreate/fs.py
by joey boggs
imgcreate/fs.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit 85673a75c9c3c08d1d077e1608a7e0ff10b09c1b
Author: Joey Boggs <jboggs(a)redhat.com>
Date: Fri May 28 13:30:49 2010 -0400
prepend _ to the file system label.
In cases where a livecd is created, the iso label and the ext root file system have the same label causing a race between what device is symlinked to /dev/live.
To avoid this confusion _ is prepended to the fslabel
diff --git a/imgcreate/fs.py b/imgcreate/fs.py
index b8d61db..f5eed39 100644
--- a/imgcreate/fs.py
+++ b/imgcreate/fs.py
@@ -395,7 +395,7 @@ class ExtDiskMount(DiskMount):
def __init__(self, disk, mountdir, fstype, blocksize, fslabel, rmmountdir=True):
DiskMount.__init__(self, disk, mountdir, fstype, rmmountdir)
self.blocksize = blocksize
- self.fslabel = fslabel
+ self.fslabel = "_" + fslabel
def __format_filesystem(self):
logging.debug("Formating %s filesystem on %s" % (self.fstype, self.disk.device))
13 years, 10 months
Changes to 'refs/tags/livecd-tools-031'
by Alan Pevec
Tag 'livecd-tools-031' created by Alan Pevec <apevec(a)redhat.com> at 2010-06-08 17:51 +0000
livecd-tools-031
Changes since livecd-tools-023:
Hans de Goede (1):
Tell dracut not to ask for LUKS passwords or activate mdraid sets
Jason Farrell (3):
Make overlay space requirements clearer
small fix for --multi mode
Fix display of free space during livecd-iso-to-disk error message
Jeremy Katz (29):
Revert "creator: "-d" opt and matching setdebug() method that gets rpm in debug mode"
Fsck after resize to catch/fix problems (#497377)
Return return code from fsck in case we want to do something with it
Fix up ppc live image creation (#497193)
Raise an error if the fsck finds problems
More ppc syntax fixing (#497193)
Bump version
Bind mount /dev/shm also (#502921)
Update for current options (#505742)
Don't error out with SELinux disabled on the host (#508402)
Use resize2fs -M instead of binary search
Consolidate calls to fsck
Store a copy of the filesystem image before resize
Don't continue if the fs unmount fails
Add a new exception type for resize errors
Also, don't lose resize2fs output (per request of sandeen)
Include new error definition which I apparently didn't commit
Make live image a hybrid
Use system-config-keyboard's bits in preference to rhpl.keyboard
Bumpv ersion
If resize2fs fails, raise an error also (related to #517222)
Add a sleep to try to avoid tracebacks with snapshot removal (#506644)
Apparently the python traceback isn't clear enough (#517841)
Fix my stupid typo. *sigh*
Support dracut based initrds
Use resize2fs -M (minimal) more
Bump version
Sleep to avoid races (#517477)
Fix traceback when implantisomd5 isn't available (Ron Yorston)
Josh Boyer (1):
Fix ppc creation
Marc Herbert (1):
cpio "-L" to dereference any symbolic link to the actual ISO
Martin Dengler (1):
don't need to checkMBR() for loop devices
Martin Langhoff (1):
creator: "-d" opt and matching setdebug() method that gets rpm in debug mode
Matthias Clasen (1):
Switch to using blkid instead of vol_id (#506360)
Warren Togami (13):
chattr -i extlinux.sys
dracut output image filename s/initrd-generic/initramfs/
ppc live was trying to copy the wrong initrd filename
Properly clean up fake /selinux directory during teardown
version 027
This fixes dracut boot for LiveCD and LiveUSB without the requirement to have a filesystem label.
version 028
Silence the /etc/modprobe.conf deprecation warning.
version 029
I am a moron, committed wrong version of this patch.
version 030
livecd-iso-to-disk properly configures a Fedora 12 Installer DVD for USB boot
version 031
---
Makefile | 2
config/livecd-fedora-minimal.ks | 1
docs/livecd-iso-to-disk.pod | 18 ++++++-
imgcreate/creator.py | 23 +++++----
imgcreate/errors.py | 2
imgcreate/fs.py | 77 ++++++++++++++++++------------
imgcreate/kickstart.py | 14 ++---
imgcreate/live.py | 100 ++++++++++++++++++++++++++++------------
tools/livecd-iso-to-disk.sh | 96 ++++++++++++++++++++++++++++++++------
tools/livecd-iso-to-pxeboot.sh | 2
10 files changed, 241 insertions(+), 94 deletions(-)
---
13 years, 10 months
revisor --cli --model=f13lrs-i386 --debug 9 --live-optical --kickstart=/etc/livecd-console-rev.ks
by Lars Bjørndal
Hello list!
I tried to send this question to the revisor-user mailing list, but that
list seems to be dead. Hope someone here is able to answer.
While trying to build an livecd from Fedora 13, using Revisor, I got the
following error:
...
Adding Package libgnomeui-2.24.3-1.fc13.i686 in mode u
Member: clamav-data.noarch 0:0.95.3-1301.fc13 - u
Adding Package clamav-data-0.95.3-1301.fc13.noarch in mode u
Member: xml-common.noarch 0:0.6.3-32.fc13 - u
Adding Package xml-common-0.6.3-32.fc13.noarch in mode u
Member: libksba.i686 0:1.0.7-1.fc13 - u
Adding Package libksba-1.0.7-1.fc13.i686 in mode u
Exception <class 'sqlite3.OperationalError'>: unable to open database file
Installing Software: Installing Software: ######################################## 100.0%
An additional error in the error. The value of errs is: unable to open database file
An error occurred during the installation of the software you selected, and an additional error occurred trying to describe what went wrong exactly.
Unmounting directory /var/tmp/revisor
Losetup remove /dev/loop0
What's wrong here, and how can I solve the problem?
Regards,
Lars
13 years, 10 months
how to enable btrfs for livecd ?
by Valent Turkovic
I have tried editing kickstart file so that instead of ext4 iso image
uses btrfs but this fails everytime I try it.
What am I doing wrong? Has anybody managed to create btrfs livecd
image via livecd-creator?
How? Please show me your example kickstart files.
I see that there was bug opened but now is closed:
https://bugzilla.redhat.com/show_bug.cgi?id=571910
If this is not user (mine) error this bug should be reopened,
Some more info is also on my blog:
http://kernelreloaded.blog385.com/index.php/archives/btrfs-fedora-remix/
--
pratite me na twitteru - www.twitter.com/valentt
blog: http://kernelreloaded.blog385.com
linux, anime, spirituality, windsurf, wireless, ronjenje, pametne kuće, zwave
registered as user #367004 with the Linux Counter, http://counter.li.org.
ICQ: 2125241, Skype: valent.turkovic, MSN: valent.turkovic(a)hotmail.com
13 years, 10 months
[PATCH] add edit-livecd script for editing livecd based images
by Joey Boggs
Resubmitting the edit-livecd script with the latest updates.
edit-livecd is used for opening up livecd images to add and/or edit files with out having to rebuild the iso image.
This script is useful for people who don't have the development and yum infrastructure/repos set up to build livecd's from scratch. This is especially useful for custom livecd images, like the ovirt-node project[1].
We agree that changes to packaging and binaries should always be done by modifying kickstart and rebuilding the image via livecd-creator. But if all you want to do is add/edit a config file, public key for SSH, or change the root password this can be done with the edit-livecd script.
This is the second generation of the edit-livecd tool that replaces our original bash script with a python version and aims to reuse as much as the livecd-creator libraries as possible. The main reason for the new creator class is to avoid the need for a kisckstart file in order to edit an existing livecd image.
[1] http://ovirt.org
---
Makefile | 2 +
tools/edit-livecd | 350 +++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 352 insertions(+), 0 deletions(-)
create mode 100755 tools/edit-livecd
diff --git a/Makefile b/Makefile
index 991b27b..62e7fd8 100644
--- a/Makefile
+++ b/Makefile
@@ -25,6 +25,7 @@ install: man
$(INSTALL_PROGRAM) -D tools/image-creator $(DESTDIR)/usr/bin/image-creator
$(INSTALL_PROGRAM) -D tools/livecd-iso-to-disk.sh $(DESTDIR)/usr/bin/livecd-iso-to-disk
$(INSTALL_PROGRAM) -D tools/livecd-iso-to-pxeboot.sh $(DESTDIR)/usr/bin/livecd-iso-to-pxeboot
+ $(INSTALL_PROGRAM) -D tools/edit-livecd $(DESTDIR)/usr/bin/edit-livecd
$(INSTALL_DATA) -D AUTHORS $(DESTDIR)/usr/share/doc/livecd-tools-$(VERSION)/AUTHORS
$(INSTALL_DATA) -D COPYING $(DESTDIR)/usr/share/doc/livecd-tools-$(VERSION)/COPYING
$(INSTALL_DATA) -D README $(DESTDIR)/usr/share/doc/livecd-tools-$(VERSION)/README
@@ -40,6 +41,7 @@ uninstall:
rm -f $(DESTDIR)/usr/bin/livecd-creator
rm -rf $(DESTDIR)/usr/lib/livecd-creator
rm -rf $(DESTDIR)/usr/share/doc/livecd-tools-$(VERSION)
+ rm -f $(DESTDIR)/usr/bin/edit-livecd
dist : all
git archive --format=tar --prefix=livecd-tools-$(VERSION)/ HEAD | bzip2 -9v > livecd-tools-$(VERSION).tar.bz2
diff --git a/tools/edit-livecd b/tools/edit-livecd
new file mode 100755
index 0000000..920522c
--- /dev/null
+++ b/tools/edit-livecd
@@ -0,0 +1,350 @@
+#!/usr/bin/python -tt
+#
+# edit livecd: Edit a livecd to insert files
+#
+# Copyright 2009, Red Hat Inc.
+# Written by Perry Myers <pmyers(a)redhat.com> & David Huff <dhuff(a)redhat.com>
+#
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Library General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+import os
+import sys
+import tempfile
+import shutil
+import subprocess
+import optparse
+import logging
+
+from imgcreate.debug import *
+from imgcreate.fs import *
+from imgcreate.live import *
+
+class ExistingSparseLoopbackDisk(SparseLoopbackDisk):
+ """don't want to expand the disk"""
+ def __init__(self, lofile, size):
+ SparseLoopbackDisk.__init__(self, lofile, size)
+
+ def create(self):
+ #self.expand(create = True)
+ LoopbackDisk.create(self)
+
+class LiveImageEditor(LiveImageCreator):
+ """class for editing LiveCD images.
+
+ We need an instance of LiveImageCreator however we do not have a kickstart
+ file nor do we need to create a new image. We just want to reuse some of
+ LiveImageCreators methods on an existing livecd image.
+
+ """
+
+ def __init__(self, name):
+ """Initialize a LiveImageEditor instance.
+
+ creates a dummy instance of LiveImageCreator
+ We do not initialize any sub classes b/c we have no ks file.
+
+ """
+ self.name = name
+
+ self.tmpdir = "/var/tmp"
+ """The directory in which all temporary files will be created."""
+
+ self.skip_compression = False
+ """Controls whether to use squashfs to compress the image."""
+
+ self.skip_minimize = False
+ """Controls whether an image minimizing snapshot should be created."""
+
+ self._isofstype = "iso9660"
+ self.__isodir = None
+
+ self._ImageCreator__builddir = None
+ """working directory"""
+
+ self._ImageCreator_instroot = None
+ """where the extfs.img is mounted for modification"""
+
+ self._ImageCreator_outdir = None
+ """where final iso gets written"""
+
+ self._ImageCreator__bindmounts = []
+
+ self._LoopImageCreator__imagedir = None
+ """dir for the extfs.img"""
+
+ self._LoopImageCreator__blocksize = 4096
+ self._LoopImageCreator__fslabel = None
+ self._LoopImageCreator__instloop = None
+ self._LoopImageCreator__fstype = None
+ self._LoopImageCreator__image_size = None
+
+ self._LiveImageCreatorBase__isodir = None
+ """directory where the iso is staged"""
+
+ # properties
+ def __get_image(self):
+ if self._LoopImageCreator__imagedir is None:
+ self.__ensure_builddir()
+ self._LoopImageCreator__imagedir = tempfile.mkdtemp(dir = os.path.abspath(self.tmpdir), prefix = self.name + "-")
+ return self._LoopImageCreator__imagedir + "/ext3fs.img"
+ _image = property(__get_image)
+ """The location of the image file"""
+
+
+ def _get_fstype(self):
+ dev_null = os.open("/dev/null", os.O_WRONLY)
+ try:
+ out = subprocess.Popen(["/sbin/blkid", self._image],
+ stdout = subprocess.PIPE,
+ stderr = dev_null).communicate()[0]
+ for word in out.split():
+ if word.startswith("TYPE"):
+ self._LoopImageCreator__fstype = word.split("=")[1].strip("\"")
+
+ except IOError, e:
+ raise CreatorError("Failed to determine fsimage TYPE: %s" % e )
+
+
+ def _get_fslable(self):
+ dev_null = os.open("/dev/null", os.O_WRONLY)
+ try:
+ out = subprocess.Popen(["/sbin/e2label", self._image],
+ stdout = subprocess.PIPE,
+ stderr = dev_null).communicate()[0]
+
+ self._LoopImageCreator__fslable = out.strip()
+
+ except IOError, e:
+ raise CreatorError("Failed to determine fsimage TYPE: %s" % e )
+
+
+ def __ensure_builddir(self):
+ if not self._ImageCreator__builddir is None:
+ return
+
+ try:
+ self._ImageCreator__builddir = tempfile.mkdtemp(dir = os.path.abspath(self.tmpdir),
+ prefix = "edit-livecd-")
+ except OSError, (err, msg):
+ raise CreatorError("Failed create build directory in %s: %s" %
+ (self.tmpdir, msg))
+
+
+ def _run_script(self, script):
+
+ (fd, path) = tempfile.mkstemp(prefix = "script-",
+ dir = self._instroot + "/tmp")
+
+ logging.debug("copying script to install root: %s" % path)
+ shutil.copy(os.path.abspath(script), path)
+ os.close(fd)
+ os.chmod(path, 0700)
+
+ script = "/tmp/" + os.path.basename(path)
+
+
+ try:
+ subprocess.call([script], preexec_fn = self._chroot)
+ except OSError, e:
+ raise CreatorError("Failed to execute script %s, %s " % (script, e))
+ finally:
+ os.unlink(path)
+
+
+ def mount(self, base_on, cachedir = None):
+ """mount existing file system.
+
+ we have to override mount b/c we are not creating an new install root
+ nor do we need to setup the file system, ie makedirs(/etc/, /boot, ...),
+ nor do we want to overwrite fstab, or create selinuxfs
+
+ We also need to get some info about the image before we
+ can mount it.
+
+ """
+
+ if not base_on:
+ raise CreatorError("No base livecd image specified")
+
+ self.__ensure_builddir()
+
+ self._ImageCreator_instroot = self._ImageCreator__builddir + "/install_root"
+ self._LoopImageCreator__imagedir = self._ImageCreator__builddir + "/ex"
+ self._ImageCreator_outdir = self._ImageCreator__builddir + "/out"
+
+ makedirs(self._ImageCreator_instroot)
+ makedirs(self._LoopImageCreator__imagedir)
+ makedirs(self._ImageCreator_outdir)
+
+ LiveImageCreator._base_on(self, base_on)
+
+ self._LoopImageCreator__image_size = os.stat(self._image)[stat.ST_SIZE]
+ self._get_fstype()
+ self._get_fslable()
+ self.fslabel = self._LoopImageCreator__fslable
+
+ self._LoopImageCreator__instloop = ExtDiskMount(ExistingSparseLoopbackDisk(self._image,
+ self._LoopImageCreator__image_size),
+ self._ImageCreator_instroot,
+ self._fstype,
+ self._LoopImageCreator__blocksize,
+ self.fslabel)
+ try:
+ self._LoopImageCreator__instloop.mount()
+ except MountError, e:
+ raise CreatorError("Failed to loopback mount '%s' : %s" %
+ (self._image, e))
+
+ cachesrc = cachedir or (self._ImageCreator__builddir + "/yum-cache")
+ makedirs(cachesrc)
+
+ for (f, dest) in [("/sys", None), ("/proc", None),
+ ("/dev/pts", None), ("/dev/shm", None),
+ (cachesrc, "/var/cache/yum")]:
+ self._ImageCreator__bindmounts.append(BindChrootMount(f, self._instroot, dest))
+
+ self._do_bindmounts()
+
+ os.symlink("../proc/mounts", self._instroot + "/etc/mtab")
+
+ self.__copy_cd_root(base_on)
+
+
+ def __copy_cd_root(self, base_on):
+ """helper function to root content of the base liveCD to ISOdir"""
+
+ isoloop = DiskMount(LoopbackDisk(base_on, 0), self._mkdtemp())
+ self._LiveImageCreatorBase__isodir = self._ImageCreator__builddir + "/iso"
+
+ try:
+ isoloop.mount()
+ # legacy LiveOS filesystem layout support, remove for F9 or F10
+ if os.path.exists(isoloop.mountdir + "/squashfs.img"):
+ squashimg = isoloop.mountdir + "/squashfs.img"
+ else:
+ squashimg = isoloop.mountdir + "/LiveOS/squashfs.img"
+
+ #copy over everything but squashimg
+ shutil.copytree(isoloop.mountdir,
+ self._LiveImageCreatorBase__isodir,
+ ignore=shutil.ignore_patterns("squashfs.img", "osmin.img"))
+ except MountError, e:
+ raise CreatorError("Failed to loopback mount '%s' : %s" %
+ (base_on, e))
+
+ finally:
+ isoloop.cleanup()
+
+
+def parse_options(args):
+ parser = optparse.OptionParser(usage = "%prog [-s=<script.sh>] <LIVECD.iso>")
+
+ parser.add_option("-n", "--name", type="string", dest="name",
+ help="name of new livecd (don't include .iso will be added)")
+
+ parser.add_option("-o", "--output", type="string", dest="output",
+ help="specify the output dir")
+
+ parser.add_option("-s", "--script", type="string", dest="script",
+ help="specify script to run chrooted in the livecd fsimage")
+
+ parser.add_option("-t", "--tmpdir", type="string",
+ dest="tmpdir", default="/var/tmp",
+ help="Temporary directory to use (default: /var/tmp)")
+
+ parser.add_option("", "--skip-compression", action="store_true", dest="skip_compression")
+
+ parser.add_option("", "--skip-minimize", action="store_true", dest="skip_minimize")
+
+ setup_logging(parser)
+
+ (options, args) = parser.parse_args()
+
+ if len(args) != 1:
+ parser.print_usage()
+ sys.exit(1)
+
+ return (args[0], options)
+
+def rebuild_iso_symlinks(isodir):
+ # remove duplicate files and rebuild symlinks to reduce iso size
+ efi_vmlinuz = "%s/EFI/boot/vmlinuz0" % isodir
+ isolinux_vmlinuz = "%s/isolinux/vmlinuz0" % isodir
+ efi_initrd = "%s/EFI/boot/initrd0.img" % isodir
+ isolinux_initrd = "%s/isolinux/initrd0.img" % isodir
+
+ os.remove(efi_vmlinuz)
+ os.remove(efi_initrd)
+ os.symlink(isolinux_vmlinuz,efi_vmlinuz)
+ os.symlink(isolinux_initrd,efi_initrd)
+
+
+def main():
+ (livecd, options) = parse_options(sys.argv[1:])
+
+ if os.geteuid () != 0:
+ print >> sys.stderr, "You must run edit-livecd as root"
+ return 1
+
+ if options.name:
+ name = options.name
+ else:
+ name = os.path.basename(livecd) + ".edited"
+
+ if options.output:
+ output = options.output
+ else:
+ output = os.path.dirname(livecd)
+
+
+ editor = LiveImageEditor(name)
+ editor.tmpdir = os.path.abspath(options.tmpdir)
+ editor.skip_compression = options.skip_compression
+ editor.skip_minimize = options.skip_minimize
+
+ try:
+ editor.mount(livecd, cachedir = None)
+ if options.script:
+ print "Running edit script '%s'" % options.script
+ editor._run_script(options.script)
+ else:
+ print "Launching shell. Exit to continue."
+ print "----------------------------------"
+ editor.launch_shell()
+ rebuild_iso_symlinks(editor._LiveImageCreatorBase__isodir)
+ editor.unmount()
+ editor.package(output)
+ except CreatorError, e:
+ logging.error(u"Error editing Live CD : %s" % e)
+ return 1
+ finally:
+ editor.cleanup()
+
+ return 0
+
+
+if __name__ == "__main__":
+ sys.exit(main())
+
+
+arch = rpmUtils.arch.getBaseArch()
+if arch in ("i386", "x86_64"):
+ LiveImageCreator = x86LiveImageCreator
+elif arch in ("ppc",):
+ LiveImageCreator = ppcLiveImageCreator
+elif arch in ("ppc64",):
+ LiveImageCreator = ppc64LiveImageCreator
+else:
+ raise CreatorError("Architecture not supported!")
--
1.6.6.1
13 years, 11 months
tools/edit-livecd
by joey boggs
tools/edit-livecd | 350 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 350 insertions(+)
New commits:
commit f8981306621b0543a66a4b1959755adcf0f25c91
Author: Joey Boggs <jboggs(a)redhat.com>
Date: Tue Jun 1 21:20:25 2010 -0400
add edit-livecd
edit-livecd is used for opening up livecd images to add and/or edit files with out having to rebuild the iso image.
This script is useful for people who don't have the development and yum infrastructure/repos set up to build livecd's
from scratch. This is especially useful for custom livecd images.
diff --git a/tools/edit-livecd b/tools/edit-livecd
new file mode 100755
index 0000000..809b015
--- /dev/null
+++ b/tools/edit-livecd
@@ -0,0 +1,350 @@
+#!/usr/bin/python -tt
+#
+# edit livecd: Edit a livecd to insert files
+#
+# Copyright 2009, Red Hat Inc.
+# Written by Perry Myers <pmyers at redhat.com> & David Huff <dhuff at redhat.com>
+#
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Library General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+import os
+import sys
+import tempfile
+import shutil
+import subprocess
+import optparse
+import logging
+
+from imgcreate.debug import *
+from imgcreate.fs import *
+from imgcreate.live import *
+
+class ExistingSparseLoopbackDisk(SparseLoopbackDisk):
+ """don't want to expand the disk"""
+ def __init__(self, lofile, size):
+ SparseLoopbackDisk.__init__(self, lofile, size)
+
+ def create(self):
+ #self.expand(create = True)
+ LoopbackDisk.create(self)
+
+class LiveImageEditor(LiveImageCreator):
+ """class for editing LiveCD images.
+
+ We need an instance of LiveImageCreator however we do not have a kickstart
+ file nor do we need to create a new image. We just want to reuse some of
+ LiveImageCreators methods on an existing livecd image.
+
+ """
+
+ def __init__(self, name):
+ """Initialize a LiveImageEditor instance.
+
+ creates a dummy instance of LiveImageCreator
+ We do not initialize any sub classes b/c we have no ks file.
+
+ """
+ self.name = name
+
+ self.tmpdir = "/var/tmp"
+ """The directory in which all temporary files will be created."""
+
+ self.skip_compression = False
+ """Controls whether to use squashfs to compress the image."""
+
+ self.skip_minimize = False
+ """Controls whether an image minimizing snapshot should be created."""
+
+ self._isofstype = "iso9660"
+ self.__isodir = None
+
+ self._ImageCreator__builddir = None
+ """working directory"""
+
+ self._ImageCreator_instroot = None
+ """where the extfs.img is mounted for modification"""
+
+ self._ImageCreator_outdir = None
+ """where final iso gets written"""
+
+ self._ImageCreator__bindmounts = []
+
+ self._LoopImageCreator__imagedir = None
+ """dir for the extfs.img"""
+
+ self._LoopImageCreator__blocksize = 4096
+ self._LoopImageCreator__fslabel = None
+ self._LoopImageCreator__instloop = None
+ self._LoopImageCreator__fstype = None
+ self._LoopImageCreator__image_size = None
+
+ self._LiveImageCreatorBase__isodir = None
+ """directory where the iso is staged"""
+
+ # properties
+ def __get_image(self):
+ if self._LoopImageCreator__imagedir is None:
+ self.__ensure_builddir()
+ self._LoopImageCreator__imagedir = tempfile.mkdtemp(dir = os.path.abspath(self.tmpdir), prefix = self.name + "-")
+ return self._LoopImageCreator__imagedir + "/ext3fs.img"
+ _image = property(__get_image)
+ """The location of the image file"""
+
+
+ def _get_fstype(self):
+ dev_null = os.open("/dev/null", os.O_WRONLY)
+ try:
+ out = subprocess.Popen(["/sbin/blkid", self._image],
+ stdout = subprocess.PIPE,
+ stderr = dev_null).communicate()[0]
+ for word in out.split():
+ if word.startswith("TYPE"):
+ self._LoopImageCreator__fstype = word.split("=")[1].strip("\"")
+
+ except IOError, e:
+ raise CreatorError("Failed to determine fsimage TYPE: %s" % e )
+
+
+ def _get_fslable(self):
+ dev_null = os.open("/dev/null", os.O_WRONLY)
+ try:
+ out = subprocess.Popen(["/sbin/e2label", self._image],
+ stdout = subprocess.PIPE,
+ stderr = dev_null).communicate()[0]
+
+ self._LoopImageCreator__fslable = out.strip()
+
+ except IOError, e:
+ raise CreatorError("Failed to determine fsimage TYPE: %s" % e )
+
+
+ def __ensure_builddir(self):
+ if not self._ImageCreator__builddir is None:
+ return
+
+ try:
+ self._ImageCreator__builddir = tempfile.mkdtemp(dir = os.path.abspath(self.tmpdir),
+ prefix = "edit-livecd-")
+ except OSError, (err, msg):
+ raise CreatorError("Failed create build directory in %s: %s" %
+ (self.tmpdir, msg))
+
+
+ def _run_script(self, script):
+
+ (fd, path) = tempfile.mkstemp(prefix = "script-",
+ dir = self._instroot + "/tmp")
+
+ logging.debug("copying script to install root: %s" % path)
+ shutil.copy(os.path.abspath(script), path)
+ os.close(fd)
+ os.chmod(path, 0700)
+
+ script = "/tmp/" + os.path.basename(path)
+
+
+ try:
+ subprocess.call([script], preexec_fn = self._chroot)
+ except OSError, e:
+ raise CreatorError("Failed to execute script %s, %s " % (script, e))
+ finally:
+ os.unlink(path)
+
+
+ def mount(self, base_on, cachedir = None):
+ """mount existing file system.
+
+ we have to override mount b/c we are not creating an new install root
+ nor do we need to setup the file system, ie makedirs(/etc/, /boot, ...),
+ nor do we want to overwrite fstab, or create selinuxfs
+
+ We also need to get some info about the image before we
+ can mount it.
+
+ """
+
+ if not base_on:
+ raise CreatorError("No base livecd image specified")
+
+ self.__ensure_builddir()
+
+ self._ImageCreator_instroot = self._ImageCreator__builddir + "/install_root"
+ self._LoopImageCreator__imagedir = self._ImageCreator__builddir + "/ex"
+ self._ImageCreator_outdir = self._ImageCreator__builddir + "/out"
+
+ makedirs(self._ImageCreator_instroot)
+ makedirs(self._LoopImageCreator__imagedir)
+ makedirs(self._ImageCreator_outdir)
+
+ LiveImageCreator._base_on(self, base_on)
+
+ self._LoopImageCreator__image_size = os.stat(self._image)[stat.ST_SIZE]
+ self._get_fstype()
+ self._get_fslable()
+ self.fslabel = self._LoopImageCreator__fslable
+
+ self._LoopImageCreator__instloop = ExtDiskMount(ExistingSparseLoopbackDisk(self._image,
+ self._LoopImageCreator__image_size),
+ self._ImageCreator_instroot,
+ self._fstype,
+ self._LoopImageCreator__blocksize,
+ self.fslabel)
+ try:
+ self._LoopImageCreator__instloop.mount()
+ except MountError, e:
+ raise CreatorError("Failed to loopback mount '%s' : %s" %
+ (self._image, e))
+
+ cachesrc = cachedir or (self._ImageCreator__builddir + "/yum-cache")
+ makedirs(cachesrc)
+
+ for (f, dest) in [("/sys", None), ("/proc", None),
+ ("/dev/pts", None), ("/dev/shm", None),
+ (cachesrc, "/var/cache/yum")]:
+ self._ImageCreator__bindmounts.append(BindChrootMount(f, self._instroot, dest))
+
+ self._do_bindmounts()
+
+ os.symlink("../proc/mounts", self._instroot + "/etc/mtab")
+
+ self.__copy_cd_root(base_on)
+
+
+ def __copy_cd_root(self, base_on):
+ """helper function to root content of the base liveCD to ISOdir"""
+
+ isoloop = DiskMount(LoopbackDisk(base_on, 0), self._mkdtemp())
+ self._LiveImageCreatorBase__isodir = self._ImageCreator__builddir + "/iso"
+
+ try:
+ isoloop.mount()
+ # legacy LiveOS filesystem layout support, remove for F9 or F10
+ if os.path.exists(isoloop.mountdir + "/squashfs.img"):
+ squashimg = isoloop.mountdir + "/squashfs.img"
+ else:
+ squashimg = isoloop.mountdir + "/LiveOS/squashfs.img"
+
+ #copy over everything but squashimg
+ shutil.copytree(isoloop.mountdir,
+ self._LiveImageCreatorBase__isodir,
+ ignore=shutil.ignore_patterns("squashfs.img", "osmin.img"))
+ except MountError, e:
+ raise CreatorError("Failed to loopback mount '%s' : %s" %
+ (base_on, e))
+
+ finally:
+ isoloop.cleanup()
+
+
+def parse_options(args):
+ parser = optparse.OptionParser(usage = "%prog [-s=<script.sh>] <LIVECD.iso>")
+
+ parser.add_option("-n", "--name", type="string", dest="name",
+ help="name of new livecd (don't include .iso will be added)")
+
+ parser.add_option("-o", "--output", type="string", dest="output",
+ help="specify the output dir")
+
+ parser.add_option("-s", "--script", type="string", dest="script",
+ help="specify script to run chrooted in the livecd fsimage")
+
+ parser.add_option("-t", "--tmpdir", type="string",
+ dest="tmpdir", default="/var/tmp",
+ help="Temporary directory to use (default: /var/tmp)")
+
+ parser.add_option("", "--skip-compression", action="store_true", dest="skip_compression")
+
+ parser.add_option("", "--skip-minimize", action="store_true", dest="skip_minimize")
+
+ setup_logging(parser)
+
+ (options, args) = parser.parse_args()
+
+ if len(args) != 1:
+ parser.print_usage()
+ sys.exit(1)
+
+ return (args[0], options)
+
+def rebuild_iso_symlinks(isodir):
+ # remove duplicate files and rebuild symlinks to reduce iso size
+ efi_vmlinuz = "%s/EFI/boot/vmlinuz0" % isodir
+ isolinux_vmlinuz = "%s/isolinux/vmlinuz0" % isodir
+ efi_initrd = "%s/EFI/boot/initrd0.img" % isodir
+ isolinux_initrd = "%s/isolinux/initrd0.img" % isodir
+
+ os.remove(efi_vmlinuz)
+ os.remove(efi_initrd)
+ os.symlink(isolinux_vmlinuz,efi_vmlinuz)
+ os.symlink(isolinux_initrd,efi_initrd)
+
+
+def main():
+ (livecd, options) = parse_options(sys.argv[1:])
+
+ if os.geteuid () != 0:
+ print >> sys.stderr, "You must run edit-livecd as root"
+ return 1
+
+ if options.name:
+ name = options.name
+ else:
+ name = os.path.basename(livecd) + ".edited"
+
+ if options.output:
+ output = options.output
+ else:
+ output = os.path.dirname(livecd)
+
+
+ editor = LiveImageEditor(name)
+ editor.tmpdir = os.path.abspath(options.tmpdir)
+ editor.skip_compression = options.skip_compression
+ editor.skip_minimize = options.skip_minimize
+
+ try:
+ editor.mount(livecd, cachedir = None)
+ if options.script:
+ print "Running edit script '%s'" % options.script
+ editor._run_script(options.script)
+ else:
+ print "Launching shell. Exit to continue."
+ print "----------------------------------"
+ editor.launch_shell()
+ rebuild_iso_symlinks(editor._LiveImageCreatorBase__isodir)
+ editor.unmount()
+ editor.package(output)
+ except CreatorError, e:
+ logging.error(u"Error editing Live CD : %s" % e)
+ return 1
+ finally:
+ editor.cleanup()
+
+ return 0
+
+
+if __name__ == "__main__":
+ sys.exit(main())
+
+
+arch = rpmUtils.arch.getBaseArch()
+if arch in ("i386", "x86_64"):
+ LiveImageCreator = x86LiveImageCreator
+elif arch in ("ppc",):
+ LiveImageCreator = ppcLiveImageCreator
+elif arch in ("ppc64",):
+ LiveImageCreator = ppc64LiveImageCreator
+else:
+ raise CreatorError("Architecture not supported!")
13 years, 11 months