livecd-tools-034 needs testing
by Bruno Wolff III
I have done a new build of livecd-tools that has lots of bugfixes (at
least I hope), but needs lots of testing. Testing image building takes
a long time and I can't do too much myself and we'd really like to be
able to use this rather than an update to 033 with only a couple of
cherry picked fixes.
Not that there has been a reported problem with gdm in testing. So you
might want to avoid that package when testing.
Currently the updates entry is at:
https://admin.fedoraproject.org/updates/livecd-tools-034-1.fc14
13 years, 6 months
Makefile
by Bruno Wolff III
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit e80c157f1bf7078c4b0877fd6bb92519b815c497
Author: Bruno Wolff III <bruno(a)wolff.to>
Date: Sat Sep 11 22:06:32 2010 -0500
Change version to 034.
diff --git a/Makefile b/Makefile
index faa3d78..a52b2a5 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
-VERSION = 033
+VERSION = 034
INSTALL = /usr/bin/install -c
INSTALL_PROGRAM = ${INSTALL}
13 years, 6 months
docs/mkbiarch.8 Makefile tools/mkbiarch.py
by Bruno Wolff III
Makefile | 2
docs/mkbiarch.8 | 89 +++++++++++++++
tools/mkbiarch.py | 315 +++++++++++++++++++++++++++++++++++++++---------------
3 files changed, 324 insertions(+), 82 deletions(-)
New commits:
commit 32674c1516525504fcf813dcaf06dd7247d9224c
Author: Jasper Hartline <jasper.hartline(a)gmail.com>
Date: Sat Sep 11 21:56:06 2010 -0500
Updated version of mkbiarch with docs and install.
Signed-off-by: Bruno Wolff III <bruno(a)wolff.to>
diff --git a/Makefile b/Makefile
index 8818236..faa3d78 100644
--- a/Makefile
+++ b/Makefile
@@ -26,6 +26,7 @@ install: man
$(INSTALL_PROGRAM) -D tools/image-creator $(DESTDIR)/usr/bin/image-creator
$(INSTALL_PROGRAM) -D tools/livecd-iso-to-disk.sh $(DESTDIR)/usr/bin/livecd-iso-to-disk
$(INSTALL_PROGRAM) -D tools/livecd-iso-to-pxeboot.sh $(DESTDIR)/usr/bin/livecd-iso-to-pxeboot
+ $(INSTALL_PROGRAM) -D tools/mkbiarch.py $(DESTDIR)/usr/bin/mkbiarch
$(INSTALL_DATA) -D AUTHORS $(DESTDIR)/usr/share/doc/livecd-tools-$(VERSION)/AUTHORS
$(INSTALL_DATA) -D COPYING $(DESTDIR)/usr/share/doc/livecd-tools-$(VERSION)/COPYING
$(INSTALL_DATA) -D README $(DESTDIR)/usr/share/doc/livecd-tools-$(VERSION)/README
@@ -41,6 +42,7 @@ uninstall:
rm -f $(DESTDIR)/usr/bin/livecd-creator
rm -rf $(DESTDIR)/usr/lib/livecd-creator
rm -rf $(DESTDIR)/usr/share/doc/livecd-tools-$(VERSION)
+ rm -f $(DESTDIR)/usr/bin/mkbiarch
dist : all
git archive --format=tar --prefix=livecd-tools-$(VERSION)/ HEAD | bzip2 -9v > livecd-tools-$(VERSION).tar.bz2
diff --git a/docs/mkbiarch.8 b/docs/mkbiarch.8
new file mode 100644
index 0000000..4ec1396
--- /dev/null
+++ b/docs/mkbiarch.8
@@ -0,0 +1,89 @@
+.\" PROCESS THIS FILE WITH
+.\" groff -man -Tascii mkbiarch.8
+.\"
+.TH mkbiarch 8 "2010-8-24" "LiveCD Tools" "User Manuals"
+
+.SH NAME
+mkbiarch.py - make a multiple architecture Live boot disk image
+for USB, CF SSD or any disk from 2 architecturally different
+LiveCD ISO9660 image files.
+
+.SH SYNOPSIS
+mkbiarch <LiveCDx86ISO> <LiveCDx64ISO> <MultipleArch Disk IMG File>
+
+.SH DESCRIPTION
+.B mkbiarch(8)
+create a multiple architecture, bootable Live Disk image file (IMG)
+for use on USB or any disk (CF, SSD)
+from 2 LiveCD ISO9660 files of different architecture (ISO).
+.BR
+
+.SH USAGE
+.B mkbiarch.py
+Fedora-13-i686-Live.iso
+Fedora-13-x86_64-Live.iso
+Fedora-13-MultiArch.img
+
+Then to write it
+/bin/dd if=Fedora-13-MultiArch.img of=/dev/sdb bs=4M
+
+In the above example, mkbiarch.py
+creates Fedora-Multi-arch.img
+from the two existing ISO9660 LiveCD image files.
+The resulting image file,
+is written to a raw disk device using
+.B dd(1)
+.BR
+
+
+.SH UNDER THE HOOD
+.B mkbiarch.py(8)
+first checks that the two ISO9660 image files exist. It will create a blank
+file using dd(1) writing data from /dev/zero, the size of the two ISO9660 images files combined.
+The blank file is then bound via loopback using
+.B losetup(8)
+partitioned, and bound at an offset via loopback
+of 512 bytes, this second loopback device is formatted type ext3 using
+.B mke2fs(8)
+This filesystem is mounted using
+.B mount(8)
+on a temporary directory. The two ISO9660 files are then mounted via loopback,
+files are copied using shutil module in Python, from them to the newly formatted
+filesystem in the image file. Data is gathered from the ISO9660 image files from it's isolinux.cfg,
+after the files are copied the loopbacked ISO9660 image files are released.
+.B extlinux(1)
+is installed to the loopback mounted filesystem on the target image file and an extlinux.conf
+is written. The temporary directories are unmounted using
+.B umount(8)
+and the looback devices are released.
+The temporary directories are then removed, and the resulting Multiple Architecture Disk Image
+File is moved using shutil to the specified location on the command line, which is provided as
+argument 3 to mkbiarch.py
+
+.SH BUGS
+Please report any bugs to
+http://bugzilla.redhat.com
+under component livecd-tools
+
+.SH AVAILABILITY
+To check out the git version of this program
+ git clone git://git.fedorahosted.org/livecd
+
+.SH AUTHOR
+Jasper Hartline <autopsy(a)liveprojects.info>
+
+.SH CONTRIBUTORS
+.B Richard Shaw <email(a)address.com>
+pyparted suggestions and feedback
+
+.B Jan Kratochvil <email(a)address.com>
+for the original bash script which
+the python version was derived
+
+.SH "SEE ALSO"
+.BR livecd-creator(8),
+.BR livecd-iso-to-disk(8),
+.BR mke2fs(8),
+.BR losetup(8),
+.BR dd(1),
+.BR exlinux(1)
diff --git a/tools/mkbiarch.py b/tools/mkbiarch.py
index 71fd54a..5178785 100644
--- a/tools/mkbiarch.py
+++ b/tools/mkbiarch.py
@@ -1,40 +1,34 @@
-#!/usr/bin/env python
-
-__author__ = "Jasper Hartline"
-__credits__ = ""
-__license__ = "GPL?"
-__version__ = "Alpha"
-__description__ = "Attempts to create a 32/64 bit combination live Fedora image."
-
+#!/usr/bin/python
import os
import sys
+
import shutil
import parted
import subprocess
+import optparse
import tempfile
-import math
+import re
-from optparse import OptionParser
def main():
- def cleanup():
- pass
+
+ def usage():
+ usage = 'usage: mkbiarch.py <x86 Live ISO File> <x64 Live ISO File> <Target Multi Arch Image File>'
+ print >> sys.stdout, usage
def mount(src, dst, options=None):
- if os.path.exists(src): # Is src the lodev device?
- if not os.path.exists(dst):
+ if os.path.exists(src):
+ if not os.path.exists(dst):
os.makedir(dst)
- if options: # None is the same as Null so you can test for existence instead.
- args = ("/bin/mount", options, src, dst)
- else:
+ if options is None:
args = ("/bin/mount", src, dst)
-
+ else:
+ args = ("/bin/mount", options, src, dst)
rc = subprocess.call(args)
return rc
- else: # Let's make sure only one return statement get's triggered.
- return False # Might as well return something useful so we can test for failure.
+ return
def umount(src):
@@ -42,111 +36,268 @@ def main():
args = ("/bin/umount", src)
rc = subprocess.call(args)
return rc
- else:
- return False
+ return
def copy(src, dst):
if os.path.exists(src):
+ if not os.path.exists(dst):
+ if not os.path.isfile(src):
+ mkdir(dst)
shutil.copy(src, dst)
- return True
- else:
- return False
def move(src, dst):
if os.path.exists(src):
- shutil.mopve(src, dst)
- return True
+ shutil.move(src, dst)
+
+ def mkdir(dir=None):
+ if dir is None:
+ tmp = tempfile.mkdtemp()
+ return tmp
else:
- return False
+ args = ("/bin/mkdir", "-p", dir)
+ rc = subprocess.call(args)
def losetup(src, dst, offset=None):
- if os.path.exists(src) and os.path.exists(dst):
- if offset:
- args = ("/sbin/losetup", "-o", offset, src, dst)
- else:
- args = ("/sbin/losetup", src, dst)
-
- rc = subprocess.call(args)
- return rc
- else:
- return False
-
+ if os.path.exists(src):
+ if os.path.exists(dst):
+ if offset is None:
+ args = ("/sbin/losetup", src, dst)
+ else:
+ args = ("/sbin/losetup", "-o", str(offset), src, dst)
+ rc = subprocess.call(args)
+ return rc
+
+ def lounset(device):
+ args = ("/sbin/losetup", "-d", device)
+ rc = subprocess.call(args)
def null():
- fd = open("/dev/null", "w")
+ fd = open(os.devnull, 'w')
return fd
+ def dd(file, target):
+ args = ("/bin/dd", "if=%s"%file, "of=%s"%target)
+ rc = subprocess.call(args)
+
def lo():
args = ("/sbin/losetup", "--find")
- rc = subprocess.call(args, stdout=open(null())).communicate()[0].rstrip()
+ rc = subprocess.Popen(args, stdout=subprocess.PIPE).communicate()[0].rstrip()
return rc
+ def lodev(file):
+ args = ("/sbin/losetup", "-j", file)
+ rc = subprocess.Popen(args, stdout=subprocess.PIPE).communicate()[0].split(":")
+ return rc[0]
+
def mkimage(bs, count):
tmp = tempfile.mkstemp()
image = tmp[1]
- args = ("/bin/dd",
- "if=/dev/zero",
- "of=%s" % image,
- "bs=%s" % bs,
- "count=%s" % count)
+ args = ("/bin/dd", "if=/dev/zero",
+ "of=%s"%image, "bs=%s"%bs,
+ "count=%s"%count)
rc = subprocess.call(args)
return image
def size(ent):
- size = os.path.getsize(ent)
- if size >= 0:
- return os.path.getsize(ent)
- else:
- print "Something is wrong, %s has no size." % ent
- return False
+ if os.path.exists(ent):
+ return os.stat(ent).st_size
+
+ def bs(size):
+ return size / 2048
+
+ def partition(device):
+ dev = parted.Device(path=device)
+ disk = parted.freshDisk(dev, 'msdos')
+ constraint = parted.Constraint(device=dev)
+
+ new_geom = parted.Geometry(device=dev,
+ start=1,
+ end=(constraint.maxSize - 1))
+ filesystem = parted.FileSystem(type="ext2",
+ geometry=new_geom)
+ partition = parted.Partition(disk=disk,
+ fs=filesystem,
+ type=parted.PARTITION_NORMAL,
+ geometry=new_geom)
+ constraint = parted.Constraint(exactGeom=new_geom)
+ partition.setFlag(parted.PARTITION_BOOT)
+ disk.addPartition(partition=partition,
+ constraint=constraint)
+
+ disk.commit()
+
+ def format(partition):
+ args = ("/sbin/mke2fs", "-j", partition)
+ rc = subprocess.call(args)
+
+ def mbr(target):
+ mbr = "/usr/share/syslinux/mbr.bin"
+ dd(mbr, target)
+
+ def getuuid(device):
+ args = ("/sbin/blkid", "-s", "UUID", "-o", "value", device)
+ rc = subprocess.Popen(args, stdout=subprocess.PIPE).communicate()[0].rstrip()
+ return rc
+
+ def syslinux(multitmp, config, **args):
+ arg = ("/sbin/extlinux", "--install", multitmp + "/extlinux/")
+ rc = subprocess.call(arg)
+
+ content = """
+ default vesamenu.c32
+ timeout 100
+ menu background splash.jpg
+ menu title Welcome to Fedora 13
+ menu color border 0 #ffffffff #00000000
+ menu color sel 7 #ffffffff #ff000000
+ menu color title 0 #ffffffff #00000000
+ menu color tabmsg 0 #ffffffff #00000000
+ menu color unsel 0 #ffffffff #00000000
+ menu color hotsel 0 #ff000000 #ffffffff
+ menu color hotkey 7 #ffffffff #ff000000
+ menu color timeout_msg 0 #ffffffff #00000000
+ menu color timeout 0 #ffffffff #00000000
+ menu color cmdline 0 #ffffffff #00000000
+ menu hidden
+ menu hiddenrow 5
- def blocks(block_size, size):
- # Round up to nearest block
- # Make sure floating math, not integer math or we don't get remainders.
- # Turn back into an integer for return statement.
- return int(math.ceil(size / float(block_size)))
+ label Fedora-13-x86
+ menu label Fedora-13-x86
+ kernel vmlinuz0
+ append initrd=initrd0.img root=UUID=%(uuid)s rootfstype=auto ro live_dir=/x86/LiveOS liveimg
+
+ label Fedora-13-x64
+ menu label Fedora-13-x64
+ kernel vmlinuz1
+ append initrd=initrd1.img root=UUID=%(uuid)s rootfstype=auto ro live_dir=/x64/LiveOS liveimg
+ """ % args
+ fd = open(config, 'w')
+ fd.write(content)
+ fd.close()
+ def verify():
+ # use md5 module to verify image files
+ pass
def setup(x86, x64, multi):
- # Reworked the logic a bit.
- block_size = 2048 # Should this be a global constant instead?
+
sz = size(x86) + size(x64)
- count = blocks(block_size, sz)
+ count = bs(sz)
+ blsz = str(2048)
+
+ count = count + 102400
+
+ multi = mkimage(blsz, count)
+ losetup(lo(), multi)
+
+ mbr(lodev(multi))
+ partition(lodev(multi))
+
+ lounset(lodev(multi))
+
+ losetup(lo(), multi, offset=512)
+ format(lodev(multi))
+
+ multitmp = mkdir()
+ mount(lodev(multi), multitmp)
+
+ losetup(lo(), x86)
+ losetup(lo(), x64)
+
+ x86tmp = mkdir()
+ x64tmp = mkdir()
+
+ mount(lodev(x86), x86tmp)
+ mount(lodev(x64), x64tmp)
+
+
+ dirs = ("/extlinux/", "/x86/", "/x64/")
+ for dir in dirs:
+ mkdir(multitmp + dir)
+ dirs = ("/x86/", "/x64/")
+ for dir in dirs:
+ mkdir(multitmp + dir + "/LiveOS/")
+
+ intermediate = tempfile.mkdtemp() # loopdev performance is slow
+ # copy to here first then back
+ # to multitmp + dir which is looback also
+
+ imgs = ("squashfs.img", "osmin.img")
+ for img in imgs:
+ copy(x86tmp + "/LiveOS/" + img, intermediate)
+ copy(intermediate + "/" + img, multitmp + "/x86/LiveOS/")
+ for img in imgs:
+ copy(x64tmp + "/LiveOS/" + img, intermediate)
+ copy(intermediate + "/" + img, multitmp + "/x64/LiveOS/")
+
+ for file in os.listdir(x86tmp + "/isolinux/"):
+ copy(x86tmp + "/isolinux/" + file, multitmp + "/extlinux/")
+
+ copy(x64tmp + "/isolinux/vmlinuz0", multitmp + "/extlinux/vmlinuz1")
+ copy(x64tmp + "/isolinux/initrd0.img", multitmp + "/extlinux/initrd1.img")
+
+
+
+ uuid = getuuid(lodev(multi))
+
+
+ config = (multitmp + "/extlinux/extlinux.conf")
+ syslinux(multitmp,
+ config,
+ uuid=uuid)
+
+
+
+ umount(x86tmp)
+ umount(x64tmp)
+ umount(multitmp)
+
+ lounset(lodev(x86))
+ lounset(lodev(x64))
+ lounset(lodev(multi))
+
+ shutil.rmtree(x86tmp)
+ shutil.rmtree(x64tmp)
+ shutil.rmtree(multitmp)
+ shutil.rmtree(intermediate)
- multi = mkimage(str(blsz), count)
- losetup(multi, lo())
+
+
+ if os.path.exists(sys.argv[3]):
+ os.unlink(sys.argv[3])
+ move(multi, sys.argv[3])
def parse(x86, x64, multi):
- for file in x86, x64, multi: # Do we expect that multi exists yet?
- if os.path.exists(file): # Should we test for existance or isfile?
+ for file in x86, x64:
+ if os.path.exists(file):
pass
else:
- parser.error("One of the images does not exist.")
+ usage()
+ if not multi:
+ usage()
setup(x86, x64, multi)
- # Generate parser and fill with options.
- usage = "usage: %prog [options] <32bit image> <64bit image> <biarch image>"
- version = "%prog " + __version__
- parser = OptionParser(usage=usage, description=__description__, version=version)
- parser.add_option("--test", action="store_true", default=False,
- dest="test", help="Doesn't do anything yet.")
- (options, args) = parser.parse_args()
- if len(args) != 3:
- parser.error("You must specify all three arguments.")
- sys.exit(0)
-
- try: # Any reason this would fail?
- parse(args[0], args[1], args[2])
+
+
+
+
+ try:
+ parse(sys.argv[1], sys.argv[2], sys.argv[3])
except:
- parser.error("Something failed. Better luck next time!")
- sys.exit(1)
-
+ usage()
+
+
+
+
+
+
+
if __name__ == "__main__":
- sys.exit(main())
\ No newline at end of file
+ sys.exit(main())
13 years, 6 months
tools/mkbiarch.py
by Bruno Wolff III
tools/mkbiarch.py | 152 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 152 insertions(+)
New commits:
commit 6c4847542a42b03ae60f78c51c0bb589ff4b25a1
Author: Richard Shaw <hobbes1069(a)gmail.com>
Date: Sat Sep 11 21:44:17 2010 -0500
A new experimental script for creating live images for both i686 and x86_64.
This won't be used by any existing stuff, so shouldn't cause problems.
Signed-off-by: Bruno Wolff III <bruno(a)wolff.to>
diff --git a/tools/mkbiarch.py b/tools/mkbiarch.py
new file mode 100644
index 0000000..71fd54a
--- /dev/null
+++ b/tools/mkbiarch.py
@@ -0,0 +1,152 @@
+#!/usr/bin/env python
+
+__author__ = "Jasper Hartline"
+__credits__ = ""
+__license__ = "GPL?"
+__version__ = "Alpha"
+__description__ = "Attempts to create a 32/64 bit combination live Fedora image."
+
+import os
+import sys
+import shutil
+import parted
+import subprocess
+import tempfile
+import math
+
+from optparse import OptionParser
+
+def main():
+
+ def cleanup():
+ pass
+
+
+ def mount(src, dst, options=None):
+ if os.path.exists(src): # Is src the lodev device?
+ if not os.path.exists(dst):
+ os.makedir(dst)
+ if options: # None is the same as Null so you can test for existence instead.
+ args = ("/bin/mount", options, src, dst)
+ else:
+ args = ("/bin/mount", src, dst)
+
+ rc = subprocess.call(args)
+ return rc
+ else: # Let's make sure only one return statement get's triggered.
+ return False # Might as well return something useful so we can test for failure.
+
+
+ def umount(src):
+ if os.path.exists(src):
+ args = ("/bin/umount", src)
+ rc = subprocess.call(args)
+ return rc
+ else:
+ return False
+
+
+ def copy(src, dst):
+ if os.path.exists(src):
+ shutil.copy(src, dst)
+ return True
+ else:
+ return False
+
+
+ def move(src, dst):
+ if os.path.exists(src):
+ shutil.mopve(src, dst)
+ return True
+ else:
+ return False
+
+
+ def losetup(src, dst, offset=None):
+ if os.path.exists(src) and os.path.exists(dst):
+ if offset:
+ args = ("/sbin/losetup", "-o", offset, src, dst)
+ else:
+ args = ("/sbin/losetup", src, dst)
+
+ rc = subprocess.call(args)
+ return rc
+ else:
+ return False
+
+
+ def null():
+ fd = open("/dev/null", "w")
+ return fd
+
+ def lo():
+ args = ("/sbin/losetup", "--find")
+ rc = subprocess.call(args, stdout=open(null())).communicate()[0].rstrip()
+ return rc
+
+
+ def mkimage(bs, count):
+ tmp = tempfile.mkstemp()
+ image = tmp[1]
+ args = ("/bin/dd",
+ "if=/dev/zero",
+ "of=%s" % image,
+ "bs=%s" % bs,
+ "count=%s" % count)
+ rc = subprocess.call(args)
+ return image
+
+
+ def size(ent):
+ size = os.path.getsize(ent)
+ if size >= 0:
+ return os.path.getsize(ent)
+ else:
+ print "Something is wrong, %s has no size." % ent
+ return False
+
+
+ def blocks(block_size, size):
+ # Round up to nearest block
+ # Make sure floating math, not integer math or we don't get remainders.
+ # Turn back into an integer for return statement.
+ return int(math.ceil(size / float(block_size)))
+
+
+ def setup(x86, x64, multi):
+ # Reworked the logic a bit.
+ block_size = 2048 # Should this be a global constant instead?
+ sz = size(x86) + size(x64)
+ count = blocks(block_size, sz)
+
+ multi = mkimage(str(blsz), count)
+ losetup(multi, lo())
+
+
+ def parse(x86, x64, multi):
+ for file in x86, x64, multi: # Do we expect that multi exists yet?
+ if os.path.exists(file): # Should we test for existance or isfile?
+ pass
+ else:
+ parser.error("One of the images does not exist.")
+ setup(x86, x64, multi)
+
+ # Generate parser and fill with options.
+ usage = "usage: %prog [options] <32bit image> <64bit image> <biarch image>"
+ version = "%prog " + __version__
+ parser = OptionParser(usage=usage, description=__description__, version=version)
+ parser.add_option("--test", action="store_true", default=False,
+ dest="test", help="Doesn't do anything yet.")
+ (options, args) = parser.parse_args()
+ if len(args) != 3:
+ parser.error("You must specify all three arguments.")
+ sys.exit(0)
+
+ try: # Any reason this would fail?
+ parse(args[0], args[1], args[2])
+ except:
+ parser.error("Something failed. Better luck next time!")
+ sys.exit(1)
+
+if __name__ == "__main__":
+ sys.exit(main())
\ No newline at end of file
13 years, 6 months
List of previous issues with livecd-tools which should be addressed
by Jasper Hartline
In response to Jan Kratochvil's shell script I have attached a python
script which replicates
what she does in the bash shell script.
There is also a patch, which fixes up some regex/match in livecd-iso-to-disk
and another section which assumes our loop devices have extra numbered
partitions.
If you guys want to help beat mkbiarch.py Python script into shape maybe
we gan get it into the tools for livecd-tools.
The way you use it, is:
mkbiarch.py <x86 ISO image> <x64 ISO image> <Target Multi Arch Image name>
13 years, 6 months
SD/MMC partition support was: Development of biarch live CD script.
by Frederick Grose
On Sun, Aug 29, 2010 at 4:12 AM, Jasper Hartline
<jasper.hartline(a)gmail.com>wrote:
>
> {...}
>
About patches, do you have any in particular you're looking at?
> Most of any of them that were not submitted by Frederick Grose were
> updated by myself, to apply against git, but it is up to your
> discretion if you want to apply
> and test any of them. The only two I wish we could really apply soon
> soon, like when you do it
> is these two:
>
> 1)
> https://bugzilla.redhat.com/attachment.cgi?id=436736&action=diff&context=...
> 2) https://bugzilla.redhat.com/attachment.cgi?id=424664
>
> 1) Fix bug with vfat only disks, including adding support for Ext4
>
Comment added to https://bugzilla.redhat.com/show_bug.cgi?id=603277.
See https://bugzilla.redhat.com/show_bug.cgi?id=587411 livecd-iso-to-disk
--format fails with SD/MMC partitions.
The umount ${device}? will fail with an SD/MMC partition that uses a
device-partition# separator, such as the 'p' in /dev/mmcblk0p1
umount ${device}* would work, but would also unmount all partitions.
Having the partition number 1 hardcoded as USBDEV=${device}1 could also fail
with some SD/MMC drivers.
Attachment, https://bugzilla.redhat.com/attachment.cgi?id=413572&action=edit
, has
some replacement code:
- USBDEV=${device}1
+ partition=$( awk '$4 ~ /'${device#/dev/}'.*[0-9]$/ {print $4}'
/proc/partitions )
+ partnum=${partition##${device#/dev/}}
+ USBDEV=${device}${partnum}
--Fred
13 years, 6 months
tools/livecd-iso-to-disk.sh
by Bruno Wolff III
tools/livecd-iso-to-disk.sh | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
New commits:
commit db7e6305138e382da9a541ae292d7b6764f3c47d
Author: Bruno Wolff III <bruno(a)wolff.to>
Date: Sat Sep 11 21:26:50 2010 -0500
Handle partition devices that have a separator character in the name.
diff --git a/tools/livecd-iso-to-disk.sh b/tools/livecd-iso-to-disk.sh
index 1347aa5..6023509 100755
--- a/tools/livecd-iso-to-disk.sh
+++ b/tools/livecd-iso-to-disk.sh
@@ -162,7 +162,7 @@ createGPTLayout() {
echo "WARNING: THIS WILL DESTROY ANY DATA ON $device!!!"
echo "Press Enter to continue or ctrl-c to abort"
read
- umount ${device}? &> /dev/null
+ umount ${device}* &> /dev/null
/sbin/parted --script $device mklabel gpt
partinfo=$(LC_ALL=C /sbin/parted --script -m $device "unit b print" |grep ^$device:)
size=$(echo $partinfo |cut -d : -f 2 |sed -e 's/B$//')
@@ -184,7 +184,7 @@ createMSDOSLayout() {
echo "WARNING: THIS WILL DESTROY ANY DATA ON $device!!!"
echo "Press Enter to continue or ctrl-c to abort"
read
- umount ${device}? &> /dev/null
+ umount ${device}* &> /dev/null
/sbin/parted --script $device mklabel msdos
partinfo=$(LC_ALL=C /sbin/parted --script -m $device "unit b print" |grep ^$device:)
size=$(echo $partinfo |cut -d : -f 2 |sed -e 's/B$//')
@@ -206,7 +206,7 @@ createEXTFSLayout() {
echo "WARNING: THIS WILL DESTROY ANY DATA ON $device!!!"
echo "Press Enter to continue or ctrl-c to abort"
read
- umount ${device}? &> /dev/null
+ umount ${device}* &> /dev/null
/sbin/parted --script $device mklabel msdos
partinfo=$(LC_ALL=C /sbin/parted --script -m $device "unit b print" |grep ^$device:)
size=$(echo $partinfo |cut -d : -f 2 |sed -e 's/B$//')
13 years, 6 months
tools/mkbackup.py
by Bruno Wolff III
tools/mkbackup.py | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 99 insertions(+)
New commits:
commit ce766247a1f6fb16732929dd175c45528d507029
Author: Jasper Hartline <jasper.hartline(a)gmail.com>
Date: Sat Sep 11 21:07:33 2010 -0500
Initial checkin of a new expermiental tool for live backup images.
This won't get used by any old stuff, so shouldn't cause problems to
existing stuff.
Signed-off-by: Bruno Wolff III <bruno(a)wolff.to>
diff --git a/tools/mkbackup.py b/tools/mkbackup.py
new file mode 100644
index 0000000..d08532c
--- /dev/null
+++ b/tools/mkbackup.py
@@ -0,0 +1,99 @@
+#!/usr/bin/python
+
+import os
+import sys
+import subprocess
+import shutil
+import tempfile
+import re
+
+#dump -0 / -f dump.img && dd if=/dev/zero of=filesystem.img bs=2M count=1000 && losetup /dev/loop0 filesystem.img && mkdir filesystem && mke2fs -j /dev/loop0 && mount -t ext3 /dev/loop0 -o loop filesystem && cd filesystem && restore -r -f ../dump.img && cd ../ && umount filesystem && losetup -d /dev/loop0
+
+
+
+def main():
+ def usage():
+ sys.exit(1)
+
+
+ def mktmpdir():
+ tmpdir = tempfile.mkdtemp()
+ return tmpdir
+
+ def mktmpfile():
+ tmpfile = tempfile.mkstemp()
+ return tmpfile[1]
+
+ def size(ent):
+ current = os.stat(ent).st_size
+ return current
+
+ def mkempty(bs, count):
+ image = tempfile.mkstemp()
+ args = ("/bin/dd", "if=/dev/zero", "of=%s"%image, "bs=%s"%bs, "count=%s"%count)
+ execute(args)
+ return image
+
+ def dump(ent, file):
+ args = ("/sbin/dump", "-0", ent, "-f", file)
+ execute(args)
+
+ def restore():
+ pass
+
+
+ def mkcopy():
+ pass
+
+ def getrootents():
+ ents = list()
+ args = ("/bin/df", "-lh")
+ data = execute(args, needdata=True)
+ lines = data.split('\n')
+
+ for line in lines:
+ if re.search(r"/dev/", line) and not re.search(r"tmpfs", line):
+ ent = re.search(r"/dev/[-0-9A-Za-z]+", line)
+ ents.append(ent.group())
+ return ents
+
+
+
+
+ def execute(args, needdata=False):
+ if needdata is False:
+ rc = subprocess.call(args)
+ else:
+ rc = subprocess.Popen(args, stdout=subprocess.PIPE).communicate()[0]
+
+ return rc
+
+
+ def setup():
+
+ dumpfiles = list()
+ ents = getrootents()
+ for ent in ents:
+ dumpfile = mktmpfile()
+ dump(ent, dumpfile)
+ dumpfiles.append(dumpfile)
+
+ tsize = 0
+ for dumpfile in dumpfiles:
+ tsize = size(dumpfile) + tsize
+
+ bs = 2048
+ count = (tsize / 2048)
+
+ target = mkempty(bs, count)
+
+ setup()
+ rc = 0
+ return rc
+
+
+
+
+
+if __name__ == "__main__":
+ sys.exit(main())
13 years, 6 months