Changes to 'f15-branch'
by Brian C. Lane
New branch 'f15-branch' available with the following commits:
commit 5c7ea3a88d4755c3ee926ff997656cfe873ef39e
Author: Brian C. Lane <bcl(a)redhat.com>
Date: Tue Feb 15 16:09:36 2011 -0800
Version 15.4
13 years, 2 months
Changes to 'refs/tags/livecd-tools-16.0'
by Brian C. Lane
Tag 'livecd-tools-16.0' created by Brian C. Lane <bcl(a)redhat.com> at 2011-02-15 23:31 +0000
Tag as livecd-tools-16.0
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
iQEVAwUATVsMwxF+jBaO/jp/AQKB6Qf8DbpbStmumUds+kp+bYxiGF33qUftZ7dw
Weed+UtOeSkqbvK/fm/UJNQLCmGu2mW+4upRqPvMEEFRXkAtmT4OlNJI1Zmpbp3i
oqs7oOR4K64fba8PJnNY62nMxPZrlKoVkkA++wVIjsOukTnrvJxUtRzTNzhYSDsi
sUq+PzxAp5gWbUPZ1XlB0CbXp+1mNuexNsnFhw7gWGUZFnmKFye8biLgp3N5/lmX
S40njfoKCQkJASai3feOlGZSywWgNjoJYuiE94VtA76OeovTdSrDo4qxTXSzxZXC
JsTRgUbgL573KgKffCLvQ4M6SRlh2s3KRVRT29/Rn5cu8aDjlRBcTQ==
=x/O1
-----END PGP SIGNATURE-----
Changes since livecd-tools-15.3:
Brian C. Lane (6):
Add tmpdir to ImageCreator class initializer (#476676)
Pass tmpdir to ImageCreator class initializer (#476676)
Align start of partition at 1MiB (#668967)
Source may be a file or a block device, mount accordingly
Add tmpdir to LiveImageCreator
Version 16.0
Frederick Grose (6):
Enable an optional tmpdir for e2image in fs.resize2fs()
Rename image source- and target-related variables
Support the propagation of an installed Live image
Update usage documentation & add it to the script
Enable cloning of a running LiveOS image into a fresh iso.
Enable reading of SquashFS compression type.
Jeroen van Meeuwen (Ergo Project) (2):
Really switch the default compression type, not just the default cli option value
Bad karma commit reverted; The option to boot from a local
---
Makefile | 2
docs/livecd-creator.pod | 1
docs/livecd-iso-to-disk.pod | 121 +++++-
imgcreate/creator.py | 18 -
imgcreate/fs.py | 52 ++
imgcreate/live.py | 24 +
tools/edit-livecd | 422 ++++++++++++++++++-----
tools/livecd-creator | 19 -
tools/livecd-iso-to-disk.sh | 783 +++++++++++++++++++++++++++++---------------
9 files changed, 1044 insertions(+), 398 deletions(-)
---
13 years, 2 months
Changes to 'refs/tags/livecd-tools-15.3'
by Brian C. Lane
Tag 'livecd-tools-15.3' created by Brian C. Lane <bcl(a)redhat.com> at 2011-01-27 19:47 +0000
Tag as livecd-tools-15.3
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
iQEVAwUATUHL2xF+jBaO/jp/AQLhSQf7Bv6Xw0rIdppEffTg05ieMX76pVSTgI0t
NZvCKY0T0EbyxmoLSLVhgKkj41Odt8l5YPgg/64WBGUSv5DkqZs8Z5rYPxArfa3Y
3DLCXhEjv7mWL43797kD2TECqk0lg9wvdK2uY4ZAinry2koCuAOFhhi/YtI6MYJI
r7ajokKy6bbSX/kQXLBq0l69BpOghoo29TLdVc10hxLghPTo320d3gb/pyPRmUlD
gUGRshVBj3EZfVoqkj9pfaxIAHYwS2zvTOLPumYauwNNweDEdvKyxcKgXK6OQ07e
/eZUaKKz1T7uBy6UQcra1aMRPcuQwfTGUW2ORXmONsj1vd7lC00mCA==
=ZQ67
-----END PGP SIGNATURE-----
Changes since livecd-tools-15.2:
Brian C. Lane (4):
Change releasever to a command line option (#667474)
Version 15.3
Check for one big initrd.img (#671900)
Remove boot from local drive option
Bruno Wolff III (2):
Update documentation for xz availability.
Make xz the default compression type for live images.
---
Makefile | 2 +-
docs/livecd-creator.pod | 20 +++++++++++++++-----
imgcreate/creator.py | 11 +++++++----
imgcreate/live.py | 11 ++++-------
imgcreate/yuminst.py | 17 +++++++++++++++--
tools/livecd-creator | 29 ++++++++++++++++-------------
tools/livecd-iso-to-disk.sh | 36 +++++++++++++++++++++++++++---------
7 files changed, 85 insertions(+), 41 deletions(-)
---
13 years, 2 months
Changes to 'refs/tags/livecd-tools-15.2'
by Brian C. Lane
Tag 'livecd-tools-15.2' created by Brian C. Lane <bcl(a)redhat.com> at 2010-12-22 22:27 +0000
Tag as livecd-tools-15.2
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
iQEVAwUATRJ7RBF+jBaO/jp/AQJawwgAjtXhBqnv07+Nq9860wvwpC/pIGhWBQzi
WOyXJdjgWFuQYqT4lhnuupkpHxIt0sXtcY2rRGh6kuuK2q95RtRZzlU631pPjYYa
AbjgUlbkJm0ALXyDK1EimLZryU9zt2dOvZ16QBVulE1CO/iospzybyAwBUosNQwf
BPZNVOV4eLt6bYWgi+YvSy8jWyxQcGtAsMal9y4o34WaUCRPOTT1sn/eqU3A/tGB
MCHgpnj2LoAQDE3cfBtIj1EPtByEMDH7cfDNp4S5bfkJ50KZ8wCE3BEON/KOWKdp
k8jKB+SaFYOZKI3tAhozC56ZxxSNHqHIzAjzuk15Zz4HXPTbptQn+g==
=5Bxj
-----END PGP SIGNATURE-----
Changes since livecd-tools-15.1:
Brian C. Lane (1):
Version 5.2
David Lehman (2):
Fix git URLs to match reality.
Assign a device-mapper UUID w/ subsystem prefix to the dm snapshot.
Frederick Grose (2):
Fix incomplete rename of freespace variable (#656154)
Trap copyFile errors (#663849)
---
HACKING | 4 ++--
Makefile | 2 +-
imgcreate/fs.py | 3 ++-
tools/livecd-iso-to-disk.sh | 10 ++++++----
4 files changed, 11 insertions(+), 8 deletions(-)
---
13 years, 2 months
Changes to 'refs/tags/livecd-tools-15.1'
by Brian C. Lane
Tag 'livecd-tools-15.1' created by Brian C. Lane <bcl(a)redhat.com> at 2010-12-01 01:07 +0000
Tag as livecd-tools-15.1
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
iQEVAwUATPWfuRF+jBaO/jp/AQJSqQgAj4bQM4sHM2GiHuuMIVj3gXmY5gE7pRyb
HpXKFvHTUT0igCUOzM11EdttdNBTRC3cdiZXDqSer6o2NbgE0KYj7QljV1Aa1g8m
3opqx0K4EcE/6qcVGSd0aYkU94Knt8uSb6bGqzXu8h0gfC9wOx69H4s1z8VbwiYP
mFX6RsstKA4An5cag7lWUNKLIrqHdiR2q7n+6vFS0zdzl4nDYs83RwFveVyEvWoX
StcnjqKc/s11Ry5ZSb45hROTVGBGkKq4afMRD7oMqkW/MlA155NNdUhiaaNkVP3G
bcKBcjYhchjvn46v1xoXt1ACw8j5qJvYR6BYc6smr21NzdOy8DS/pw==
=XsMY
-----END PGP SIGNATURE-----
Changes since livecd-tools-15.0:
Brian C. Lane (2):
Create tmpdir if it doesn't exist (#658632)
Bump version to 15.1
Frederick Grose (3):
Cleanup if/then blocks (#652522)
Fix disk space estimation errors (#656154)
Fix partition number selection for MMC bus devices (#587411)
James Laska (3):
Add a quiet option to surpress stdout. Adjust handle_logfile to not surpress stdout.
Work with the logging settings when emitting progress.
Wrap subprocess.call() so we can capture all command output for debugging.
Lubomir Rintel (2):
Merge livecd-creator and image-creator
Tolerate empty transactions
---
Makefile | 4 -
imgcreate/debug.py | 14 +++-
imgcreate/fs.py | 76 +++++++++++++-------------
imgcreate/util.py | 39 +++++++++++++
imgcreate/yuminst.py | 16 ++++-
tools/image-creator | 75 --------------------------
tools/livecd-creator | 51 ++++++++++++++----
tools/livecd-iso-to-disk.sh | 124 +++++++++++++++++++++++++++++---------------
8 files changed, 230 insertions(+), 169 deletions(-)
---
13 years, 2 months
Changes to 'refs/tags/livecd-tools-15.0'
by Brian C. Lane
Tag 'livecd-tools-15.0' created by Brian C. Lane <bcl(a)redhat.com> at 2010-11-16 01:14 +0000
Tag as livecd-tools-15.0
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Remember Lexington Green!
iQEVAwUATOHa3BF+jBaO/jp/AQIPXwf+OMkIaZ0x/46hd1rTUhh94XMfHwGmnCQH
JT2o82yvRw3LC3kMkSoAe+KRpuFVEmGQZBC1qDGUrI7V2AiCL+v7UL+0UOTXN8lw
5ggkDtlKC+ykBLJfo+IVWy77dgy9fLtjZ122//2B+5ntCd6igsjgn48Ph0YqKlO+
DqUS8Jkcfp/nCfSsHQ3n5J+zffE8jg+MtvtkC6NUae/6hgG+i1ueoTsj5ntVDt21
KNT+Z05w8Q7jIrgopTv65kyGBWczgSue+MCiqQC2kFy0UmdpvErAzGnkF69GBRrE
QdFEBUfcEAd7/o6njjU/LCi0BRh2AOCtGD10AeH8nso/483Fxt9Ylw==
=GaMN
-----END PGP SIGNATURE-----
Changes since livecd-tools-0.3.6:
Brian C. Lane (1):
Change version number
---
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
---
13 years, 2 months
Changes to 'refs/tags/livecd-tools-14.1'
by Brian C. Lane
Tag 'livecd-tools-14.1' created by Brian C. Lane <bcl(a)redhat.com> at 2010-12-22 23:23 +0000
Tag as livecd-tools-14.1
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
iQEVAwUATRKIgRF+jBaO/jp/AQLLxAf/d6ybU8kczjthyA4vvJpkRbxVpefp7uYS
yaH2GFogZpanLChbVGXiZlywhBfqNgwONJXfoG6ISYpuEG9FWX2BUMAvsNx6s69b
3Igs9BuPtw/F/XFgxe7hFpv6JO8yy/XCBfarvY8rHT8I6RtZyz0BVwiQRf9UN65Y
nTWZiK7zljwxVlcEVF0NnvV3ZaC5oRRS/MGUhQ3AobjkIWt3RyB9ZFNTC86NXHA+
LfVTdXnuwNQrThl0PW7Z9D/VJHpfvPULoaDOWt2SEEpZZkCQYx9bacFcVlKtmr11
rhyU6P6/sNe+CppVOikc/L7SQ6aBaoHD355YIdfvtKWFMKJOjNH+gg==
=RPal
-----END PGP SIGNATURE-----
Changes since livecd-tools-14.0:
Brian C. Lane (2):
Create tmpdir if it doesn't exist (#658632)
Version 14.1
Frederick Grose (2):
Fix partition number selection for MMC bus devices (#587411)
Trap copyFile errors (#663849)
Lubomir Rintel (1):
Tolerate empty transactions
---
Makefile | 2 +-
imgcreate/yuminst.py | 4 ++++
tools/livecd-creator | 3 +++
tools/livecd-iso-to-disk.sh | 28 ++++++++++++++++++++--------
4 files changed, 28 insertions(+), 9 deletions(-)
---
13 years, 2 months
Changes to 'refs/tags/livecd-tools-13.1'
by Brian C. Lane
Tag 'livecd-tools-13.1' created by Brian C. Lane <bcl(a)redhat.com> at 2010-12-22 23:36 +0000
Tag as livecd-tools-13.1
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
iQEVAwUATRKLkBF+jBaO/jp/AQLyWAf/S7OKkoTPrA6EoP11K7yBzdXBsrW4MLff
jM3WFNdNYhGhXr3sNc452DXRGeYsWXag6EJV9F9DW+2AHB1XIxTA/dXx931bmIxI
LuuS9oHC/CaCaluqTpd5aOe8TQFdbTrnOm5m0RCvEPgfBHjvTXI+ynQHWxjr+p56
Jw1/0LaWRr0BvB8qsciXEdlXRvVV6sUUBU20Oel0NiFkn2Neakh/eEEG2IJWlEOM
Qe8E6WdmgaaYt4EaJletA2k4PpnA4BpymtMzIxqenlrA/nzLHcVxkaPRooXdOR+i
4xGQTvx7nzhbX1xlmygDEp6odZn9HI3RCTrICSa9kK0d+lecRyYP8g==
=bOPT
-----END PGP SIGNATURE-----
Changes since livecd-tools-13.0:
Brian C. Lane (2):
Create tmpdir if it doesn't exist (#658632)
Version 13.1
Frederick Grose (2):
Fix partition number selection for MMC bus devices (#587411)
Trap copyFile errors (#663849)
Lubomir Rintel (1):
Tolerate empty transactions
---
Makefile | 2 +-
imgcreate/yuminst.py | 4 ++++
tools/livecd-creator | 3 +++
tools/livecd-iso-to-disk.sh | 28 ++++++++++++++++++++--------
4 files changed, 28 insertions(+), 9 deletions(-)
---
13 years, 2 months
8 commits - docs/livecd-creator.pod docs/livecd-iso-to-disk.pod imgcreate/fs.py imgcreate/live.py Makefile tools/edit-livecd tools/livecd-creator tools/livecd-iso-to-disk.sh
by Brian C. Lane
Makefile | 2
docs/livecd-creator.pod | 1
docs/livecd-iso-to-disk.pod | 121 +++++-
imgcreate/fs.py | 29 +
imgcreate/live.py | 13
tools/edit-livecd | 422 ++++++++++++++++++-----
tools/livecd-creator | 6
tools/livecd-iso-to-disk.sh | 777 ++++++++++++++++++++++++++++++--------------
8 files changed, 999 insertions(+), 372 deletions(-)
New commits:
commit 71ac1656ddec675eca28e8b8a2f9b9f95e07674c
Author: Brian C. Lane <bcl(a)redhat.com>
Date: Tue Feb 15 14:50:39 2011 -0800
Version 16.0
diff --git a/Makefile b/Makefile
index 0340df1..7ac3511 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
-VERSION = 15.3
+VERSION = 16.0
INSTALL = /usr/bin/install -c
INSTALL_PROGRAM = ${INSTALL}
commit c345f6afb63d41e2118073512e5cfa74b5be5d6b
Author: Brian C. Lane <bcl(a)redhat.com>
Date: Tue Feb 15 14:39:46 2011 -0800
Add tmpdir to LiveImageCreator
diff --git a/imgcreate/live.py b/imgcreate/live.py
index f388825..708ff05 100755
--- a/imgcreate/live.py
+++ b/imgcreate/live.py
@@ -38,13 +38,16 @@ class LiveImageCreatorBase(LoopImageCreator):
"""
- def __init__(self, ks, name, fslabel=None, releasever=None):
+ def __init__(self, ks, name, fslabel=None, releasever=None, tmpdir="/tmp"):
"""Initialise a LiveImageCreator instance.
This method takes the same arguments as LoopImageCreator.__init__().
"""
- LoopImageCreator.__init__(self, ks, name, fslabel=fslabel, releasever=releasever)
+ LoopImageCreator.__init__(self, ks, name,
+ fslabel=fslabel,
+ releasever=releasever,
+ tmpdir=tmpdir)
self.compress_type = "xz"
"""mksquashfs compressor to use."""
commit 5e8c294abe448bc15839c7781174ea9b7156228b
Author: Brian C. Lane <bcl(a)redhat.com>
Date: Tue Feb 15 11:51:48 2011 -0800
Source may be a file or a block device, mount accordingly
livecd-iso-to-disk can now copy the running live system over to a
target device. When the source is a block device don't mount it
loopback.
diff --git a/tools/livecd-iso-to-disk.sh b/tools/livecd-iso-to-disk.sh
index c58d6c2..ad0eebc 100755
--- a/tools/livecd-iso-to-disk.sh
+++ b/tools/livecd-iso-to-disk.sh
@@ -812,7 +812,14 @@ fi
# FIXME: would be better if we had better mountpoints
SRCMNT=$(mktemp -d /media/srctmp.XXXXXX)
-mount -o loop,ro "$SRC" $SRCMNT || exitclean
+if [ -b $SRC ]; then
+ mount -o ro "$SRC" $SRCMNT || exitclean
+elif [ -f $SRC ]; then
+ mount -o loop,ro "$SRC" $SRCMNT || exitclean
+else
+ echo "$SRC is not a file or block device."
+ exitclean
+fi
TGTMNT=$(mktemp -d /media/tgttmp.XXXXXX)
mount $mountopts $TGTDEV $TGTMNT || exitclean
commit 1aabfeae37aa87607a5e083e2775f744773619eb
Author: Frederick Grose <fgrose(a)gmail.com>
Date: Mon Feb 14 17:21:07 2011 -0800
Enable reading of SquashFS compression type.
Support edit-livecd & livecd-creator base_on image options by
adding the capability in fs.py to read the base_on image
compression type. Specifying a compressor type will override
the default; specifying 'None' will trigger reading and using
the base_on image's compression type.
diff --git a/docs/livecd-creator.pod b/docs/livecd-creator.pod
index 1827728..ce7b94e 100644
--- a/docs/livecd-creator.pod
+++ b/docs/livecd-creator.pod
@@ -47,6 +47,7 @@ xz is the default and works with 2.6.38 and later kernels.
gzip works with all kernels.
lzo works with 2.6.36 and later kernels.
lzma will only work with custom kernels.
+Set to 'None' to force reading the compressor used in BASE_ON.
If gzip is used, the -comp option is not passed to mksquashfs to allow the use of older versions of mksquashfs.
=item --releasever=VER
diff --git a/imgcreate/fs.py b/imgcreate/fs.py
index de61c7b..d5307a2 100644
--- a/imgcreate/fs.py
+++ b/imgcreate/fs.py
@@ -41,6 +41,35 @@ def makedirs(dirname):
if e.errno != errno.EEXIST:
raise
+def squashfs_compression_type(sqfs_img):
+ """Check the compression type of a SquashFS image. If the type cannot be
+ ascertained, return 'undetermined'. The calling code must decide what to
+ do."""
+
+ env = os.environ.copy()
+ env['LC_ALL'] = 'C'
+ args = ['/usr/sbin/unsquashfs', '-s', sqfs_img]
+ try:
+ p = subprocess.Popen(args, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE, env=env)
+ out, err = p.communicate()
+ except OSError, e:
+ raise SquashfsError(u"Error white stat-ing '%s'\n'%s'" % (args, e))
+ except:
+ raise SquashfsError(u"Error while stat-ing '%s'" % args)
+ else:
+ if p.returncode != 0:
+ raise SquashfsError(
+ u"Error while stat-ing '%s'\n'%s'\nreturncode: '%s'" %
+ (args, err, p.returncode))
+ else:
+ compress_type = 'undetermined'
+ for l in out.splitlines():
+ if l.split(None, 1)[0] == 'Compression':
+ compress_type = l.split()[1]
+ break
+ return compress_type
+
def mksquashfs(in_img, out_img, compress_type):
# Allow gzip to work for older versions of mksquashfs
if compress_type == "gzip":
diff --git a/imgcreate/live.py b/imgcreate/live.py
old mode 100644
new mode 100755
index bf3a4dd..f388825
--- a/imgcreate/live.py
+++ b/imgcreate/live.py
@@ -152,6 +152,12 @@ class LiveImageCreatorBase(LoopImageCreator):
squashloop = DiskMount(LoopbackDisk(squashimg, 0), self._mkdtemp(), "squashfs")
+ # 'self.compress_type = None' will force reading it from base_on.
+ if self.compress_type is None:
+ self.compress_type = squashfs_compression_type(squashimg)
+ if self.compress_type == 'undetermined':
+ # Default to 'gzip' for compatibility with older versions.
+ self.compress_type = 'gzip'
try:
if not squashloop.disk.exists():
raise CreatorError("'%s' is not a valid live CD ISO : "
diff --git a/tools/livecd-creator b/tools/livecd-creator
index 3424636..d997095 100755
--- a/tools/livecd-creator
+++ b/tools/livecd-creator
@@ -48,7 +48,11 @@ def parse_options(args):
imgopt.add_option("", "--image-type", type="string", dest="image_type",
help=optparse.SUPPRESS_HELP)
imgopt.add_option("", "--compression-type", type="string", dest="compress_type",
- help="Compression type recognized by mksquashfs (default xz needs a 2.6.38+ kernel, gzip works with all kernels, lzo needs a 2.6.36+ kernel, lzma needs custom kernel)",
+ help="Compression type recognized by mksquashfs "
+ "(default xz needs a 2.6.38+ kernel, gzip works "
+ "with all kernels, lzo needs a 2.6.36+ kernel, lzma "
+ "needs custom kernel.) Set to 'None' to force read "
+ "from base_on.",
default="xz")
imgopt.add_option("", "--releasever", type="string", dest="releasever",
default=None,
commit c41b33bf4f59c35fc9cf8fd8dd6933cf142e8f0c
Author: Frederick Grose <fgrose(a)gmail.com>
Date: Mon Feb 14 17:16:02 2011 -0800
Enable cloning of a running LiveOS image into a fresh iso.
Add image copying (via rsync), branding, & boot configuration
facilities to edit-livecd that permiting a running LiveOS
installation to be cloned into a fresh LiveCD iso9660 file.
This makes easy the building and propagation of customized images.
diff --git a/tools/edit-livecd b/tools/edit-livecd
index c98e652..79a6061 100755
--- a/tools/edit-livecd
+++ b/tools/edit-livecd
@@ -1,9 +1,11 @@
#!/usr/bin/python -tt
#
-# edit livecd: Edit a livecd to insert files
+# edit-liveos: Edit a LiveOS to insert files or to clone an instance onto a new
+# iso image file.
#
# Copyright 2009, Red Hat Inc.
# Written by Perry Myers <pmyers at redhat.com> & David Huff <dhuff at redhat.com>
+# Cloning code added by Frederick Grose <fgrose at sugarlabs.org>
#
#
# This program is free software; you can redistribute it and/or modify
@@ -21,6 +23,7 @@
import os
import sys
+import stat
import tempfile
import shutil
import subprocess
@@ -28,8 +31,10 @@ import optparse
import logging
from imgcreate.debug import *
+from imgcreate.errors import *
from imgcreate.fs import *
from imgcreate.live import *
+from imgcreate.creator import *
class ExistingSparseLoopbackDisk(SparseLoopbackDisk):
"""don't want to expand the disk"""
@@ -41,11 +46,11 @@ class ExistingSparseLoopbackDisk(SparseLoopbackDisk):
LoopbackDisk.create(self)
class LiveImageEditor(LiveImageCreator):
- """class for editing LiveCD images.
+ """class for editing LiveOS 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.
+ We need an instance of LiveImageCreator, however, we do not have a kickstart
+ file and we may not need to create a new image. We just want to reuse some
+ of LiveImageCreators methods on an existing LiveOS image.
"""
@@ -61,8 +66,20 @@ class LiveImageEditor(LiveImageCreator):
self.tmpdir = "/var/tmp"
"""The directory in which all temporary files will be created."""
- self.compress_type = "gzip"
- """mksquashfs compressor to use."""
+ self.clone = False
+ """Signals when to copy a running LiveOS image as base."""
+
+ self._include = None
+ """A string of file or directory paths to include in __copy_img_root."""
+
+ self._builder = "someone"
+ """The name of the Remix builder for _branding."""
+
+ self.compress_type = None
+ """mksquashfs compressor to use. Use 'None' to force reading of the
+ existing image, or enter a -p --compress_type value to override the
+ current compression or lack thereof. Compression type options vary with
+ the version of the kernel and SquashFS used."""
self.skip_compression = False
"""Controls whether to use squashfs to compress the image."""
@@ -76,23 +93,19 @@ class LiveImageEditor(LiveImageCreator):
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.__instroot = None
+
self._LiveImageCreatorBase__isodir = None
"""directory where the iso is staged"""
@@ -100,38 +113,41 @@ class LiveImageEditor(LiveImageCreator):
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"
+ self._LoopImageCreator__imagedir = \
+ tempfile.mkdtemp(dir = os.path.abspath(self.tmpdir),
+ prefix = self.name + "-")
+ rtn = self._LoopImageCreator__imagedir + "/ext3fs.img"
+ return rtn
_image = property(__get_image)
- """The location of the image file"""
+ """The location of the image file or filesystem root."""
-
- def _get_fstype(self):
- dev_null = os.open("/dev/null", os.O_WRONLY)
+ def _get_fstype(self, filesystem):
+ dev_null = os.open('/dev/null', os.O_WRONLY)
+ args = ['/sbin/blkid', '-s', 'TYPE', '-o', 'value', filesystem]
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("\"")
-
+ fs_type = subprocess.Popen(args,
+ stdout=subprocess.PIPE,
+ stderr=dev_null).communicate()[0]
except IOError, e:
raise CreatorError("Failed to determine fsimage TYPE: %s" % e )
+ finally:
+ os.close(dev_null)
+ return fs_type.rstrip()
- def _get_fslable(self):
+ def _get_fslabel(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()
+ self._LoopImageCreator__fslabel = out.strip()
except IOError, e:
- raise CreatorError("Failed to determine fsimage TYPE: %s" % e )
-
+ raise CreatorError("Failed to determine fsimage LABEL: %s" % e )
+ finally:
+ os.close(dev_null)
def __ensure_builddir(self):
if not self._ImageCreator__builddir is None:
@@ -139,12 +155,11 @@ class LiveImageEditor(LiveImageCreator):
try:
self._ImageCreator__builddir = tempfile.mkdtemp(dir = os.path.abspath(self.tmpdir),
- prefix = "edit-livecd-")
+ prefix = "edit-liveos-")
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-",
@@ -157,7 +172,6 @@ class LiveImageEditor(LiveImageCreator):
script = "/tmp/" + os.path.basename(path)
-
try:
subprocess.call([script], preexec_fn = self._chroot)
except OSError, e:
@@ -165,21 +179,25 @@ class LiveImageEditor(LiveImageCreator):
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 have to override mount b/c we many not be creating an new install
+ root nor do we need to setup the file system, i.e., 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.
- We also need to get some info about the image before we
- can mount it.
+ base_on -- the <LIVEIMG.src> a LiveOS.iso file or an attached LiveOS
+ device, such as, /dev/live for a currently running image.
+
+ cachedir -- a directory in which to store a Yum cache;
+ Not used in edit-liveos.
"""
if not base_on:
- raise CreatorError("No base livecd image specified")
+ raise CreatorError("No base LiveOS image specified.")
self.__ensure_builddir()
@@ -191,19 +209,26 @@ class LiveImageEditor(LiveImageCreator):
makedirs(self._LoopImageCreator__imagedir)
makedirs(self._ImageCreator_outdir)
- LiveImageCreator._base_on(self, base_on)
+ if self.clone:
+ # Need to clone base_on into ext3fs.img at this point
+ self._base_on(base_on)
+ self._LoopImageCreator__fslabel = self.name
+ else:
+ LiveImageCreator._base_on(self, base_on)
+ self._LoopImageCreator__fstype = self._get_fstype(self._image)
+ self._get_fslabel()
+ self.fslabel = self._LoopImageCreator__fslabel
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)
+
+ self._LoopImageCreator__instloop = ExtDiskMount(
+ ExistingSparseLoopbackDisk(self._image,
+ self._LoopImageCreator__image_size),
+ self._ImageCreator_instroot,
+ self._fstype,
+ self._LoopImageCreator__blocksize,
+ self.fslabel,
+ self.tmpdir)
try:
self._LoopImageCreator__instloop.mount()
except MountError, e:
@@ -222,54 +247,253 @@ class LiveImageEditor(LiveImageCreator):
os.symlink("../proc/mounts", self._instroot + "/etc/mtab")
- self.__copy_cd_root(base_on)
+ self.__copy_img_root(base_on)
+ self._brand(self._builder)
- def __copy_cd_root(self, base_on):
- """helper function to root content of the base liveCD to ISOdir"""
+ def _base_on(self, base_on):
+ """Clone the running LiveOS image as the basis for the new image."""
- isoloop = DiskMount(LoopbackDisk(base_on, 0), self._mkdtemp())
- self._LiveImageCreatorBase__isodir = self._ImageCreator__builddir + "/iso"
+ self.__fstype = 'ext4'
+ self.__image_size = 4096L * 1024 * 1024
+ self.__blocksize = 4096
+ self.__instloop = ExtDiskMount(SparseLoopbackDisk(self._image,
+ self.__image_size),
+ self._instroot,
+ self.__fstype,
+ self.__blocksize,
+ self.fslabel,
+ self.tmpdir)
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"))
+ self.__instloop.mount()
except MountError, e:
raise CreatorError("Failed to loopback mount '%s' : %s" %
- (base_on, e))
+ (self._image, e))
+
+ subprocess.call(['rsync', '-ptgorlHASx', '--specials', '--progress',
+ '--include', '/*/',
+ '--exclude', '/etc/mtab',
+ '--exclude', '/etc/blkid/*',
+ '--exclude', '/dev/*',
+ '--exclude', '/proc/*',
+ '--exclude', '/home/*',
+ '--exclude', '/media/*',
+ '--exclude', '/mnt/live',
+ '--exclude', '/sys/*',
+ '--exclude', '/tmp/*',
+ '--exclude', '/.liveimg*',
+ '--exclude', '/.autofsck',
+ '/', self._instroot])
+ subprocess.call(['sync'])
+
+ self._ImageCreator__create_minimal_dev()
+
+ self.__instloop.cleanup()
+
+
+ def __copy_img_root(self, base_on):
+ """helper function to copy root content of the base LiveIMG to
+ ISOdir"""
+
+ ignore_list = ['ext3fs.img', 'squashfs.img', 'osmin.img', 'home.img',
+ 'overlay-*']
+
+ if self.clone:
+ ignore_list.remove('home.img')
+ includes = 'boot, /EFI, /syslinux, /LiveOS'
+ if self._include:
+ includes += ", " + self._include
+
+ imgmnt = DiskMount(RawDisk(0, base_on), self._mkdtemp())
+ else:
+ imgmnt = DiskMount(LoopbackDisk(base_on, 0), self._mkdtemp())
+
+ self._LiveImageCreatorBase__isodir = self._ImageCreator__builddir + "/iso"
+ try:
+ imgmnt.mount()
+ except MountError, e:
+ raise CreatorError("Failed to mount '%s' : %s" % (base_on, e))
+ else:
+ # include specified files or directories
+ if self.clone:
+ baseimg = os.path.join(imgmnt.mountdir, 'LiveOS',
+ 'squashfs.img')
+ # 'self.compress_type = None' will force reading it from
+ # base_on.
+ if self.compress_type is None:
+ self.compress_type = squashfs_compression_type(baseimg)
+ if self.compress_type == 'undetermined':
+ # 'gzip' for compatibility with older versions.
+ self.compress_type = 'gzip'
+
+ dst = self._LiveImageCreatorBase__isodir
+ print includes
+ for fd in includes.split(', /'):
+ src = os.path.join(imgmnt.mountdir, fd)
+ if os.path.isfile(src):
+ shutil.copy2(src, os.path.join(dst, fd))
+ elif os.path.isdir(src):
+ shutil.copytree(src, os.path.join(dst, fd),
+ symlinks=True,
+ ignore=shutil.ignore_patterns(
+ *ignore_list))
+ else:
+ #copy over everything but squashfs.img or ext3fs.img
+ shutil.copytree(imgmnt.mountdir,
+ self._LiveImageCreatorBase__isodir,
+ ignore=shutil.ignore_patterns(*ignore_list))
+ subprocess.call(['sync'])
finally:
- isoloop.cleanup()
+ imgmnt.cleanup()
+
+
+ def _brand (self, _builder):
+ """Adjust the image branding to show its variation from original
+ source by builder and build date."""
+
+ dt = time.strftime('%d-%b-%Y')
+
+ lst = ['isolinux/isolinux.cfg', 'syslinux/syslinux.cfg',
+ 'syslinux/extlinux.conf']
+ for f in lst:
+ fpath = os.path.join(self._LiveImageCreatorBase__isodir, f)
+ if os.path.exists(fpath):
+ break
+
+ # Get build name from boot configuration file.
+ try:
+ cfgf = open(fpath, 'r')
+ except IOError, e:
+ raise CreatorError("Failed to open '%s' : %s" % (fpath, e))
+ else:
+ for line in cfgf:
+ i = line.find('Welcome to ')
+ if i > -1:
+ self.name = line[i+11:-2]
+ break
+ cfgf.close()
+
+ ntext = dt.translate(None,
+ '-') + '-' + _builder + '-Remix-' + self.name
+
+ # Update fedora-release message with Remix details.
+ releasefiles = '/etc/fedora-release, /etc/generic-release'
+ if self._releasefile:
+ releasefiles += ', ' + self._releasefile
+ for fn in releasefiles.split(', '):
+ if os.path.exists(fn):
+ try:
+ with open(self._instroot + fn, 'r') as f:
+ text = ntext + '\n' + f.read()
+ open(f.name, 'w').write(text)
+ except IOError, e:
+ raise CreatorError("Failed to open or write '%s' : %s" %
+ (f.name, e))
+
+ self.name = ntext
+ self.fslabel += '-' + os.uname()[4] + '-' + time.strftime('%Y%m%d.%H')
+
+
+ def _configure_bootloader(self, isodir):
+ """Restore the boot configuration files for an iso image boot."""
+
+ bootfolder = os.path.join(isodir, 'isolinux')
+ oldpath = os.path.join(isodir, 'syslinux')
+ if os.path.exists(oldpath):
+ os.rename(oldpath, bootfolder)
+
+ cfgf = os.path.join(bootfolder, 'isolinux.cfg')
+ for f in ['syslinux.cfg', 'extlinux.conf']:
+ src = os.path.join(bootfolder, f)
+ if os.path.exists(src):
+ os.rename(src, cfgf)
+
+ args = ['/bin/sed', '-i',
+ '-e', 's/Welcome to .*/Welcome to ' + self.name + '!/',
+ '-e', 's/root=[^ ]*/root=live:CDLABEL=' + self.fslabel + '/',
+ '-e', 's/rootfstype=[^ ]* [^ ]*/rootfstype=auto ro/',
+ '-e', 's/liveimg .* quiet/liveimg quiet/', cfgf]
+
+ dev_null = os.open("/dev/null", os.O_WRONLY)
+ try:
+ subprocess.Popen(args,
+ stdout = subprocess.PIPE,
+ stderr = dev_null).communicate()[0]
+ return 0
+ except IOError, e:
+ raise CreatorError("Failed to configure bootloader file: %s" % e)
+ return 1
+ finally:
+ os.close(dev_null)
def parse_options(args):
- parser = optparse.OptionParser(usage = "%prog [-s=<script.sh>] <LIVECD.iso>")
+ parser = optparse.OptionParser(usage = "\n %prog [-n=<name>]"
+ "\n [-o=<output>]"
+ "\n [-s=<script.sh>]"
+ "\n [-t=<tmpdir>]"
+ "\n [-e=<excludes>]"
+ "\n [-f=<exclude-file>]"
+ "\n [-i=<includes>]"
+ "\n [-r=<releasefile>]"
+ "\n [-b=<builder>]"
+ "\n [--clone]"
+ "\n [-c=<compress_type>]"
+ "\n [--skip-compression]"
+ "\n [--skip-minimize]"
+ "\n <LIVEIMG.src>")
parser.add_option("-n", "--name", type="string", dest="name",
- help="name of new livecd (don't include .iso will be added)")
+ help="name of new LiveOS (don't include .iso, it will "
+ "be added)")
parser.add_option("-o", "--output", type="string", dest="output",
- help="specify the output dir")
+ help="specify directory for new iso file.")
parser.add_option("-s", "--script", type="string", dest="script",
- help="specify script to run chrooted in the livecd fsimage")
+ help="specify script to run chrooted in the LiveOS "
+ "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("-e", "--exclude", type="string", dest="exclude",
+ help="Specify directory or file patterns to be excluded "
+ "from the rsync copy of the filesystem.")
+
+ parser.add_option("-f", "--exclude-file", type="string",
+ dest="exclude_file",
+ help="Specify a file containing file patterns to be "
+ "excluded from the rsync copy of the filesystem.")
+
+ parser.add_option("-i", "--include", type="string", dest="include",
+ help="Specify directory or file patterns to be included "
+ "in copy_img_root.")
+
+ parser.add_option("-r", "--releasefile", type="string", dest="releasefile",
+ help="Specify release file/s for branding.")
+
+ parser.add_option("-b", "--builder", type="string", dest="builder",
+ help="Specify the builder of a Remix.")
+
+ parser.add_option("", "--clone", action="store_true", dest="clone",
+ help="Specify that source image is LiveOS block device.")
+
+ parser.add_option("-c", "--compress_type", type="string",
+ dest="compress_type",
+ help="Specify the compression type for SquashFS. Will "
+ "override the current compression or lack thereof.")
- parser.add_option("", "--skip-minimize", action="store_true", dest="skip_minimize")
+ parser.add_option("", "--skip-compression", action="store_true",
+ dest="skip_compression", default=False,
+ help="Specify no compression of filesystem, ext3fs.img")
+
+ parser.add_option("", "--skip-minimize", action="store_true",
+ dest="skip_minimize", default=False,
+ help="Specify no osmin.img minimal snapshot.")
setup_logging(parser)
@@ -279,6 +503,8 @@ def parse_options(args):
parser.print_usage()
sys.exit(1)
+ print args[0]
+
return (args[0], options)
def rebuild_iso_symlinks(isodir):
@@ -288,60 +514,60 @@ def rebuild_iso_symlinks(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)
-
+ if os.path.exists(efi_vmlinuz):
+ 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:])
+ # LiveOS set to <LIVEIMG.src>
+ (LiveOS, options) = parse_options(sys.argv[1:])
if os.geteuid () != 0:
- print >> sys.stderr, "You must run edit-livecd as root"
+ print >> sys.stderr, "You must run edit-liveos as root"
return 1
- if options.name:
+ if options.name and options.name != os.path.basename(LiveOS):
name = options.name
else:
- name = os.path.basename(livecd) + ".edited"
+ name = os.path.basename(LiveOS) + ".edited"
if options.output:
output = options.output
else:
- output = os.path.dirname(livecd)
-
+ output = os.path.dirname(LiveOS)
editor = LiveImageEditor(name)
- editor.tmpdir = os.path.abspath(options.tmpdir)
+ editor._exclude = options.exclude
+ editor._exclude_file = options.exclude_file
+ editor._include = options.include
+ editor.clone = options.clone
+ editor.tmpdir = options.tmpdir
+ editor._builder = options.builder
+ editor._releasefile = options.releasefile
+ editor.compress_type = options.compress_type
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()
+ editor.mount(LiveOS, cachedir = None)
+ editor._configure_bootloader(editor._LiveImageCreatorBase__isodir)
+ editor.name = editor.fslabel
rebuild_iso_symlinks(editor._LiveImageCreatorBase__isodir)
editor.unmount()
editor.package(output)
except CreatorError, e:
- logging.error(u"Error editing Live CD : %s" % e)
+ logging.error(u"Error editing LiveOS : %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
commit 2acbe2084e7861cfc17706eceeaca116d459b5a5
Author: Frederick Grose <fgrose(a)gmail.com>
Date: Mon Feb 14 17:08:17 2011 -0800
Update usage documentation & add it to the script
Update the usage manual and include all options.
Provide complete usage documentation onboard the script, as the
script is often distributed independently.
diff --git a/docs/livecd-iso-to-disk.pod b/docs/livecd-iso-to-disk.pod
index 1ccab66..7ef0c14 100644
--- a/docs/livecd-iso-to-disk.pod
+++ b/docs/livecd-iso-to-disk.pod
@@ -2,63 +2,138 @@
=head1 NAME
-livecd-iso-to-disk - installs bootable CD images on a USB storage devices.
+livecd-iso-to-disk - installs bootable Live images onto USB/SD storage devices.
=head1 SYNOPSIS
-B<livecd-iso-to-disk> [--format] [--reset-mbr] [--noverify] [--efi] [--overlay-size-mb <size>] [\-\-home\-size\-mb <size>] [\-\-unencrypted\-home] [\-\-skipcopy] <path-to-iso> <usb storage device>
+B<livecd-iso-to-disk> [--help] [--noverify] [--format] [--reset-mbr] [--efi] [--skipcopy] [--force] [--xo] [--xo-no-home] [--timeout <time>] [--totaltimeout <time>] [--extra-kernel-args <args>] [--multi] [--livedir <dir>] [--compress] [--skipcompress] [--swap-size-mb <size>] [--overlay-size-mb <size>] [--home-size-mb <size>] [--delete-home] [--crypted-home] [--unencrypted-home] <source> <target device>
+
+Simplest
+
+The script may be run in simplest form with just the two arguments:
+
+B<livecd-iso-to-disk> <source> <target device>
+
+To execute the script to completion, you will need to run it with root user permissions. SYSLINUX must be installed on the computer running the installation script.
+
+=over 4
+
+=item <source>
+
+This may be the filesystem path to a LiveOS .iso image file, such as from a CD-ROM, DVD, or download. It could also be the device node reference for the mount point of another LiveOS filesystem, including the currently-running one (such as a booted Live CD/DVD/USB, where /dev/live references the running image device).
+
+=item <target device>
+
+This should be the device partition name for the attached, target device, such as /dev/sdb1 or /dev/sdc1. (Issue the df -Th command to get a listing of the mounted partitions, where you can confirm the filesystem types, available space, and device names.) Be careful to specify the correct device, or you may overwrite important data on another disk!
+
+=back
=head1 DESCRIPTION
-B<livecd-iso-to-disk> installs a live CD or DVD image(ISO image) onto a USB storage device. The USB storage device can then boot the installed operating system on systems which support booting via USB. B<livecd-iso-to-disk> requires an ISO image and a USB storage device. ISO images can be created with B<livecd-creator>.
+B<livecd-iso-to-disk> installs a Live CD/DVD/USB image (LiveOS) onto a USB/SD storage device (or any storage partition that will boot with a SYSLINUX bootloader). The target storage device can then boot the installed operating system on systems that support booting via the USB or the SD interface. The script requires a LiveOS source image and a target storage device. The source image may be either a LiveOS .iso file, the currently-running LiveOS image, the device node reference for an attached device with an installed LiveOS image, or a file backed by a block device with an installed LiveOS image. If the operating system supports persistent overlays for saving system changes, a pre-sized overlay may be included with the installation.
+
+Unless you request the --format option, the installation does not destroy data outside of the LiveOS, syslinux, & EFI folders on your target device. This allows one to maintain other files on the target disk outside of the LiveOS filesystem.
-B<livecd-iso-to-disk> is not a destructive process; any data you currently have on your USB stick is preserved.
+LiveOS images provide embedded filesystems through the Device-mapper component of the Linux kernel. The embedded filesystems exist within files such as /LiveOS/squashfs.img (the default compressed storage) or /LiveOS/ext3fs.img (an uncompressed version) on the primary volume partition of the storage device. In use, these are read-only filesystems. Optionally, one may specify a persistent LiveOS overlay to hold image-change snapshots (that use write-once, difference-tracking storage) in the /LiveOS/overlay-<device_id> file, which, *one should note*, always grows in size due to the storage mechanism. (The fraction of allocated space that has been consumed by system activity and changes may be displayed by issuing the 'dmsetup status' command in a terminal session of a running LiveOS image.) One way to conserve the unrecoverable, overlay file space, is to specify a persistent home folder for user files, which will be saved in a /LiveOS/home.img filesystem image file. This
file space is encrypted by default, but is not compressed. (One may bypass encryption with the --unencrypted-home installation option.) Files in this home folder may be erased to recover and reuse their storage space. The home.img file is also convenient for backing up or swapping user account files.
=head1 OPTIONS
=over 4
+=item --help
+
+Displays usage information and exits.
+
+=item --noverify
+
+Disables the image validation process that occurs before the image is installed from the original Live CD .iso image. When this option is specified, the image is not verified before loading onto the target storage device.
+
=item --format
-Formats the USB stick and creates an MS-DOS partition table (or GPT partition table if --efi is passed).
+Formats the target device and creates an MS-DOS partition table (or GUID partition table, if the --efi option is passed).
=item --reset-mbr
-Sets the Master Boot Record(MBR) of the USB storage device to the mbr.bin file from the image's syslinux directory.
+Sets the Master Boot Record (MBR) of the target storage device to the mbr.bin file from the installation system's syslinux directory. This may be helpful in recovering a damaged or corrupted device.
-=item --noverify
+=item --efi
-Disables the image validation process which occurs before the image is installed. When this option is enabled the image is not verified before installation on the USB storage device.
+Creates a GUID partition table when --format is passed, and installs a hybrid Extensible Firmware Interface (EFI)/MBR bootloader on the disk. This is necessary for most Intel Macs.
-=item --overlay-size-mb
+=item --skipcopy
-This option sets the overlay size in megabytes. The overlay is additional storage available to the live operating system if the operating system supports it. The USB storage device must have enough free space for the image and the overlay.
+Skips the copying of the live image to the target device, bypassing the actions of the --format, --overlay-size-mb, --home-size-mb, & --swap-size-mb options, if present on the command line. (The --skipcopy option may be used while testing the script, in order to avoid repeated and lengthy copy commands, or to repair boot configuration files on a previously installed device.)
-=item --home-size-mb
+=item --force
-Sets the home directory size in megabytes.
+This option allows the installation script to bypass a delete confirmation dialog in the event that a pre-existing LiveOS directory is found on the target device.
-=item --unencrypted-home
+=item --xo
-Disables the encryption of the home directory.
+Used to prepare an image for the OLPC XO-1 laptop with its compressed, JFFS2 filesystem. Do not use the following options with --xo:
-=item --skipcopy
+=over 4
-Skips the copy of the live image to the USB stick and disables the --forma, --home-size-mb, and --swap-size-mb options. The --overlay-size-mb option is changed to only reinitialize the existing overlay area, to recreate it from scratch.
+--overlay-size-mb <size>, home-size-mb <size>, --delete-home, --compress
-The intended use of this option is to speed up testing of the boot configuration of live images.
+=back
-=item --efi
+=item --xo-no-home
-Create a GPT partition table when --format is passed, and install an hybrid EFI/MBR bootloader on the disk. This is necessary for most Intel Macs.
+Used together with the --xo option to prepare an image for an OLPC XO laptop with the home folder on an SD card instead of the internal flash storage.
=item --timeout
-Modify the bootloader's timeout value. This overrides the value set during iso creation. Units are 1/10s
+Modifies the bootloader's timeout value, which indicates how long to pause at the boot: prompt before booting automatically. This overrides the value set during iso creation. Units are 1/10 s. The timeout is canceled when any key is pressed, the assumption being that the user will complete the command line. A timeout of zero will disable the timeout completely.
=item --totaltimeout
-Add a totaltimeout to the bootloader config. This is used to force and automatic boot. This cannot be canceled by the user. Units are 1/10s
+Adds a bootloader totaltimeout, which indicates how long to wait before booting automatically. This is used to force an automatic boot. This timeout cannot be canceled by the user. Units are 1/10 s.
+
+=item --extra-kernel-args <args>
+
+Specifies additional kernel arguments, <args>, that will be inserted into the syslinux and EFI boot configurations. Multiple arguments should be specified in one string, i.e., --extra-kernel-args "arg1 arg2 ..."
+
+=item --multi
+
+Used when installing multiple image copies to signal configuration of the boot files for the image in the --livedir <dir> parameter.
+
+=item --livedir <dir>
+
+Used with multiple image installations to designate the directory <dir> for the particular image.
+
+=item --compress (default state for the operating system files)
+
+The default, compressed SquashFS filesystem image is copied on installation. This option has no effect when the source filesystem
+is already expanded.
+
+=item --skipcompress (default option when --xo is specified)
+
+Expands the source SquashFS image on installation into the read-only /LiveOS/ext3fs.img filesystem image file.
+
+=item --swap-size-mb <size>
+
+Sets up a swap file of <size> mebibytes (integer values only) on the target device.
+
+=item --overlay-size-mb <size>
+
+This option sets the overlay size in mebibytes (integer values only). The overlay makes persistent storage available to the live operating system, if the operating system supports it. The persistent LiveOS overlay holds image-change snapshots (using write-once, difference-tracking storage) in the /LiveOS/overlay-<device_id> file, which, *one should note*, always grows in size due to the storage mechanism. (The fraction of allocated space that has been consumed may be displayed by issuing the 'dmsetup status' command in a terminal session of a running LiveOS installation.) One way to conserve the unrecoverable, overlay file space, is to specify a persistent home folder for user files, see --home-size-mb below. The target storage device must have enough free space for the image and the overlay. A maximum <size> of 2047 MiB is permitted for vfat-formatted devices. If there is insufficient room on your device, you will be given information to help in adjusting your setti
ngs.
+
+=item --home-size-mb <size>
+
+Sets the home directory size in mebibytes (integer values only). A persistent home directory will be made in the /LiveOS/home.img filesystem image file. This file space is encrypted by default, but not compressed (one may bypass encryption with the --unencrypted-home installation option). Files in this home folder may be erased to recover and reuse their storage space. The target storage device must have enough free space for the image, any overlay, and the home directory. Note that the --delete-home option must also be selected to replace an existing persistent home with a new, empty one. A maximum <size> of 2047 MiB is permitted for vfat-formatted devices. If there is insufficient room on your device, you will be given information to help in adjusting your settings.
+
+=item --delete-home
+
+To prevent unwitting deletion of user files, this option must be explicitly selected when the option --home-size-mb <size> is selected and there is an existing persistent home directory on the target device.
+
+=item --crypted-home (default that only applies to new home-size-mb requests)
+
+Specifies the default option to encrypt a new persistent home directory if --home-size-mb <size> is specified.
+
+=item --unencrypted-home
+
+Prevents the default option to encrypt a new persistent home directory.
=back
@@ -68,11 +143,11 @@ David Zeuthen, Jeremy Katz, Douglas McClendon, Chris Curran and other contributo
=head1 BUGS
-Report bugs to the mailing list C<http://www.redhat.com/mailman/listinfo/fedora-livecd-list> or directly to Bugzilla C<http://bugzilla.redhat.com/bugzilla/> against the C<Fedora> product, and the C<lived-tools> component.
+Report bugs to the mailing list C<http://admin.fedoraproject.org/mailman/listinfo/livecd> or directly to Bugzilla C<http://bugzilla.redhat.com/bugzilla/> against the C<Fedora> product, and the C<livecd-tools> component.
=head1 COPYRIGHT
-Copyright (C) Fedora Project 2008,2009, and various contributors. This is free software. You may redistribute copies of it under the terms of the GNU General Public License C<http://www.gnu.org/licenses/gpl.html>. There is NO WARRANTY, to the extent permitted by law.
+Copyright (C) Fedora Project 2008, 2009, 2010 and various contributors. This is free software. You may redistribute copies of it under the terms of the GNU General Public License C<http://www.gnu.org/licenses/gpl.html>. There is NO WARRANTY, to the extent permitted by law.
=head1 SEE ALSO
diff --git a/tools/livecd-iso-to-disk.sh b/tools/livecd-iso-to-disk.sh
index aca77d2..c58d6c2 100755
--- a/tools/livecd-iso-to-disk.sh
+++ b/tools/livecd-iso-to-disk.sh
@@ -22,8 +22,248 @@
export PATH=/sbin:/usr/sbin:$PATH
+shortusage() {
+ echo "
+ SYNTAX
+
+ livecd-iso-to-disk [--help] [--noverify] [--format] [--reset-mbr] [--efi]
+ [--skipcopy] [--force] [--xo] [--xo-no-home]
+ [--timeout <time>] [--totaltimeout <time>]
+ [--extra-kernel-args <args>] [--multi] [--livedir <dir>]
+ [--compress] [--skipcompress] [--swap-size-mb <size>]
+ [--overlay-size-mb <size>] [--home-size-mb <size>]
+ [--delete-home] [--crypted-home] [--unencrypted-home]
+ <source> <target device>
+
+ (Enter livecd-iso-to-disk --help on the command line for more information.)"
+}
+
usage() {
- echo "$0 [--timeout <time>] [--totaltimeout <time>] [--format] [--reset-mbr] [--noverify] [--overlay-size-mb <size>] [--home-size-mb <size>] [--unencrypted-home] [--skipcopy] [--efi] <source> <target device>"
+ echo "
+ "
+ shortusage
+ echo "
+ livecd-iso-to-disk - Transfer a LiveOS image so that it's bootable off of
+ a USB/SD device.
+
+ The script may be run in simplest form with just the two arguments:
+
+ <source>
+ This may be the filesystem path to a LiveOS .iso image file,
+ such as from a CD-ROM, DVD, or download. It could also be the
+ device node reference for the mount point of another LiveOS
+ filesystem, including the currently-running one (such as a
+ booted Live CD/DVD/USB, where /dev/live references the running
+ image device).
+
+ <target device>
+ This should be the device partition name for the attached,
+ target device, such as /dev/sdb1 or /dev/sdc1. (Issue the
+ df -Th command to get a listing of the mounted partitions,
+ where you can confirm the filesystem types, available space,
+ and device names.) Be careful to specify the correct device,
+ or you may overwrite important data on another disk!
+
+ To execute the script to completion, you will need to run it with root user
+ permissions.
+ SYSLINUX must be installed on the computer running the installation script.
+
+ DESCRIPTION
+
+ livecd-iso-to-disk installs a Live CD/DVD/USB image (LiveOS) onto a USB/SD
+ storage device (or any storage partition that will boot with a SYSLINUX
+ bootloader). The target storage device can then boot the installed
+ operating system on systems that support booting via the USB or the SD
+ interface. The script requires a LiveOS source image and a target storage
+ device. The source image may be either a LiveOS .iso file, the currently-
+ running LiveOS image, the device node reference for an attached device with
+ an installed LiveOS image, or a file backed by a block device with an
+ installed LiveOS image. If the operating system supports persistent
+ overlays for saving system changes, a pre-sized overlay may be included with
+ the installation.
+
+ Unless you request the --format option, the installation does not destroy
+ data outside of the LiveOS, syslinux, & EFI folders on your target device.
+ This allows one to maintain other files on the target disk outside of the
+ LiveOS filesystem.
+
+ LiveOS images provide embedded filesystems through the Device-mapper
+ component of the Linux kernel. The embedded filesystems exist within files
+ such as /LiveOS/squashfs.img (the default compressed storage) or
+ /LiveOS/ext3fs.img (an uncompressed version) on the primary volume partition
+ of the storage device. In use, these are read-only filesystems. Optionally,
+ one may specify a persistent LiveOS overlay to hold image-change snapshots
+ (that use write-once, difference-tracking storage) in the
+ /LiveOS/overlay-<device_id> file, which, *one should note*, always grows in
+ size due to the storage mechanism. (The fraction of allocated space that
+ has been consumed by system activity and changes may be displayed by issuing
+ the 'dmsetup status' command in a terminal session of a running LiveOS
+ image.) One way to conserve the unrecoverable, overlay file space, is to
+ specify a persistent home folder for user files, which will be saved in a
+ /LiveOS/home.img filesystem image file. This file space is encrypted by
+ default, but is not compressed. (One may bypass encryption with the
+ --unencrypted-home installation option.) Files in this home folder may be
+ erased to recover and reuse their storage space. The home.img file is also
+ convenient for backing up or swapping user account files.
+
+ OPTIONS
+
+ --help
+ Displays usage information and exits.
+
+ --noverify
+ Disables the image validation process that occurs before the image is
+ installed from the original Live CD .iso image. When this option is
+ specified, the image is not verified before loading onto the target
+ storage device.
+
+ --format
+ Formats the target device and creates an MS-DOS partition table (or GPT
+ partition table, if the --efi option is passed).
+
+ --reset-mbr
+ Sets the Master Boot Record (MBR) of the target storage device to the
+ mbr.bin file from the installation system's syslinux directory. This
+ may be helpful in recovering a damaged or corrupted device.
+
+ --efi
+ Creates a GUID partition table when --format is passed, and installs a
+ hybrid Extensible Firmware Interface (EFI)/MBR bootloader on the disk.
+ This is necessary for most Intel Macs.
+
+ --skipcopy
+ Skips the copying of the live image to the target device, bypassing the
+ actions of the --format, --overlay-size-mb, --home-size-mb, &
+ --swap-size-mb options, if present on the command line. (The --skipcopy
+ option may be used while testing the script, in order to avoid repeated
+ and lengthy copy commands, or to repair boot configuration files on a
+ previously installed device.)
+
+ --force
+ This option allows the installation script to bypass a delete
+ confirmation dialog in the event that a pre-existing LiveOS directory
+ is found on the target device.
+
+ --xo
+ Used to prepare an image for the OLPC XO-1 laptop with its compressed,
+ JFFS2 filesystem. Do not use the following options with --xo:
+ --overlay-size-mb <size>, home-size-mb <size>, --delete-home,
+ --compress
+
+ --xo-no-home
+ Used together with the --xo option to prepare an image for an OLPC XO
+ laptop with the home folder on an SD card instead of the internal flash
+ storage.
+
+ --timeout
+ Modifies the bootloader's timeout value, which indicates how long to
+ pause at the boot: prompt before booting automatically. This overrides
+ the value set during iso creation. Units are 1/10 s. The timeout is
+ canceled when any key is pressed, the assumption being that the user
+ will complete the command line. A timeout of zero will disable the
+ timeout completely.
+
+ --totaltimeout
+ Adds a bootloader totaltimeout, which indicates how long to wait before
+ booting automatically. This is used to force an automatic boot. This
+ timeout cannot be canceled by the user. Units are 1/10 s.
+
+ --extra-kernel-args <args>
+ Specifies additional kernel arguments, <args>, that will be inserted
+ into the syslinux and EFI boot configurations. Multiple arguments
+ should be specified in one string, i.e.,
+ --extra-kernel-args \"arg1 arg2 ...\"
+
+ --multi
+ Used when installing multiple image copies to signal configuration of
+ the boot files for the image in the --livedir <dir> parameter.
+
+
+ --livedir <dir>
+ Used with multiple image installations to designate the directory <dir>
+ for the particular image.
+
+ --compress (default state for the operating system files)
+ The default, compressed SquashFS filesystem image is copied on
+ installation. This option has no effect when the source filesystem is
+ already expanded.
+
+ --skipcompress (default option when --xo is specified)
+ Expands the source SquashFS image on installation into the read-only
+ /LiveOS/ext3fs.img filesystem image file.
+
+ --swap-size-mb <size>
+ Sets up a swap file of <size> mebibytes (integer values only) on the
+ target device.
+
+ --overlay-size-mb <size>
+ This option sets the overlay size in mebibytes (integer values only).
+ The overlay makes persistent storage available to the live operating
+ system, if the operating system supports it. The persistent LiveOS
+ overlay holds image-change snapshots (using write-once, difference-
+ tracking storage) in the /LiveOS/overlay-<device_id> file, which, *one
+ should note*, always grows in size due to the storage mechanism. (The
+ fraction of allocated space that has been consumed may be displayed by
+ issuing the 'dmsetup status' command in a terminal session of a running
+ LiveOS installation.) One way to conserve the unrecoverable, overlay
+ file space, is to specify a persistent home folder for user files, see
+ --home-size-mb below. The target storage device must have enough free
+ space for the image and the overlay. A maximum <size> of 2047 MiB is
+ permitted for vfat-formatted devices. If there is insufficient room on
+ your device, you will be given information to help in adjusting your
+ settings.
+
+ --home-size-mb <size>
+ Sets the home directory size in mebibytes (integer values only). A
+ persistent home directory will be made in the /LiveOS/home.img
+ filesystem image file. This file space is encrypted by default, but not
+ compressed (one may bypass encryption with the --unencrypted-home
+ installation option). Files in this home folder may be erased to
+ recover and reuse their storage space. The target storage device must
+ have enough free space for the image, any overlay, and the home
+ directory. Note that the --delete-home option must also be selected to
+ replace an existing persistent home with a new, empty one. A maximum
+ <size> of 2047 MiB is permitted for vfat-formatted devices. If there is
+ insufficient room on your device, you will be given information to help
+ in adjusting your settings.
+
+ --delete-home
+ To prevent unwitting deletion of user files, this option must be
+ explicitly selected when the option --home-size-mb <size> is selected
+ and there is an existing persistent home directory on the target device.
+
+ --crypted-home (default that only applies to new home-size-mb requests)
+ Specifies the default option to encrypt a new persistent home directory
+ if --home-size-mb <size> is specified.
+
+ --unencrypted-home
+ Prevents the default option to encrypt a new persistent home directory.
+
+ CONTRIBUTORS
+
+ livecd-iso-to-disk: David Zeuthen, Jeremy Katz, Douglas McClendon,
+ Chris Curran and other contributors.
+ (See the AUTHORS file in the source distribution for
+ the complete list of credits.)
+
+ BUGS
+
+ Report bugs to the mailing list
+ http://admin.fedoraproject.org/mailman/listinfo/livecd or directly to
+ Bugzilla http://bugzilla.redhat.com/bugzilla/ against the Fedora product,
+ and the livecd-tools component.
+
+ COPYRIGHT
+
+ Copyright (C) Fedora Project 2008, 2009, 2010 and various contributors.
+ This is free software. You may redistribute copies of it under the terms of
+ the GNU General Public License http://www.gnu.org/licenses/gpl.html.
+ There is NO WARRANTY, to the extent permitted by law.
+
+ SEE ALSO
+
+ livecd-creator, project website http://fedoraproject.org/wiki/FedoraLiveCD
+ "
exit 1
}
@@ -327,7 +567,8 @@ checkMounted() {
checkint() {
if ! test $1 -gt 0 2>/dev/null ; then
- usage
+ shortusage
+ exit 1
fi
}
@@ -396,49 +637,34 @@ overlaysizemb=0
srctype=
imgtype=
LIVEOS=LiveOS
-
HOMEFILE="home.img"
+
+if [[ "$*" =~ "--help" ]]; then
+ usage
+fi
while [ $# -gt 2 ]; do
case $1 in
- --overlay-size-mb)
- checkint $2
- overlaysizemb=$2
- shift
- ;;
- --home-size-mb)
- checkint $2
- homesizemb=$2
- shift
- ;;
- --swap-size-mb)
- checkint $2
- swapsizemb=$2
- shift
- ;;
- --crypted-home)
- cryptedhome=1
- ;;
- --unencrypted-home)
- cryptedhome=""
- ;;
- --delete-home)
- keephome=""
+ --help)
+ usage
;;
--noverify)
noverify=1
;;
+ --format)
+ format=1
+ ;;
--reset-mbr|--resetmbr)
resetmbr=1
;;
--efi|--mactel)
efi=1
;;
- --format)
- format=1
- ;;
--skipcopy)
skipcopy=1
;;
+ --force)
+ force=1
+ ;;
--xo)
xo=1
skipcompress=1
@@ -446,39 +672,61 @@ while [ $# -gt 2 ]; do
--xo-no-home)
xonohome=1
;;
- --compress)
- skipcompress=""
+ --timeout)
+ checkint $2
+ timeout=$2
+ shift
;;
- --skipcompress)
- skipcompress=1
+ --totaltimeout)
+ checkint $2
+ totaltimeout=$2
+ shift
;;
--extra-kernel-args)
kernelargs=$2
shift
;;
- --force)
- force=1
+ --multi)
+ multi=1
;;
--livedir)
LIVEOS=$2
shift
;;
- --multi)
- multi=1
+ --compress)
+ skipcompress=""
;;
- --timeout)
+ --skipcompress)
+ skipcompress=1
+ ;;
+ --swap-size-mb)
checkint $2
- timeout=$2
+ swapsizemb=$2
shift
;;
- --totaltimeout)
+ --overlay-size-mb)
checkint $2
- totaltimeout=$2
+ overlaysizemb=$2
+ shift
+ ;;
+ --home-size-mb)
+ checkint $2
+ homesizemb=$2
shift
;;
+ --crypted-home)
+ cryptedhome=1
+ ;;
+ --unencrypted-home)
+ cryptedhome=""
+ ;;
+ --delete-home)
+ keephome=""
+ ;;
*)
echo "invalid arg -- $1"
- usage
+ shortusage
+ exit 1
;;
esac
shift
@@ -488,16 +736,19 @@ SRC=$(readlink -f "$1")
TGTDEV=$(readlink -f "$2")
if [ -z "$SRC" ]; then
- usage
+ shortusage
+ exit 1
fi
if [ ! -b "$SRC" -a ! -f "$SRC" ]; then
- usage
+ shortusage
+ exit 1
fi
# FIXME: If --format is given, we shouldn't care and just use /dev/foo1
if [ -z "$TGTDEV" -o ! -b "$TGTDEV" ]; then
- usage
+ shortusage
+ exit 1
fi
if [ -z "$noverify" ]; then
commit 93f1fb890bb72422449eb3187072e1179a5b7f1a
Author: Frederick Grose <fgrose(a)gmail.com>
Date: Mon Feb 14 16:54:56 2011 -0800
Support the propagation of an installed Live image
Adjust the size-checking and boot configuration code to support
propagation of an installed Live image from the running or an
attached source. Copy the livecd-iso-to-disk script to the new
installations to support continued or self propagation.
diff --git a/tools/livecd-iso-to-disk.sh b/tools/livecd-iso-to-disk.sh
index fa46c47..aca77d2 100755
--- a/tools/livecd-iso-to-disk.sh
+++ b/tools/livecd-iso-to-disk.sh
@@ -337,7 +337,7 @@ if [ $(id -u) != 0 ]; then
fi
detectsrctype() {
- if [ -e $SRCMNT/LiveOS/squashfs.img ]; then
+ if [[ -e $SRCMNT/$LIVEOS/squashfs.img ]]; then
srctype=live
return
fi
@@ -581,53 +581,50 @@ if [ -n "$efi" -a ! -d $SRCMNT/EFI/boot ]; then
fi
# let's try to make sure there's enough room on the target device
-if [ -d $SRCMNT/LiveOS ]; then
- check=$SRCMNT/LiveOS
-else
- check=$SRCMNT
-fi
if [[ -d $TGTMNT/$LIVEOS ]]; then
tbd=($(du -B 1M $TGTMNT/$LIVEOS))
- [[ -s $TGTMNT/$LIVEOS/$HOMEFILE ]] && \
+ if [[ -s $TGTMNT/$LIVEOS/$HOMEFILE ]] && [[ -n $keephome ]]; then
homesize=($(du -B 1M $TGTMNT/$LIVEOS/$HOMEFILE))
- ((homesize > 0)) && [[ -n $keephome ]] && ((tbd -= homesize))
+ ((tbd -= homesize))
+ fi
else
tbd=0
fi
-targets="$TGTMNT/$SYSLINUXPATH"
-if [[ -n $efi ]]; then
- targets+=" $TGTMNT/EFI/boot"
+
+if [[ live == $srctype ]]; then
+ targets="$TGTMNT/$SYSLINUXPATH"
+ [[ -n $efi ]] && targets+=" $TGTMNT/EFI/boot"
+ [[ -n $xo ]] && targets+=" $TGTMNT/boot/olpc.fth"
+ duTable=($(du -c -B 1M $targets 2> /dev/null))
+ ((tbd += ${duTable[*]: -2:1}))
fi
-duTable=($(du -c -B 1M $targets 2> /dev/null))
-((tbd += ${duTable[*]: -2:1}))
-sources="$SRCMNT/isolinux"
-[[ -n $efi ]] && sources+=" $SRCMNT/EFI/boot"
-if [[ -n $skipcompress ]]; then
- if [[ -s $SRCMNT/LiveOS/squashfs.img ]]; then
- if mount -o loop $SRCMNT/LiveOS/squashfs.img $SRCMNT; then
- livesize=($(du -B 1M --apparent-size $SRCMNT/LiveOS/ext3fs.img))
- umount $SRCMNT
- else
- echo "WARNING: --skipcompress or --xo was specified but the
- currently-running kernel can not mount the SquashFS from the source
- file to extract it. Instead, the compressed SquashFS will be copied
- to the target device."
- skipcompress=""
- fi
- fi
- duTable=($(du -c -B 1M $sources 2> /dev/null))
+if [[ -n $skipcompress ]] && [[ -s $SRCMNT/$LIVEOS/squashfs.img ]]; then
+ if mount -o loop $SRCMNT/$LIVEOS/squashfs.img $SRCMNT; then
+ livesize=($(du -B 1M --apparent-size $SRCMNT/LiveOS/ext3fs.img))
+ umount $SRCMNT
+ else
+ echo "WARNING: --skipcompress or --xo was specified but the
+ currently-running kernel can not mount the SquashFS from the source
+ file to extract it. Instead, the compressed SquashFS will be copied
+ to the target device."
+ skipcompress=""
+ fi
+fi
+if [[ live == $srctype ]]; then
+ thisScriptpath=$(readlink -f "$0")
+ sources="$SRCMNT/$LIVEOS/ext3fs.img $SRCMNT/$LIVEOS/osmin.img"
+ [[ -z $skipcompress ]] && sources+=" $SRCMNT/$LIVEOS/squashfs.img"
+ sources+=" $SRCMNT/isolinux $SRCMNT/syslinux"
+ [[ -n $efi ]] && sources+=" $SRCMNT/EFI/boot"
+ duTable=($(du -c -B 1M "$thisScriptpath" $sources 2> /dev/null))
((livesize += ${duTable[*]: -2:1}))
-else
- sources+=" $check/osmin.img $check/squashfs.img"
- duTable=($(du -c -B 1M $sources 2> /dev/null))
- livesize=${duTable[*]: -2:1}
fi
freespace=($(df -B 1M --total $TGTDEV))
freespace=${freespace[*]: -2:1}
-if [ "$srctype" = "live" ]; then
+if [[ live == $srctype ]]; then
tba=$((overlaysizemb + homesizemb + livesize + swapsizemb))
if ((tba > freespace + tbd)); then
needed=$((tba - freespace - tbd))
@@ -646,7 +643,7 @@ if [ "$srctype" = "live" ]; then
printf " Space needed: %15s MiB\n\n" $needed
printf " To fit the installation on this device,
\r free space on the target, or decrease the
- \r requested size total by: %s MiB\n\n" $needed
+ \r requested size total by: %6s MiB\n\n" $needed
exitclean
fi
fi
@@ -705,18 +702,18 @@ if [ "$srctype" = "live" -a -z "$skipcopy" ]; then
echo "Copying live image to target device."
[ ! -d $TGTMNT/$LIVEOS ] && mkdir $TGTMNT/$LIVEOS
[ -n "$keephome" -a -f "$TGTMNT/$HOMEFILE" ] && mv $TGTMNT/$HOMEFILE $TGTMNT/$LIVEOS/$HOMEFILE
- if [ -n "$skipcompress" -a -f $SRCMNT/LiveOS/squashfs.img ]; then
- mount -o loop $SRCMNT/LiveOS/squashfs.img $SRCMNT || exitclean
+ if [ -n "$skipcompress" -a -f $SRCMNT/$LIVEOS/squashfs.img ]; then
+ mount -o loop $SRCMNT/$LIVEOS/squashfs.img $SRCMNT || exitclean
copyFile $SRCMNT/LiveOS/ext3fs.img $TGTMNT/$LIVEOS/ext3fs.img || {
umount $SRCMNT ; exitclean ; }
umount $SRCMNT
- elif [ -f $SRCMNT/LiveOS/squashfs.img ]; then
- copyFile $SRCMNT/LiveOS/squashfs.img $TGTMNT/$LIVEOS/squashfs.img || exitclean
- elif [ -f $SRCMNT/LiveOS/ext3fs.img ]; then
- copyFile $SRCMNT/LiveOS/ext3fs.img $TGTMNT/$LIVEOS/ext3fs.img || exitclean
+ elif [ -f $SRCMNT/$LIVEOS/squashfs.img ]; then
+ copyFile $SRCMNT/$LIVEOS/squashfs.img $TGTMNT/$LIVEOS/squashfs.img || exitclean
+ elif [ -f $SRCMNT/$LIVEOS/ext3fs.img ]; then
+ copyFile $SRCMNT/$LIVEOS/ext3fs.img $TGTMNT/$LIVEOS/ext3fs.img || exitclean
fi
- if [ -f $SRCMNT/LiveOS/osmin.img ]; then
- copyFile $SRCMNT/LiveOS/osmin.img $TGTMNT/$LIVEOS/osmin.img || exitclean
+ if [ -f $SRCMNT/$LIVEOS/osmin.img ]; then
+ copyFile $SRCMNT/$LIVEOS/osmin.img $TGTMNT/$LIVEOS/osmin.img || exitclean
fi
sync
fi
@@ -734,7 +731,19 @@ if [ \( "$srctype" = "installer" -o "$srctype" = "netinst" \) -a -z "$skipcopy"
sync
fi
-cp $SRCMNT/isolinux/* $TGTMNT/$SYSLINUXPATH
+# Adjust syslinux sources for replication of installed images
+# between filesystem types.
+if [[ -d $SRCMNT/isolinux/ ]]; then
+ cp $SRCMNT/isolinux/* $TGTMNT/$SYSLINUXPATH
+elif [[ -d $SRCMNT/syslinux/ ]]; then
+ cp $SRCMNT/syslinux/* $TGTMNT/$SYSLINUXPATH
+ if [[ -f $SRCMNT/syslinux/extlinux.conf ]]; then
+ mv $TGTMNT/$SYSLINUXPATH/extlinux.conf \
+ $TGTMNT/$SYSLINUXPATH/isolinux.cfg
+ elif [[ -f $SRCMNT/syslinux/syslinux.cfg ]]; then
+ mv $TGTMNT/$SYSLINUXPATH/syslinux.cfg $TGTMNT/$SYSLINUXPATH/isolinux.cfg
+ fi
+fi
BOOTCONFIG=$TGTMNT/$SYSLINUXPATH/isolinux.cfg
# Set this to nothing so sed doesn't care
BOOTCONFIG_EFI=
@@ -746,6 +755,21 @@ if [ -n "$efi" ]; then
rm -f $TGTMNT/EFI/boot/grub.conf
fi
+if [[ live == $srctype ]]; then
+ # Copy this installer script.
+ cp -fTp "$thisScriptpath" $TGTMNT/$LIVEOS/livecd-iso-to-disk &> /dev/null
+
+ # When the source is an installed Live USB/SD image, restore the boot config
+ # file to a base state before updating.
+ if [[ -d $SRCMNT/syslinux/ ]]; then
+ echo "Preparing boot config file."
+ sed -i -e "s/root=live:[^ ]*/root=live:CDLABEL=name/"\
+ -e "s/liveimg .* quiet/liveimg quiet/"\
+ $BOOTCONFIG $BOOTCONFIG_EFI
+ sed -i -e "s/^timeout.*$/timeout\ 100/"\
+ -e "/^totaltimeout.*$/d" $BOOTCONFIG
+ fi
+fi
echo "Updating boot config file"
# adjust label and fstype
if [ -n "$LANG" ]; then
commit df332292da16e22f2cb118f0f59b8656ed6e6551
Author: Frederick Grose <fgrose(a)gmail.com>
Date: Mon Feb 14 13:35:53 2011 -0800
Rename image source- and target-related variables
Source- and target-related variables are renamed to reflect these
roles rather than a media, file, or bus type. This supports the
extended capability of the script to install from Live USB/SD
sources, and removes code name ambiguity for these variables.
diff --git a/tools/livecd-iso-to-disk.sh b/tools/livecd-iso-to-disk.sh
index d6fa95a..fa46c47 100755
--- a/tools/livecd-iso-to-disk.sh
+++ b/tools/livecd-iso-to-disk.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-# Convert a live CD iso so that it's bootable off of a USB stick
+# Transfer a Live image so that it's bootable off of a USB/SD device.
# Copyright 2007 Red Hat, Inc.
# Jeremy Katz <katzj(a)redhat.com>
#
@@ -23,14 +23,14 @@
export PATH=/sbin:/usr/sbin:$PATH
usage() {
- echo "$0 [--timeout <time>] [--totaltimeout <time>] [--format] [--reset-mbr] [--noverify] [--overlay-size-mb <size>] [--home-size-mb <size>] [--unencrypted-home] [--skipcopy] [--efi] <isopath> <usbstick device>"
+ echo "$0 [--timeout <time>] [--totaltimeout <time>] [--format] [--reset-mbr] [--noverify] [--overlay-size-mb <size>] [--home-size-mb <size>] [--unencrypted-home] [--skipcopy] [--efi] <source> <target device>"
exit 1
}
cleanup() {
sleep 2
- [ -d "$CDMNT" ] && umount $CDMNT && rmdir $CDMNT
- [ -d "$USBMNT" ] && umount $USBMNT && rmdir $USBMNT
+ [ -d "$SRCMNT" ] && umount $SRCMNT && rmdir $SRCMNT
+ [ -d "$TGTMNT" ] && umount $TGTMNT && rmdir $TGTMNT
}
exitclean() {
@@ -178,10 +178,10 @@ createGPTLayout() {
/sbin/udevadm settle
sleep 5
getpartition ${device#/dev/}
- USBDEV=${device}${partnum}
- umount $USBDEV &> /dev/null
- /sbin/mkdosfs -n LIVE $USBDEV
- USBLABEL="UUID=$(/sbin/blkid -s UUID -o value $USBDEV)"
+ TGTDEV=${device}${partnum}
+ umount $TGTDEV &> /dev/null
+ /sbin/mkdosfs -n LIVE $TGTDEV
+ TGTLABEL="UUID=$(/sbin/blkid -s UUID -o value $TGTDEV)"
}
createMSDOSLayout() {
@@ -202,13 +202,13 @@ createMSDOSLayout() {
sleep 5
if ! isdevloop "$DEV"; then
getpartition ${device#/dev/}
- USBDEV=${device}${partnum}
+ TGTDEV=${device}${partnum}
else
- USBDEV=${device}
+ TGTDEV=${device}
fi
- umount $USBDEV &> /dev/null
- /sbin/mkdosfs -n LIVE $USBDEV
- USBLABEL="UUID=$(/sbin/blkid -s UUID -o value $USBDEV)"
+ umount $TGTDEV &> /dev/null
+ /sbin/mkdosfs -n LIVE $TGTDEV
+ TGTLABEL="UUID=$(/sbin/blkid -s UUID -o value $TGTDEV)"
}
createEXTFSLayout() {
@@ -228,10 +228,10 @@ createEXTFSLayout() {
/sbin/udevadm settle
sleep 5
getpartition ${device#/dev/}
- USBDEV=${device}${partnum}
- umount $USBDEV &> /dev/null
- /sbin/mkfs.ext4 -L LIVE $USBDEV
- USBLABEL="UUID=$(/sbin/blkid -s UUID -o value $USBDEV)"
+ TGTDEV=${device}${partnum}
+ umount $TGTDEV &> /dev/null
+ /sbin/mkfs.ext4 -L LIVE $TGTDEV
+ TGTLABEL="UUID=$(/sbin/blkid -s UUID -o value $TGTDEV)"
}
checkGPT() {
@@ -265,36 +265,36 @@ checkGPT() {
checkFilesystem() {
dev=$1
- USBFS=$(/sbin/blkid -s TYPE -o value $dev)
- if [ "$USBFS" != "vfat" ] && [ "$USBFS" != "msdos" ]; then
- if [ "$USBFS" != "ext2" ] && [ "$USBFS" != "ext3" ] && [ "$USBFS" != "ext4" ] && [ "$USBFS" != "btrfs" ]; then
- echo "USB filesystem must be vfat, ext[234] or btrfs"
+ TGTFS=$(/sbin/blkid -s TYPE -o value $dev)
+ if [ "$TGTFS" != "vfat" ] && [ "$TGTFS" != "msdos" ]; then
+ if [ "$TGTFS" != "ext2" ] && [ "$TGTFS" != "ext3" ] && [ "$TGTFS" != "ext4" ] && [ "$TGTFS" != "btrfs" ]; then
+ echo "Target filesystem must be vfat, ext[234] or btrfs"
exitclean
fi
fi
- USBLABEL=$(/sbin/blkid -s UUID -o value $dev)
- if [ -n "$USBLABEL" ]; then
- USBLABEL="UUID=$USBLABEL"
+ TGTLABEL=$(/sbin/blkid -s UUID -o value $dev)
+ if [ -n "$TGTLABEL" ]; then
+ TGTLABEL="UUID=$TGTLABEL"
else
- USBLABEL=$(/sbin/blkid -s LABEL -o value $dev)
- if [ -n "$USBLABEL" ]; then
- USBLABEL="LABEL=$USBLABEL"
+ TGTLABEL=$(/sbin/blkid -s LABEL -o value $dev)
+ if [ -n "$TGTLABEL" ]; then
+ TGTLABEL="LABEL=$TGTLABEL"
else
- echo "Need to have a filesystem label or UUID for your USB device"
- if [ "$USBFS" = "vfat" -o "$USBFS" = "msdos" ]; then
+ echo "Need to have a filesystem label or UUID for your target device"
+ if [ "$TGTFS" = "vfat" -o "$TGTFS" = "msdos" ]; then
echo "Label can be set with /sbin/dosfslabel"
- elif [ "$USBFS" = "ext2" -o "$USBFS" = "ext3" -o "$USBFS" = "ext4" ]; then
+ elif [ "$TGTFS" = "ext2" -o "$TGTFS" = "ext3" -o "$TGTFS" = "ext4" ]; then
echo "Label can be set with /sbin/e2label"
- elif [ "$USBFS" = "btrfs" ]; then
+ elif [ "$TGTFS" = "btrfs" ]; then
echo "Eventually you'll be able to use /sbin/btrfs filesystem label to add a label."
fi
exitclean
fi
fi
- if [ "$USBFS" = "vfat" -o "$USBFS" = "msdos" ]; then
+ if [ "$TGTFS" = "vfat" -o "$TGTFS" = "msdos" ]; then
mountopts="-o shortname=winnt,umask=0077"
fi
}
@@ -336,25 +336,25 @@ if [ $(id -u) != 0 ]; then
exit 1
fi
-detectisotype() {
- if [ -e $CDMNT/LiveOS/squashfs.img ]; then
- isotype=live
+detectsrctype() {
+ if [ -e $SRCMNT/LiveOS/squashfs.img ]; then
+ srctype=live
return
fi
- if [ -e $CDMNT/images/install.img -o $CDMNT/isolinux/initrd.img ]; then
+ if [ -e $SRCMNT/images/install.img -o $SRCMNT/isolinux/initrd.img ]; then
imgtype=install
- if [ -e $CDMNT/Packages ]; then
- isotype=installer
+ if [ -e $SRCMNT/Packages ]; then
+ srctype=installer
else
- isotype=netinst
+ srctype=netinst
fi
- if [ ! -e $CDMNT/images/install.img ]; then
- echo "$ISO uses initrd.img w/o install.img"
+ if [ ! -e $SRCMNT/images/install.img ]; then
+ echo "$SRC uses initrd.img w/o install.img"
imgtype=initrd
fi
return
fi
- echo "ERROR: $ISO does not appear to be a Live image or DVD installer."
+ echo "ERROR: $SRC does not appear to be a Live image or DVD installer."
exitclean
}
@@ -393,7 +393,7 @@ keephome=1
homesizemb=0
swapsizemb=0
overlaysizemb=0
-isotype=
+srctype=
imgtype=
LIVEOS=LiveOS
@@ -484,26 +484,26 @@ while [ $# -gt 2 ]; do
shift
done
-ISO=$(readlink -f "$1")
-USBDEV=$(readlink -f "$2")
+SRC=$(readlink -f "$1")
+TGTDEV=$(readlink -f "$2")
-if [ -z "$ISO" ]; then
+if [ -z "$SRC" ]; then
usage
fi
-if [ ! -b "$ISO" -a ! -f "$ISO" ]; then
+if [ ! -b "$SRC" -a ! -f "$SRC" ]; then
usage
fi
# FIXME: If --format is given, we shouldn't care and just use /dev/foo1
-if [ -z "$USBDEV" -o ! -b "$USBDEV" ]; then
+if [ -z "$TGTDEV" -o ! -b "$TGTDEV" ]; then
usage
fi
if [ -z "$noverify" ]; then
# verify the image
echo "Verifying image..."
- checkisomd5 --verbose "$ISO"
+ checkisomd5 --verbose "$SRC"
if [ $? -ne 0 ]; then
echo "Are you SURE you want to continue?"
echo "Press Enter to continue or ctrl-c to abort"
@@ -511,48 +511,48 @@ if [ -z "$noverify" ]; then
fi
fi
-#checkFilesystem $USBDEV
+#checkFilesystem $TGTDEV
# do some basic sanity checks.
-checkMounted $USBDEV
+checkMounted $TGTDEV
if [ -n "$format" -a -z "$skipcopy" ]; then
- checkLVM $USBDEV
+ checkLVM $TGTDEV
# checks for a valid filesystem
if [ -n "$efi" ]; then
- createGPTLayout $USBDEV
- elif [ "$USBFS" == "vfat" -o "$USBFS" == "msdos" ]; then
- createMSDOSLayout $USBDEV
+ createGPTLayout $TGTDEV
+ elif [ "$TGTFS" == "vfat" -o "$TGTFS" == "msdos" ]; then
+ createMSDOSLayout $TGTDEV
else
- createEXTFSLayout $USBDEV
+ createEXTFSLayout $TGTDEV
fi
fi
-checkFilesystem $USBDEV
+checkFilesystem $TGTDEV
if [ -n "$efi" ]; then
- checkGPT $USBDEV
+ checkGPT $TGTDEV
fi
checkSyslinuxVersion
# Because we can't set boot flag for EFI Protective on msdos partition tables
-[ -z "$efi" ] && checkPartActive $USBDEV
-[ -n "$resetmbr" ] && resetMBR $USBDEV
-checkMBR $USBDEV
+[ -z "$efi" ] && checkPartActive $TGTDEV
+[ -n "$resetmbr" ] && resetMBR $TGTDEV
+checkMBR $TGTDEV
-if [ "$overlaysizemb" -gt 0 -a "$USBFS" = "vfat" ]; then
+if [ "$overlaysizemb" -gt 0 -a "$TGTFS" = "vfat" ]; then
if [ "$overlaysizemb" -gt 2047 ]; then
echo "Can't have an overlay of 2048MB or greater on VFAT"
exitclean
fi
fi
-if [ "$homesizemb" -gt 0 -a "$USBFS" = "vfat" ]; then
+if [ "$homesizemb" -gt 0 -a "$TGTFS" = "vfat" ]; then
if [ "$homesizemb" -gt 2047 ]; then
echo "Can't have a home overlay greater than 2048MB on VFAT"
exitclean
fi
fi
-if [ "$swapsizemb" -gt 0 -a "$USBFS" = "vfat" ]; then
+if [ "$swapsizemb" -gt 0 -a "$TGTFS" = "vfat" ]; then
if [ "$swapsizemb" -gt 2047 ]; then
echo "Can't have a swap file greater than 2048MB on VFAT"
exitclean
@@ -560,58 +560,59 @@ if [ "$swapsizemb" -gt 0 -a "$USBFS" = "vfat" ]; then
fi
# FIXME: would be better if we had better mountpoints
-CDMNT=$(mktemp -d /media/cdtmp.XXXXXX)
-mount -o loop,ro "$ISO" $CDMNT || exitclean
-USBMNT=$(mktemp -d /media/usbdev.XXXXXX)
-mount $mountopts $USBDEV $USBMNT || exitclean
+SRCMNT=$(mktemp -d /media/srctmp.XXXXXX)
+mount -o loop,ro "$SRC" $SRCMNT || exitclean
+TGTMNT=$(mktemp -d /media/tgttmp.XXXXXX)
+mount $mountopts $TGTDEV $TGTMNT || exitclean
trap exitclean SIGINT SIGTERM
-detectisotype
+detectsrctype
-if [ -f "$USBMNT/$LIVEOS/$HOMEFILE" -a -n "$keephome" -a "$homesizemb" -gt 0 ]; then
+if [ -f "$TGTMNT/$LIVEOS/$HOMEFILE" -a -n "$keephome" -a "$homesizemb" -gt 0 ]; then
echo "ERROR: Requested keeping existing /home and specified a size for /home"
echo "Please either don't specify a size or specify --delete-home"
exitclean
fi
-if [ -n "$efi" -a ! -d $CDMNT/EFI/boot ]; then
+if [ -n "$efi" -a ! -d $SRCMNT/EFI/boot ]; then
echo "ERROR: This live image does not support EFI booting"
exitclean
fi
-# let's try to make sure there's enough room on the stick
-if [ -d $CDMNT/LiveOS ]; then
- check=$CDMNT/LiveOS
+# let's try to make sure there's enough room on the target device
+if [ -d $SRCMNT/LiveOS ]; then
+ check=$SRCMNT/LiveOS
else
- check=$CDMNT
+ check=$SRCMNT
fi
-if [[ -d $USBMNT/$LIVEOS ]]; then
- tbd=($(du -B 1M $USBMNT/$LIVEOS))
- [[ -s $USBMNT/$LIVEOS/$HOMEFILE ]] && \
- homesize=($(du -B 1M $USBMNT/$LIVEOS/$HOMEFILE))
+if [[ -d $TGTMNT/$LIVEOS ]]; then
+ tbd=($(du -B 1M $TGTMNT/$LIVEOS))
+ [[ -s $TGTMNT/$LIVEOS/$HOMEFILE ]] && \
+ homesize=($(du -B 1M $TGTMNT/$LIVEOS/$HOMEFILE))
((homesize > 0)) && [[ -n $keephome ]] && ((tbd -= homesize))
else
tbd=0
fi
-targets="$USBMNT/$SYSLINUXPATH"
+targets="$TGTMNT/$SYSLINUXPATH"
if [[ -n $efi ]]; then
- targets+=" $USBMNT/EFI/boot"
+ targets+=" $TGTMNT/EFI/boot"
fi
duTable=($(du -c -B 1M $targets 2> /dev/null))
((tbd += ${duTable[*]: -2:1}))
-sources="$CDMNT/isolinux"
-[[ -n $efi ]] && sources+=" $CDMNT/EFI/boot"
+sources="$SRCMNT/isolinux"
+[[ -n $efi ]] && sources+=" $SRCMNT/EFI/boot"
if [[ -n $skipcompress ]]; then
- if [[ -s $CDMNT/LiveOS/squashfs.img ]]; then
- if mount -o loop $CDMNT/LiveOS/squashfs.img $CDMNT; then
- livesize=($(du -B 1M --apparent-size $CDMNT/LiveOS/ext3fs.img))
- umount $CDMNT
+ if [[ -s $SRCMNT/LiveOS/squashfs.img ]]; then
+ if mount -o loop $SRCMNT/LiveOS/squashfs.img $SRCMNT; then
+ livesize=($(du -B 1M --apparent-size $SRCMNT/LiveOS/ext3fs.img))
+ umount $SRCMNT
else
- echo "WARNING: --skipcompress or --xo was specified but the currently"
- echo "running kernel can not mount the squashfs from the ISO file to extract"
- echo "it. The compressed squashfs will be copied to the USB stick."
+ echo "WARNING: --skipcompress or --xo was specified but the
+ currently-running kernel can not mount the SquashFS from the source
+ file to extract it. Instead, the compressed SquashFS will be copied
+ to the target device."
skipcompress=""
fi
fi
@@ -623,10 +624,10 @@ else
livesize=${duTable[*]: -2:1}
fi
-freespace=($(df -B 1M --total $USBDEV))
+freespace=($(df -B 1M --total $TGTDEV))
freespace=${freespace[*]: -2:1}
-if [ "$isotype" = "live" ]; then
+if [ "$srctype" = "live" ]; then
tba=$((overlaysizemb + homesizemb + livesize + swapsizemb))
if ((tba > freespace + tbd)); then
needed=$((tba - freespace - tbd))
@@ -651,35 +652,35 @@ if [ "$isotype" = "live" ]; then
fi
# Verify available space for DVD installer
-if [ "$isotype" = "installer" ]; then
- isosize=$(du -s -B 1M $ISO | awk {'print $1;'})
+if [ "$srctype" = "installer" ]; then
+ srcsize=$(du -s -B 1M $SRC | awk {'print $1;'})
if [ "$imgtype" = "install" ]; then
imgpath=images/install.img
else
imgpath=isolinux/initrd.img
fi
- installimgsize=$(du -s -B 1M $CDMNT/$imgpath | awk {'print $1;'})
+ installimgsize=$(du -s -B 1M $SRCMNT/$imgpath | awk {'print $1;'})
tbd=0
- if [ -e $USBMNT/$imgpath ]; then
- tbd=$(du -s -B 1M $USBMNT/$imgpath | awk {'print $1;'})
+ if [ -e $TGTMNT/$imgpath ]; then
+ tbd=$(du -s -B 1M $TGTMNT/$imgpath | awk {'print $1;'})
fi
- if [ -e $USBMNT/$(basename $ISO) ]; then
- tbd=$(($tbd + $(du -s -B 1M $USBMNT/$(basename $ISO) | awk {'print $1;'})))
+ if [ -e $TGTMNT/$(basename $SRC) ]; then
+ tbd=$(($tbd + $(du -s -B 1M $TGTMNT/$(basename $SRC) | awk {'print $1;'})))
fi
- echo "Size of DVD image: $isosize"
+ echo "Size of DVD image: $srcsize"
echo "Size of $imgpath: $installimgsize"
echo "Available space: $((freespace + tbd))"
- if (( ((isosize + installimgsize)) > ((freespace + tbd)) )); then
- echo "ERROR: Unable to fit DVD image + install.img on available space on USB stick"
+ if (( ((srcsize + installimgsize)) > ((freespace + tbd)) )); then
+ echo "ERROR: Unable to fit DVD image + install.img on available space on the target device."
exitclean
fi
fi
-if [ -z "$skipcopy" ] && [ "$isotype" = "live" ]; then
- if [ -d $USBMNT/$LIVEOS -a -z "$force" ]; then
+if [ -z "$skipcopy" ] && [ "$srctype" = "live" ]; then
+ if [ -d $TGTMNT/$LIVEOS -a -z "$force" ]; then
echo "Already set up as live image."
- if [ -z "$keephome" -a -e $USBMNT/$LIVEOS/$HOMEFILE ]; then
+ if [ -z "$keephome" -a -e $TGTMNT/$LIVEOS/$HOMEFILE ]; then
echo "WARNING: Persistent /home will be deleted!!!"
echo "Press Enter to continue or ctrl-c to abort"
read
@@ -687,62 +688,62 @@ if [ -z "$skipcopy" ] && [ "$isotype" = "live" ]; then
echo "Deleting old OS in fifteen seconds..."
sleep 15
- [ -e "$USBMNT/$LIVEOS/$HOMEFILE" -a -n "$keephome" ] && mv $USBMNT/$LIVEOS/$HOMEFILE $USBMNT/$HOMEFILE
+ [ -e "$TGTMNT/$LIVEOS/$HOMEFILE" -a -n "$keephome" ] && mv $TGTMNT/$LIVEOS/$HOMEFILE $TGTMNT/$HOMEFILE
fi
- rm -rf $USBMNT/$LIVEOS
+ rm -rf $TGTMNT/$LIVEOS
fi
fi
# Bootloader is always reconfigured, so keep these out of the if skipcopy stuff.
-[ ! -d $USBMNT/$SYSLINUXPATH ] && mkdir -p $USBMNT/$SYSLINUXPATH
-[ -n "$efi" -a ! -d $USBMNT/EFI/boot ] && mkdir -p $USBMNT/EFI/boot
+[ ! -d $TGTMNT/$SYSLINUXPATH ] && mkdir -p $TGTMNT/$SYSLINUXPATH
+[ -n "$efi" -a ! -d $TGTMNT/EFI/boot ] && mkdir -p $TGTMNT/EFI/boot
# Live image copy
set -o pipefail
-if [ "$isotype" = "live" -a -z "$skipcopy" ]; then
- echo "Copying live image to USB stick"
- [ ! -d $USBMNT/$LIVEOS ] && mkdir $USBMNT/$LIVEOS
- [ -n "$keephome" -a -f "$USBMNT/$HOMEFILE" ] && mv $USBMNT/$HOMEFILE $USBMNT/$LIVEOS/$HOMEFILE
- if [ -n "$skipcompress" -a -f $CDMNT/LiveOS/squashfs.img ]; then
- mount -o loop $CDMNT/LiveOS/squashfs.img $CDMNT || exitclean
- copyFile $CDMNT/LiveOS/ext3fs.img $USBMNT/$LIVEOS/ext3fs.img || {
- umount $CDMNT ; exitclean ; }
- umount $CDMNT
- elif [ -f $CDMNT/LiveOS/squashfs.img ]; then
- copyFile $CDMNT/LiveOS/squashfs.img $USBMNT/$LIVEOS/squashfs.img || exitclean
- elif [ -f $CDMNT/LiveOS/ext3fs.img ]; then
- copyFile $CDMNT/LiveOS/ext3fs.img $USBMNT/$LIVEOS/ext3fs.img || exitclean
- fi
- if [ -f $CDMNT/LiveOS/osmin.img ]; then
- copyFile $CDMNT/LiveOS/osmin.img $USBMNT/$LIVEOS/osmin.img || exitclean
+if [ "$srctype" = "live" -a -z "$skipcopy" ]; then
+ echo "Copying live image to target device."
+ [ ! -d $TGTMNT/$LIVEOS ] && mkdir $TGTMNT/$LIVEOS
+ [ -n "$keephome" -a -f "$TGTMNT/$HOMEFILE" ] && mv $TGTMNT/$HOMEFILE $TGTMNT/$LIVEOS/$HOMEFILE
+ if [ -n "$skipcompress" -a -f $SRCMNT/LiveOS/squashfs.img ]; then
+ mount -o loop $SRCMNT/LiveOS/squashfs.img $SRCMNT || exitclean
+ copyFile $SRCMNT/LiveOS/ext3fs.img $TGTMNT/$LIVEOS/ext3fs.img || {
+ umount $SRCMNT ; exitclean ; }
+ umount $SRCMNT
+ elif [ -f $SRCMNT/LiveOS/squashfs.img ]; then
+ copyFile $SRCMNT/LiveOS/squashfs.img $TGTMNT/$LIVEOS/squashfs.img || exitclean
+ elif [ -f $SRCMNT/LiveOS/ext3fs.img ]; then
+ copyFile $SRCMNT/LiveOS/ext3fs.img $TGTMNT/$LIVEOS/ext3fs.img || exitclean
+ fi
+ if [ -f $SRCMNT/LiveOS/osmin.img ]; then
+ copyFile $SRCMNT/LiveOS/osmin.img $TGTMNT/$LIVEOS/osmin.img || exitclean
fi
sync
fi
# DVD installer copy
-if [ \( "$isotype" = "installer" -o "$isotype" = "netinst" \) -a -z "$skipcopy" ]; then
- echo "Copying DVD image to USB stick"
- mkdir -p $USBMNT/images/
+if [ \( "$srctype" = "installer" -o "$srctype" = "netinst" \) -a -z "$skipcopy" ]; then
+ echo "Copying DVD image to target device."
+ mkdir -p $TGTMNT/images/
if [ "$imgtype" = "install" ]; then
- copyFile $CDMNT/images/install.img $USBMNT/images/install.img || exitclean
+ copyFile $SRCMNT/images/install.img $TGTMNT/images/install.img || exitclean
fi
- if [ "$isotype" = "installer" ]; then
- cp $ISO $USBMNT/
+ if [ "$srctype" = "installer" ]; then
+ cp $SRC $TGTMNT/
fi
sync
fi
-cp $CDMNT/isolinux/* $USBMNT/$SYSLINUXPATH
-BOOTCONFIG=$USBMNT/$SYSLINUXPATH/isolinux.cfg
+cp $SRCMNT/isolinux/* $TGTMNT/$SYSLINUXPATH
+BOOTCONFIG=$TGTMNT/$SYSLINUXPATH/isolinux.cfg
# Set this to nothing so sed doesn't care
BOOTCONFIG_EFI=
if [ -n "$efi" ]; then
- cp $CDMNT/EFI/boot/* $USBMNT/EFI/boot
+ cp $SRCMNT/EFI/boot/* $TGTMNT/EFI/boot
# this is a little ugly, but it gets the "interesting" named config file
- BOOTCONFIG_EFI=$USBMNT/EFI/boot/boot?*.conf
- rm -f $USBMNT/EFI/boot/grub.conf
+ BOOTCONFIG_EFI=$TGTMNT/EFI/boot/boot?*.conf
+ rm -f $TGTMNT/EFI/boot/grub.conf
fi
echo "Updating boot config file"
@@ -750,7 +751,7 @@ echo "Updating boot config file"
if [ -n "$LANG" ]; then
kernelargs="$kernelargs LANG=$LANG"
fi
-sed -i -e "s/CDLABEL=[^ ]*/$USBLABEL/" -e "s/rootfstype=[^ ]*/rootfstype=$USBFS/" -e "s/LABEL=[^ ]*/$USBLABEL/" $BOOTCONFIG $BOOTCONFIG_EFI
+sed -i -e "s/CDLABEL=[^ ]*/$TGTLABEL/" -e "s/rootfstype=[^ ]*/rootfstype=$TGTFS/" -e "s/LABEL=[^ ]*/$TGTLABEL/" $BOOTCONFIG $BOOTCONFIG_EFI
if [ -n "$kernelargs" ]; then
sed -i -e "s/liveimg/liveimg ${kernelargs}/" $BOOTCONFIG $BOOTCONFIG_EFI
fi
@@ -759,15 +760,15 @@ if [ "$LIVEOS" != "LiveOS" ]; then
fi
# DVD Installer
-if [ "$isotype" = "installer" ]; then
- sed -i -e "s;initrd=initrd.img;initrd=initrd.img ${LANG:+LANG=$LANG} repo=hd:$USBLABEL:/;g" $BOOTCONFIG $BOOTCONFIG_EFI
+if [ "$srctype" = "installer" ]; then
+ sed -i -e "s;initrd=initrd.img;initrd=initrd.img ${LANG:+LANG=$LANG} repo=hd:$TGTLABEL:/;g" $BOOTCONFIG $BOOTCONFIG_EFI
sed -i -e "s;stage2=\S*;;g" $BOOTCONFIG $BOOTCONFIG_EFI
fi
# DVD Installer for netinst
-if [ "$isotype" = "netinst" ]; then
+if [ "$srctype" = "netinst" ]; then
if [ "$imgtype" = "install" ]; then
- sed -i -e "s;stage2=\S*;stage2=hd:$USBLABEL:/images/install.img;g" $BOOTCONFIG $BOOTCONFIG_EFI
+ sed -i -e "s;stage2=\S*;stage2=hd:$TGTLABEL:/images/install.img;g" $BOOTCONFIG $BOOTCONFIG_EFI
else
# The initrd has everything, so no stage2
sed -i -e "s;stage2=\S*;;g" $BOOTCONFIG $BOOTCONFIG_EFI
@@ -784,7 +785,7 @@ fi
# Use repo if the .iso has the repository on it, otherwise use stage2 which
# will default to using the network mirror
-if [ -e "$CDMNT/.discinfo" ]; then
+if [ -e "$SRCMNT/.discinfo" ]; then
METHODSTR=repo
else
METHODSTR=stage2
@@ -792,38 +793,38 @@ fi
if [ "$overlaysizemb" -gt 0 ]; then
echo "Initializing persistent overlay file"
- OVERFILE="overlay-$( /sbin/blkid -s LABEL -o value $USBDEV )-$( /sbin/blkid -s UUID -o value $USBDEV )"
+ OVERFILE="overlay-$( /sbin/blkid -s LABEL -o value $TGTDEV )-$( /sbin/blkid -s UUID -o value $TGTDEV )"
if [ -z "$skipcopy" ]; then
- if [ "$USBFS" = "vfat" ]; then
+ if [ "$TGTFS" = "vfat" ]; then
# vfat can't handle sparse files
- dd if=/dev/zero of=$USBMNT/$LIVEOS/$OVERFILE count=$overlaysizemb bs=1M
+ dd if=/dev/zero of=$TGTMNT/$LIVEOS/$OVERFILE count=$overlaysizemb bs=1M
else
- dd if=/dev/null of=$USBMNT/$LIVEOS/$OVERFILE count=1 bs=1M seek=$overlaysizemb
+ dd if=/dev/null of=$TGTMNT/$LIVEOS/$OVERFILE count=1 bs=1M seek=$overlaysizemb
fi
fi
- sed -i -e "s/liveimg/liveimg overlay=${USBLABEL}/" $BOOTCONFIG $BOOTCONFIG_EFI
+ sed -i -e "s/liveimg/liveimg overlay=${TGTLABEL}/" $BOOTCONFIG $BOOTCONFIG_EFI
sed -i -e "s/\ ro\ /\ rw\ /" $BOOTCONFIG $BOOTCONFIG_EFI
fi
if [ "$swapsizemb" -gt 0 -a -z "$skipcopy" ]; then
echo "Initializing swap file"
- dd if=/dev/zero of=$USBMNT/$LIVEOS/swap.img count=$swapsizemb bs=1M
- mkswap -f $USBMNT/$LIVEOS/swap.img
+ dd if=/dev/zero of=$TGTMNT/$LIVEOS/swap.img count=$swapsizemb bs=1M
+ mkswap -f $TGTMNT/$LIVEOS/swap.img
fi
if [ "$homesizemb" -gt 0 -a -z "$skipcopy" ]; then
echo "Initializing persistent /home"
homesource=/dev/zero
[ -n "$cryptedhome" ] && homesource=/dev/urandom
- if [ "$USBFS" = "vfat" ]; then
+ if [ "$TGTFS" = "vfat" ]; then
# vfat can't handle sparse files
- dd if=${homesource} of=$USBMNT/$LIVEOS/$HOMEFILE count=$homesizemb bs=1M
+ dd if=${homesource} of=$TGTMNT/$LIVEOS/$HOMEFILE count=$homesizemb bs=1M
else
- dd if=/dev/null of=$USBMNT/$LIVEOS/$HOMEFILE count=1 bs=1M seek=$homesizemb
+ dd if=/dev/null of=$TGTMNT/$LIVEOS/$HOMEFILE count=1 bs=1M seek=$homesizemb
fi
if [ -n "$cryptedhome" ]; then
loop=$(losetup -f)
- losetup $loop $USBMNT/$LIVEOS/$HOMEFILE
+ losetup $loop $TGTMNT/$LIVEOS/$HOMEFILE
setupworked=1
until [ ${setupworked} == 0 ]; do
echo "Encrypting persistent /home"
@@ -843,8 +844,8 @@ if [ "$homesizemb" -gt 0 -a -z "$skipcopy" ]; then
losetup -d $loop
else
echo "Formatting unencrypted /home"
- mke2fs -F -j $USBMNT/$LIVEOS/$HOMEFILE
- tune2fs -c0 -i0 -ouser_xattr,acl $USBMNT/$LIVEOS/$HOMEFILE
+ mke2fs -F -j $TGTMNT/$LIVEOS/$HOMEFILE
+ tune2fs -c0 -i0 -ouser_xattr,acl $TGTMNT/$LIVEOS/$HOMEFILE
fi
fi
@@ -853,16 +854,16 @@ fi
# boot on the XO anyway.
if [ -n "$xo" ]; then
echo "Setting up /boot/olpc.fth file"
- args=$(grep "^ *append" $USBMNT/$SYSLINUXPATH/isolinux.cfg |head -n1 |sed -e 's/.*initrd=[^ ]*//')
- if [ -z "$xonohome" -a ! -f $USBMNT/$LIVEOS/$HOMEFILE ]; then
+ args=$(grep "^ *append" $TGTMNT/$SYSLINUXPATH/isolinux.cfg |head -n1 |sed -e 's/.*initrd=[^ ]*//')
+ if [ -z "$xonohome" -a ! -f $TGTMNT/$LIVEOS/$HOMEFILE ]; then
args="$args persistenthome=mtd0"
fi
args="$args reset_overlay"
xosyspath=$(echo $SYSLINUXPATH | sed -e 's;/;\\;')
- if [ ! -d $USBMNT/boot ]; then
- mkdir -p $USBMNT/boot
+ if [ ! -d $TGTMNT/boot ]; then
+ mkdir -p $TGTMNT/boot
fi
- cat > $USBMNT/boot/olpc.fth <<EOF
+ cat > $TGTMNT/boot/olpc.fth <<EOF
\ Boot script for USB boot
hex rom-pa fffc7 + 4 \$number drop h# 2e19 < [if]
patch 2drop erase claim-params
@@ -906,55 +907,55 @@ if [ -z "$multi" ]; then
echo "Installing boot loader"
if [ -n "$efi" ]; then
# replace the ia32 hack
- if [ -f "$USBMNT/EFI/boot/boot.conf" ]; then
- cp -f $USBMNT/EFI/boot/bootia32.conf $USBMNT/EFI/boot/boot.conf
+ if [ -f "$TGTMNT/EFI/boot/boot.conf" ]; then
+ cp -f $TGTMNT/EFI/boot/bootia32.conf $TGTMNT/EFI/boot/boot.conf
fi
fi
# this is a bit of a kludge, but syslinux doesn't guarantee the API for its com32 modules :/
- if [ -f $USBMNT/$SYSLINUXPATH/vesamenu.c32 -a -f /usr/share/syslinux/vesamenu.c32 ]; then
- cp /usr/share/syslinux/vesamenu.c32 $USBMNT/$SYSLINUXPATH/vesamenu.c32
- elif [ -f $USBMNT/$SYSLINUXPATH/vesamenu.c32 -a -f /usr/lib/syslinux/vesamenu.c32 ]; then
- cp /usr/lib/syslinux/vesamenu.c32 $USBMNT/$SYSLINUXPATH/vesamenu.c32
- elif [ -f $USBMNT/$SYSLINUXPATH/menu.c32 -a -f /usr/share/syslinux/menu.c32 ]; then
- cp /usr/share/syslinux/menu.c32 $USBMNT/$SYSLINUXPATH/menu.c32
- elif [ -f $USBMNT/$SYSLINUXPATH/menu.c32 -a -f /usr/lib/syslinux/menu.c32 ]; then
- cp /usr/lib/syslinux/menu.c32 $USBMNT/$SYSLINUXPATH/menu.c32
+ if [ -f $TGTMNT/$SYSLINUXPATH/vesamenu.c32 -a -f /usr/share/syslinux/vesamenu.c32 ]; then
+ cp /usr/share/syslinux/vesamenu.c32 $TGTMNT/$SYSLINUXPATH/vesamenu.c32
+ elif [ -f $TGTMNT/$SYSLINUXPATH/vesamenu.c32 -a -f /usr/lib/syslinux/vesamenu.c32 ]; then
+ cp /usr/lib/syslinux/vesamenu.c32 $TGTMNT/$SYSLINUXPATH/vesamenu.c32
+ elif [ -f $TGTMNT/$SYSLINUXPATH/menu.c32 -a -f /usr/share/syslinux/menu.c32 ]; then
+ cp /usr/share/syslinux/menu.c32 $TGTMNT/$SYSLINUXPATH/menu.c32
+ elif [ -f $TGTMNT/$SYSLINUXPATH/menu.c32 -a -f /usr/lib/syslinux/menu.c32 ]; then
+ cp /usr/lib/syslinux/menu.c32 $TGTMNT/$SYSLINUXPATH/menu.c32
fi
- if [ "$USBFS" == "vfat" -o "$USBFS" == "msdos" ]; then
+ if [ "$TGTFS" == "vfat" -o "$TGTFS" == "msdos" ]; then
# syslinux expects the config to be named syslinux.cfg
# and has to run with the file system unmounted
- mv $USBMNT/$SYSLINUXPATH/isolinux.cfg $USBMNT/$SYSLINUXPATH/syslinux.cfg
+ mv $TGTMNT/$SYSLINUXPATH/isolinux.cfg $TGTMNT/$SYSLINUXPATH/syslinux.cfg
# deal with mtools complaining about ldlinux.sys
- if [ -f $USBMNT/$SYSLINUXPATH/ldlinux.sys ]; then
- rm -f $USBMNT/$SYSLINUXPATH/ldlinux.sys
+ if [ -f $TGTMNT/$SYSLINUXPATH/ldlinux.sys ]; then
+ rm -f $TGTMNT/$SYSLINUXPATH/ldlinux.sys
fi
cleanup
if [ -n "$SYSLINUXPATH" ]; then
- syslinux -d $SYSLINUXPATH $USBDEV
+ syslinux -d $SYSLINUXPATH $TGTDEV
else
- syslinux $USBDEV
+ syslinux $TGTDEV
fi
- elif [ "$USBFS" == "ext2" -o "$USBFS" == "ext3" -o "$USBFS" == "ext4" -o "$USBFS" == "btrfs" ]; then
+ elif [ "$TGTFS" == "ext2" -o "$TGTFS" == "ext3" -o "$TGTFS" == "ext4" -o "$TGTFS" == "btrfs" ]; then
# extlinux expects the config to be named extlinux.conf
# and has to be run with the file system mounted
- mv $USBMNT/$SYSLINUXPATH/isolinux.cfg $USBMNT/$SYSLINUXPATH/extlinux.conf
- extlinux -i $USBMNT/$SYSLINUXPATH
+ mv $TGTMNT/$SYSLINUXPATH/isolinux.cfg $TGTMNT/$SYSLINUXPATH/extlinux.conf
+ extlinux -i $TGTMNT/$SYSLINUXPATH
# Starting with syslinux 4 ldlinux.sys is used on all file systems.
- if [ -f "$USBMNT/$SYSLINUXPATH/extlinux.sys" ]; then
- chattr -i $USBMNT/$SYSLINUXPATH/extlinux.sys
- elif [ -f "$USBMNT/$SYSLINUXPATH/ldlinux.sys" ]; then
- chattr -i $USBMNT/$SYSLINUXPATH/ldlinux.sys
+ if [ -f "$TGTMNT/$SYSLINUXPATH/extlinux.sys" ]; then
+ chattr -i $TGTMNT/$SYSLINUXPATH/extlinux.sys
+ elif [ -f "$TGTMNT/$SYSLINUXPATH/ldlinux.sys" ]; then
+ chattr -i $TGTMNT/$SYSLINUXPATH/ldlinux.sys
fi
cleanup
fi
else
# we need to do some more config file tweaks for multi-image mode
- sed -i -e "s;kernel vm;kernel /$LIVEOS/syslinux/vm;" $USBMNT/$SYSLINUXPATH/isolinux.cfg
- sed -i -e "s;initrd=i;initrd=/$LIVEOS/syslinux/i;" $USBMNT/$SYSLINUXPATH/isolinux.cfg
- mv $USBMNT/$SYSLINUXPATH/isolinux.cfg $USBMNT/$SYSLINUXPATH/syslinux.cfg
+ sed -i -e "s;kernel vm;kernel /$LIVEOS/syslinux/vm;" $TGTMNT/$SYSLINUXPATH/isolinux.cfg
+ sed -i -e "s;initrd=i;initrd=/$LIVEOS/syslinux/i;" $TGTMNT/$SYSLINUXPATH/isolinux.cfg
+ mv $TGTMNT/$SYSLINUXPATH/isolinux.cfg $TGTMNT/$SYSLINUXPATH/syslinux.cfg
cleanup
fi
-echo "USB stick set up as live image!"
+echo "Target device is now set up with a Live image!"
13 years, 2 months
[PATCH] Enable reading of SquashFS compression type
by Frederick Grose
Please review. I'm not familiar with the preferred exception
reporting formats.
--Fred
Author: Frederick Grose <fgrose(a)gmail.com>
Date: Tue Feb 8 02:47:25 2011 -0500
Enable reading of SquashFS compression type.
Support edit-livecd & livecd-creator base_on image options by
adding the capability in fs.py to read the base_on image
compression type. Specifying a compressor type will override
the default; specifying 'None' will trigger reading and using
the base_on image's compression type.
diff --git a/docs/livecd-creator.pod b/docs/livecd-creator.pod
index 1827728..ce7b94e 100644
--- a/docs/livecd-creator.pod
+++ b/docs/livecd-creator.pod
@@ -47,6 +47,7 @@ xz is the default and works with 2.6.38 and later kernels.
gzip works with all kernels.
lzo works with 2.6.36 and later kernels.
lzma will only work with custom kernels.
+Set to 'None' to force reading the compressor used in BASE_ON.
If gzip is used, the -comp option is not passed to mksquashfs to allow the
use of older versions of mksquashfs.
=item --releasever=VER
diff --git a/imgcreate/fs.py b/imgcreate/fs.py
index de61c7b..d5307a2 100644
--- a/imgcreate/fs.py
+++ b/imgcreate/fs.py
@@ -41,6 +41,35 @@ def makedirs(dirname):
if e.errno != errno.EEXIST:
raise
+def squashfs_compression_type(sqfs_img):
+ """Check the compression type of a SquashFS image. If the type cannot
be
+ ascertained, return 'undetermined'. The calling code must decide what
to
+ do."""
+
+ env = os.environ.copy()
+ env['LC_ALL'] = 'C'
+ args = ['/usr/sbin/unsquashfs', '-s', sqfs_img]
+ try:
+ p = subprocess.Popen(args, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE, env=env)
+ out, err = p.communicate()
+ except OSError, e:
+ raise SquashfsError(u"Error white stat-ing '%s'\n'%s'" % (args, e))
+ except:
+ raise SquashfsError(u"Error while stat-ing '%s'" % args)
+ else:
+ if p.returncode != 0:
+ raise SquashfsError(
+ u"Error while stat-ing '%s'\n'%s'\nreturncode: '%s'" %
+ (args, err, p.returncode))
+ else:
+ compress_type = 'undetermined'
+ for l in out.splitlines():
+ if l.split(None, 1)[0] == 'Compression':
+ compress_type = l.split()[1]
+ break
+ return compress_type
+
def mksquashfs(in_img, out_img, compress_type):
# Allow gzip to work for older versions of mksquashfs
if compress_type == "gzip":
diff --git a/imgcreate/live.py b/imgcreate/live.py
old mode 100644
new mode 100755
index bf3a4dd..f388825
--- a/imgcreate/live.py
+++ b/imgcreate/live.py
@@ -152,6 +152,12 @@ class LiveImageCreatorBase(LoopImageCreator):
squashloop = DiskMount(LoopbackDisk(squashimg, 0), self._mkdtemp(),
"squashfs")
+ # 'self.compress_type = None' will force reading it from base_on.
+ if self.compress_type is None:
+ self.compress_type = squashfs_compression_type(squashimg)
+ if self.compress_type == 'undetermined':
+ # Default to 'gzip' for compatibility with older versions.
+ self.compress_type = 'gzip'
try:
if not squashloop.disk.exists():
raise CreatorError("'%s' is not a valid live CD ISO : "
diff --git a/tools/livecd-creator b/tools/livecd-creator
index 3424636..d997095 100755
--- a/tools/livecd-creator
+++ b/tools/livecd-creator
@@ -48,7 +48,11 @@ def parse_options(args):
imgopt.add_option("", "--image-type", type="string", dest="image_type",
help=optparse.SUPPRESS_HELP)
imgopt.add_option("", "--compression-type", type="string",
dest="compress_type",
- help="Compression type recognized by mksquashfs
(default xz needs a 2.6.38+ kernel, gzip works with all kernels, lzo needs a
2.6.36+ kernel, lzma needs custom kernel)",
+ help="Compression type recognized by mksquashfs "
+ "(default xz needs a 2.6.38+ kernel, gzip works
"
+ "with all kernels, lzo needs a 2.6.36+ kernel,
lzma "
+ "needs custom kernel.) Set to 'None' to force
read "
+ "from base_on.",
default="xz")
imgopt.add_option("", "--releasever", type="string", dest="releasever",
default=None,
13 years, 2 months