How can I add Symbolic Link (/Application) and background image in .dmg package?



  • Hello,

    I am deploying my application with help of macdeployqt tool.

    macdeployqt tool create read only .dmg packet. I would like to add Symbolic link "ln -s /Application" in dmg packet. what is good way to do it?



  • got solution from
    https://asmaloney.com/2013/07/howto/packaging-a-mac-os-x-application-using-a-dmg/

    example script:

    echo "change the permision of .dmg file"
    hdiutil convert "SquidStat.dmg" -format UDRW -o "SquidStat_Rw.dmg"
    
    echo "mount it and save the device"
    DEVICE=$(hdiutil attach -readwrite -noverify "SquidStat_Rw.dmg" |egrep '^/dev/' |sed 1q |awk '{print $1}')
    
    sleep 2
    
    echo "create the sysmbolic link to application folder"
    PATH_AT_VOLUME=/Volumes/..:..:out:Release:_SquidStat:SquidStat     ## check Path inside cd /Volume/
    
    pushd "$PATH_AT_VOLUME"
    ln -s /Applications
    popd
    
    echo "copy the background image in to package"
    mkdir "$PATH_AT_VOLUME"/.background
    cp backgroundImage.png "$PATH_AT_VOLUME"/.background/
    echo "done"
    
    # tell the Finder to resize the window, set the background,
    #  change the icon size, place the icons in the right position, etc.
    echo '
        tell application "Finder"
        tell disk "../../out/Release/_SquidStat/SquidStat"   ## check Path inside cd /Volume/
            open
                set current view of container window to icon view
                set toolbar visible of container window to false
                set statusbar visible of container window to false
                set the bounds of container window to {400, 100, 1110, 645}
                set viewOptions to the icon view options of container window
                set arrangement of viewOptions to not arranged
                set icon size of viewOptions to 72
                set background picture of viewOptions to file ".background:backgroundImage.png"
                set position of item "SquidStat.app" of container window to {160, 325}
                set position of item "Applications" of container window to {560, 320}
            close
            open
            update without registering applications
            delay 2
        end tell
        end tell
    ' | osascript
    
    sync
    
    # unmount it
    hdiutil detach "${DEVICE}"
    
    rm -f "SquidStat.dmg"
    
    
    hdiutil convert "SquidStat_Rw.dmg" -format UDZO -o "SquidStat.dmg"
    
    rm -f "SquidStat_Rw.dmg"
    exit
    
    


  • Another way is to create .dmg file by hdiutil create instead of macdeployqt -dmg .

    mkdir ui-release
    cd ui-release
    ln -s /Applications
    cd ..
    mv $appfolder ui-release/
    hdiutil create -volname $volname -srcfolder ui-release/ -ov -format UDZO $dmgfilename
    


Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.