mkdmg 459 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#!/usr/bin/env ruby

# usage error
if ARGV.length < 1 or ARGV.length > 2 then
    $stderr.puts( "Usage: #{File.basename( $0 )} directory [cd name]" )
    exit( 1 )
end

# get variables
dir = ARGV.shift.sub( /\/$/, "" )
volname = if ARGV.length == 0 then
        File.basename( File.expand_path( dir ) )
    else
        ARGV.shift
    end
output = "#{dir}.dmg"

# dmg the folder
`hdiutil create -fs HFS+ -srcfolder "#{dir}" -volname "#{volname}" "#{output}"`