From: Tatsuki Sugiura Date: Mon, 30 Sep 2019 04:06:17 +0000 (+0900) Subject: Add container definition JSON writer. X-Git-Url: http://git.osdn.net/view?p=osdn-codes%2Fimage-creator.git;a=commitdiff_plain;h=d871eb2a6136d0068990ce2bcc0817aa012d4746 Add container definition JSON writer. --- diff --git a/create-image b/create-image index 96a4ead..f110622 100755 --- a/create-image +++ b/create-image @@ -3,6 +3,7 @@ require 'pp' require 'shellwords' require 'tmpdir' require 'yaml' +require 'json' class SyncDirDef DEFAULT_EXCLUDE = %w[/proc/* /sys/* /dev/mqueue /dev/hugepages /run/* /var/lib/os-prober/mount /swap /dev/shm/* /var/lib/lxcfs/*] @@ -164,14 +165,30 @@ class ImageCreator end end + def write_json + jdef = [] + dirs.each_with_index do |dir, idx| + jdef.push({ + "Description" => dir.path == '/' ? 'root' : dir.path[1..-1].tr('/', '-'), + "Format" => "raw", + "UserBucket" => { + "S3Bucket" => "Change-to-your-buket-name", + "S3Key" => "/src-disks/#{img_path_base}_#{idx}.img" + } + }) + end + File.write "#{img_path_base}.json", JSON.pretty_generate(jdef) + end + + def run create_disk create_fs sync_dirs fix_boot + write_json puts "Image creation has been complated (#{name})" end - end if $0 == __FILE__