[euca2ools] Preserve filesystem labels and UUIDs when bundling [LP:667793 LP:672986]
gholms
gholms at fedoraproject.org
Wed Feb 23 00:59:22 UTC 2011
commit 41f7cd6d5ef5eade5f4f7a2f722fdfb88fc77da6
Author: Garrett Holmstrom <gholms at fedoraproject.org>
Date: Thu Feb 17 19:53:11 2011 -0800
Preserve filesystem labels and UUIDs when bundling [LP:667793 LP:672986]
euca2ools-1.3.1-fsid.patch | 156 ++++++++++++++++++++++++++++++++++++++++++++
euca2ools.spec | 5 ++
2 files changed, 161 insertions(+), 0 deletions(-)
---
diff --git a/euca2ools-1.3.1-fsid.patch b/euca2ools-1.3.1-fsid.patch
new file mode 100644
index 0000000..41be8e8
--- /dev/null
+++ b/euca2ools-1.3.1-fsid.patch
@@ -0,0 +1,156 @@
+--- euca2ools-1.3.1/bin/euca-bundle-vol.fsid 2011-02-17 19:05:37.148478765 -0800
++++ euca2ools-1.3.1/bin/euca-bundle-vol 2011-02-17 19:23:42.916491932 -0800
+@@ -41,6 +41,8 @@ from euca2ools import Euca2ool, FileVali
+ NotFoundError, CommandFailed, UnsupportedException
+ from subprocess import *
+ import platform
++import tempfile
++import stat
+
+ usage_string = \
+ """
+@@ -193,6 +195,37 @@ def cleanup(path):
+ if os.path.exists(path):
+ os.remove(path)
+
++def get_fs_info(path):
++ fs_type = None
++ uuid = None
++ label = None
++ devpth = None
++ tmpd = None
++ try:
++ st_dev=os.stat(path).st_dev
++ dev=os.makedev(os.major(st_dev),os.minor(st_dev))
++ tmpd=tempfile.mkdtemp()
++ devpth=("%s/dev" % tmpd)
++ os.mknod(devpth,0400 | stat.S_IFBLK ,dev)
++ except:
++ raise
++
++ ret = { }
++ pairs = { 'LABEL' : 'label', 'UUID' : 'uuid' , 'FS_TYPE' : 'fs_type' }
++ for (blkid_n, my_n) in pairs.iteritems():
++ cmd = [ 'blkid', '-s%s' % blkid_n, '-ovalue', devpth ]
++ print cmd
++ try:
++ output = Popen(cmd, stdout=PIPE).communicate()[0]
++ ret[my_n]=output.rstrip()
++ except Exception, e:
++ os.unlink(devpth)
++ os.rmdir(tmpd)
++ raise UnsupportedException("Unable to determine %s for %s" % (blkid_n, path))
++
++ os.unlink(devpth)
++ os.rmdir(tmpd)
++ return(ret)
+
+ def main():
+ euca = None
+@@ -355,9 +388,17 @@ def main():
+ if product_code_string:
+ product_codes = add_product_codes(product_code_string,
+ product_codes)
++
++ try:
++ fsinfo = get_fs_info(volume_path)
++ except UnsupportedException, e:
++ print e
++ sys.exit(1)
+ try:
+ image_path = euca.make_image(size_in_MB, excludes, prefix,
+- destination_path)
++ destination_path,
++ fs_type=fsinfo['fs_type'], uuid=fsinfo['uuid'],
++ label=fsinfo['label'])
+ except NotFoundError:
+ sys.exit(1)
+ except UnsupportedException:
+--- euca2ools-1.3.1/euca2ools/euca2ools/__init__.py.fsid 2011-02-17 19:05:37.143479037 -0800
++++ euca2ools-1.3.1/euca2ools/euca2ools/__init__.py 2011-02-17 19:45:06.945327441 -0800
+@@ -213,13 +213,40 @@ devpts /dev/pts devpts g
+ print 'Creating disk image...', image_path
+ Popen(dd_cmd, PIPE).communicate()[0]
+
+- def make_fs(self, image_path):
+- Util().check_prerequisite_command(self.MAKEFS_CMD)
++ def make_fs(self, image_path, fs_type = None, uuid = None, label = None):
++ mkfs_prog = self.MAKEFS_CMD
++ if fs_type:
++ mkfs_prog = "mkfs.%s" % fs_type
++ else:
++ fs_type = "ext3"
++
++ tunecmd = [ ]
++ if fs_type.startswith("ext"):
++ mkfs = [ mkfs_prog , '-F', image_path ]
++ if uuid: mkfs.extend([ '-U', uuid ])
++ if label: mkfs.extend([ '-L', label ])
++ elif fs_type == "xfs":
++ mkfs = [ mkfs_prog , image_path ]
++ if label: mkfs.extend([ '-L', label ])
++ tunecmd = [ 'xfs_admin', '-U', uuid ]
++
++ elif fs_type == "btrfs":
++ if uuid: raise(UnsupportedException("btrfs with uuid not supported"))
++ if label: mkfs.extend([ '-L', label ])
++ else:
++ raise(UnsupportedException("unsupported fs %s" % fs_type))
++
++
++ Util().check_prerequisite_command(mkfs_prog)
+
+ if self.debug:
+- print 'Creating filesystem...'
+- makefs_cmd = Popen([self.MAKEFS_CMD, '-F', image_path],
+- PIPE).communicate()[0]
++ print 'Creating filesystem with %s' % mkfs
++
++ makefs_cmd = Popen(mkfs,PIPE).communicate()[0]
++
++ if len(tunecmd):
++ Util().check_prerequisite_command(tunecmd[0])
++ tune_cmd = Popen(tunecmd,PIPE).communicate[0]
+
+ def add_fstab(
+ self,
+@@ -292,7 +319,7 @@ class SolarisImage:
+ print 'Sorry. Solaris not supported yet'
+ raise UnsupportedException
+
+- def make_fs(self, image_path):
++ def make_fs(self, image_path, fstype = None, uuid = None, label = None):
+ print 'Sorry. Solaris not supported yet'
+ raise UnsupportedException
+
+@@ -427,8 +454,11 @@ class NotFoundError:
+
+ class UnsupportedException:
+
+- def __init__(self):
+- self.message = 'Not supported'
++ def __init__(self, msg=None):
++ if msg:
++ self.message = 'Not supported: %s' % msg
++ else:
++ self.message = 'Not supported'
+
+
+ class CommandFailed:
+@@ -1215,6 +1245,7 @@ class Euca2ool:
+ excludes,
+ prefix,
+ destination_path,
++ fs_type = None, uuid = None, label = None
+ ):
+ image_file = '%s.img' % prefix
+ image_path = '%s/%s' % (destination_path, image_file)
+@@ -1224,7 +1255,7 @@ class Euca2ool:
+ print 'Platform not fully supported.'
+ raise UnsupportedException
+ self.img.create_image(size_in_MB, image_path)
+- self.img.make_fs(image_path)
++ self.img.make_fs(image_path, fs_type=fstype, uuid=uuid, label=label)
+ return image_path
+
+ def create_loopback(self, image_path):
diff --git a/euca2ools.spec b/euca2ools.spec
index 68041f2..f224b1f 100644
--- a/euca2ools.spec
+++ b/euca2ools.spec
@@ -44,6 +44,9 @@ Patch14: euca2ools-1.3.1-shasum.patch
Patch15: euca2ools-1.3.1-userint.patch
# (upstream bzr revision 331)
Patch16: euca2ools-1.3.1-userdash.patch
+# https://bugs.launchpad.net/euca2ools/+bug/667793
+# https://bugs.launchpad.net/euca2ools/+bug/672986
+Patch17: euca2ools-1.3.1-fsid.patch
Requires: m2crypto
Requires: python-boto
@@ -83,6 +86,7 @@ Eucalyptus. These tools are also compatible with Amazon AWS.
%patch14 -p1
%patch15 -p1
%patch16 -p1
+%patch17 -p1
%build
@@ -121,6 +125,7 @@ rm -rf %{buildroot}
* Thu Feb 17 2011 Garrett Holmstrom <gholms at fedoraproject.org> - 1.3.1-6
- Stop stripping leading '0's from user IDs [LP:479823]
- Fix bad behavior with user IDs that contain '-'
+- Preserve filesystem labels and UUIDs when bundling [LP:667793 LP:672986]
* Tue Feb 08 2011 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 1.3.1-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
More information about the scm-commits
mailing list