1 | #!/bin/sh |
---|
2 | |
---|
3 | PORT="" |
---|
4 | OPTS="" |
---|
5 | |
---|
6 | while [ $# != 0 ] ;do |
---|
7 | case $1 in |
---|
8 | -*) |
---|
9 | # unused for now |
---|
10 | OPTS="${OPTS} $1" |
---|
11 | ;; |
---|
12 | *) |
---|
13 | PORT="${PORT} $1" |
---|
14 | ;; |
---|
15 | esac |
---|
16 | shift |
---|
17 | done |
---|
18 | |
---|
19 | if [ "${PORT}" != "" ] ;then |
---|
20 | for p in $PORT ;do |
---|
21 | WD="`port work ${p}`" |
---|
22 | STATEFILE=${WD}/.macports.${p}.state |
---|
23 | PFILE="`port dir ${p}`/Portfile" |
---|
24 | CHKSUM="`openssl sha256 -r ${PFILE} | sed -e 's| \*.*||g'`" |
---|
25 | if [ -e ${STATEFILE} ] ;then |
---|
26 | OCHKSUM="`fgrep 'checksum:' ${STATEFILE} | sed -e 's|checksum: ||g'`" |
---|
27 | if [ "${OCHKSUM}" != "${CHKSUM}" ] ;then |
---|
28 | echo "Changing ${p}'s checksum from ${OCHKSUM} to ${CHKSUM}" |
---|
29 | cp -p ${STATEFILE} ${STATEFILE}.bak |
---|
30 | sed -e "s|checksum: .*|checksum: ${CHKSUM}|g" < ${STATEFILE}.bak > ${STATEFILE} |
---|
31 | rm -f ${STATEFILE}.bak |
---|
32 | fi |
---|
33 | fi |
---|
34 | done |
---|
35 | else |
---|
36 | echo "Usage: `basename $0` <port1> [port2 [port3 [...]]]" |
---|
37 | echo "This utility updates the checksum in the port's state file" |
---|
38 | fi |
---|