1
# Copyright 2008 Amazon.com, Inc. or its affiliates. All Rights
2
# Reserved. Licensed under the Amazon Software License (the
3
# "License"). You may not use this file except in compliance with the
4
# License. A copy of the License is located at
5
# http://aws.amazon.com/asl or in the "license" file accompanying this
6
# file. This file is distributed on an "AS IS" BASIS, WITHOUT
7
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See
8
# the License for the specific language governing permissions and
9
# limitations under the License.
11
require 'ec2/amitools/bundle'
12
require 'ec2/amitools/bundleimageparameters'
16
MAX_SIZE = 10 * 1024 * 1024 * 1024 # 10 GB in bytes.
17
NAME = 'ec2-bundle-image'
21
#{NAME} is a command line tool that creates a bundled Amazon Machine \
22
Image (AMI) from a specified loopback filesystem image.
25
- tar -S the AMI to preserve sparseness of the image file
29
- generate a manifest file describing the bundled AMI
31
#{NAME} will bundle AMIs of up to 10GB.
35
# Command line parameters.
36
p = BundleImageParameters.new( ARGV, NAME )
39
STDERR.puts 'try --help' unless e.is_a? BundleParameters::Error::PromptTimeout
54
unless File.size( p.image_path ) <= MAX_SIZE
55
raise "the specified image file #{p.image_path} is too large"
59
:kernel_id => p.kernel_id,
60
:ramdisk_id => p.ramdisk_id,
61
:product_codes => p.product_codes,
62
:ancestor_ami_ids => p.ancestor_ami_ids,
63
:block_device_mapping => p.block_device_mapping
65
STDOUT.puts 'Bundling image file...'
67
Bundle.bundle_image( File::expand_path( p.image_path ),
70
Bundle::ImageType::MACHINE,
81
STDOUT.puts( "#{NAME} complete." )
83
STDERR.puts "Error: #{e.message}"
84
STDERR.puts e.backtrace if p.debug
85
STDOUT.puts "#{NAME} failed."