Linux method of establishing dmg file through command line

  

In Linux system operation, many people don't know much about dmg file, but don't know how to create dmg file. This article will introduce you to Linux using command line to establish dmg. The method of the document, friends who do not understand can come to understand.

What is the DMG file, how to open?

The DMG format is a mirror file on the MAC system. It can also be said to be a compressed file. If you use a PC and do not have MAC OS X for X86, don't bother. If you are using a Mac or installing MAC OS X for X86 on your PC, double-click on the file on the MAC system to unlock it. If you want to burn this file to a DVD, use toast to burn the file to a CD: Dmg=”disc image

Command line creation dmg

Get software version number automatically

APP_NAME=“Soulver”

VERSION=$(/usr /libexec/plistbuddy -c Print:CFBundleShortVersionString: “${APP_NAME}.app/Contents/Info.plist”)

DMG_BACKGROUND_IMG=“Background.png”

VOL_NAME=“ ${APP_NAME} ${VERSION}”

DMG_TMP=“${VOL_NAME}-temp.dmg”

DMG_FINAL=“${VOL_NAME}.dmg”

STAGING_DIR=“. /Install”

Create dmg

#Clean up folders

rm -rf “${STAGING_DIR}” “${DMG_TMP}” “${ DMG_FINAL}”

#Create Folder, Copy, Calculate

mkdir -p “${STAGING_DIR}”

cp -rpf “${APP_NAME} .app” “${STAGING_DIR}”

SIZE=`du -sh “${STAGING_DIR}” |  Sed ‘s/([0-9.]*)M(.*)/1/’`

SIZE=`echo “${SIZE} + 1.0” |  Bc |  Awk ‘{print int($1+0.5)}’`

# Fault-tolerant processing

if [ $? -ne 0 ]; then

echo “Error: Cannot compute size of staging dir”

exit

fi

# Create a temporary dmg file< Br>

hdiutil create -srcfolder “${STAGING_DIR}” -volname “${VOL_NAME}” -fs HFS+

-fsargs “-cc=64,a=16,e =16” -format UDRW -size ${SIZE}M “${DMG_TMP}”

echo “Created DMG: ${DMG_TMP}”

Set dmg

DEVICE=$(hdiutil attach -readwrite -noverify “${DMG_TMP}” |

egrep ‘^/dev/’ |  Sed 1q |  Awk ‘{print $1}’)

sleep 2
Previous12Next Total 2 Pages

Copyright © Windows knowledge All Rights Reserved