File: new

package info (click to toggle)
pcp 7.1.0-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 252,748 kB
  • sloc: ansic: 1,483,656; sh: 182,366; xml: 160,462; cpp: 83,813; python: 24,980; perl: 18,327; yacc: 6,877; lex: 2,864; makefile: 2,738; awk: 165; fortran: 60; java: 52
file content (141 lines) | stat: -rwxr-xr-x 2,945 bytes parent folder | download
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/bin/sh
#
# Generate a new package list file using ../check-vm
#

_usage()
{
    echo "Usage: $0 [options]"
    echo "  -A arch      override platform arch"
    echo "  -D distro    override platform distro"
    echo "  -n           show me, change nothing"
    echo "  -v           verbose (debugging)"
    echo "  -V version   override platform version"
    exit 1
}

showme=false
verbose=false
very_verbose=false
Distro=''
Version=''
Arch=''
while getopts 'A:D:nvV:?' p
do
    case "$p"
    in
	A)	Arch="$OPTARG"
		;;

	D)	Distro="$OPTARG"
		;;

	n)	showme=true
		;;

	v)	if $verbose
		then
		    very_verbose=true
		else
		    verbose=true
		fi
		;;

	V)	Version="$OPTARG"
		;;

	?)	_usage
		# NOTREACHED
    esac
done
shift `expr $OPTIND - 1`
[ $# -eq 0 ] || _usage

status=1		# failure is the default
if $very_verbose
then
    tmp=tmp
else
    tmp=/var/tmp/$$
    trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
fi
rm -f $tmp.*

# Need directory where this script is located so we can find the other
# scripts and control files
#
home=`echo $0 | sed -e 's/\/*new$//'`
home=`cd $home/..; /bin/pwd`
if [ ! -f $home/whatami ]
then
    echo >&2 "Botch: \$0=$0 -> bad \$home=$home ?"
    exit 1
fi

# Use the same algorithm as ../check-vm and ../list-packages to identify the
# correct package list file
#
if [ ! -f $home/packages.rc ]
then
    echo >&2 "Botch: cannot find $home/packages.rc"
    exit
fi

. $home/packages.rc

_setversions
# $distro, $version and $arch now set

# optionally over-ridden from the comand line ...
#
[ -n "$Distro" ] && distro="$Distro"
[ -n "$Version" ] && version="$Version"
[ -n "$Arch" ] && arch="$Arch"

echo >&2 "Info: distro=$distro version=$version arch=$arch"

echo "# PCP required package list for $distro $version $arch" >$tmp.list
echo "# created by `id -un` on `hostname` `date`" >>$tmp.list
echo "#" >>$tmp.list

$home/old-list-packages -fap \
| tr ' ' '\012' \
| sed \
    -e 's/\(.*\)(\(.*\))/\2 \1/' \
    -e '/^{[A-Z][A-Za-z]*}$/d' \
| LC_COLLATE=POSIX sort \
| uniq >>$tmp.list

if [ -f "${distro}+${version}+$arch" ]
then
    grep -v '^# created' <$tmp.list >$tmp.new
    grep -v '^# created' <"${distro}+${version}+$arch" >$tmp.old
    if cmp $tmp.new $tmp.old >/dev/null
    then
	echo "${distro}+${version}+$arch: no change"
    else
	if $verbose
	then
	    echo "${distro}+${version}+$arch: exists, diffs"
	    diff -u "${distro}+${version}+$arch" $tmp.list
	fi
	if $showme
	then
	    echo "+ mv ${distro}+${version}+$arch ${distro}+${version}+$arch.old"
	    echo "+ install new ${distro}+${version}+$arch"
	else
	    mv "${distro}+${version}+$arch" "${distro}+${version}+$arch.old"
	    mv $tmp.list "${distro}+${version}+$arch"
	    echo "${distro}+${version}+$arch: updated"
	fi
    fi
else
    if $showme
    then
	echo "+ install new ${distro}+${version}+$arch"
	cat $tmp.list
    else
	mv $tmp.list "${distro}+${version}+$arch"
	echo "${distro}+${version}+$arch: created"
    fi
fi