diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2016-04-05 11:18:18 +0200 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2016-04-05 11:25:12 +0200 |
commit | 69c746d06bd98cbf2b413aec9064d075f5d82638 (patch) | |
tree | 2d6896a486e3b32f425d806ea24b92b6961da631 /nixos/maintainers | |
parent | 2bbae9696afac559506a2589ec3ea67ca982b8bd (diff) |
Update AMI creation script
Diffstat (limited to 'nixos/maintainers')
-rwxr-xr-x | nixos/maintainers/scripts/ec2/create-amis.sh | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/nixos/maintainers/scripts/ec2/create-amis.sh b/nixos/maintainers/scripts/ec2/create-amis.sh index 8604091dbcdb..1bf2a9c5830b 100755 --- a/nixos/maintainers/scripts/ec2/create-amis.sh +++ b/nixos/maintainers/scripts/ec2/create-amis.sh @@ -8,14 +8,15 @@ echo "keeping state in $stateDir" mkdir -p $stateDir version=$(nix-instantiate --eval --strict '<nixpkgs>' -A lib.nixpkgsVersion | sed s/'"'//g) -echo "NixOS version is $version" +major=${version:0:5} +echo "NixOS version is $version ($major)" rm -f ec2-amis.nix for type in hvm pv; do link=$stateDir/$type - imageFile=$link/nixos.img + imageFile=$link/nixos.qcow2 system=x86_64-linux arch=x86_64 @@ -61,12 +62,19 @@ for type in hvm pv; do # Bundle the image. imageDir=$stateDir/$type-bundled + # Convert the image to raw format. + rawFile=$stateDir/$type.raw + if ! [ -e $rawFile ]; then + qemu-img convert -f qcow2 -O raw $imageFile $rawFile.tmp + mv $rawFile.tmp $rawFile + fi + if ! [ -d $imageDir ]; then rm -rf $imageDir.tmp mkdir -p $imageDir.tmp ec2-bundle-image \ -d $imageDir.tmp \ - -i $imageFile --arch $arch \ + -i $rawFile --arch $arch \ --user "$AWS_ACCOUNT" -c "$EC2_CERT" -k "$EC2_PRIVATE_KEY" mv $imageDir.tmp $imageDir fi @@ -75,14 +83,14 @@ for type in hvm pv; do if ! [ -e $imageDir/uploaded ]; then echo "uploading bundle to S3..." ec2-upload-bundle \ - -m $imageDir/nixos.img.manifest.xml \ + -m $imageDir/$type.raw.manifest.xml \ -b "$bucket/$bucketDir" \ -a "$EC2_ACCESS_KEY" -s "$EC2_SECRET_KEY" \ --location EU touch $imageDir/uploaded fi - extraFlags="$bucket/$bucketDir/nixos.img.manifest.xml" + extraFlags="$bucket/$bucketDir/$type.raw.manifest.xml" else @@ -90,7 +98,7 @@ for type in hvm pv; do # to upload a huge raw image. vhdFile=$stateDir/$type.vhd if ! [ -e $vhdFile ]; then - qemu-img convert -O vpc $imageFile $vhdFile.tmp + qemu-img convert -f qcow2 -O vpc $imageFile $vhdFile.tmp mv $vhdFile.tmp $vhdFile fi @@ -209,7 +217,7 @@ for type in hvm pv; do prevRegion="$region" fi - echo " \"15.09\".$region.$type-$store = \"$ami\";" >> ec2-amis.nix + echo " \"$major\".$region.$type-$store = \"$ami\";" >> ec2-amis.nix done done |