1 | #!/macports/bin/bash |
---|
2 | |
---|
3 | # |
---|
4 | # usage: |
---|
5 | # ${1}: the macports install path |
---|
6 | # |
---|
7 | |
---|
8 | ( cd $( dirname ${0} ) |
---|
9 | |
---|
10 | echo -e "\n"'+----------------+' |
---|
11 | echo '| macportsupdate |' |
---|
12 | echo '+----------------+' |
---|
13 | |
---|
14 | declare installPath=${1:-'/macports'} |
---|
15 | declare rsyncMacportsOrg='/var/macports/sources/rsync.macports.org/release/ports' |
---|
16 | |
---|
17 | echo "selfupdating & syncing all repositories" |
---|
18 | ${installPath}/bin/port -d selfupdate |
---|
19 | cp -Rv newPorts/_resources \ |
---|
20 | ${installPath}${rsyncMacportsOrg} |
---|
21 | |
---|
22 | echo -e "\ncopy additional files to the ports" |
---|
23 | for filesDir in $(find portfiles -type d -name 'files') |
---|
24 | do |
---|
25 | mkdir -p ${installPath}${rsyncMacportsOrg}/${filesDir#*portfiles/} |
---|
26 | cp -Rv ${filesDir}/* \ |
---|
27 | ${installPath}${rsyncMacportsOrg}/${filesDir#*portfiles/} |
---|
28 | done |
---|
29 | |
---|
30 | echo -e "\npatching the portfiles" |
---|
31 | for portPatch in $(find portfiles -type f -name 'patch-Portfile') |
---|
32 | do |
---|
33 | patchFile=$( sed -En -e '1,1p' ${portPatch} | tr -s "\t" " " | cut -f2 -d ' ' ) |
---|
34 | patch -u <${portPatch} ${patchFile} |
---|
35 | done |
---|
36 | |
---|
37 | echo '' |
---|
38 | ${installPath}/bin/port outdated |
---|
39 | |
---|
40 | echo -e "\nupgrading the outdated ports" |
---|
41 | for outDated in $(${installPath}/bin/port outdated | sed -e '1,1d' | tr -s " \t" | cut -f 1 -d ' ') |
---|
42 | do |
---|
43 | ${installPath}/bin/port -cuRp upgrade ${outDated} |
---|
44 | done |
---|
45 | |
---|
46 | |
---|
47 | echo -e "\nremoving macport saved files" |
---|
48 | find ${installPath} -iname *.mpsaved -delete |
---|
49 | find ${installPath} -iname *.mp_* -delete |
---|
50 | |
---|
51 | echo -e "\nremoving inactive ports" |
---|
52 | ${installPath}/bin/port installed | sed -e '1,1d' -e '/active/d' | xargs -n2 ${installPath}/bin/port uninstall |
---|
53 | |
---|
54 | ) ; wait |
---|