File: post-auto-install

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 (309 lines) | stat: -rwxr-xr-x 7,469 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
#!/bin/sh
#
# run after dh_auto_install to distribute installed files into
# their appropriate per-package locations
#

iam=post-auto-install
tmp=/var/tmp/$iam-$$
sts=1
trap "rm -f $tmp.*; exit \$sts" 0 1 2 3 15

# -n for show-me
# -v for increased verbosity
# ... no real checking of args here
#
verbose=0
showme=false
RM=rm
RMDIR=rmdir
while [ $# -gt 0 ]
do
    if [ X"$1" = X-v ]
    then
	verbose=`expr $verbose + 1`
    elif [ X"$1" = X-n ]
    then
	RM='echo + rm'
	RMDIR='echo + rmdir'
	showme=true
    fi
    shift
done

if [ -d debian ]
then
    cd debian
else
    # not run from dpkg-buildpackage, warn and continue
    #
    echo >&2 "$iam: Warning: debian not a dir below pwd, hope you know what you're doing"
fi

# from here on, everything is assumed to be happening from the
# "debian" directory created by dpkg-buildpackage, e.g.
# build/deb/pcp-X.Y.Z/debian
#

if [ ! -f control ]
then
    echo >&2 "$iam: Error: no control file"
    exit
fi

# base package is the first one in control ... all files and dirs
# not claimed by other packages will end up in this package
#
base_pkg=`sed <control -n -e '/^Package:/{
s/^Package://
s/[ 	]//g
p
q
}'`
if [ -z $base_pkg ]
then
    echo >&2 "$iam: Error: no Package: in the control file"
    exit
fi

# check dh_auto_install did the expected thing ... we assume
# rules overrides the dh_auto_install step with something like
#	dh_auto_install --destdir=debian/<base_pkg>
#
if [ ! -d $base_pkg ]
then
    echo >&2 "$iam: Error: base package $base_pkg dir not found"
    exit
fi

for pkg in `sed <control -n -e '/^Package:/{
s/^Package://
s/[ 	]//g
p
}'`
do
    if [ ! -d $pkg ]
    then
	if ! mkdir $pkg
	then
	    echo >&2 "$iam: Error: mkdir $pkg failed"
	    exit
	fi
    fi

    # skip the base package ... it will contain anything *not* distributed
    # to the other packages
    #
    [ $pkg = $base_pkg ] && continue

    # special-case handling for some packages ... the only part of
    # this script that is not generic, and is specific to PCP ...
    # we need special handling of the filelist here and at the removal
    # step below
    #
    filelist=$pkg.install
    rm -f $tmp.filelist
    case "$pkg"
    in
	python3-pcp)
		if [ ! -f ../python3-pcp.list ]
		then
		    echo >&2 "$iam: Error: python3-pcp expects ../python3-pcp.list"
		    echo >&2 "pwd=`pwd`"
		    ls >&2 -l ../*.list
		    exit
		fi
		# this one is special and outside the python3 build
		#
		echo "/usr/share/lintian/overrides/python3-pcp" >>../python3-pcp.list
 		sed <../python3-pcp.list >$tmp.filelist \
 		    -e '/\/__pycache__\//d' \
 		    -e 's@^/@@' \
 		# end
		filelist=$tmp.filelist
		;;
    esac

    if [ -f $filelist ]
    then
	# cherry-pick files from $base_pkg to $pkg
	#  - glob-expand any filenames in $filelist
	#  - then copy them out with tar so we preserve any directories
	#  - then remove them from $base_pkg
	#
	[ "$verbose" -gt 0 ] && echo >&2 "$iam: Info: processing $pkg filelist ($filelist)"
	rm -f $tmp.bad $tmp.tmp
	cat $filelist | while read file
	do
	    # special case if $file ends <path>/* use just <path> and tar
	    # will pick up everything below <path> ... needed for
	    # pcp-testsuite.install
	    #
	    case "$file"
	    in
		*/\*)
		    [ "$verbose" -gt 1 ] && echo "$iam: $file: trim trailing /*"
		    file=`echo "$file" | sed -e 's@/\*$@@'`
		    ;;
	    esac
	    if [ -f "$base_pkg/$file" -o -d "$base_pkg/$file" -o -L "$base_pkg/$file" ]
	    then
		echo "$file" >>$tmp.tmp
	    else
		# try glob expansion
		#
		[ "$verbose" -gt 1 ] && echo >&2 "$iam: try glob expansion for $file"
		for arg in `( cd $base_pkg; eval echo "$file" ) 2>/dev/null`
		do
		    [ "$verbose" -gt 1 ] && echo >&2 "$iam: glob: $file -> $arg"
		    if [ -z "$arg" ]
		    then
			echo >&2 "$iam: Warning: $pkg: $filelist: $file: no glob expansion files"
		    elif [ -f "$base_pkg/$arg" -o -d "$base_pkg/$arg" -o -L "$base_pkg/$arg" ]
		    then
			echo "$arg" >>$tmp.tmp
		    else
			echo >&2 "$iam: Warning: $pkg: $filelist: $file -> $arg: glob expansion file not found"
			ls >&2 -ld "$base_pkg/$arg"
		    fi
		done
	    fi
	done
	if [ -s $tmp.tmp ]
	then
	    # exit status from tar is not necessarily helpful, hence sniffing
	    # stderr files
	    #
	    if $showme
	    then
		echo "+ ( cd $base_pkg; tar cf - -T tmp.tmp ) | ( cd $pkg; tar xpf - )"
		echo "+ and tmp.tmp contains ..."
		cat $tmp.tmp
	    else
		( cd $base_pkg; tar cf - -T $tmp.tmp 2>$tmp.tar.in.err ) | ( cd $pkg; tar xpf - 2>$tmp.tar.out.err || touch $tmp.bad )
		if [ "$verbose" -gt 2 ]
		then
		    echo >&2 "$iam: tarball contents ..."
		    ( cd $base_pkg; tar cf - -T $tmp.tmp ) | tar tvf - >&2
		fi
	    fi
	    if [ -f $tmp.bad ] || [ -s $tmp.tar.in.err ] || [ -s $tmp.tar.out.err ]
	    then
		cat >&2 $tmp.tar.in.err $tmp.tar.out.err
		echo >&2 "$iam: Error: extract files from $base_pkg to $pkg failed"
		exit
	    fi
	else
	    # hmm ... no files found?
	    #
	    echo >&2 "$iam: Warning: $pkg: $filelist: nothing to copy, already done?"
	fi

	# for python3-pcp remove the full list (especially the __pycache__
	# dir that is not packaged and is populated with files in addition
	# to those mentioned in python3-pcp.list)
	#
	case "$pkg"
	in
	    python3-pcp)
 		sed -n <../python3-pcp.list >>$filelist -e '/__pycache__/{
s@^/@@
s@/[^/]*$@/*@
p
q
}'
 		# end
		;;
	esac

	cat $filelist \
	| while read file
	do
	    # remove files and symbolic links
	    #
	    # special case for "everthing below a dir" ... see note above
	    #
	    case "$file"
	    in
		*/\*)
		    file=`echo "$file" | sed -e 's@/\*$@@'`
		    ;;
	    esac
	    # may need glob expansion here, hence the unusual syntax
	    #
	    target=`echo $base_pkg/$file 2>/dev/null`
	    if [ -n "$target" ]
	    then
		$RM -rf "$target"
		# now cull any empty directories on the path to $file
		# - leaf to root traversal
		#
		dir=`dirname "$target"`
		while [ "$dir" != $base_pkg ]
		do
		    $RMDIR "$dir" >/dev/null 2>&1 || break
		    dir=`dirname "$dir"`
		done
	    else
		echo >&2 "$iam: Warning: $base_pkg/$file: removal failed (bad glob expansion?)"
	    fi
	done
    fi
    if [ -f $pkg.dirs ]
    then
	[ "$verbose" -gt 0 ] && echo >&2 "$iam: Info: processing $pkg.dirs"
	cat $pkg.dirs \
	| while read dir
	do
	    [ -d "$pkg/$dir" ] && continue
	    if ! mkdir -p -m 755 "$pkg/$dir"
	    then
		echo >&2 "$iam: Error: failed to mkdir: $pkg/$dir"
		exit
	    fi
	done
    fi

done

# Perl needs special handling to run "make install_perl" in each Perl
# source dir with DIST_ROOT set to the base dir for each package
#

if ( cd ..; debian/checkconf HAVE_PERL )
then
    if [ -z "$MAKE" ]
    then
	MAKE=`which make`
	echo >&2 "$iam: Warning: \$MAKE not set, using $MAKE"
    fi

    # add new Perl packages here ...
    #
    cat <<End-of-File | sed -e '/^#/d' | while read srcdir pkg
# src dir		package
src/perl/MMV		libpcp-mmv-perl
src/perl/PMDA		libpcp-pmda-perl
src/perl/LogImport	libpcp-import-perl
src/perl/LogSummary	libpcp-logsummary-perl
End-of-File
    do
	if [ ! -d "../$srcdir" ]
	then
	    echo >&2 "$iam: Error: Perl ../$srcdir: source dir does not exist"
	    exit
	fi
	if ! grep -q "^Package: $pkg$" control
	then
	    echo >&2 "$iam: Error: Perl package $pkg not in debian/control"
	    exit
	fi
	echo >&2 "$iam: Info: Perl install src=../$srcdir pkg=$pkg"
	DIST_ROOT=`pwd`/$pkg $MAKE -C "../$srcdir" install_perl
    done
else
    echo >&2 "$iam: Warning: HAVE_PERL is false, nothing to do"
fi

sts=0
exit