# Copyright 2005 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ # This eclass provides the utilities for unpacking dmg's and installing an os X application ECLASS=macos INHERITED="$INHERITED $ECLASS" # since in most dmg's there isnt a ${P} folder S=${WORKDIR} # unpack_dmg(file) # unpacks given dmg to ${WORKDIR} unpack_dmg() { if [ ! -f /usr/bin/hdiutil ]; then die "Missing hdiutil - Mac OS X required" fi location=$(mktemp -dp ${T}) DMGPATH=${DISTDIR}/${1} hdiutil attach "$DMGPATH" -mountpoint $location >/dev/null 2>&1 || die "mount failed" ditto --rsrc ${location} ${WORKDIR} hdiutil detach $location >/dev/null 2>&1 || die "unmount failed" } # doapp(location) # installs the given .app doapp() { for app in $@; do if ! [[ $app = *.app ]] && ! [ -d $app ]; then # can't install this continue fi DIE=0 tmpfile=$(mktemp -p ${T}) # yep, this is bad, I'm open to suggestions einfo "Checking for broken symlinks" # it appears that many .apps have broken symlinks, # while this doesnt show up in normal use, it breaks emerge find "$app" -name "*" >$tmpfile while read filename; do if [ -L "$filename" ] && [ ! -e "$filename" ]; then eerror "Broken symlink - $filename" DIE=1 fi done <$tmpfile rm $tmpfile # don't die until we have a list of the broken links if [ $DIE -ne 0 ]; then die "broken symlinks" fi einfo "Copying $app" dodir /Applications APPPATH=${D}/Applications/`basename "$app"` ditto "$app" $APPPATH chown -R root:admin $APPPATH done } # remove_broken_links(location) # remove all broken symlinks in the given app # verify that the modified app works before using this # but if the app works with the broken link, it will probably work without it remove_broken_links() { find "$1" -name "*" | while read filename; do if [ -L "$filename" ] && [ ! -e "$filename" ]; then ewarn "Removing broken link - $filename" rm "$filename" fi done }