forked from derphilipp/macportsscripts
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
install_macports.sh
executable file
·112 lines (91 loc) · 2.97 KB
/
install_macports.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
# This script was taken from https://trac.macports.org/wiki/howto/AdvancedDailyAdm
# If you are using the copy of this that came with the "macportsscripts" port,
# then you probably will NOT need to use this, as that should mean that you
# already have MacPorts installed
################################################################################
# copyright Bjarne D Mathiesen
# København ; Danmark ; Europa
# macintosh .at. mathiesen .dot. info
# date 04/07-2007
# revised 02/12-2007 implemented automatic patching of Portfiles
# 28/12-2009 fixed the download link
# modified source/build directory
# removed sudo from commands
# 18/06-2011 added default values for the parameters
# updated path values for XCode4
#
# this script is released under the BSD license
# the author welcomes feedback and improvements
#
usage() {
cat <<EOT
purpose : to automate the whole install process
\${1} : action [ install (default) , paths ]
\${2} : install prefix ( default /macports )
\${3} : macports base version ( default 2.2.1 )
EOT
}
declare action=${1:-"install"}
# Leaving this alternate prefix as-is, as we are installing a new MacPorts there
declare prefix=${2:-"/macports"}
declare version=${3:-"2.2.1"}
case ${action} in
########################
# setup the system paths
'paths')
mkdir -p /etc/paths.d
cp -np /etc/paths /etc/paths.orig
mv -n /etc/paths /etc/paths.d/999macosx
touch /etc/paths
echo "${prefix}/bin" > /etc/paths.d/000macports
echo "${prefix}/sbin" >> /etc/paths.d/000macports
echo "/Developer/usr/bin" > /etc/paths.d/888developer
echo "/Developer/usr/sbin" >> /etc/paths.d/888developer
mkdir -p /etc/manpaths.d
cp -np /etc/manpaths /etc/manpaths.orig
mv -n /etc/manpaths /etc/manpaths.d/999macosx
touch /etc/manpaths
echo "${prefix}/share/man" > /etc/manpaths.d/000macports
echo "/Developer/usr/share/man" > /etc/manpaths.d/888developer
echo "/Developer/usr/X11/share/man" >> /etc/manpaths.d/888developer
# path_helper is buggy under 10.5
# however, messing with system stuff is a bad idea
;;
##################
# install macports
'install')
export OLDPWD=$(pwd)
if [ ! -z "$TMPDIR" ]; then
cd $TMPDIR
echo "cd $(pwd)"
else
export TMPDIR=/tmp
cd $TMPDIR
echo "cd $(pwd)"
fi
if [ ! -e MacPorts-${version}.tar.gz ]
then
curl -O --url "http://distfiles.macports.org/MacPorts/MacPorts-${version}.tar.gz"
fi
rm -rf ./MacPorts-${version}
tar -zxf MacPorts-${version}.tar.gz
if [ -d /Developer/SDKs/MacOSX10.6.sdk/usr/X11/lib ]; then
export MP_LDFLAGS=-L/Developer/SDKs/MacOSX10.6.sdk/usr/X11/lib
fi
set -e
cd MacPorts-${version}
./configure LDFLAGS=${MP_LDFLAGS} --prefix=${prefix}
make
make install
# update MacPorts itself
${prefix}/bin/port -d selfupdate
# let us get gawk
${prefix}/bin/port install gawk
# let us get bash
${prefix}/bin/port install bash
;;
# default
*)
usage
esac