Class: Linecook::GCPPacker

Inherits:
Packer
  • Object
show all
Defined in:
lib/linecook-gem/packager/packer/gcp.rb

Constant Summary collapse

BUILDER_CONFIG =
{
  type: 'null',
}.freeze
PRE_MOUNT_COMMANDS =

run with 'shell-local'

[

  # create a sparse image with dd
  "dd if=/dev/zero of=#{image_path} bs=1 count=0 seek=#{image_size}",
  "parted -s $(losetup | grep #{image_path} | awk '{print $1}') mklabel msdos",
  "parted -s $(losetup | grep #{image_path} | awk '{print $1}') mkpart primary ext4 0% 100%",
  "mkfs.ext4 $(losetup | grep #{image_path} | awk '{print $1}')p1",
  "tune2fs -L cloudimg-rootfs $(losetup | grep #{image_path} | awk '{print $1}')p1",
  "mount $(losetup | grep #{image_path} | awk '{print $1}')p1 /mnt/#{build_uuid}"
]
CHROOT_SETUP =
[
#      tar -C "${MOUNT_PATH}" -xpf "${TAR_PATH}"
#
#mount --bind /dev "${MOUNT_PATH}"/dev
#mount --bind /proc "${MOUNT_PATH}"/proc
#mount --bind /sys "${MOUNT_PATH}"/sys
#
#echo "LABEL=cloudimg-rootfs   /        ext4   defaults,discard        0 0" >> "${MOUNT_PATH}"/etc/fstab
]
CHROOT_COMMNANDS_EXTRA =
[
#APT_PACKAGES=(
#  grub-pc
#  cloud-init
#  cloud-initramfs-growroot
#  gce-daemon
#  gce-startup-scripts
#  gce-image-bundle
#  gce-cloud-config
#)
#
#DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confdef" \
#  -o Dpkg::Options::="--force-confold" -y --force-yes --no-upgrade install "${APT_PACKAGES}"
#
#rm -f /etc/hostname
#ln -s /usr/share/google/set-hostname /etc/dhcp/dhclient-exit-hooks.d/
#
#echo "169.254.169.254 metadata.google.internal metadata" >> /etc/hosts
#echo "127.0.0.1 localhost" >> /etc/hosts
]
CHROOT_UNMOUNT =
[
  "umount /mnt/#{build_uuid}/dev",
  "umount /mnt/#{build_uuid}/sys",
  "umount /mnt/#{build_uuid}/proc",
  "umount /mnt/#{build_uuid}"
]
COMPRESS_IMAGE =
[
  "losetup -d $(losetup | grep #{image_path} | awk '{print $1}')",
  "mkdir -p /tmp/#{build_uuid}",
  "mv #{image_path} /tmp/#{build_uuid}/disk.raw", #must be called disk.raw
  "cd /tmp/#{build_uuid} && tar -czvf #{build_uuid}.tar.gz disk.raw",
  "rm /tmp#{build_uuid}/disk.raw"
]

Constants inherited from Packer

Packer::CHROOT_COMMANDS, Packer::PACKER_PATH, Packer::PACKER_VERSION, Packer::POST_MOUNT_COMMANDS, Packer::SOURCE_URL

Constants included from Downloader

Downloader::LOCK_WAIT_TIMEOUT

Method Summary

Methods inherited from Packer

#initialize, #package

Methods included from Locking

#clear_lock, #lock, #lock_path, #lockfile, #unlock

Methods included from Downloader

#download, #unzip

Constructor Details

This class inherits a constructor from Linecook::Packer