File: fix.sh

package info (click to toggle)
sysstat 12.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 20,092 kB
  • sloc: ansic: 47,023; sh: 1,314; xml: 1,287; makefile: 766; tcl: 756; python: 277; perl: 257
file content (50 lines) | stat: -rw-r--r-- 1,109 bytes parent folder | download | duplicates (5)
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
#!/bin/sh
# $Id: fix.sh 1459 2009-08-18 04:28:45Z robert $

set -e 

if [ "X$1" = "Xsysstat" ] ; then
	FFILES="usr/lib/sysstat/sa[12]
		usr/share/man/man*/*
		usr/share/doc/sysstat/FAQ
		usr/share/doc/sysstat/examples/*"
elif [ "X$1" = "Xisag" ] ; then
	FFILES="usr/share/man/man*/*" 
else
	echo "Usage: $0 [ sysstat | isag ]" 1>&2
	exit 1
fi

dir="debian/$1"

if [ ! -d "$dir" ] ; then
	echo "Directory $dir does not exist!" 1>&2
	exit 1
fi

cd "$dir"

for file in `echo $FFILES`; do
 man_re=""
 # try to fix hyphens in systat's man pages
 if [ "${file%man/man*}" != "$file" ] && [ "${file%isag*}" = "$file" ]; then
 	man_re='2,${s|^-|\\-|;:S;s|\([^\\]\)-|\1\\-|g;tS}'
 fi	

 if [ -n "$man_re" ] || grep -q 'l[oi][gb]/sa' "$file" >/dev/null 2>&1 ; then
	echo  " + processing file: $dir/$file"
	mv "$file" _tmp_
	sed -e 's|usr/lib/sa|usr/lib/sysstat|g' \
	    -e 's|var/log/sa|var/log/sysstat|g' \
	    -e 's|usr/local/lib/sa|usr/local/lib/sysstat|g' \
	    -e 's|^\.IX|.\\"&|' \
	    -e "$man_re" \
		< _tmp_ > "$file"
	chmod --reference=_tmp_ "$file" 
	touch -r _tmp_	"$file"
	rm -f _tmp_
 fi
done

exit 0