--- ec2-ami-tools-1.4.0.9.orig/debian/README.source +++ ec2-ami-tools-1.4.0.9/debian/README.source @@ -0,0 +1,20 @@ +These are the ec2-ami-tools, from + http://aws.amazon.com/developertools/368 + +The upstream development for this package will take place in + lp:~awstools-dev/ubuntu//ec2-ami-tools/ + +For example, if the current release is 'natty': + lp:~awstools-dev/ubuntu/natty/ec2-ami-tools/natty + +There is a tool debian/upstream-check, and a debian/rules rule 'upstream-check' +that will crawl through the xml output and find the latest version of +ec2-ami-tools at http://s3.amazonaws.com/ec2-downloads/ . It will print out +the highest version there, along with the modified date and the size. + +For example: + $ ./debian/rules upstream-check + ec2-ami-tools-1.3-66634.zip 2011-03-10T18:17:14.000Z 137948 + +== Test == +See debian/tests/README for more information. --- ec2-ami-tools-1.4.0.9.orig/debian/changelog +++ ec2-ami-tools-1.4.0.9/debian/changelog @@ -0,0 +1,161 @@ +ec2-ami-tools (1.4.0.9-0ubuntu3) noble; urgency=medium + + * No change rebuild to gain buildinfo. + + -- Dimitri John Ledkov Fri, 16 Feb 2024 12:35:33 +0000 + +ec2-ami-tools (1.4.0.9-0ubuntu2) trusty; urgency=medium + + * Drop dependency on libopenssl-ruby. + + -- Matthias Klose Fri, 21 Feb 2014 16:10:09 +0100 + +ec2-ami-tools (1.4.0.9-0ubuntu1) raring; urgency=low + + * New upstream release 1.4.0.9 (2012-11-12) + * add knowledge of 'ap-southeast-2' + * add flag '--delegation-token' to tools, to allow use of the iam + credentials inside an ec2 instance. + * New upstream release 1.4.0.7 (2012-03-26) + * centralize the list of regions and locations ec2/amitools/region.rb + * add govcloud support, with + * public certificate to /ec2/amitools/cert-ec2-gov.pem + * knowledge of us-gov-west-1 region + * use pid in fifo name, which improves upstream for the same code + path that use-mktemp-like-mkfifo-name.patch affects. But the + patch here still does a better job. + * debian/patches/remove-explicit-regions.patch: + rework to build upon existing functionality in upstream code. + upstream consolidated the lists to a single place. + * New upstream release 1.4.0.5 (2011-12-14) + * image bundle is now created with '--user 0' and '--group 0'. + This just avoids the local username getting into the tarball. + * ec2-bundle-vol: add --filter flag, with description + 'Do not use the default filtered files list.' + * add knowledge of regions us-west-2 and sa-east-1 + * debian/patches/use-mktemp-like-mkfifo-name.patch + update to work with ruby 1.9 (LP: #1088540) + * add debian/watch and update debian/rules to support uscan. + * debian/patches/ruby-1.9-cleanup.patch + fix some errors when running with ruby 1.9 + + -- Scott Moser Mon, 10 Dec 2012 18:46:35 -0500 + +ec2-ami-tools (1.4.0.2-0ubuntu1) precise; urgency=low + + * New upstream release (1.4.0.2) + - add knowledge of us-west-2 + - help for migrate-bundle now mentions it is deprecated + * New upstream release (1.4.0.1) + - bundle commands: adds --no-size-checks flag + - bundle-vol + + blacklists several temp, sensitive and swap files + + add --include param + + upstream now copies uuid, label, fstype. No more need + for bundle-vol-copy-fs-info.patch + * remove-explicit-regions.patch: (LP: #888618) + remove need for explicit list of regions and locations + * add debian/test directory with some tests of tools + * debian/patches: add dep-3 headers to patches + * bin/* all programs now use a different wrapper script for launching. + which allows running out of source directory or installed location. + + -- Scott Moser Wed, 09 Nov 2011 16:48:21 -0500 + +ec2-ami-tools (1.3.66634-0ubuntu1) oneiric; urgency=low + + * New upstream release. Adds support for ap-northeast-1. + * add debian/upstream-check for checking latest upstream release + * add debian/README.source + * change Maintainer to ubuntu-devel-discuss@lists.ubuntu.com + + -- Scott Moser Wed, 15 Jun 2011 15:33:22 -0400 + +ec2-ami-tools (1.3.49953-0ubuntu3) natty; urgency=low + + * fix previous upload, making ec2-bundle-vol work again. + (LP: #667793, #672986) + + -- Scott Moser Fri, 14 Jan 2011 13:42:03 -0500 + +ec2-ami-tools (1.3.49953-0ubuntu2) natty; urgency=low + + * copy filesystem uuid, label, fstype from source filesytem to + bundled volume (LP: #667793, #672986) + + -- Scott Moser Thu, 13 Jan 2011 13:42:01 -0500 + +ec2-ami-tools (1.3.49953-0ubuntu1) maverick; urgency=low + + * New upstream release. Adds support for ap-southeast-1. LP: #582387 + + -- Scott Moser Tue, 18 May 2010 13:48:53 -0400 + +ec2-ami-tools (1.3-45758-0ubuntu1) lucid; urgency=low + + * New upstream version. Supports us-west-1. + + -- Scott Moser Mon, 07 Dec 2009 13:51:18 -0500 + +ec2-ami-tools (1.3-34544-0ubuntu3) karmic; urgency=low + + * Fix FTBFS. + + -- Chuck Short Mon, 05 Oct 2009 11:55:28 -0400 + +ec2-ami-tools (1.3-34544-0ubuntu2) karmic; urgency=low + + * use randomly generated filenames when calling mkfifo + + -- Scott Moser Thu, 01 Oct 2009 00:00:36 -0400 + +ec2-ami-tools (1.3-34544-0ubuntu1) karmic; urgency=low + + * New upstream version. + + -- Chuck Short Tue, 02 Jun 2009 10:07:14 -0400 + +ec2-ami-tools (1.3-31057-0ubuntu1) jaunty; urgency=low + + * New upstream version. (LP: #310547) + * debian/patches/exclude-udev-rules.patch: Exclude the copying of + /etc/udev/rules.d/70-persistent-net.rules and + /etc/udev/rules.d/z25_persistent-net.rules when rebundling an image. + (LP: #308548) + * debian/patches/point-to-right-place: Updated patch to take in account + ec2-migrate-manifest and ec2-migrate-bundle. + + -- Chuck Short Tue, 13 Jan 2009 11:46:59 -0500 + +ec2-ami-tools (1.3-26357-0ubuntu5) intrepid; urgency=low + + * debian/control: depend on curl. + + -- Mathias Gug Thu, 23 Oct 2008 11:22:38 -0400 + +ec2-ami-tools (1.3-26357-0ubuntu4) intrepid; urgency=low + + * Fix typo in debian/patches/point-to-right-place.patch. + + -- Chuck Short Tue, 21 Oct 2008 11:09:00 -0400 + +ec2-ami-tools (1.3-26357-0ubuntu3) intrepid; urgency=low + + * debian/control: depend on libopenssl-ruby (LP: #284744). + + -- Mathias Gug Fri, 17 Oct 2008 12:44:45 -0400 + +ec2-ami-tools (1.3-26357-0ubuntu2) intrepid; urgency=low + + * New upstream version. + * Update the debian copyright file. + * Added quilt patch system to make it easier to maintain. + + -- Chuck Short Tue, 14 Oct 2008 08:35:25 -0400 + +ec2-ami-tools (1.3-21885-0ubuntu1) unstable; urgency=low + + * Initial release. + + -- Soren Hansen Wed, 10 Sep 2008 13:22:10 +0200 + --- ec2-ami-tools-1.4.0.9.orig/debian/compat +++ ec2-ami-tools-1.4.0.9/debian/compat @@ -0,0 +1 @@ +7 --- ec2-ami-tools-1.4.0.9.orig/debian/control +++ ec2-ami-tools-1.4.0.9/debian/control @@ -0,0 +1,15 @@ +Source: ec2-ami-tools +Section: admin +Priority: extra +Maintainer: Ubuntu Developers +Build-Depends: cdbs, debhelper (>= 7), quilt +Standards-Version: 3.7.3 +Homepage: http://aws.amazon.com/developertools/368 + +Package: ec2-ami-tools +Architecture: all +Depends: ${misc:Depends}, ruby, curl +Description: Amazon EC2 AMI tools + The Amazon EC2 AMI Tools are command-line utilities to help bundle an + Amazon Machine Image (AMI), create an AMI from an existing machine or + installed volume, and upload a bundled AMI to Amazon S3. --- ec2-ami-tools-1.4.0.9.orig/debian/copyright +++ ec2-ami-tools-1.4.0.9/debian/copyright @@ -0,0 +1,26 @@ +This package was debianized by Soren Hansen on +Wed, 10 Sep 2008 13:22:10 +0200. + +It was downloaded from + +Upstream Author(s): + + Amazon.com + +Copyright: + + Copyright 2008 Amazon.com, Inc or its affiliates. + +License: + + Licensed under the Amazon Software License (the + "License"). You may not use this file except in compliance with the + License. A copy of the License is located at + http://aws.amazon.com/asl or in the "license" file accompanying this + file. This file is distributed on an "AS IS" BASIS, WITHOUT + WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See + the License for the specific language governing permissions and + limitations under the License + +The Debian packaging is (C) 2008, Soren Hansen and +is licensed under the GPL, see `/usr/share/common-licenses/GPL'. --- ec2-ami-tools-1.4.0.9.orig/debian/dirs +++ ec2-ami-tools-1.4.0.9/debian/dirs @@ -0,0 +1 @@ +usr/bin --- ec2-ami-tools-1.4.0.9.orig/debian/docs +++ ec2-ami-tools-1.4.0.9/debian/docs @@ -0,0 +1,2 @@ +readme-install.txt +readme-install.txt --- ec2-ami-tools-1.4.0.9.orig/debian/patches/exclude-udev-rules.patch +++ ec2-ami-tools-1.4.0.9/debian/patches/exclude-udev-rules.patch @@ -0,0 +1,19 @@ +Description: exclude udev persistent network rules +Origin: Scott Moser +Bug: https://launchpad.net/bugs/308548 +Forwarded: not-needed +Last-Update: 2009-01-15 +--- a/lib/ec2/platform/linux/image.rb ++++ b/lib/ec2/platform/linux/image.rb +@@ -27,7 +27,10 @@ module EC2 + # Symbolic links are preserved. + class Image + IMG_MNT = '/mnt/img-mnt' +- EXCLUDES= ['/dev', '/media', '/mnt', '/proc', '/sys'] ++ EXCLUDES= ['/dev', '/media', '/mnt', '/proc', '/sys', ++ '/etc/udev/rules.d/70-persistent-net.rules', ++ '/etc/udev/rules.d/z25_persistent-net.rules' ++ ] + DEFAULT_FSTAB = EC2::Platform::Linux::Fstab::DEFAULT + LEGACY_FSTAB = EC2::Platform::Linux::Fstab::LEGACY + --- ec2-ami-tools-1.4.0.9.orig/debian/patches/point-to-right-place.patch +++ ec2-ami-tools-1.4.0.9/debian/patches/point-to-right-place.patch @@ -0,0 +1,113 @@ +Description: set install path in launcher scripts + This patch is generated using debian/update-bin-wrappers +Origin: Scott Moser +Forwarded: not-needed +Last-Update: 2011-11-10 +--- a/bin/ec2-ami-tools-version ++++ b/bin/ec2-ami-tools-version +@@ -1,4 +1,6 @@ + #!/bin/bash +- +-home=${EC2_AMITOOL_HOME:-${EC2_HOME:?Neither of EC2_AMITOOL_HOME or EC2_HOME environment variables are set}} +-ruby -I $home/lib ${home}/lib/ec2/amitools/showversion.rb $* ++home="${EC2_AMITOOL_HOME:-@@EC2_AMITOOL_HOME@@}" ++[ "${home#@@}" = "${home}" ] || ++ { echo "you must either set EC2_AMITOOL_HOME or install" 1>&2; exit 1; } ++exec -a "${0##*/}" ruby -I "${home}/lib" \ ++ "$home/lib/ec2/amitools/showversion.rb" "$@" +--- a/bin/ec2-bundle-image ++++ b/bin/ec2-bundle-image +@@ -1,4 +1,6 @@ + #!/bin/bash +- +-home=${EC2_AMITOOL_HOME:-${EC2_HOME:?Neither of EC2_AMITOOL_HOME or EC2_HOME environment variables are set}} +-ruby -I $home/lib ${home}/lib/ec2/amitools/bundleimage.rb $* ++home="${EC2_AMITOOL_HOME:-@@EC2_AMITOOL_HOME@@}" ++[ "${home#@@}" = "${home}" ] || ++ { echo "you must either set EC2_AMITOOL_HOME or install" 1>&2; exit 1; } ++exec -a "${0##*/}" ruby -I "${home}/lib" \ ++ "$home/lib/ec2/amitools/bundleimage.rb" "$@" +--- a/bin/ec2-bundle-vol ++++ b/bin/ec2-bundle-vol +@@ -1,4 +1,6 @@ + #!/bin/bash +- +-home=${EC2_AMITOOL_HOME:-${EC2_HOME:?Neither of EC2_AMITOOL_HOME or EC2_HOME environment variables are set}} +-ruby -I $home/lib ${home}/lib/ec2/amitools/bundlevol.rb $* ++home="${EC2_AMITOOL_HOME:-@@EC2_AMITOOL_HOME@@}" ++[ "${home#@@}" = "${home}" ] || ++ { echo "you must either set EC2_AMITOOL_HOME or install" 1>&2; exit 1; } ++exec -a "${0##*/}" ruby -I "${home}/lib" \ ++ "$home/lib/ec2/amitools/bundlevol.rb" "$@" +--- a/bin/ec2-delete-bundle ++++ b/bin/ec2-delete-bundle +@@ -1,4 +1,6 @@ + #!/bin/bash +- +-home=${EC2_AMITOOL_HOME:-${EC2_HOME:?Neither of EC2_AMITOOL_HOME or EC2_HOME environment variables are set}} +-ruby -I $home/lib ${home}/lib/ec2/amitools/deletebundle.rb $* ++home="${EC2_AMITOOL_HOME:-@@EC2_AMITOOL_HOME@@}" ++[ "${home#@@}" = "${home}" ] || ++ { echo "you must either set EC2_AMITOOL_HOME or install" 1>&2; exit 1; } ++exec -a "${0##*/}" ruby -I "${home}/lib" \ ++ "$home/lib/ec2/amitools/deletebundle.rb" "$@" +--- a/bin/ec2-download-bundle ++++ b/bin/ec2-download-bundle +@@ -1,4 +1,6 @@ + #!/bin/bash +- +-home=${EC2_AMITOOL_HOME:-${EC2_HOME:?Neither of EC2_AMITOOL_HOME or EC2_HOME environment variables are set}} +-ruby -I $home/lib ${home}/lib/ec2/amitools/downloadbundle.rb $* ++home="${EC2_AMITOOL_HOME:-@@EC2_AMITOOL_HOME@@}" ++[ "${home#@@}" = "${home}" ] || ++ { echo "you must either set EC2_AMITOOL_HOME or install" 1>&2; exit 1; } ++exec -a "${0##*/}" ruby -I "${home}/lib" \ ++ "$home/lib/ec2/amitools/downloadbundle.rb" "$@" +--- a/bin/ec2-migrate-bundle ++++ b/bin/ec2-migrate-bundle +@@ -1,4 +1,6 @@ + #!/bin/bash +- +-home=${EC2_AMITOOL_HOME:-${EC2_HOME:?Neither of EC2_AMITOOL_HOME or EC2_HOME environment variables are set}} +-ruby -I $home/lib ${home}/lib/ec2/amitools/migratebundle.rb $* ++home="${EC2_AMITOOL_HOME:-@@EC2_AMITOOL_HOME@@}" ++[ "${home#@@}" = "${home}" ] || ++ { echo "you must either set EC2_AMITOOL_HOME or install" 1>&2; exit 1; } ++exec -a "${0##*/}" ruby -I "${home}/lib" \ ++ "$home/lib/ec2/amitools/migratebundle.rb" "$@" +--- a/bin/ec2-migrate-manifest ++++ b/bin/ec2-migrate-manifest +@@ -1,4 +1,6 @@ + #!/bin/bash +- +-home=${EC2_AMITOOL_HOME:-${EC2_HOME:?Neither of EC2_AMITOOL_HOME or EC2_HOME environment variables are set}} +-ruby -I $home/lib ${home}/lib/ec2/amitools/migratemanifest.rb $* ++home="${EC2_AMITOOL_HOME:-@@EC2_AMITOOL_HOME@@}" ++[ "${home#@@}" = "${home}" ] || ++ { echo "you must either set EC2_AMITOOL_HOME or install" 1>&2; exit 1; } ++exec -a "${0##*/}" ruby -I "${home}/lib" \ ++ "$home/lib/ec2/amitools/migratemanifest.rb" "$@" +--- a/bin/ec2-unbundle ++++ b/bin/ec2-unbundle +@@ -1,4 +1,6 @@ + #!/bin/bash +- +-home=${EC2_AMITOOL_HOME:-${EC2_HOME:?Neither of EC2_AMITOOL_HOME or EC2_HOME environment variables are set}} +-ruby -I $home/lib ${home}/lib/ec2/amitools/unbundle.rb $* ++home="${EC2_AMITOOL_HOME:-@@EC2_AMITOOL_HOME@@}" ++[ "${home#@@}" = "${home}" ] || ++ { echo "you must either set EC2_AMITOOL_HOME or install" 1>&2; exit 1; } ++exec -a "${0##*/}" ruby -I "${home}/lib" \ ++ "$home/lib/ec2/amitools/unbundle.rb" "$@" +--- a/bin/ec2-upload-bundle ++++ b/bin/ec2-upload-bundle +@@ -1,4 +1,6 @@ + #!/bin/bash +- +-home=${EC2_AMITOOL_HOME:-${EC2_HOME:?Neither of EC2_AMITOOL_HOME or EC2_HOME environment variables are set}} +-ruby -I $home/lib ${home}/lib/ec2/amitools/uploadbundle.rb $* ++home="${EC2_AMITOOL_HOME:-@@EC2_AMITOOL_HOME@@}" ++[ "${home#@@}" = "${home}" ] || ++ { echo "you must either set EC2_AMITOOL_HOME or install" 1>&2; exit 1; } ++exec -a "${0##*/}" ruby -I "${home}/lib" \ ++ "$home/lib/ec2/amitools/uploadbundle.rb" "$@" --- ec2-ami-tools-1.4.0.9.orig/debian/patches/remove-explicit-regions.patch +++ ec2-ami-tools-1.4.0.9/debian/patches/remove-explicit-regions.patch @@ -0,0 +1,68 @@ +Description: remove/minimize explicit references to location and regions + This changes the check for "is this a valid location" from checking + an explicit list of known values to checking that known list of locations + and then additionally checking to see if ec2.#{region}.amazonaws.com + is a valid dns entry. This allows us to not have to patch / SRU existing + tools to address new regions in EC2. + . + It assumes that: + location -> region + US -> us-east-1 + EU -> eu-west-1 + * -> * +Origin: Scott Moser +Bug: https://launchpad.net/bugs/888618 +Forwarded: https://forums.aws.amazon.com/thread.jspa?threadID=79936 +Last-Update: 2012-12-10 +--- a/lib/ec2/amitools/migratebundleparameters.rb ++++ b/lib/ec2/amitools/migratebundleparameters.rb +@@ -121,7 +121,9 @@ class MigrateBundleParameters < Paramete + end + + on('--location LOCATION', LOCATION_DESCRIPTION) do |location| +- assert_option_in(location, AwsRegion.s3_locations, '--location') ++ if not AwsRegion.is_location(location) ++ raise InvalidValue.new(location, "--location") ++ end + @location = location + @location = :unconstrained if @location == "US" + end +--- a/lib/ec2/amitools/uploadbundleparameters.rb ++++ b/lib/ec2/amitools/uploadbundleparameters.rb +@@ -72,7 +72,9 @@ class UploadBundleParameters < S3ToolPar + end + + on('--location LOCATION', LOCATION_DESCRIPTION) do |location| +- assert_option_in(location, AwsRegion.s3_locations, '--location') ++ if not AwsRegion.is_location(location) ++ raise InvalidValue.new(location, "--location") ++ end + @location = location + @location = :unconstrained if @location == "US" + end +--- a/lib/ec2/amitools/region.rb ++++ b/lib/ec2/amitools/region.rb +@@ -75,5 +75,23 @@ module AwsRegion + S3_LOCATIONS + end + ++ def is_region(region) ++ return true if AWS_REGIONS.include?(region) ++ require "socket" ++ begin ++ Socket.gethostbyname("ec2.#{region}.amazonaws.com") ++ return true ++ rescue SocketError ++ return false ++ end ++ end ++ ++ def is_location(location) ++ return true if S3_LOCATIONS.include?(location) ++ return true if location == :unconstrained ++ return false if location == 'us-east-1' ++ return(is_region(location)) ++ end ++ + end + --- ec2-ami-tools-1.4.0.9.orig/debian/patches/ruby-1.9-cleanup.patch +++ ec2-ami-tools-1.4.0.9/debian/patches/ruby-1.9-cleanup.patch @@ -0,0 +1,11 @@ +--- a/lib/ec2/amitools/format.rb ++++ b/lib/ec2/amitools/format.rb +@@ -58,7 +58,7 @@ module Format + def Format.hex2bin(hex) + hex = '0' + hex unless (hex.size % 2) == 0 + data = StringIO.new +- hex.to_a.pack('H*').each {|digit| data.write(digit)} ++ Array(Array(hex).pack('H*')).each {|digit| data.write(digit)} + data.string + end + --- ec2-ami-tools-1.4.0.9.orig/debian/patches/series +++ ec2-ami-tools-1.4.0.9/debian/patches/series @@ -0,0 +1,5 @@ +point-to-right-place.patch +exclude-udev-rules.patch +use-mktemp-like-mkfifo-name.patch +remove-explicit-regions.patch +ruby-1.9-cleanup.patch --- ec2-ami-tools-1.4.0.9.orig/debian/patches/use-mktemp-like-mkfifo-name.patch +++ ec2-ami-tools-1.4.0.9/debian/patches/use-mktemp-like-mkfifo-name.patch @@ -0,0 +1,71 @@ +Description: use temporary filenames and fifos in bundle + Previously ec2-bundle-image and ec2-unbundle-image tools made fifos in + /tmp with names of ec2-bundle-image-digest and ec2-unbundle-image-digest + respectively. As of 1.4.0.5 or so, they now append the pid. + That is slightly better, but can still be attacked, and permissions + are not adjusted past the default umask. + . + This is potentially a security issue. This patch uses random filenames + and sets the umask appropriately. + . + The random 'id' code was originally using gen_ident from util.rb + but that code is no longer in use elsewhere, so we did not want to + depend on it and have moved it in-line here. Also, the 'gen_ident' + code has an issue with ruby 1.9 (LP: #1088540) + . +Origin: Scott Moser +Bug: https://launchpad.net/bugs/439788 +Forwarded: https://forums.aws.amazon.com/thread.jspa?threadID=37039 +Last-Update: 2012-12-10 +--- a/lib/ec2/amitools/fileutil.rb ++++ b/lib/ec2/amitools/fileutil.rb +@@ -219,4 +219,17 @@ module FileUtil + end + sf.eof + end ++ ++ def FileUtil.tempfifo(basename="ec2ami", tmpdir=Dir::tmpdir, tries=10) ++ dir = Dir.tmpdir() ++ for i in (1..tries) ++ id = (0..19).inject("") {|ident, n| ident+(?A.ord + Kernel.rand(26)).chr} ++ file = File::join(dir, basename + "." + id ) ++ if system( "mkfifo --mode 600 #{file}" ) ++ return file ++ end ++ end ++ return false ++ end ++ + end +--- a/lib/ec2/amitools/unbundle.rb ++++ b/lib/ec2/amitools/unbundle.rb +@@ -33,10 +33,9 @@ class Unbundler < AMITool + src_dir = p.source + dst_dir = p.destination + +- digest_pipe = File::join( '/tmp', "ec2-unbundle-image-digest-pipe" ) +- File::delete( digest_pipe ) if File::exist?( digest_pipe ) +- unless system( "mkfifo #{digest_pipe}" ) +- raise "error creating named pipe #{digest_pipe}" ++ digest_pipe = FileUtil::tempfifo("ec2-unbundle-image-digest") ++ if digest_pipe == false ++ raise "Error creating named pipe" + end + + # Load manifest and the user's private key. +--- a/lib/ec2/amitools/bundle.rb ++++ b/lib/ec2/amitools/bundle.rb +@@ -45,10 +45,9 @@ module Bundle + begin + raise "invalid image-type #{image_type}" unless image_type.is_a? Bundle::ImageType + # Create named pipes. +- digest_pipe = File::join('/tmp', "ec2-bundle-image-digest-pipe-#{$$}") +- File::delete(digest_pipe) if File::exist?(digest_pipe) +- unless system( "mkfifo #{digest_pipe}" ) +- raise "Error creating named pipe #{digest_pipe}" ++ digest_pipe = FileUtil::tempfifo("ec2-bundle-image-digest") ++ if digest_pipe == false ++ raise "Error creating named pipe" + end + + # If the prefix differs from the file name create a symlink --- ec2-ami-tools-1.4.0.9.orig/debian/rules +++ ec2-ami-tools-1.4.0.9/debian/rules @@ -0,0 +1,19 @@ +#!/usr/bin/make -f + +include /usr/share/cdbs/1/rules/debhelper.mk +include /usr/share/cdbs/1/rules/patchsys-quilt.mk + +install/ec2-ami-tools:: + mkdir -p debian/ec2-ami-tools/etc + mkdir -p debian/ec2-ami-tools/usr/bin/ + mkdir -p debian/ec2-ami-tools/usr/lib/ec2-ami-tools/lib + cp -r etc/* debian/ec2-ami-tools/etc/ + cp -r bin/* debian/ec2-ami-tools/usr/bin/ + sed -i "s,@@EC2_AMITOOL_HOME@@,/usr/lib/ec2-ami-tools,g" debian/ec2-ami-tools/usr/bin/* + cp -r lib/* debian/ec2-ami-tools/usr/lib/ec2-ami-tools/lib/ + +get-orig-source: + uscan --verbose --repack + +upstream-check: + @python debian/upstream-check ec2-ami-tools --- ec2-ami-tools-1.4.0.9.orig/debian/test/README +++ ec2-ami-tools-1.4.0.9/debian/test/README @@ -0,0 +1,9 @@ +This directory contains some some tests for these utilities. + +- config.example: example config file for test files +- test-upload-download tests upload and download and register + setting DRY_RUN=1 in environment will just print output + of what would be done, giving useful examples +- test-bundle-vol: test a bundle-vol + must be run on an ec2 instance. run with --help to see + expected usage. --- ec2-ami-tools-1.4.0.9.orig/debian/test/common +++ ec2-ami-tools-1.4.0.9/debian/test/common @@ -0,0 +1,94 @@ +#!/bin/bash + +TEMP_D="" +REQUIRED="EC2_CERT EC2_PRIVATE_KEY EC2_USER_ID EC2_ACCESS_KEY EC2_SECRET_KEY + REGIONS BUCKET_BASE ARCH" + +error() { echo "$@" 1>&2; } +fail() { [ $# -eq 0 ] || error "$@"; exit 1; } + +cleanup() { + if [ "${DRY_RUN:-0}" = "0" ]; then + if [ -n "$CLEAN_DEREGISTER" ]; then + set -- $CLEAN_DEREGISTER + error "deregistering $2 in region $1" + ec2-deregister --region "$1" $XKEY_ARGS "$2" || + error "failed to deregister $1:$2" + fi + + if [ -n "$CLEAN_DELETE_BUNDLE_2" ]; then + set -- ${CLEAN_DELETE_BUNDLE_2} + error "cleaning up manifest ${2##*/} in $1" + ec2-delete-bundle $SECRET_ARGS --bucket "$1" \ + --manifest "$2" --yes --batch --clear || + error "failed to delete bucket=$1 manifest=$2" + fi + + if [ -n "$CLEAN_DELETE_BUNDLE" ]; then + set -- $CLEAN_DELETE_BUNDLE + error "cleaning up $1/$2" + ec2-delete-bundle $SECRET_ARGS --bucket "$1" \ + --manifest "$2" --yes --batch --clear || + error "failed to delete bucket=$1 manifest=$2" + fi + + if [ -n "$CLEAN_INSTANCE_ID" ]; then + error "*********************************" + error "I ran instance $CLEAN_INSTANCE_ID. Remember to delete it" + error "*********************************" + fi + + fi + [ ! -d "$TEMP_D" ] || rm -Rf "$TEMP_D" + +} + +sanit() { + local sanit clean toclean val + _RET=( "$@" ) + toclean="EC2_ACCESS_KEY EC2_CERT EC2_SECRET_KEY EC2_PRIVATE_KEY EC2_USER_ID" + toclean="$toclean BUNDLE_D UNBUNDLE_D" + + for clean in $toclean; do + val=${!clean} + [ -n "${val}" ] || continue + _RET=( ${_RET[@]//${val}/\$$clean} ) + done + return 0 +} + +run() { + local msg="$1"; shift + error "## $msg" + sanit "$@" + error "#" "${_RET[@]}" + if [ "${DRY_RUN:-0}" = "0" ]; then + "$@" || { + fail "FAILED:" "$msg"; + } + else + case "$1" in + ec2-register) echo "IMAGE ami-00000000";; + ec2-run-instances) cat <&2; fail "must give argument for config"; } + +config "$1" + +ARCH=$(uname -m) +case $ARCH in + i?86) ARCH=i386; +esac +BUNDLE_D=$BASE_D/bundle +tmpf="$TEMP_D/tmp" + +run "rm -rf BUNDLE_D" sudo rm -Rf "$BUNDLE_D" +run "mkdir -p BUNDLE_D" mkdir -p "$BUNDLE_D" + +error "# may take quite a long time (10s of minutes)" + +run "load module" sudo sh -c 'modprobe loop || :' +# this leaves /home/ubuntu/.ssh keys in place so that we could potentially +# actually ssh to the image. +run "bundle-vol" \ + sudo -E ec2-bundle-vol --arch "$ARCH" \ + --destination "$BUNDLE_D" \ + --prefix "testbundle.img" \ + --user $EC2_USER_ID \ + --size 10240 \ + --exclude /mnt,/root/.ssh \ + $KEY_ARGS + +run "perms to user" \ + sudo chown -R "$(id -u):$(id -g)" "$BASE_D" + +if [ "${DRY_RUN:-0}" = "0" ]; then + region=$(ec2metadata --availability-zone) && + region=${region%[a-z]} || region="us-east-1" + sgroup=$(ec2metadata --security-group) || sgroup="default" + if ! itype=$(ec2metadata --instance-type); then + [ "$ARCH" = "i386" ] && itype="m1.small" || itype="m1.large" + fi + # newer versions of ami tools exclude .ssh/authorized_keys + # so we have to launch with a key + if [ -z "$EC2_KEY_PAIR" ]; then + mdurl="http://169.254.169.254/2009-04-04/meta-data/" + out=$(wget -O - "$mdurl/public-keys") + key="${out#0=}" + fi +else + echo "# get current availability-zone, security-group, instance-type, keypair" + echo "# from metadata service using ec2metadata" + itype="m1.small" + region="us-east-1" + sgroup="default" + key=${EC2_KEY_PAIR:-"default"} +fi + +bucket="${BUCKET_BASE}-$region" +manifest="testbundle.img.manifest.xml" + +run "uploading to $bucket in $region with no location argument" \ + ec2-upload-bundle $SECRET_ARGS --bucket $bucket \ + --manifest "$BUNDLE_D/$manifest" +CLEAN_DELETE_BUNDLE="$bucket $BUNDLE_D/$manifest" + +run "registering $bucket/$manifest in region $region" \ + ec2-register --region $region \ + --name "$bucket/${manifest%.manifest.xml}" \ + $XKEY_ARGS "$bucket/$manifest" > "$tmpf" +read a ami_id < "$tmpf" +CLEAN_DEREGISTER="$region $ami_id" + +run "run instance of $ami_id" \ + ec2-run-instances --region $region $XKEY_ARGS \ + --key "${key}" \ + $ami_id --group $sgroup --instance-type $itype > "$tmpf" +{ read res id other; read instance inst_id other; } < "$tmpf" +CLEAN_INSTANCE_ID=$inst_id + +cat <&2; fail "must give argument for config"; } + +config "$1" + +BUNDLE_D="$TEMP_D/bundle" +UNBUNDLE_D="$TEMP_D/unbundle" +tmpf="$TEMP_D/tmp" + +run "clean tempdirs" rm -Rf "$BUNDLE_D" "$UNBUNDLE_D" +run "make dirs" mkdir -p "$BUNDLE_D" "$UNBUNDLE_D" +run "bundle-image $IMAGE" \ + ec2-bundle-image $KEY_ARGS --user $EC2_USER_ID \ + --destination "$BUNDLE_D" --arch "$ARCH" --image "$IMAGE" + +last_region="" + +# == Upload a bundle to multiple regions == +for region in ${REGIONS}; do + error "=== testing $region ===" + loc_arg="--location=$region" + [ "$region" = "us-east-1" ] && loc_arg="--location=US" + [ "$region" = "eu-west-1" ] && loc_arg="--location=EU" + bucket="${BUCKET_BASE}-$region" + manifest="${IMAGE##*/}.manifest.xml" + + run "uploading to $bucket in $region with $loc_arg" \ + ec2-upload-bundle $SECRET_ARGS $loc_arg --bucket $bucket \ + --manifest "$BUNDLE_D/$manifest" + CLEAN_DELETE_BUNDLE="$bucket $BUNDLE_D/$manifest" + + run "downloading bundle from $bucket" \ + ec2-download-bundle $SECRET_ARGS --privatekey=$EC2_PRIVATE_KEY \ + --bucket $bucket --manifest $manifest --directory "$UNBUNDLE_D" + + run "unbundling $manifest in $UNBUNDLE_D" \ + ec2-unbundle --privatekey $EC2_PRIVATE_KEY --manifest "$UNBUNDLE_D/$manifest" \ + --source "$UNBUNDLE_D" --destination "$UNBUNDLE_D" + + run "compare $IMAGE and $UNBUNDLE_D/${IMAGE##*/}" \ + cmp "$IMAGE" "$UNBUNDLE_D/${IMAGE##*/}" + + run "registering $bucket/$manifest in region $region" \ + ec2-register --region $region $XKEY_ARGS "$bucket/$manifest" > "$tmpf" + read a ami_id < "$tmpf" + CLEAN_DEREGISTER="$region $ami_id" + + error "registered as $ami_id" + + ## + ## Below tests migrate-bundle, but that is failing for me running on precise + ## similar to as seen at https://forums.aws.amazon.com/thread.jspa?threadID=54372 + ## This is replaced by ec2-migrate-image, though + ## + #if [ -n "$last_region" ]; then + # error "testing migration $region to $last_region" + # + # lbucket="${BUCKET_BASE}-${last_region}" + # run "migrate-bundle $region to $last_region" \ + # ec2-migrate-bundle $KEY_ARGS $SECRET_ARGS \ + # --no-mapping \ + # "--bucket=$bucket" \ + # "--destination-bucket=$lbucket" $last_loc_arg \ + # "--manifest=$manifest" + # CLEAN_DELETE_BUNDLE_2="$lbucket $BUNDLE_D/$manifest" + # + # run "deleting migrated bundle $lbucket/$manifest" \ + # ec2-delete-bundle $SECRET_ARGS --bucket "$lbucket" \ + # --manifest "$BUNDLE_D/$manifest" --batch --yes --clear + #fi + + run "deregister $ami_id $bucket/$manifest" \ + ec2-deregister --region $region $XKEY_ARGS "$ami_id" + CLEAN_DEREGISTER="" + + run "deleting bundle for $bucket/$manifest" \ + ec2-delete-bundle $SECRET_ARGS --bucket $bucket \ + --manifest "$BUNDLE_D/$manifest" --batch --yes --clear + CLEAN_DELETE_BUNDLE="" + + last_region="$region" + last_loc_arg="${loc_arg}" + +done --- ec2-ami-tools-1.4.0.9.orig/debian/update-bin-wrappers +++ ec2-ami-tools-1.4.0.9/debian/update-bin-wrappers @@ -0,0 +1,44 @@ +#!/bin/sh -e + +patch=debian/patches/point-to-right-place.patch +if ! quilt pop -a; then + quilt applied && { echo "failed to pop"; exit 1; } +fi + +quilt delete "${patch##*/}" +quilt new "${patch##*/}" +quilt header -r < +Forwarded: not-needed +Last-Update: $(date "+%Y-%m-%d") +EOF + +for x in bin/*; do + cmd=${x#bin/} + case "$cmd" in + ec2-ami-tools-version) rb=showversion;; + ec2-bundle-image) rb=bundleimage;; + ec2-bundle-vol) rb=bundlevol;; + ec2-delete-bundle) rb=deletebundle;; + ec2-download-bundle) rb=downloadbundle;; + ec2-migrate-bundle) rb=migratebundle;; + ec2-migrate-manifest) rb=migratemanifest;; + ec2-unbundle) rb=unbundle;; + ec2-upload-bundle) rb=uploadbundle;; + *) echo "unknown command $cmd"; exit 1;; + esac + quilt add "$x" + cat > "$x" <&2; exit 1; } +exec -a "\${0##*/}" ruby -I "\${home}/lib" \\ + "\$home/lib/ec2/amitools/$rb.rb" "\$@" +EOF +done + +quilt refresh +quilt pop --- ec2-ami-tools-1.4.0.9.orig/debian/upstream-check +++ ec2-ami-tools-1.4.0.9/debian/upstream-check @@ -0,0 +1,85 @@ +#!/usr/bin/python +# vi: noexpandtab tabstop=4 +# upstream-check - utility for checking upstream amazon source +# +# Copyright (C) 2010 Canonical Ltd. +# +# Authors: Scott Moser +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, version 3 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +download_url = "http://s3.amazonaws.com/ec2-downloads/" +Usage = """ +Usage: upstream-check + +This will search the ec2 bucket xml, looking for files matching + and print the newest. + +Searches url: %s + +Example: + upstream-check ec2-api-tools +""" % download_url + +import urllib2 +import sys +import xml.dom.minidom + + +def getText(nodelist): + rc = [] + for node in nodelist: + if node.nodeType == node.TEXT_NODE: + rc.append(node.data) + return ''.join(rc) + +def main(basename): + xmlstr = urllib2.urlopen(download_url).read() + dom = xml.dom.minidom.parseString(xmlstr) + # each 'Contents' looks like: + # + # 2006-06-26.ec2.wsdl + # 2006-10-23T12:22:30.000Z + # "d4fa76ef26b78d3905e009de9db8bf7d" + # 28344 + # STANDARD + # + flist = ( "Key", "LastModified", "ETag", "Size", "StorageClass" ) + matches = [ ] + for content in dom.getElementsByTagName("Contents"): + fields = { } + for key in flist: + fields[key]=getText(content.getElementsByTagName(key)[0].childNodes) + try: + if not ( fields["Key"].startswith("%s-" % basename) and + fields["Key"].endswith(".zip")) : + continue + except KeyError: + continue + + matches.append(fields) + + matches.sort(cmp=lambda x,y: cmp(x["Key"], y["Key"])) + #for f in matches: + # print "%s\t%s\t%s" % (f["Key"], f["LastModified"], f["Size"]) + ent = matches[len(matches)-1] + print "%s\t%s\t%s" % (ent["Key"], ent["LastModified"], ent["Size"]) + +if __name__ == '__main__': + if len(sys.argv) == 2: + swith=sys.argv[1] + else: + sys.stderr.write(Usage) + sys.exit(1) + + main(swith) --- ec2-ami-tools-1.4.0.9.orig/debian/watch +++ ec2-ami-tools-1.4.0.9/debian/watch @@ -0,0 +1,2 @@ +version=3 +http://s3.amazonaws.com/ec2-downloads/ec2-ami-tools-([0-9.]*).zip