howto/AdvancedDailyAdm: updating.bash

File updating.bash, 1.5 KB (added by BjarneDMat, 10 years ago)

the updating script

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