howto/AdvancedDailyAdm: macports.bash

File macports.bash, 3.6 KB (added by BjarneDMat, 5 weeks ago)

Script 1: Installation

Line 
1#!/usr/bin/env bash
2
3################################################################################
4# copyright Bjarne D Mathiesen
5#           Kors¿r ; Danmark ; Europa
6#           macintosh .at. mathiesen .dot. info
7# date      04/07-2007
8# revised   02/12-2007  implemented automatic patching of Portfiles
9#           28/12-2009  fixed the download link
10#                       modified source/build directory
11#                       removed sudo from commands
12#           18/06-2011  added default values for the parameters
13#                       updated path values for XCode4
14#           05/03-2017  added update to actions
15#           31/01-2018  added checkpaths & fixpaths
16#                       updated default values for the parameters
17#           02/03-2021  removed  fixpaths
18#                       reworked setpaths
19#                       added fixCLT
20#
21# this script is released under the OSS GPL v3 license
22# the author welcomes feedback and improvements
23#
24(   cd  $( dirname ${0} )
25
26source ./portDefaults
27
28usage() {
29cat <<EOT
30purpose : to automate the whole install process
31\${1} : action                 [ update (default) , install , setpaths , checkpaths , select , fixCLT ]
32\${2} : macports base version  ( default ${version} ) only for install
33EOT
34}
35
36declare action=${1:-"update"}
37[ ! -z ${2} ] && declare version=${2}
38
39case ${action} in
40
41########################
42# https://trac.macports.org/wiki/ProblemHotlist#reinstall-clt
43('fixCLT')
44touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
45softwareupdate -ia
46rm /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
47
48;;
49########################
50#
51('select')
52while read -u 9 name selected options
53do
54    options=( $( echo ${options} ) )
55    port select --set "${name}" ${options[@]: -2:1}
56done 9< <( port -q select --summary )
57port select --summary
58
59;;
60########################
61# update installed ports
62('update')
63port -dN selfupdate
64port outdated
65port clean --work outdated
66port -cuNp upgrade outdated
67port -pN clean --work installed
68# port -pN reclaim
69
70;;
71########################
72# setup the system paths
73('setpaths')
74
75mkdir -p  /etc/paths.d
76cp    -np /etc/paths /etc/paths.orig
77mv    -n  /etc/paths /etc/paths.d/999macosx
78touch     /etc/paths
79
80echo "${prefix}/bin"        >  /etc/paths
81echo "${prefix}/sbin"       >> /etc/paths
82
83echo "/Applications/Xcode.app/Contents/Developer/usr/bin"   >  /etc/paths.d/888developer
84
85mkdir -p  /etc/manpaths.d
86cp    -np /etc/manpaths /etc/manpaths.orig
87mv    -n  /etc/manpaths /etc/manpaths.d/999macosx
88touch     /etc/manpaths
89
90echo "${prefix}/share/man"  > /etc/manpaths
91#echo "/Developer/usr/share/man"     >  /etc/manpaths.d/888developer
92#echo "/Developer/usr/X11/share/man" >> /etc/manpaths.d/888developer
93
94;;
95########################
96# check the system paths
97('checkpaths')
98/usr/libexec/path_helper
99
100;;
101##################
102# install macports
103('install')
104
105if [ ! -e MacPorts-${version}.tar.gz ]
106then
107    curl -O --url "https://distfiles.macports.org/MacPorts/MacPorts-${version}.tar.gz"
108fi
109
110rm  -rf  ./MacPorts-${version}
111tar -zxf   MacPorts-${version}.tar.gz
112
113cd MacPorts-${version}
114#patch -p0 </Volumes/Bjarne/WebServer/MacPorts/newPorts/pathces/mp-base-no-progress-if-stdout-no-tty.patch
115#./configure LDFLAGS=-L/Developer/SDKs/MacOSX10.6.sdk/usr/X11/lib --prefix=${prefix}
116./configure --prefix=${prefix}
117make
118make install
119
120# update MacPorts itself
121${prefix}/bin/port -dN selfupdate
122
123# let's get bash, zsh & nano
124${prefix}/bin/port -cuNp install bash zsh nano
125echo "${prefix}/bin/bash" >> /etc/shells
126echo "${prefix}/bin/zsh"  >> /etc/shells
127
128# cleanup
129rm  -rf  ./MacPorts-${version}
130
131;;
132# default
133(*)
134usage
135esac
136
137) ; wait