Skip to content

Commit

Permalink
First
Browse files Browse the repository at this point in the history
  • Loading branch information
iromu committed Jun 30, 2012
0 parents commit 7517e41
Show file tree
Hide file tree
Showing 6 changed files with 292 additions and 0 deletions.
24 changes: 24 additions & 0 deletions scripts/all
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
# Copyright (C) 2012 Ivan Rodriguez Murillo <[email protected]>. All rights reserved.
#
# Licensed under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License

set -e

scriptPath=${0%/*}

source $scriptPath/makebrew
source $scriptPath/makevsfm
source $scriptPath/makeapp
38 changes: 38 additions & 0 deletions scripts/common
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
# Copyright (C) 2012 Ivan Rodriguez Murillo <[email protected]>. All rights reserved.
#
# Licensed under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License

set -e

ROOT=/tmp/iromu
APP_ROOT=${ROOT}/VisualSFM.app
HOMEBREW=${APP_ROOT}/Contents/Resources

BUILDDIR=~/src/homebrew/vsfm

function macports_deactivate() {
if [ -e /opt/local ]; then
echo "Macports omitted"
sudo mv /opt/local ~/macports
fi
}

function macports_activate() {
if [ -e ~/macports ]; then
echo "Macports restored"
sudo mv ~/macports /opt/local
fi
}
61 changes: 61 additions & 0 deletions scripts/makeapp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/bin/bash
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
# Copyright (C) 2012 Ivan Rodriguez Murillo <[email protected]>. All rights reserved.
#
# Licensed under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License

set -e

scriptPath=${0%/*}

source $scriptPath/common

BUILD_RES=$BUILDDIR/Contents/Resources
APP_RES="$scriptPath/../VisualSFM.app/Contents/Resources"

echo "Preparing app dir"
rm -fr VisualSFM.app
cp -R $scriptPath/../template_app $scriptPath/../VisualSFM.app

echo "Copying Cellar dir..."
cp -R "$BUILD_RES/Cellar" "$APP_RES/"

echo "Copying etc dir..."
cp -R "$BUILD_RES/etc" "$APP_RES/"

echo "Copying lib dir..."
cp -R "$BUILD_RES/lib" "$APP_RES/"

echo "Copying share dir..."
cp -R "$BUILD_RES/share" "$APP_RES/"


echo "Copying main binary..."
cp vsfm/bin/VisualSFM $APP_RES/bin/

echo "Relinking main binary"
libs=$(otool -L "$APP_RES/bin/VisualSFM" 2>/dev/null | fgrep compatibility | cut -d\( -f1 | grep Contents/Resources | sort | uniq)

echo $libs
for lib in $libs
do
echo $lib
done
#install_name_tool -change /Users/wantez/src/homebrew/vsfm/Contents/Resources/lib/libpixman-1.0.24.4.dylib /tmp/iromu/VisualSFM.app/Contents/Resources/lib/libpixman-1.0.24.4.dylib ./scripts/../VisualSFM.app/Contents/Resources/bin/VisualSFM
#dylibbundler -of -x "$APP_RES/bin/VisualSFM" -p "$APP_ROOT/Contents/Resources/lib" -i /usr/X11/lib

echo "Disconnecting BUILDDIR link"
if [ -e "$APP_ROOT" ]; then
rm ${APP_ROOT}
fi
81 changes: 81 additions & 0 deletions scripts/makebrew
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/bin/bash
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
# Copyright (C) 2012 Ivan Rodriguez Murillo <[email protected]>. All rights reserved.
#
# Licensed under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License

set -e

scriptPath=${0%/*}

source $scriptPath/common


# Create dirs and links
if [ ! -e "${BUILDDIR}" ]; then
$(mkdir -p ${BUILDDIR})
fi

if [ ! -e "${ROOT}" ]; then
$(mkdir -p ${ROOT})
fi

# Homebrew doesn't handle symlinks very good
#$(mkdir -p ${HOMEBREW})
if [ ! -e "${APP_ROOT}" ]; then
$(ln -s ${BUILDDIR} ${APP_ROOT})
fi


function rollback() {
echo "Rollback"
macports_activate
exit
}

function install_brew () {
if [ ! -e "$HOMEBREW/bin/brew" ]; then
echo "Installing Homebrew"
mkdir -p ${HOMEBREW} && curl -L https://github.com/mxcl/homebrew/tarball/master | tar xz --strip 1 -C ${HOMEBREW}
fi
}

trap rollback INT TERM EXIT

macports_deactivate

install_brew

echo $PATH | grep -q Contents/Resources/bin || export PATH="$HOMEBREW/bin:$HOMEBREW/sbin:$PATH"

echo "$HOMEBREW/bin/pkg-config"

if [ ! -h "$HOMEBREW/bin/pkg-config" ]; then
echo "Installing Homebrew dependencies"
$HOMEBREW/bin/brew install pkg-config
$HOMEBREW/bin/brew install gdk-pixbuf --use-llvm
$HOMEBREW/bin/brew install gtk+ cairo pango
else
echo "Updating Homebrew dependencies"
$HOMEBREW/bin/brew update
$HOMEBREW/bin/brew update pkg-config
$HOMEBREW/bin/brew update gdk-pixbuf --use-llvm
$HOMEBREW/bin/brew update gtk+ cairo pango
fi

source $scriptPath/repairbrew

macports_activate

trap - INT TERM EXIT
47 changes: 47 additions & 0 deletions scripts/makevsfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
# Copyright (C) 2012 Ivan Rodriguez Murillo <[email protected]>. All rights reserved.
#
# Licensed under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License

set -e

scriptPath=${0%/*}

source $scriptPath/common

function make_sfm () {
VSFM_SRC=http://abstract.cs.washington.edu/~ccwu/vsfm/vsfm.cgi?mac64
VSFM_ZIP=VisualSFM_osx_64bit.zip

if [ ! -e "${VSFM_ZIP}" ]; then
echo "Downloading vsfm"
curl -L $VSFM_SRC > VisualSFM_osx_64bit.zip
unzip VisualSFM_osx_64bit.zip
fi

echo "Patching vsfm makefile"
KEYWORD=$(echo /usr/local | sed -e 's/\//\\\//g')
REPLACE=$(echo $HOMEBREW | sed -e 's/\//\\\//g')
sed -e "s/${KEYWORD}/${REPLACE}/g" vsfm/makefile > output.file;mv output.file vsfm/makefile

echo $PATH | grep -q Contents/Resources/bin || export PATH="$HOMEBREW/bin:$HOMEBREW/sbin:$PATH"

cd vsfm
make clean && make
cd - > /dev/null

}

make_sfm
41 changes: 41 additions & 0 deletions scripts/repairbrew
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
# Copyright (C) 2012 Ivan Rodriguez Murillo <[email protected]>. All rights reserved.
#
# Licensed under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License

set -e

scriptPath=${0%/*}

source $scriptPath/common
REPLACE=Contents/Resources

function repair_links () {
for link in $(find $1 -type l)
do
loc=$(dirname $link)
dir=$(readlink $link)
if [[ "$dir" =~ "$REPLACE" ]]; then
rm $link
KEYWORD=$(echo $REPLACE | sed -e 's/\//\\\//g')
echo "Repairing $link->${dir/*$KEYWORD/..}"
$(ln -s ${dir/*$KEYWORD/..} ${link})
fi
done
}

repair_links $HOMEBREW/bin
repair_links $HOMEBREW/lib
repair_links $HOMEBREW/include

0 comments on commit 7517e41

Please sign in to comment.