-
Notifications
You must be signed in to change notification settings - Fork 0
/
pmmacports.sh
executable file
·55 lines (38 loc) · 1.06 KB
/
pmmacports.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
#!/bin/sh
#set -x
#set -e
STARTDIR=$(pwd)
mkdir "${STARTDIR}"/TMP
STARTDIR="${STARTDIR}"/TMP
cd "${STARTDIR}"
PACKAGES="curl glib2 physfs libsdl2_mixer libsdl2_image ncurses libxml2"
getPkgUrl(){
PACKAGENAME="${1}"
lynx -dump -listonly http://nue.de.packages.macports.org/macports/packages/"${PACKAGENAME}"/ |tail -2|head -1|awk '{print $2}'
}
installPkg(){
PACKAGENAME="${1}"
cd "${STARTDIR}"
PKGURL=$(getPkgUrl "${PACKAGENAME}")
PKGFILE=$(echo "${PKGURL}" | awk -F'/' '{print $NF}' )
if [ ! -d "${PACKAGENAME}/opt" ]; then
echo Installing "${PACKAGENAME}" to /opt/local ...
mkdir "${PACKAGENAME}"
cd "${PACKAGENAME}" && wget --quiet -c "${PKGURL}" && tar xf "${PKGFILE}"
fi
cd "${STARTDIR}"/"${PACKAGENAME}"
for PKGDEP in $(grep '@pkgdep' \+CONTENTS | cut -d\ -f2 | rev | cut -f2-100 -d\- | rev)
do
installPkg "${PKGDEP}"
done
cp -a "${STARTDIR}"/"${PACKAGENAME}"/opt "${STARTDIR}"/
}
main(){
for PACKAGE in ${*}
do
cd "${STARTDIR}"
installPkg $PACKAGE
cd "${STARTDIR}"
done
}
main $PACKAGES