1 | #!/bin/sh |
---|
2 | |
---|
3 | PORT="" |
---|
4 | PHASE="" |
---|
5 | |
---|
6 | while [ $# != 0 ] ;do |
---|
7 | case $1 in |
---|
8 | -*) |
---|
9 | f=${1:1} |
---|
10 | case ${f} in |
---|
11 | fetch|checksum|extract|patch|patch-all|configure|build|destroot) |
---|
12 | PHASE="${PHASE} $f" |
---|
13 | ;; |
---|
14 | *) |
---|
15 | echo "${f}: invalid install phase" |
---|
16 | exit 1 |
---|
17 | ;; |
---|
18 | esac |
---|
19 | ;; |
---|
20 | *) |
---|
21 | PORT="${PORT} $1" |
---|
22 | ;; |
---|
23 | esac |
---|
24 | shift |
---|
25 | done |
---|
26 | |
---|
27 | if [ "${PORT}" != "" -a "${PHASE}" != "" ] ;then |
---|
28 | for p in $PORT ;do |
---|
29 | WD="`port work ${p}`" |
---|
30 | STATEFILE=${WD}/.macports.${p}.state |
---|
31 | PFILE="`port dir ${p}`/Portfile" |
---|
32 | if [ -e ${STATEFILE} ] ;then |
---|
33 | # let's protect the user from the effects of forgetting port's -o option! |
---|
34 | port-update-state-checksum ${p} |
---|
35 | for f in ${PHASE} ;do |
---|
36 | case ${f} in |
---|
37 | patch-all) |
---|
38 | echo "Rewinding patch phase completely" |
---|
39 | cp -p ${STATEFILE} ${STATEFILE}.bak |
---|
40 | sed -e "/patch: .*/d" \ |
---|
41 | -e "/target: org\.macports\.patch/d" < ${STATEFILE}.bak > ${STATEFILE} |
---|
42 | ;; |
---|
43 | patch) |
---|
44 | echo "Rewinding patch phase up to the last patch applied successfully" |
---|
45 | cp -p ${STATEFILE} ${STATEFILE}.bak |
---|
46 | sed -e "/target: org\.macports\.${f}.*/d" < ${STATEFILE}.bak > ${STATEFILE} |
---|
47 | ;; |
---|
48 | destroot) |
---|
49 | echo "Rewinding the destroot phase and removing the destroot directory" |
---|
50 | cp -p ${STATEFILE} ${STATEFILE}.bak |
---|
51 | sed -e "/target: org\.macports\.destroot/d" \ |
---|
52 | -e "/target: org\.macports\.archivefetch/d" < ${STATEFILE}.bak > ${STATEFILE} |
---|
53 | rm -rf ${WD}/destroot* |
---|
54 | ;; |
---|
55 | *) |
---|
56 | echo "Rewinding the ${f} phase" |
---|
57 | cp -p ${STATEFILE} ${STATEFILE}.bak |
---|
58 | sed -e "/target: org\.macports\.${f}.*/d" < ${STATEFILE}.bak > ${STATEFILE} |
---|
59 | ;; |
---|
60 | esac |
---|
61 | done |
---|
62 | rm -f ${STATEFILE}.bak |
---|
63 | fi |
---|
64 | done |
---|
65 | else |
---|
66 | echo "Usage: `basename $0` <-phase1> [<-phase2>] <port1> [port2 [port3 [...]]]" |
---|
67 | echo "This utility \"rewinds\" the specified phases in a port's build/install procedure, allowing them to be repeated" |
---|
68 | echo "Special cases:" |
---|
69 | echo "\t-destroot: also rewinds archivefetch, and causes the destroot directory to be removed," |
---|
70 | echo "\t so no \"file already exists\" conflicts can occur" |
---|
71 | echo "\t-patch: allows the patch phase to be repeated without resetting any information on" |
---|
72 | echo "\t what patches were applied successfully" |
---|
73 | echo "\t-patch-all: allows the patch phase to be repeated completely, all patchfiles included" |
---|
74 | fi |
---|