"Fossies" - the Fresh Open Source Software Archive

Member "scipy-1.3.0/tools/scipy-macosx-installer/new-create-dmg" (17 Feb 2019, 3288 Bytes) of package /linux/misc/scipy-1.3.0.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #! /bin/bash
    2 SRC_FOLDER=content
    3 VOLUME_NAME=scipy
    4 DMG_TEMP_NAME=scipy.tmp.dmg
    5 title="${VOLUME_NAME}"
    6 applicationName=scipy-0.9.0b1-py2.6.mpkg
    7 finalDMGName=scipy.dmg
    8 backgroundPictureName=dmgbackground.png
    9 
   10 # dmgbackground.png was exported from Inkscape as 600x600 px (Page), then
   11 # resized in Preview to 500x500 px.
   12 WINX=100
   13 WINY=100
   14 WINW=600
   15 WINH=600
   16 ICON_SIZE=128
   17 
   18 BACKGROUND_FILE=art/dmgbackground.png
   19 SCIPY_MPKG=""
   20 
   21 while test "${1:0:1}" = "-"; do
   22   case $1 in
   23     --pkgname)
   24       SCIPY_MPKG="$2"
   25       shift; shift;;
   26     --volname)
   27       VOLUME_NAME="$2"
   28       shift; shift;;
   29     -h | --help)
   30       usage;;
   31     --version)
   32       version; exit 0;;
   33     --pure-version)
   34       pure_version; exit 0;;
   35     -*)
   36       echo "Unknown option $1. Run with --help for help."
   37       exit 1;;
   38   esac
   39 done
   40 
   41 test -z "$2" && {
   42   echo "Not enough arguments. Invoke with --help for help."
   43   exit 1
   44 }
   45 
   46 # Check for mandatory options
   47 if [ -e $SCIPY_MPKG ]
   48 then
   49     echo "--pkgname is mandatory"
   50 fi
   51 
   52 BACKGROUND_FILE_NAME="$(basename $BACKGROUND_FILE)"
   53 BACKGROUND_CLAUSE="set background picture of opts to file \".background:$BACKGROUND_FILE_NAME\""
   54 
   55 DOCUMENTATION_PATH="Documentation"
   56 
   57 DMG_PATH="$1"
   58 DMG_DIRNAME="$(dirname "$DMG_PATH")"
   59 DMG_DIR="$(cd $DMG_DIRNAME > /dev/null; pwd)"
   60 DMG_NAME="$(basename "$DMG_PATH")"
   61 DMG_TEMP_NAME="$DMG_DIR/rw.${DMG_NAME}"
   62 SRC_FOLDER="$(cd "$2" > /dev/null; pwd)"
   63 DMG_SIZE=43m
   64 test -z "$VOLUME_NAME" && VOLUME_NAME="$(basename "$DMG_PATH" .dmg)"
   65 
   66 # Create the image
   67 echo "Creating disk image..."
   68 test -f "${DMG_TEMP_NAME}" && rm -f "${DMG_TEMP_NAME}"
   69 hdiutil create -srcfolder "$SRC_FOLDER" -volname "${VOLUME_NAME}" -fs HFS+ -fsargs "-c c=64,a=16,e=16" -format UDRW -size "${DMG_SIZE}" "${DMG_TEMP_NAME}"
   70 device=$(hdiutil attach -readwrite -noverify -noautoopen "${DMG_TEMP_NAME}" | egrep '^/dev/' | sed 1q | awk '{print $1}')
   71 
   72 # Copy background image
   73 mkdir /Volumes/"${VOLUME_NAME}"/.background
   74 cp $BACKGROUND_FILE /Volumes/"${VOLUME_NAME}"/.background/"${BACKGROUND_FILE_NAME}"
   75 
   76 # Set background image + icon size + icon position
   77 # XXX: the close/open after icon positioning is to circumvent a bug in Snow
   78 # Leopard. Without it, the icon position is not changed
   79 echo '
   80    tell application "Finder"
   81        tell disk "'${VOLUME_NAME}'"
   82            open
   83            set current view of container window to icon view
   84            set toolbar visible of container window to false
   85            set statusbar visible of container window to false
   86            set the bounds of container window to {100, 100, 600, 600}
   87            set theViewOptions to the icon view options of container window
   88            set arrangement of theViewOptions to not arranged
   89            set icon size of theViewOptions to 128
   90            set background picture of theViewOptions to file ".background:'${BACKGROUND_FILE_NAME}'"
   91            set position of item "'${SCIPY_MPKG}'" of container window to {125, 320}
   92            set position of item "'${DOCUMENTATION_PATH}'" of container window to {375, 320}
   93            close
   94            open
   95            update without registering applications
   96            delay 5
   97        end tell
   98    end tell
   99 ' | osascript
  100 
  101 rm -f "${DMG_NAME}"
  102 chmod -Rf go-w /Volumes/"${VOLUME_NAME}"
  103 sync
  104 sync
  105 hdiutil detach ${device}
  106 hdiutil convert "${DMG_TEMP_NAME}" -format UDZO -imagekey zlib-level=9 -o "${DMG_NAME}"
  107 rm -f ${DMG_TEMP_NAME}